integralOrderCartPay.vue 14 KB

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