paymentOrder.vue 16 KB

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