confirmIntegralOrder.vue 16 KB

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