storeOrderPay.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761
  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 v-for="(item,index) in items" :key="index" class="item">
  32. <view class="img-box">
  33. <image :src="JSON.parse(item.jsonInfo).image==''?'/static/images/drug.svg':JSON.parse(item.jsonInfo).image" mode="aspectFill"></image>
  34. </view>
  35. <view class="info-box">
  36. <view>
  37. <view class="name-box ellipsis2">
  38. {{JSON.parse(item.jsonInfo).productName}}
  39. </view>
  40. <view class="spec ellipsis2">{{JSON.parse(item.jsonInfo).sku}}</view>
  41. </view>
  42. <view class="price-num">
  43. <view class="price">
  44. <!-- <text class="unit">¥</text> -->
  45. <!-- <text class="num">{{JSON.parse(item.jsonInfo).price.toFixed(2)}}</text> -->
  46. </view>
  47. <view class="num" v-if="order.orderType==1">x{{item.num}}</view>
  48. </view>
  49. </view>
  50. </view>
  51. <!-- 小计 -->
  52. <view class="sub-total">
  53. <text class="label">合计:</text>
  54. <view class="price">
  55. <text class="unit">¥</text>
  56. <text class="num" v-if="order!=null">{{order.totalPrice.toFixed(2)}}</text>
  57. </view>
  58. </view>
  59. </view>
  60. <view class="other-info">
  61. <view class="title">支付明细</view>
  62. <view class="item">
  63. <view class="left">
  64. <text class="label">订单金额:</text>
  65. </view>
  66. <view class="right">
  67. <text class="text" v-if="order!=null">{{order.payPrice.toFixed(2)}}</text>
  68. </view>
  69. </view>
  70. <view class="item" v-if="order!=null&&(order.userCouponId==null||order.userCouponId==0)" @click.stop="openCoupon()">
  71. <view class="left">
  72. <text class="label">优惠券:</text>
  73. </view>
  74. <view class="right">
  75. <text class="text">{{couponText}}</text>
  76. <image v-if="userCouponId!=0" @click.stop="delCoupon()" class="ic-close" src="../static/images/close.png"></image>
  77. <image class="ic-back" src="../static/images/arrow_gray.png"></image>
  78. </view>
  79. </view>
  80. <view class="item" >
  81. <view class="left">
  82. <text class="label">优惠金额:</text>
  83. </view>
  84. <view class="right">
  85. <text class="text">{{discountMoney.toFixed(2)}}</text>
  86. </view>
  87. </view>
  88. <view class="item">
  89. <view class="left">
  90. <text class="label">支付金额:</text>
  91. </view>
  92. <view class="right">
  93. <text class="text">{{payMoney.toFixed(2)}}</text>
  94. </view>
  95. </view>
  96. </view>
  97. <view class="pay-type">
  98. <view class="title">支付方式</view>
  99. <view class="item">
  100. <view class="left">
  101. <image src="/static/images/wecha_pay.png" mode=""></image>
  102. <text class="text">全款支付</text>
  103. </view>
  104. <label>
  105. <radio value="" :checked="wxPay" color="#C39A58"></radio>
  106. </label>
  107. </view>
  108. </view>
  109. <!-- 备注 -->
  110. <view class="remarks" v-if="order!=null">
  111. <input type="text" v-model="order.remark" placeholder="备注留言(选填)" placeholder-class="input" />
  112. </view>
  113. </view>
  114. <u-popup :closeable="true" :show="couponShow" :round="10" mode="bottom" @close="close" @open="open">
  115. <view class="coupon">
  116. <view class="coupon-box" v-if="coupons.length>0" >
  117. <view @click="couponSelect(item)" class="coupon-item" v-for="(item) in coupons">
  118. <view class="left" >
  119. <image v-if="item.status==0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/0fdd75d89db84458886d38e615011048.png" mode="widthFix"></image>
  120. <image v-if="item.status!=0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/d950e4c7af1e4464be1a7777e9dca576.png" mode="widthFix"></image>
  121. <view style="z-index: 999;">
  122. ¥<span class="num">{{item.price.toFixed(2)}}</span>
  123. </view>
  124. <view class="pic-num" >满{{item.minPrice.toFixed(2)}}元可用</view>
  125. </view>
  126. <view class="right">
  127. <view class="title">
  128. {{item.title}}
  129. </view>
  130. <view class="btns">
  131. <view v-if="item.status==0||item.status==2" >{{item.limitTime}} 到期</view>
  132. <view v-if="item.status==1">使用时间 {{item.useTime}}</view>
  133. <view class="bnt gray" v-if="item.status==1" >已使用</view>
  134. <view class="bnt gray" v-if="item.status==2" >已过期</view>
  135. <view class="btn" v-if="item.status==0" >使用</view>
  136. </view>
  137. </view>
  138. </view>
  139. </view>
  140. <view class="empty" v-if="coupons.length==0">
  141. <image src="https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png"></image>
  142. </view>
  143. </view>
  144. </u-popup>
  145. <!-- 底部按钮 -->
  146. <view class="btn-box">
  147. <view class="btn" v-if="order!=null" @click="payOrder()">支付{{payMoney.toFixed(2)}}元</view>
  148. </view>
  149. </view>
  150. </template>
  151. <script>
  152. import {getMyEnableCouponList} from '@/api/user.js'
  153. import {getStoreOrderById,pay,compute} from '@/api/storeOrder'
  154. export default {
  155. data() {
  156. return {
  157. addressId:null,
  158. wxPay: true,
  159. address:null,
  160. orderId:null,
  161. order:null,
  162. items:null,
  163. couponText:"请选择优惠券",
  164. userCouponId:0,
  165. coupons:[],
  166. couponShow:false,
  167. payMoney:0,
  168. discountMoney:0
  169. }
  170. },
  171. onLoad(option) {
  172. this.orderId=option.orderId;
  173. var that=this;
  174. uni.$on('updateAddress', (e) => {
  175. that.addressId=e.addressId;
  176. that.address=e;
  177. that.address.address=e.province+e.city+e.district+e.detail
  178. })
  179. },
  180. onShow() {
  181. this.getStoreOrderById();
  182. },
  183. // onShareAppMessage(res) {
  184. // var that=this;
  185. // if(this.$isLogin()){
  186. // return {
  187. // title: "订单支付",
  188. // path: '/pages_order/storeOrderPay?orderId='+that.orderId,
  189. // imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  190. // }
  191. // }
  192. // },
  193. methods: {
  194. couponSelect(item){
  195. this.couponShow = false;
  196. //计算金额
  197. this.userCouponId=item.id;
  198. console.log(item)
  199. this.couponText=item.price+"元优惠券"
  200. this.compute()
  201. },
  202. open() {
  203. },
  204. close() {
  205. this.couponShow = false
  206. },
  207. openCoupon(){
  208. this.couponShow=true;
  209. },
  210. delCoupon(){
  211. this.userCouponId=0;
  212. this.couponText="请选择优惠券";
  213. this.compute();
  214. },
  215. compute(){
  216. var data={
  217. orderId:this.orderId,
  218. userCouponId:this.userCouponId
  219. }
  220. console.log(data)
  221. compute(data).then(
  222. res => {
  223. if(res.code==200){
  224. this.payMoney=res.data.payMoney;
  225. this.discountMoney=res.data.discountMoney;
  226. }
  227. else{
  228. this.userCouponId=0;
  229. this.couponText="请选择优惠券"
  230. uni.showToast({
  231. icon:'none',
  232. title: res.msg,
  233. });
  234. }
  235. },
  236. err => {
  237. }
  238. );
  239. },
  240. getMyEnableCouponList(){
  241. let data={couponType:2}
  242. if(this.order.orderType == 2) {
  243. data={couponType:'2,4'}
  244. }
  245. getMyEnableCouponList(data).then(
  246. res => {
  247. if(res.code==200){
  248. this.coupons=res.data;
  249. }
  250. },
  251. err => {
  252. }
  253. );
  254. },
  255. getStoreOrderById(){
  256. var data={orderId:this.orderId};
  257. console.log(data)
  258. getStoreOrderById(data).then(
  259. res => {
  260. if(res.code==200){
  261. this.order=res.order
  262. this.items=res.items
  263. if(this.order.userName!=null){
  264. this.address={
  265. realName:this.order.userName,
  266. phone:this.order.userPhone,
  267. address:this.order.userAddress,
  268. }
  269. }
  270. this.compute();
  271. this.getMyEnableCouponList();
  272. }else{
  273. }
  274. },
  275. rej => {}
  276. );
  277. },
  278. openAddress(){
  279. uni.navigateTo({
  280. url: '/pages_user/address'
  281. })
  282. },
  283. payOrder(){
  284. var data = {
  285. userCouponId:this.userCouponId,
  286. addressId:this.addressId,
  287. remark:this.order.remark,
  288. orderId:this.order.orderId,
  289. };
  290. var that=this;
  291. uni.showLoading();
  292. pay(data).then(
  293. res => {
  294. if(res.code==200){
  295. uni.redirectTo({
  296. url:"/pages_order/storeOrderPayment?orderId="+that.order.orderId
  297. })
  298. }else{
  299. uni.showToast({
  300. icon:'none',
  301. title: res.msg,
  302. });
  303. }
  304. },
  305. rej => {}
  306. );
  307. }
  308. }
  309. }
  310. </script>
  311. <style lang="scss">
  312. .inner-box{
  313. padding: 20upx 20upx 140upx;
  314. .address-box{
  315. box-sizing: border-box;
  316. min-height: 171upx;
  317. background: #FFFFFF;
  318. border-radius: 16upx;
  319. background-image: url(/static/images/address_bg.png);
  320. background-repeat: no-repeat;
  321. background-size: 100% 30upx;
  322. background-position: left bottom;
  323. padding: 38upx 30upx 36upx;
  324. display: flex;
  325. align-items: center;
  326. justify-content: space-between;
  327. .left{
  328. width: 92%;
  329. .name-box{
  330. display: flex;
  331. align-items: center;
  332. .text{
  333. font-size: 32upx;
  334. font-family: PingFang SC;
  335. font-weight: bold;
  336. color: #111111;
  337. line-height: 1;
  338. &.name{
  339. margin-right: 30upx;
  340. }
  341. }
  342. }
  343. .address{
  344. font-size: 28upx;
  345. font-family: PingFang SC;
  346. font-weight: 500;
  347. color: #666666;
  348. line-height: 42upx;
  349. text-align:left;
  350. margin-top: 23upx;
  351. }
  352. }
  353. .arrow-box{
  354. width: 12upx;
  355. height: 23upx;
  356. display: flex;
  357. align-items: cenetr;
  358. justify-content: cenetr;
  359. image{
  360. width: 100%;
  361. height: 100%;
  362. }
  363. }
  364. }
  365. .goods-list{
  366. margin-top: 20upx;
  367. padding: 0 30upx;
  368. background-color: #FFFFFF;
  369. border-radius: 16upx;
  370. .item{
  371. padding: 30upx 0;
  372. border-bottom: 1px solid #EDEEEF;
  373. display: flex;
  374. align-items: center;
  375. .img-box{
  376. width: 160upx;
  377. height: 160upx;
  378. margin-right: 30upx;
  379. image{
  380. width: 100%;
  381. height: 100%;
  382. }
  383. }
  384. .info-box{
  385. width: calc(100% - 190upx);
  386. height: 160upx;
  387. display: flex;
  388. flex-direction: column;
  389. justify-content: space-between;
  390. .name-box{
  391. font-size: 28upx;
  392. font-family: PingFang SC;
  393. font-weight: 500;
  394. color: #111111;
  395. line-height: 40upx;
  396. .tag{
  397. display: inline-block;
  398. padding: 0 6upx;
  399. height: 30upx;
  400. background: linear-gradient(90deg, #C39A58 0%, #E2C99E 100%);
  401. border-radius: 4upx;
  402. margin-right: 10upx;
  403. font-size: 22upx;
  404. font-family: PingFang SC;
  405. font-weight: bold;
  406. color: #FFFFFF;
  407. line-height: 30upx;
  408. float: left;
  409. margin-top: 7upx;
  410. }
  411. }
  412. .spec{
  413. margin-top: 10upx;
  414. font-size: 24upx;
  415. font-family: PingFang SC;
  416. font-weight: 500;
  417. color: #999999;
  418. line-height: 1;
  419. }
  420. .price-num{
  421. display: flex;
  422. align-items: center;
  423. justify-content: space-between;
  424. .price{
  425. display: flex;
  426. align-items: flex-end;
  427. .unit{
  428. font-size: 24upx;
  429. font-family: PingFang SC;
  430. font-weight: 500;
  431. color: #111111;
  432. line-height: 1.2;
  433. margin-right: 4upx;
  434. }
  435. .num{
  436. font-size: 32upx;
  437. font-family: PingFang SC;
  438. font-weight: 500;
  439. color: #111111;
  440. line-height: 1;
  441. }
  442. }
  443. .num{
  444. font-size: 24upx;
  445. font-family: PingFang SC;
  446. font-weight: 500;
  447. color: #999999;
  448. line-height: 1;
  449. }
  450. }
  451. }
  452. }
  453. .sub-total{
  454. height: 88upx;
  455. display: flex;
  456. align-items: center;
  457. justify-content: flex-end;
  458. .label{
  459. font-size: 24upx;
  460. font-family: PingFang SC;
  461. font-weight: 500;
  462. color: #999999;
  463. }
  464. .price{
  465. display: flex;
  466. align-items: flex-end;
  467. .unit{
  468. font-size: 24upx;
  469. font-family: PingFang SC;
  470. font-weight: 500;
  471. color: #FF6633;
  472. line-height: 1.2;
  473. margin-right: 4upx;
  474. }
  475. .num{
  476. font-size: 32upx;
  477. font-family: PingFang SC;
  478. font-weight: bold;
  479. color: #FF6633;
  480. line-height: 1;
  481. }
  482. }
  483. }
  484. }
  485. .other-info{
  486. margin-top: 20upx;
  487. background-color: #fff;
  488. border-radius: 20upx;
  489. overflow: hidden;
  490. padding: 0 30upx;
  491. .title{
  492. height: 80upx;
  493. line-height: 80upx;
  494. font-size: 30upx;
  495. color: #000;
  496. font-weight: bold;
  497. border-bottom: 2upx solid #eeeeee;
  498. }
  499. .item{
  500. height: 80upx;
  501. display: flex;
  502. align-items: center;
  503. justify-content: space-between;
  504. &:last-child{
  505. border-bottom: none;
  506. }
  507. .left{
  508. flex: 1;
  509. display: flex;
  510. align-items: center;
  511. .label{
  512. min-width: 140rpx;
  513. font-size: 28upx;
  514. color: #000;
  515. }
  516. .text{
  517. font-size: 28upx;
  518. color: #1b1b1b;
  519. }
  520. }
  521. .right{
  522. display: flex;
  523. align-items: center;
  524. justify-content: flex-end;
  525. .text{
  526. font-size: 28upx;
  527. color: #1b1b1b;
  528. }
  529. .ic-close{
  530. margin-left: 10rpx;
  531. width: 30rpx;
  532. height:30rpx;
  533. }
  534. .ic-back{
  535. margin-left: 10rpx;
  536. width: 15rpx;
  537. height:30rpx;
  538. }
  539. }
  540. .item-btn{
  541. max-width: 200rpx;
  542. padding: 0rpx 15rpx;
  543. height: 48upx;
  544. border-radius: 24upx;
  545. line-height: 48upx;
  546. font-size: 24upx;
  547. color: #000;
  548. border: 1upx solid #d8d8d8;
  549. display: flex;
  550. align-items: center;
  551. justify-content: center;
  552. }
  553. }
  554. }
  555. .remarks{
  556. height: 88upx;
  557. padding: 0 30upx;
  558. background: #FFFFFF;
  559. border-radius: 16upx;
  560. margin-top: 20upx;
  561. display: flex;
  562. align-items: center;
  563. input{
  564. width: 100%;
  565. font-size: 28upx;
  566. font-family: PingFang SC;
  567. font-weight: 500;
  568. color: #000000;
  569. }
  570. .input{
  571. font-size: 28upx;
  572. font-family: PingFang SC;
  573. font-weight: 500;
  574. color: #999999;
  575. }
  576. }
  577. }
  578. .btn-box{
  579. height: 140upx;
  580. z-index: 9999;
  581. width: 100%;
  582. padding: 0rpx 30upx;
  583. position: fixed;
  584. bottom: 0;
  585. left: 0;
  586. box-sizing: border-box;
  587. background-color: #ffffff;
  588. display: flex;
  589. align-items: center;
  590. justify-content: center;
  591. .btn{
  592. width: 100%;
  593. height: 88upx;
  594. line-height: 88upx;
  595. text-align: center;
  596. font-size: 34upx;
  597. font-family: PingFang SC;
  598. font-weight: 400;
  599. color: #FFFFFF;
  600. background: #C39A58;
  601. border-radius: 10upx;
  602. }
  603. }
  604. .pay-type{
  605. box-sizing: border-box;
  606. height: 192upx;
  607. background: #FFFFFF;
  608. border-radius: 16upx;
  609. margin-top: 20upx;
  610. padding: 40upx 30upx;
  611. display: flex;
  612. flex-direction: column;
  613. justify-content: space-between;
  614. .title{
  615. font-size: 28upx;
  616. font-family: PingFang SC;
  617. font-weight: 500;
  618. color: #999999;
  619. line-height: 1;
  620. }
  621. .item{
  622. display: flex;
  623. align-items: center;
  624. justify-content: space-between;
  625. .left{
  626. display: flex;
  627. align-items: center;
  628. image{
  629. width: 44upx;
  630. height: 44upx;
  631. margin-right: 20upx;
  632. }
  633. .text{
  634. font-size: 30upx;
  635. font-family: PingFang SC;
  636. font-weight: bold;
  637. color: #222222;
  638. line-height: 1;
  639. }
  640. }
  641. }
  642. }
  643. .coupon{
  644. height: 100%;
  645. .empty{
  646. display: flex;
  647. align-items: center;
  648. justify-content: center;
  649. height: 650rpx;
  650. width: 100%;
  651. image{
  652. width: 280rpx;
  653. height: 200rpx;
  654. }
  655. }
  656. }
  657. .coupon-box{
  658. overflow-y: auto;
  659. padding: 80rpx 20rpx 80rpx;
  660. height: 650rpx;
  661. width: 100%;
  662. display: flex;
  663. flex-direction: column;
  664. align-items: flex-start;
  665. justify-content: flex-start;
  666. box-sizing: border-box;
  667. .coupon-item{
  668. width: 100%;
  669. display: flex;
  670. align-items: center;
  671. justify-content: flex-start;
  672. margin-bottom: 16rpx;
  673. height:170rpx;
  674. &:last-child{
  675. margin-bottom: 0rpx;
  676. }
  677. .left{
  678. color: #fff;
  679. font-size: 36rpx;
  680. font-weight: bold;
  681. text-align: center;
  682. display: flex;
  683. flex-direction: column;
  684. align-items: center;
  685. justify-content: center;
  686. position: relative;
  687. width: 230rpx;
  688. image{
  689. position: absolute;
  690. width: 230rpx;
  691. height:170rpx;
  692. color: #fff;
  693. }
  694. .num{
  695. font-size: 40rpx;
  696. }
  697. .pic-num{
  698. font-size: 20rpx;
  699. z-index: 99;
  700. }
  701. }
  702. .right{
  703. display: flex;
  704. flex-direction: column;
  705. align-items: flex-start;
  706. justify-content: flex-start;
  707. height:170rpx;
  708. width: calc(100% - 230rpx);
  709. padding: 0 17rpx 0 24rpx;
  710. background-color: #fff;
  711. box-sizing: border-box;
  712. .title{
  713. width: 100%;
  714. font-size: 0.3 * 100rpx;
  715. color: #282828;
  716. height: 0.93 * 100rpx;
  717. line-height: 0.93 * 100rpx;
  718. border-bottom: 1px solid #f0f0f0;
  719. }
  720. .btns{
  721. display: flex;
  722. align-items: center;
  723. justify-content: space-between;
  724. width: 100%;
  725. font-size: 0.2 * 100rpx;
  726. color: #999;
  727. height: 0.76 * 100rpx;
  728. .btn{
  729. width: 1.36 * 100rpx;
  730. height: 0.44 * 100rpx;
  731. border-radius: 0.22 * 100rpx;
  732. font-size: 0.22 * 100rpx;
  733. color: #fff;
  734. text-align: center;
  735. line-height: 0.44 * 100rpx;
  736. background-color: #C39A58;
  737. .gray{
  738. background-color: #ccc;
  739. }
  740. }
  741. }
  742. }
  743. }
  744. }
  745. </style>