storeOrderPay.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758
  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.ordetType==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. this.getMyEnableCouponList();
  183. },
  184. // onShareAppMessage(res) {
  185. // var that=this;
  186. // if(this.$isLogin()){
  187. // return {
  188. // title: "订单支付",
  189. // path: '/pages_order/storeOrderPay?orderId='+that.orderId,
  190. // imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  191. // }
  192. // }
  193. // },
  194. methods: {
  195. couponSelect(item){
  196. this.couponShow = false;
  197. //计算金额
  198. this.userCouponId=item.id;
  199. console.log(item)
  200. this.couponText=item.price+"元优惠券"
  201. this.compute()
  202. },
  203. open() {
  204. },
  205. close() {
  206. this.couponShow = false
  207. },
  208. openCoupon(){
  209. this.couponShow=true;
  210. },
  211. delCoupon(){
  212. this.userCouponId=0;
  213. this.couponText="请选择优惠券";
  214. this.compute();
  215. },
  216. compute(){
  217. var data={
  218. orderId:this.orderId,
  219. userCouponId:this.userCouponId
  220. }
  221. console.log(data)
  222. compute(data).then(
  223. res => {
  224. if(res.code==200){
  225. this.payMoney=res.data.payMoney;
  226. this.discountMoney=res.data.discountMoney;
  227. }
  228. else{
  229. this.userCouponId=0;
  230. this.couponText="请选择优惠券"
  231. uni.showToast({
  232. icon:'none',
  233. title: res.msg,
  234. });
  235. }
  236. },
  237. err => {
  238. }
  239. );
  240. },
  241. getMyEnableCouponList(){
  242. var data={couponType:2}
  243. getMyEnableCouponList(data).then(
  244. res => {
  245. if(res.code==200){
  246. this.coupons=res.data;
  247. }
  248. },
  249. err => {
  250. }
  251. );
  252. },
  253. getStoreOrderById(){
  254. var data={orderId:this.orderId};
  255. console.log(data)
  256. getStoreOrderById(data).then(
  257. res => {
  258. if(res.code==200){
  259. this.order=res.order
  260. this.items=res.items
  261. if(this.order.userName!=null){
  262. this.address={
  263. realName:this.order.userName,
  264. phone:this.order.userPhone,
  265. address:this.order.userAddress,
  266. }
  267. }
  268. this.compute();
  269. }else{
  270. }
  271. },
  272. rej => {}
  273. );
  274. },
  275. openAddress(){
  276. uni.navigateTo({
  277. url: '/pages_user/address'
  278. })
  279. },
  280. payOrder(){
  281. var data = {
  282. userCouponId:this.userCouponId,
  283. addressId:this.addressId,
  284. remark:this.order.remark,
  285. orderId:this.order.orderId,
  286. };
  287. var that=this;
  288. uni.showLoading();
  289. pay(data).then(
  290. res => {
  291. if(res.code==200){
  292. uni.redirectTo({
  293. url:"/pages_order/storeOrderPayment?orderId="+that.order.orderId
  294. })
  295. }else{
  296. uni.showToast({
  297. icon:'none',
  298. title: res.msg,
  299. });
  300. }
  301. },
  302. rej => {}
  303. );
  304. }
  305. }
  306. }
  307. </script>
  308. <style lang="scss">
  309. .inner-box{
  310. padding: 20upx 20upx 140upx;
  311. .address-box{
  312. box-sizing: border-box;
  313. min-height: 171upx;
  314. background: #FFFFFF;
  315. border-radius: 16upx;
  316. background-image: url(/static/images/address_bg.png);
  317. background-repeat: no-repeat;
  318. background-size: 100% 30upx;
  319. background-position: left bottom;
  320. padding: 38upx 30upx 36upx;
  321. display: flex;
  322. align-items: center;
  323. justify-content: space-between;
  324. .left{
  325. width: 92%;
  326. .name-box{
  327. display: flex;
  328. align-items: center;
  329. .text{
  330. font-size: 32upx;
  331. font-family: PingFang SC;
  332. font-weight: bold;
  333. color: #111111;
  334. line-height: 1;
  335. &.name{
  336. margin-right: 30upx;
  337. }
  338. }
  339. }
  340. .address{
  341. font-size: 28upx;
  342. font-family: PingFang SC;
  343. font-weight: 500;
  344. color: #666666;
  345. line-height: 42upx;
  346. text-align:left;
  347. margin-top: 23upx;
  348. }
  349. }
  350. .arrow-box{
  351. width: 12upx;
  352. height: 23upx;
  353. display: flex;
  354. align-items: cenetr;
  355. justify-content: cenetr;
  356. image{
  357. width: 100%;
  358. height: 100%;
  359. }
  360. }
  361. }
  362. .goods-list{
  363. margin-top: 20upx;
  364. padding: 0 30upx;
  365. background-color: #FFFFFF;
  366. border-radius: 16upx;
  367. .item{
  368. padding: 30upx 0;
  369. border-bottom: 1px solid #EDEEEF;
  370. display: flex;
  371. align-items: center;
  372. .img-box{
  373. width: 160upx;
  374. height: 160upx;
  375. margin-right: 30upx;
  376. image{
  377. width: 100%;
  378. height: 100%;
  379. }
  380. }
  381. .info-box{
  382. width: calc(100% - 190upx);
  383. height: 160upx;
  384. display: flex;
  385. flex-direction: column;
  386. justify-content: space-between;
  387. .name-box{
  388. font-size: 28upx;
  389. font-family: PingFang SC;
  390. font-weight: 500;
  391. color: #111111;
  392. line-height: 40upx;
  393. .tag{
  394. display: inline-block;
  395. padding: 0 6upx;
  396. height: 30upx;
  397. background: linear-gradient(90deg, #C39A58 0%, #E2C99E 100%);
  398. border-radius: 4upx;
  399. margin-right: 10upx;
  400. font-size: 22upx;
  401. font-family: PingFang SC;
  402. font-weight: bold;
  403. color: #FFFFFF;
  404. line-height: 30upx;
  405. float: left;
  406. margin-top: 7upx;
  407. }
  408. }
  409. .spec{
  410. margin-top: 10upx;
  411. font-size: 24upx;
  412. font-family: PingFang SC;
  413. font-weight: 500;
  414. color: #999999;
  415. line-height: 1;
  416. }
  417. .price-num{
  418. display: flex;
  419. align-items: center;
  420. justify-content: space-between;
  421. .price{
  422. display: flex;
  423. align-items: flex-end;
  424. .unit{
  425. font-size: 24upx;
  426. font-family: PingFang SC;
  427. font-weight: 500;
  428. color: #111111;
  429. line-height: 1.2;
  430. margin-right: 4upx;
  431. }
  432. .num{
  433. font-size: 32upx;
  434. font-family: PingFang SC;
  435. font-weight: 500;
  436. color: #111111;
  437. line-height: 1;
  438. }
  439. }
  440. .num{
  441. font-size: 24upx;
  442. font-family: PingFang SC;
  443. font-weight: 500;
  444. color: #999999;
  445. line-height: 1;
  446. }
  447. }
  448. }
  449. }
  450. .sub-total{
  451. height: 88upx;
  452. display: flex;
  453. align-items: center;
  454. justify-content: flex-end;
  455. .label{
  456. font-size: 24upx;
  457. font-family: PingFang SC;
  458. font-weight: 500;
  459. color: #999999;
  460. }
  461. .price{
  462. display: flex;
  463. align-items: flex-end;
  464. .unit{
  465. font-size: 24upx;
  466. font-family: PingFang SC;
  467. font-weight: 500;
  468. color: #FF6633;
  469. line-height: 1.2;
  470. margin-right: 4upx;
  471. }
  472. .num{
  473. font-size: 32upx;
  474. font-family: PingFang SC;
  475. font-weight: bold;
  476. color: #FF6633;
  477. line-height: 1;
  478. }
  479. }
  480. }
  481. }
  482. .other-info{
  483. margin-top: 20upx;
  484. background-color: #fff;
  485. border-radius: 20upx;
  486. overflow: hidden;
  487. padding: 0 30upx;
  488. .title{
  489. height: 80upx;
  490. line-height: 80upx;
  491. font-size: 30upx;
  492. color: #000;
  493. font-weight: bold;
  494. border-bottom: 2upx solid #eeeeee;
  495. }
  496. .item{
  497. height: 80upx;
  498. display: flex;
  499. align-items: center;
  500. justify-content: space-between;
  501. &:last-child{
  502. border-bottom: none;
  503. }
  504. .left{
  505. flex: 1;
  506. display: flex;
  507. align-items: center;
  508. .label{
  509. min-width: 140rpx;
  510. font-size: 28upx;
  511. color: #000;
  512. }
  513. .text{
  514. font-size: 28upx;
  515. color: #1b1b1b;
  516. }
  517. }
  518. .right{
  519. display: flex;
  520. align-items: center;
  521. justify-content: flex-end;
  522. .text{
  523. font-size: 28upx;
  524. color: #1b1b1b;
  525. }
  526. .ic-close{
  527. margin-left: 10rpx;
  528. width: 30rpx;
  529. height:30rpx;
  530. }
  531. .ic-back{
  532. margin-left: 10rpx;
  533. width: 15rpx;
  534. height:30rpx;
  535. }
  536. }
  537. .item-btn{
  538. max-width: 200rpx;
  539. padding: 0rpx 15rpx;
  540. height: 48upx;
  541. border-radius: 24upx;
  542. line-height: 48upx;
  543. font-size: 24upx;
  544. color: #000;
  545. border: 1upx solid #d8d8d8;
  546. display: flex;
  547. align-items: center;
  548. justify-content: center;
  549. }
  550. }
  551. }
  552. .remarks{
  553. height: 88upx;
  554. padding: 0 30upx;
  555. background: #FFFFFF;
  556. border-radius: 16upx;
  557. margin-top: 20upx;
  558. display: flex;
  559. align-items: center;
  560. input{
  561. width: 100%;
  562. font-size: 28upx;
  563. font-family: PingFang SC;
  564. font-weight: 500;
  565. color: #000000;
  566. }
  567. .input{
  568. font-size: 28upx;
  569. font-family: PingFang SC;
  570. font-weight: 500;
  571. color: #999999;
  572. }
  573. }
  574. }
  575. .btn-box{
  576. height: 140upx;
  577. z-index: 9999;
  578. width: 100%;
  579. padding: 0rpx 30upx;
  580. position: fixed;
  581. bottom: 0;
  582. left: 0;
  583. box-sizing: border-box;
  584. background-color: #ffffff;
  585. display: flex;
  586. align-items: center;
  587. justify-content: center;
  588. .btn{
  589. width: 100%;
  590. height: 88upx;
  591. line-height: 88upx;
  592. text-align: center;
  593. font-size: 34upx;
  594. font-family: PingFang SC;
  595. font-weight: 400;
  596. color: #FFFFFF;
  597. background: #C39A58;
  598. border-radius: 10upx;
  599. }
  600. }
  601. .pay-type{
  602. box-sizing: border-box;
  603. height: 192upx;
  604. background: #FFFFFF;
  605. border-radius: 16upx;
  606. margin-top: 20upx;
  607. padding: 40upx 30upx;
  608. display: flex;
  609. flex-direction: column;
  610. justify-content: space-between;
  611. .title{
  612. font-size: 28upx;
  613. font-family: PingFang SC;
  614. font-weight: 500;
  615. color: #999999;
  616. line-height: 1;
  617. }
  618. .item{
  619. display: flex;
  620. align-items: center;
  621. justify-content: space-between;
  622. .left{
  623. display: flex;
  624. align-items: center;
  625. image{
  626. width: 44upx;
  627. height: 44upx;
  628. margin-right: 20upx;
  629. }
  630. .text{
  631. font-size: 30upx;
  632. font-family: PingFang SC;
  633. font-weight: bold;
  634. color: #222222;
  635. line-height: 1;
  636. }
  637. }
  638. }
  639. }
  640. .coupon{
  641. height: 100%;
  642. .empty{
  643. display: flex;
  644. align-items: center;
  645. justify-content: center;
  646. height: 650rpx;
  647. width: 100%;
  648. image{
  649. width: 280rpx;
  650. height: 200rpx;
  651. }
  652. }
  653. }
  654. .coupon-box{
  655. overflow-y: auto;
  656. padding: 80rpx 20rpx 80rpx;
  657. height: 650rpx;
  658. width: 100%;
  659. display: flex;
  660. flex-direction: column;
  661. align-items: flex-start;
  662. justify-content: flex-start;
  663. box-sizing: border-box;
  664. .coupon-item{
  665. width: 100%;
  666. display: flex;
  667. align-items: center;
  668. justify-content: flex-start;
  669. margin-bottom: 16rpx;
  670. height:170rpx;
  671. &:last-child{
  672. margin-bottom: 0rpx;
  673. }
  674. .left{
  675. color: #fff;
  676. font-size: 36rpx;
  677. font-weight: bold;
  678. text-align: center;
  679. display: flex;
  680. flex-direction: column;
  681. align-items: center;
  682. justify-content: center;
  683. position: relative;
  684. width: 230rpx;
  685. image{
  686. position: absolute;
  687. width: 230rpx;
  688. height:170rpx;
  689. color: #fff;
  690. }
  691. .num{
  692. font-size: 40rpx;
  693. }
  694. .pic-num{
  695. font-size: 20rpx;
  696. z-index: 99;
  697. }
  698. }
  699. .right{
  700. display: flex;
  701. flex-direction: column;
  702. align-items: flex-start;
  703. justify-content: flex-start;
  704. height:170rpx;
  705. width: calc(100% - 230rpx);
  706. padding: 0 17rpx 0 24rpx;
  707. background-color: #fff;
  708. box-sizing: border-box;
  709. .title{
  710. width: 100%;
  711. font-size: 0.3 * 100rpx;
  712. color: #282828;
  713. height: 0.93 * 100rpx;
  714. line-height: 0.93 * 100rpx;
  715. border-bottom: 1px solid #f0f0f0;
  716. }
  717. .btns{
  718. display: flex;
  719. align-items: center;
  720. justify-content: space-between;
  721. width: 100%;
  722. font-size: 0.2 * 100rpx;
  723. color: #999;
  724. height: 0.76 * 100rpx;
  725. .btn{
  726. width: 1.36 * 100rpx;
  727. height: 0.44 * 100rpx;
  728. border-radius: 0.22 * 100rpx;
  729. font-size: 0.22 * 100rpx;
  730. color: #fff;
  731. text-align: center;
  732. line-height: 0.44 * 100rpx;
  733. background-color: #C39A58;
  734. .gray{
  735. background-color: #ccc;
  736. }
  737. }
  738. }
  739. }
  740. }
  741. }
  742. </style>