confirmIntegralOrder.vue 14 KB

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