storeOrderPay.vue 17 KB

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