paymentOrder.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <view class="content">
  3. <view class="inner">
  4. <!-- 时间、价格 -->
  5. <view class="time-price">
  6. <text class="time">请在{{payLimitTime}}前完成支付</text>
  7. <view class="price-box">
  8. <text class="unit">¥</text>
  9. <text class="num" >{{payMoney.toFixed(2)}}</text>
  10. </view>
  11. <text class="desc" v-if="payType==2">代收金额{{payDelivery.toFixed(2)}},请您在收到快递后支付尾款给快递人员。</text>
  12. <text class="desc" v-if="payType==3">货到付款金额{{payDelivery.toFixed(2)}},请您在收到快递后支付给快递人员。</text>
  13. </view>
  14. <!-- 支付方式 -->
  15. <view class="pay-type">
  16. <view class="title">支付方式</view>
  17. <!-- 改价订单只能选择微信支付和物流代收 -->
  18. <radio-group @change="payTypeChange" v-if="order.isEditMoney!=null&&order.isEditMoney==1">
  19. <view class="item" >
  20. <view class="left" >
  21. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/wecha_pay.png" mode=""></image>
  22. <text class="text">微信支付</text>
  23. </view>
  24. <label>
  25. <radio :value="1" :checked="order.payType=='1'" />
  26. </label>
  27. </view>
  28. <view class="item" >
  29. <view class="left">
  30. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_de.png" mode=""></image>
  31. <text class="text">物流代收</text>
  32. </view>
  33. <label>
  34. <radio :value="2" :checked="order.payType=='2'" />
  35. </label>
  36. </view>
  37. </radio-group>
  38. <radio-group @change="payTypeChange" v-else-if="order.orderCreateType!=null&& order.orderCreateType==3">
  39. <view class="item" >
  40. <view class="left" >
  41. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/wecha_pay.png" mode=""></image>
  42. <text class="text">微信支付</text>
  43. </view>
  44. <label>
  45. <radio :value="1" :checked="order.payType=='1'" />
  46. </label>
  47. </view>
  48. <view class="item" >
  49. <view class="left">
  50. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_de.png" mode=""></image>
  51. <text class="text">物流代收</text>
  52. </view>
  53. <label>
  54. <radio :value="2" :checked="order.payType=='2'" />
  55. </label>
  56. </view>
  57. <!-- <view class="item" v-if="user!=null&&user.level==1 "> -->
  58. <view class="item" >
  59. <view class="left">
  60. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_1.png" mode=""></image>
  61. <text class="text">货到付款</text>
  62. </view>
  63. <label>
  64. <radio :value="3" :checked="order.payType=='3'" />
  65. </label>
  66. </view>
  67. </radio-group>
  68. <radio-group @change="payTypeChange" v-else-if="order.orderCreateType!=null&& order.orderCreateType==2">
  69. <view class="item" v-if="payType==1||payType==4" >
  70. <view class="left" >
  71. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/wecha_pay.png" mode=""></image>
  72. <text class="text">微信支付</text>
  73. </view>
  74. <label>
  75. <radio :value="1" :checked="order.payType=='1'" />
  76. </label>
  77. </view>
  78. <view class="item" v-if="payType==2||payType==4">
  79. <view class="left" >
  80. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_de.png" mode=""></image>
  81. <text class="text">物流代收</text>
  82. </view>
  83. <label>
  84. <radio :value="2" :checked="order.payType=='2'" />
  85. </label>
  86. </view>
  87. <!-- <view class="item" v-if="user!=null&&user.level==1 "> -->
  88. <view class="item" v-if="payType==1||payType==4" >
  89. <view class="left">
  90. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/pay_1.png" mode=""></image>
  91. <text class="text">货到付款</text>
  92. </view>
  93. <label>
  94. <radio :value="3" :checked="order.payType=='3'" />
  95. </label>
  96. </view>
  97. </radio-group>
  98. <radio-group @change="payTypeChange" v-else-if="order.orderCreateType!=null&&(order.orderCreateType==1)">
  99. <view class="item" >
  100. <view class="left" >
  101. <image src="https://zkzh-2025.oss-cn-beijing.aliyuncs.com/shop/images/wecha_pay.png" mode=""></image>
  102. <text class="text">微信支付</text>
  103. </view>
  104. <label>
  105. <radio :value="1" checked />
  106. </label>
  107. </view>
  108. </radio-group>
  109. </view>
  110. <!-- 订单详情查看 -->
  111. <view class="order-info">
  112. <view class="title">订单信息</view>
  113. <view class="item">
  114. <text class="label">订单编号</text>
  115. <view class="sn-box">
  116. <text class="text">{{order.orderCode}}</text>
  117. <view class="copy-btn" @click="copyOrderSn(order.orderCode)">复制</view>
  118. </view>
  119. </view>
  120. <view class="item">
  121. <text class="label">下单时间</text>
  122. <text class="text">{{order.createTime}}</text>
  123. </view>
  124. <view class="item">
  125. <text class="label">订单金额</text>
  126. <text class="text" v-if="order!=null">{{order.payPrice.toFixed(2)}}</text>
  127. </view>
  128. <!-- <view class="item">
  129. <text class="label">支付方式</text>
  130. <text class="text">微信支付</text>
  131. </view> -->
  132. </view>
  133. </view>
  134. <view class="btn-box">
  135. <view class="btn" @click="payOrder()">去支付</view>
  136. <!-- <view class="other-btn" >
  137. 亲友代付
  138. <button class="share" data-name="shareBtn" open-type="share">分享</button>
  139. </view> -->
  140. </view>
  141. </view>
  142. </template>
  143. <script>
  144. import {getUserInfo} from '@/api/user'
  145. import {getStoreConfig} from '@/api/common'
  146. import {editPayType,pay,getStoreOrderById,orderBindUser} from '@/api/storeOrder'
  147. export default {
  148. data() {
  149. return {
  150. orderId:null,
  151. payDelivery:0,
  152. payMoney:0,
  153. config:null,
  154. payType:1,
  155. payLimitTime:null,
  156. order:null,
  157. user:null,
  158. }
  159. },
  160. onLoad(option) {
  161. this.orderId=JSON.parse(option.orderId);
  162. // this.orderBindUser(this.orderId)
  163. this.getStoreOrderById();
  164. this.getStoreConfig();
  165. this.getUserInfo();
  166. // uni.showShareMenu({
  167. // withShareTicket:true,
  168. // //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  169. // menus:["shareAppMessage"] //不设置默认发送给朋友
  170. // })
  171. },
  172. //发送给朋友
  173. // onShareAppMessage(res) {
  174. // return {
  175. // title: "帮TA支付",
  176. // path: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId,
  177. // imageUrl: 'https://zkzh-2024.oss-cn-beijing.aliyuncs.com/fs/20241127/5b9750f911804728b153ebe5c0051a6f.jpg' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  178. // }
  179. // },
  180. methods: {
  181. orderBindUser(orderId) {
  182. uni.showLoading({
  183. title: '加载中...'
  184. })
  185. orderBindUser({orderId: orderId}).then(res => {
  186. uni.hideLoading()
  187. if(res.code==200){
  188. this.getStoreOrderById();
  189. this.getStoreConfig();
  190. this.getUserInfo();
  191. // uni.showShareMenu({
  192. // withShareTicket:true,
  193. // //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  194. // menus:["shareAppMessage"] //不设置默认发送给朋友
  195. // })
  196. }else{
  197. uni.showToast({
  198. icon:'none',
  199. title: res.msg,
  200. });
  201. }
  202. }).catch(()=>{
  203. uni.hideLoading()
  204. });
  205. },
  206. getUserInfo(){
  207. getUserInfo().then(
  208. res => {
  209. if(res.code==200){
  210. if(res.user!=null){
  211. this.user=res.user;
  212. }
  213. }else{
  214. uni.showToast({
  215. icon:'none',
  216. title: "请求失败",
  217. });
  218. }
  219. },
  220. rej => {}
  221. );
  222. },
  223. getStoreConfig(){
  224. getStoreConfig().then(
  225. res => {
  226. if(res.code==200){
  227. this.config=res.data
  228. console.log(this.config);
  229. }
  230. },
  231. rej => {}
  232. );
  233. },
  234. payTypeChange(e){
  235. this.editPayType(e.detail.value)
  236. },
  237. copyOrderSn(text) {
  238. // 复制方法
  239. uni.setClipboardData({
  240. data:text,
  241. success:()=>{
  242. uni.showToast({
  243. title:'内容已成功复制到剪切板',
  244. icon:'none'
  245. })
  246. }
  247. });
  248. },
  249. getStoreOrderById(){
  250. var data = {orderId:this.orderId};
  251. var that=this;
  252. uni.showLoading();
  253. getStoreOrderById(data).then(
  254. res => {
  255. if(res.code==200){
  256. console.log(res);
  257. uni.hideLoading();
  258. that.order=res.order;
  259. that.payLimitTime=res.payLimitTime;
  260. //套餐订单处理
  261. if(res.productPackage!=null){
  262. this.payType=res.productPackage.payType;
  263. console.log(this.payType)
  264. if(this.order.payType==4){
  265. this.order.payType=1;
  266. }
  267. }
  268. this.editPayType(this.order.payType)
  269. }else{
  270. uni.showToast({
  271. icon:'none',
  272. title: res.msg,
  273. });
  274. }
  275. },
  276. rej => {}
  277. );
  278. },
  279. editPayType(payType){
  280. var data = {orderId:this.orderId,payType:payType};
  281. var that=this;
  282. uni.showLoading();
  283. editPayType(data).then(
  284. res => {
  285. if(res.code==200){
  286. console.log(res);
  287. uni.hideLoading();
  288. that.order=res.order;
  289. //this.payType=this.order.payType
  290. this.payMoney=this.order.payMoney;
  291. this.payDelivery=this.order.payDelivery;
  292. }else{
  293. uni.showToast({
  294. icon:'none',
  295. title: res.msg,
  296. });
  297. }
  298. },
  299. rej => {}
  300. );
  301. },
  302. otherPayOrder(){
  303. uni.navigateTo({
  304. url: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId
  305. })
  306. },
  307. payOrder(){
  308. var data = {orderId:this.order.id,payType:this.order.payType};
  309. var that=this;
  310. uni.showLoading();
  311. pay(data).then(
  312. res => {
  313. if(res.code==200){
  314. console.log(res);
  315. if(res.payType==1||res.payType==2||res.payType==3){
  316. uni.requestPayment({
  317. provider: 'wxpay',
  318. timeStamp: res.result.timeStamp,
  319. nonceStr:res.result.nonceStr,
  320. package: res.result.packageValue,
  321. signType: res.result.signType,
  322. paySign: res.result.paySign,
  323. success: function(res) {
  324. console.log('yess:' + JSON.stringify(res));
  325. uni.hideLoading();
  326. uni.redirectTo({
  327. url:"success?order="+JSON.stringify(that.order)
  328. })
  329. },
  330. fail: function(err) {
  331. uni.showToast({
  332. icon:'none',
  333. title:'fail:' + JSON.stringify(err),
  334. });
  335. console.log('fail:' + JSON.stringify(err));
  336. uni.hideLoading();
  337. },
  338. complete: (err) => {
  339. console.log('fail:' + JSON.stringify(err));
  340. }
  341. });
  342. }
  343. // else if(res.payType==3){
  344. // uni.hideLoading();
  345. // if(that.order.isPrescribe){
  346. // //如果是处方订单开处方
  347. // uni.redirectTo({
  348. // url:"prescribe?orderId="+that.order.id
  349. // })
  350. // }
  351. // else{
  352. // //如果是普通订单
  353. // uni.redirectTo({
  354. // url:"success?order="+JSON.stringify(that.order)
  355. // })
  356. // }
  357. // }
  358. }else{
  359. uni.showToast({
  360. icon:'none',
  361. title: res.msg,
  362. });
  363. }
  364. },
  365. rej => {}
  366. );
  367. }
  368. }
  369. }
  370. </script>
  371. <style lang="scss">
  372. page{
  373. height: 100%;
  374. }
  375. .content{
  376. height: 100%;
  377. display: flex;
  378. flex-direction: column;
  379. justify-content: space-between;
  380. .inner{
  381. padding: 20upx;
  382. .time-price{
  383. box-sizing: border-box;
  384. padding: 50upx 0upx;
  385. background: #FFFFFF;
  386. border-radius: 16upx;
  387. display: flex;
  388. flex-direction: column;
  389. align-items: center;
  390. .time{
  391. font-size: 32upx;
  392. font-family: PingFang SC;
  393. font-weight: 500;
  394. color: #222222;
  395. line-height: 1;
  396. text-align: center;
  397. }
  398. .desc{
  399. margin: 30upx 0upx 15upx;
  400. font-size: 26upx;
  401. font-family: PingFang SC;
  402. color: #999999;
  403. line-height: 1;
  404. text-align: center;
  405. }
  406. .price-box{
  407. display: flex;
  408. align-items: flex-end;
  409. margin-top: 28upx;
  410. .unit{
  411. font-size: 32upx;
  412. font-family: PingFang SC;
  413. font-weight: bold;
  414. color: #FF6633;
  415. line-height: 1.3;
  416. margin-right: 10upx;
  417. }
  418. .num{
  419. font-size: 56upx;
  420. font-family: PingFang SC;
  421. font-weight: bold;
  422. color: #FF6633;
  423. line-height: 1;
  424. }
  425. }
  426. }
  427. .pay-type{
  428. box-sizing: border-box;
  429. background: #FFFFFF;
  430. border-radius: 16upx;
  431. margin-top: 20upx;
  432. padding: 40upx 30upx;
  433. display: flex;
  434. flex-direction: column;
  435. justify-content: space-between;
  436. .title{
  437. font-size: 28upx;
  438. font-family: PingFang SC;
  439. font-weight: 500;
  440. color: #999999;
  441. line-height: 1;
  442. margin-bottom: 10upx;
  443. }
  444. .item{
  445. padding: 15upx 0upx;
  446. display: flex;
  447. align-items: center;
  448. justify-content: space-between;
  449. .left{
  450. display: flex;
  451. align-items: center;
  452. image{
  453. width: 44upx;
  454. height: 44upx;
  455. margin-right: 20upx;
  456. }
  457. .text{
  458. font-size: 30upx;
  459. font-family: PingFang SC;
  460. font-weight: bold;
  461. color: #222222;
  462. line-height: 1;
  463. }
  464. }
  465. }
  466. }
  467. .order-info{
  468. margin-top: 20upx;
  469. background: #FFFFFF;
  470. border-radius: 16upx;
  471. padding: 40upx 30upx;
  472. .title{
  473. font-size: 30upx;
  474. font-family: PingFang SC;
  475. font-weight: bold;
  476. color: #222222;
  477. line-height: 1;
  478. }
  479. .item{
  480. margin-top: 40upx;
  481. display: flex;
  482. align-items: center;
  483. justify-content: space-between;
  484. .label{
  485. font-size: 26upx;
  486. font-family: PingFang SC;
  487. font-weight: 500;
  488. color: #666666;
  489. line-height: 1;
  490. }
  491. .text{
  492. font-size: 26upx;
  493. font-family: PingFang SC;
  494. font-weight: 500;
  495. color: #222222;
  496. line-height: 32upx;
  497. }
  498. .cont-text{
  499. font-size: 26upx;
  500. font-family: PingFang SC;
  501. font-weight: 500;
  502. color: #666666;
  503. .bold{
  504. color: #111111;
  505. }
  506. }
  507. .sn-box{
  508. display: flex;
  509. align-items: center;
  510. .copy-btn{
  511. width: 58upx;
  512. height: 32upx;
  513. line-height: 32upx;
  514. text-align: center;
  515. font-size: 22upx;
  516. font-family: PingFang SC;
  517. font-weight: 500;
  518. color: #222222;
  519. background: #F5F5F5;
  520. border-radius: 4upx;
  521. margin-left: 24upx;
  522. }
  523. }
  524. }
  525. .line{
  526. width: 100%;
  527. height: 1px;
  528. background: #F0F0F0;
  529. margin-top: 30upx;
  530. }
  531. }
  532. }
  533. .btn-box{
  534. height: 242upx;
  535. background: #FFFFFF;
  536. display: flex;
  537. align-items: center;
  538. justify-content: center;
  539. flex-direction: column;
  540. .btn{
  541. width: 91.73%;
  542. height: 88upx;
  543. line-height: 88upx;
  544. font-size: 30upx;
  545. font-family: PingFang SC;
  546. font-weight: bold;
  547. color: #FFFFFF;
  548. text-align: center;
  549. background: #2BC7B9;
  550. border-radius: 44upx;
  551. margin-bottom: 10rpx;
  552. }
  553. .other-btn{
  554. width: 91.73%;
  555. height: 88upx;
  556. line-height: 88upx;
  557. font-size: 30upx;
  558. font-family: PingFang SC;
  559. font-weight: bold;
  560. color: #2BC7B9;
  561. border: 1rpx solid #2BC7B9;
  562. text-align: center;
  563. background: #FFFFFF;
  564. border-radius: 44upx;
  565. margin-bottom: 10rpx;
  566. position: relative;
  567. .share{
  568. display: inline-block;
  569. position: absolute;
  570. top: 0;
  571. left: 0;
  572. width: 100%;
  573. height: 100%;
  574. opacity: 0;
  575. }
  576. }
  577. }
  578. }
  579. </style>