integralOrderPay.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750
  1. <template>
  2. <view>
  3. <view class="inner-box">
  4. <!-- 收货人 -->
  5. <view class="address-box" v-if="address==null" @click="openAddress()">
  6. <view class="left">
  7. <view class="name-box">
  8. <text class="text name">添加收货地址</text>
  9. </view>
  10. </view>
  11. <view class="arrow-box">
  12. <image src="https://hdtobs.obs.cn-north-4.myhuaweicloud.com/miniapp/arrow_gray.png" mode=""></image>
  13. </view>
  14. </view>
  15. <view class="address-box" v-if="address!=null" @click="openAddress()">
  16. <view class="left">
  17. <view class="name-box">
  18. <text class="text name">{{address.realName}}</text>
  19. <text class="text" v-if="address.phone!=null">{{address.phone}}</text>
  20. </view>
  21. <!-- {{address.address}} -->
  22. <view class="address">
  23. {{address.province}}{{address.city}}{{address.district}}{{address.detail}}
  24. </view>
  25. </view>
  26. <view class="arrow-box">
  27. <image src="https://hdtobs.obs.cn-north-4.myhuaweicloud.com/miniapp/arrow_gray.png" mode=""></image>
  28. </view>
  29. </view>
  30. <!-- 药品列表 -->
  31. <view class="goods-list">
  32. <view class="item">
  33. <view class="img-box">
  34. <image
  35. :src="item.imgUrl==''?'https://hdtobs.obs.cn-north-4.myhuaweicloud.com/miniapp/drug.svg':item.imgUrl"
  36. mode="aspectFill"></image>
  37. </view>
  38. <view class="info-box">
  39. <view>
  40. <view class="name-box ellipsis2">
  41. {{item.goodsName}}
  42. </view>
  43. </view>
  44. <view class="price-num">
  45. <view class="price">
  46. <text class="num">{{item.integral}}</text>
  47. <text class="unit">积分</text>
  48. <text class="num" v-show="item.cash>0">+{{item.cash.toFixed(2)}}</text>
  49. <text class="unit" v-show="item.cash>0">元</text>
  50. </view>
  51. <view class="num">x1</view>
  52. </view>
  53. </view>
  54. </view>
  55. </view>
  56. <view class="other-info">
  57. <view class="item">
  58. <view class="left">
  59. <text class="label">所需积分:</text>
  60. </view>
  61. <view class="right">
  62. <text class="text">{{item.integral}}</text>
  63. </view>
  64. </view>
  65. <view class="item">
  66. <view class="left">
  67. <text class="label">我的积分:</text>
  68. </view>
  69. <view class="right">
  70. <text class="text">{{integral}}</text>
  71. </view>
  72. </view>
  73. <view class="item" v-if='item.cash>0'>
  74. <view class="left">
  75. <text class="label">支付金额:</text>
  76. </view>
  77. <view class="right">
  78. <text class="text">{{item.cash.toFixed(2)}}</text>
  79. </view>
  80. </view>
  81. </view>
  82. <view class="pay-type" v-if='item.cash>0'>
  83. <view class="title">支付方式</view>
  84. <radio-group>
  85. <view class="item">
  86. <view class="left">
  87. <image src="https://hdtobs.obs.cn-north-4.myhuaweicloud.com/miniapp/wecha_pay.png" mode="">
  88. </image>
  89. <text class="text">全款支付</text>
  90. </view>
  91. <label>
  92. <radio :value="1" :checked="payType=='1'" color="#DA251C" />
  93. </label>
  94. </view>
  95. </radio-group>
  96. </view>
  97. <!-- 备注 -->
  98. <!-- <view class="remarks" v-if='item.cash>0&&order!=null'>
  99. <input type="text" v-model="order.remark" placeholder="备注留言(选填)" placeholder-class="input" />
  100. </view> -->
  101. </view>
  102. <!-- 底部按钮 -->
  103. <view class="btn-box">
  104. <view class="btn" v-if="item!=null" @click="payOrder()">{{item.cash>0?'立即支付':'立即兑换'}}</view>
  105. </view>
  106. </view>
  107. </template>
  108. <script>
  109. import {
  110. getIntegralGoodsById,
  111. createOrder
  112. } from '@/api/integral.js'
  113. import {
  114. getUserInfo
  115. } from '@/api/user'
  116. export default {
  117. data() {
  118. return {
  119. addressId: null,
  120. address: null,
  121. orderId: null,
  122. order: null,
  123. item: {
  124. cash: null,
  125. },
  126. integral: 0,
  127. payTypes: [],
  128. payType: '1',
  129. }
  130. },
  131. onLoad(option) {
  132. this.goodsId = option.goodsId;
  133. var that = this;
  134. uni.$on('updateAddress', (e) => {
  135. console.log("选择地址", e)
  136. that.addressId = e.addressId;
  137. that.address = e;
  138. // that.address.address=e.province+e.city+e.district+e.detail
  139. })
  140. this.getIntegralGoodsById();
  141. this.getUserInfo();
  142. },
  143. methods: {
  144. getUserInfo() {
  145. getUserInfo().then(
  146. res => {
  147. if (res.code == 200) {
  148. if (res.user != null) {
  149. this.integral = res.user.integral;
  150. }
  151. }
  152. },
  153. rej => {}
  154. );
  155. },
  156. getIntegralGoodsById() {
  157. var data = {
  158. goodsId: this.goodsId
  159. };
  160. console.log(data)
  161. getIntegralGoodsById(data).then(
  162. res => {
  163. if (res.code == 200) {
  164. this.item = res.data;
  165. } else {
  166. }
  167. },
  168. rej => {}
  169. );
  170. },
  171. openAddress() {
  172. uni.navigateTo({
  173. url: '/pages_user/user/address'
  174. })
  175. },
  176. payOrder() {
  177. if (this.addressId == null) {
  178. uni.showToast({
  179. icon: 'none',
  180. title: "请选择收货地址",
  181. });
  182. return;
  183. }
  184. var data = {
  185. goodsId: this.goodsId,
  186. addressId: this.addressId,
  187. };
  188. var that = this;
  189. uni.showLoading();
  190. createOrder(data).then(
  191. res => {
  192. if (res.code == 200) {
  193. var temps = ['wqKEklE_w5N19w9VAGY74TltPE6Ne3BaFObDD47uDEo']
  194. uni.requestSubscribeMessage({
  195. tmplIds: temps,
  196. success(e) {
  197. setTimeout(function() {
  198. if (that.item.cash > 0) {
  199. uni.redirectTo({
  200. url: "./integralPayment?orderId=" + res.order
  201. .orderId
  202. })
  203. } else {
  204. uni.redirectTo({
  205. url: "./integralOrderPaySuccess?orderId=" + res
  206. .order.orderId
  207. })
  208. }
  209. }, 200);
  210. },
  211. fail(e) {
  212. setTimeout(function() {
  213. if (that.item.cash > 0) {
  214. uni.redirectTo({
  215. url: "./integralPayment?orderId=" + res.order
  216. .orderId
  217. })
  218. } else {
  219. uni.redirectTo({
  220. url: "./integralOrderPaySuccess?orderId=" + res
  221. .order.orderId
  222. })
  223. }
  224. }, 200);
  225. }
  226. })
  227. } else {
  228. uni.showToast({
  229. icon: 'none',
  230. title: res.msg,
  231. });
  232. }
  233. },
  234. rej => {}
  235. );
  236. }
  237. }
  238. }
  239. </script>
  240. <style lang="scss">
  241. .inner-box {
  242. padding: 20upx 20upx 140upx;
  243. .address-box {
  244. box-sizing: border-box;
  245. min-height: 171upx;
  246. background: #FFFFFF;
  247. border-radius: 16upx;
  248. background-image: url(https://hdtobs.obs.cn-north-4.myhuaweicloud.com/miniapp/address_bg.png);
  249. background-repeat: no-repeat;
  250. background-size: 100% 30upx;
  251. background-position: left bottom;
  252. padding: 38upx 30upx 36upx;
  253. display: flex;
  254. align-items: center;
  255. justify-content: space-between;
  256. .left {
  257. width: 92%;
  258. .name-box {
  259. display: flex;
  260. align-items: center;
  261. .text {
  262. font-size: 32upx;
  263. font-family: PingFang SC;
  264. font-weight: bold;
  265. color: #111111;
  266. line-height: 1;
  267. &.name {
  268. margin-right: 30upx;
  269. }
  270. }
  271. }
  272. .address {
  273. font-size: 28upx;
  274. font-family: PingFang SC;
  275. font-weight: 500;
  276. color: #666666;
  277. line-height: 42upx;
  278. text-align: left;
  279. margin-top: 23upx;
  280. }
  281. }
  282. .arrow-box {
  283. width: 12upx;
  284. height: 23upx;
  285. display: flex;
  286. align-items: cenetr;
  287. justify-content: cenetr;
  288. image {
  289. width: 100%;
  290. height: 100%;
  291. }
  292. }
  293. }
  294. .goods-list {
  295. margin-top: 20upx;
  296. padding: 0 30upx;
  297. background-color: #FFFFFF;
  298. border-radius: 16upx;
  299. .item {
  300. padding: 30upx 0;
  301. border-bottom: 1px solid #EDEEEF;
  302. display: flex;
  303. align-items: center;
  304. .img-box {
  305. width: 160upx;
  306. height: 160upx;
  307. margin-right: 30upx;
  308. image {
  309. width: 100%;
  310. height: 100%;
  311. }
  312. }
  313. .info-box {
  314. width: calc(100% - 190upx);
  315. height: 160upx;
  316. display: flex;
  317. flex-direction: column;
  318. justify-content: space-between;
  319. .name-box {
  320. font-size: 28upx;
  321. font-family: PingFang SC;
  322. font-weight: 500;
  323. color: #111111;
  324. line-height: 40upx;
  325. .tag {
  326. display: inline-block;
  327. padding: 0 6upx;
  328. height: 30upx;
  329. background: linear-gradient(90deg, #DA251C 0%, #E2C99E 100%);
  330. border-radius: 4upx;
  331. margin-right: 10upx;
  332. font-size: 22upx;
  333. font-family: PingFang SC;
  334. font-weight: bold;
  335. color: #FFFFFF;
  336. line-height: 30upx;
  337. float: left;
  338. margin-top: 7upx;
  339. }
  340. }
  341. .spec {
  342. margin-top: 10upx;
  343. font-size: 24upx;
  344. font-family: PingFang SC;
  345. font-weight: 500;
  346. color: #999999;
  347. line-height: 1;
  348. }
  349. .price-num {
  350. display: flex;
  351. align-items: center;
  352. justify-content: space-between;
  353. .price {
  354. display: flex;
  355. align-items: flex-end;
  356. .unit {
  357. font-size: 24upx;
  358. font-family: PingFang SC;
  359. font-weight: 500;
  360. color: #111111;
  361. line-height: 1.2;
  362. margin-right: 4upx;
  363. }
  364. .num {
  365. font-size: 32upx;
  366. font-family: PingFang SC;
  367. font-weight: 500;
  368. color: #111111;
  369. line-height: 1;
  370. }
  371. }
  372. .num {
  373. font-size: 24upx;
  374. font-family: PingFang SC;
  375. font-weight: 500;
  376. color: #999999;
  377. line-height: 1;
  378. }
  379. }
  380. }
  381. }
  382. .sub-total {
  383. height: 88upx;
  384. display: flex;
  385. align-items: center;
  386. justify-content: flex-end;
  387. .label {
  388. font-size: 24upx;
  389. font-family: PingFang SC;
  390. font-weight: 500;
  391. color: #999999;
  392. }
  393. .price {
  394. display: flex;
  395. align-items: flex-end;
  396. .unit {
  397. font-size: 24upx;
  398. font-family: PingFang SC;
  399. font-weight: 500;
  400. color: #FF6633;
  401. line-height: 1.2;
  402. margin-right: 4upx;
  403. }
  404. .num {
  405. font-size: 32upx;
  406. font-family: PingFang SC;
  407. font-weight: bold;
  408. color: #FF6633;
  409. line-height: 1;
  410. }
  411. }
  412. }
  413. }
  414. .other-info {
  415. margin-top: 20upx;
  416. background-color: #fff;
  417. border-radius: 20upx;
  418. overflow: hidden;
  419. padding: 0 30upx;
  420. .title {
  421. height: 80upx;
  422. line-height: 80upx;
  423. font-size: 30upx;
  424. color: #000;
  425. font-weight: bold;
  426. border-bottom: 2upx solid #eeeeee;
  427. }
  428. .item {
  429. height: 80upx;
  430. display: flex;
  431. align-items: center;
  432. justify-content: space-between;
  433. &:last-child {
  434. border-bottom: none;
  435. }
  436. .left {
  437. flex: 1;
  438. display: flex;
  439. align-items: center;
  440. .label {
  441. min-width: 140rpx;
  442. font-size: 28upx;
  443. color: #000;
  444. }
  445. .text {
  446. font-size: 28upx;
  447. color: #1b1b1b;
  448. }
  449. }
  450. .right {
  451. display: flex;
  452. align-items: center;
  453. justify-content: flex-end;
  454. .text {
  455. font-size: 28upx;
  456. color: #1b1b1b;
  457. }
  458. .ic-close {
  459. margin-left: 10rpx;
  460. width: 30rpx;
  461. height: 30rpx;
  462. }
  463. .ic-back {
  464. margin-left: 10rpx;
  465. width: 15rpx;
  466. height: 30rpx;
  467. }
  468. }
  469. .item-btn {
  470. max-width: 200rpx;
  471. padding: 0rpx 15rpx;
  472. height: 48upx;
  473. border-radius: 24upx;
  474. line-height: 48upx;
  475. font-size: 24upx;
  476. color: #000;
  477. border: 1upx solid #d8d8d8;
  478. display: flex;
  479. align-items: center;
  480. justify-content: center;
  481. }
  482. }
  483. }
  484. .remarks {
  485. height: 88upx;
  486. padding: 0 30upx;
  487. background: #FFFFFF;
  488. border-radius: 16upx;
  489. margin-top: 20upx;
  490. display: flex;
  491. align-items: center;
  492. input {
  493. width: 100%;
  494. font-size: 28upx;
  495. font-family: PingFang SC;
  496. font-weight: 500;
  497. color: #000000;
  498. }
  499. .input {
  500. font-size: 28upx;
  501. font-family: PingFang SC;
  502. font-weight: 500;
  503. color: #999999;
  504. }
  505. }
  506. }
  507. .btn-box {
  508. height: 140upx;
  509. z-index: 9999;
  510. width: 100%;
  511. padding: 0rpx 30upx;
  512. position: fixed;
  513. bottom: 0;
  514. left: 0;
  515. box-sizing: border-box;
  516. background-color: #ffffff;
  517. display: flex;
  518. align-items: center;
  519. justify-content: center;
  520. .btn {
  521. width: 100%;
  522. height: 88upx;
  523. line-height: 88upx;
  524. text-align: center;
  525. font-size: 34upx;
  526. font-family: PingFang SC;
  527. font-weight: 400;
  528. color: #FFFFFF;
  529. background: #DA251C;
  530. border-radius: 10upx;
  531. }
  532. }
  533. .pay-type {
  534. box-sizing: border-box;
  535. height: 192upx;
  536. background: #FFFFFF;
  537. border-radius: 16upx;
  538. margin-top: 20upx;
  539. padding: 40upx 30upx;
  540. display: flex;
  541. flex-direction: column;
  542. justify-content: space-between;
  543. .title {
  544. font-size: 28upx;
  545. font-family: PingFang SC;
  546. font-weight: 500;
  547. color: #999999;
  548. line-height: 1;
  549. }
  550. .item {
  551. display: flex;
  552. align-items: center;
  553. justify-content: space-between;
  554. .left {
  555. display: flex;
  556. align-items: center;
  557. image {
  558. width: 44upx;
  559. height: 44upx;
  560. margin-right: 20upx;
  561. }
  562. .text {
  563. font-size: 30upx;
  564. font-family: PingFang SC;
  565. font-weight: bold;
  566. color: #222222;
  567. line-height: 1;
  568. }
  569. }
  570. }
  571. }
  572. .coupon {
  573. height: 100%;
  574. .empty {
  575. display: flex;
  576. align-items: center;
  577. justify-content: center;
  578. height: 650rpx;
  579. width: 100%;
  580. image {
  581. width: 280rpx;
  582. height: 200rpx;
  583. }
  584. }
  585. }
  586. .coupon-box {
  587. overflow-y: auto;
  588. padding: 80rpx 20rpx 80rpx;
  589. height: 650rpx;
  590. width: 100%;
  591. display: flex;
  592. flex-direction: column;
  593. align-items: flex-start;
  594. justify-content: flex-start;
  595. box-sizing: border-box;
  596. .coupon-item {
  597. width: 100%;
  598. display: flex;
  599. align-items: center;
  600. justify-content: flex-start;
  601. margin-bottom: 16rpx;
  602. height: 170rpx;
  603. &:last-child {
  604. margin-bottom: 0rpx;
  605. }
  606. .left {
  607. color: #fff;
  608. font-size: 36rpx;
  609. font-weight: bold;
  610. text-align: center;
  611. display: flex;
  612. flex-direction: column;
  613. align-items: center;
  614. justify-content: center;
  615. position: relative;
  616. width: 230rpx;
  617. image {
  618. position: absolute;
  619. width: 230rpx;
  620. height: 170rpx;
  621. color: #fff;
  622. }
  623. .num {
  624. font-size: 40rpx;
  625. }
  626. .pic-num {
  627. font-size: 20rpx;
  628. z-index: 99;
  629. }
  630. }
  631. .right {
  632. display: flex;
  633. flex-direction: column;
  634. align-items: flex-start;
  635. justify-content: flex-start;
  636. height: 170rpx;
  637. width: calc(100% - 230rpx);
  638. padding: 0 17rpx 0 24rpx;
  639. background-color: #fff;
  640. box-sizing: border-box;
  641. .title {
  642. width: 100%;
  643. font-size: 0.3 * 100rpx;
  644. color: #282828;
  645. height: 0.93 * 100rpx;
  646. line-height: 0.93 * 100rpx;
  647. border-bottom: 1px solid #f0f0f0;
  648. }
  649. .btns {
  650. display: flex;
  651. align-items: center;
  652. justify-content: space-between;
  653. width: 100%;
  654. font-size: 0.2 * 100rpx;
  655. color: #999;
  656. height: 0.76 * 100rpx;
  657. .btn {
  658. width: 1.36 * 100rpx;
  659. height: 0.44 * 100rpx;
  660. border-radius: 0.22 * 100rpx;
  661. font-size: 0.22 * 100rpx;
  662. color: #fff;
  663. text-align: center;
  664. line-height: 0.44 * 100rpx;
  665. background-color: #DA251C;
  666. .gray {
  667. background-color: #ccc;
  668. }
  669. }
  670. }
  671. }
  672. }
  673. }
  674. </style>