paymentOrder.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621
  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. <ykscreenRecord></ykscreenRecord>
  157. </view>
  158. </template>
  159. <script>
  160. import {getUserInfo} from '@/api/user'
  161. import {getStoreConfig} from '@/api/common'
  162. import {editPayType,pay,getStoreOrderById,orderBindUser} from '@/api/storeOrder'
  163. import ykscreenRecord from "@/components/yk-screenRecord/yk-screenRecord.vue"
  164. export default {
  165. components:{
  166. ykscreenRecord
  167. },
  168. data() {
  169. return {
  170. orderId:null,
  171. payDelivery:0,
  172. payMoney:0,
  173. config:null,
  174. payType:1,
  175. payLimitTime:null,
  176. order:null,
  177. user:null,
  178. }
  179. },
  180. onLoad(option) {
  181. this.orderId=JSON.parse(option.orderId);
  182. // this.orderBindUser(this.orderId)
  183. this.getStoreOrderById();
  184. this.getStoreConfig();
  185. this.getUserInfo();
  186. // uni.showShareMenu({
  187. // withShareTicket:true,
  188. // //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  189. // menus:["shareAppMessage"] //不设置默认发送给朋友
  190. // })
  191. },
  192. //发送给朋友
  193. // onShareAppMessage(res) {
  194. // return {
  195. // title: "帮TA支付",
  196. // path: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId,
  197. // imageUrl: this.$store.state.imgpath+'/app/image/logo.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  198. // }
  199. // },
  200. methods: {
  201. orderBindUser(orderId) {
  202. uni.showLoading({
  203. title: '加载中...'
  204. })
  205. orderBindUser({orderId: orderId}).then(res => {
  206. uni.hideLoading()
  207. if(res.code==200){
  208. this.getStoreOrderById();
  209. this.getStoreConfig();
  210. this.getUserInfo();
  211. // uni.showShareMenu({
  212. // withShareTicket:true,
  213. // //小程序的原生菜单中显示分享按钮,才能够让发送给朋友与分享到朋友圈两个按钮可以点击
  214. // menus:["shareAppMessage"] //不设置默认发送给朋友
  215. // })
  216. }else{
  217. uni.showToast({
  218. icon:'none',
  219. title: res.msg,
  220. });
  221. }
  222. }).catch(()=>{
  223. uni.hideLoading()
  224. });
  225. },
  226. getUserInfo(){
  227. getUserInfo().then(
  228. res => {
  229. if(res.code==200){
  230. if(res.user!=null){
  231. this.user=res.user;
  232. }
  233. }else{
  234. uni.showToast({
  235. icon:'none',
  236. title: "请求失败",
  237. });
  238. }
  239. },
  240. rej => {}
  241. );
  242. },
  243. getStoreConfig(){
  244. getStoreConfig().then(
  245. res => {
  246. if(res.code==200){
  247. this.config=res.data
  248. console.log(this.config);
  249. }
  250. },
  251. rej => {}
  252. );
  253. },
  254. payTypeChange(e){
  255. this.editPayType(e.detail.value)
  256. },
  257. copyOrderSn(text) {
  258. // 复制方法
  259. uni.setClipboardData({
  260. data:text,
  261. success:()=>{
  262. uni.showToast({
  263. title:'内容已成功复制到剪切板',
  264. icon:'none'
  265. })
  266. }
  267. });
  268. },
  269. getStoreOrderById(){
  270. var data = {orderId:this.orderId};
  271. var that=this;
  272. uni.showLoading();
  273. getStoreOrderById(data).then(
  274. res => {
  275. if(res.code==200){
  276. console.log(res);
  277. uni.hideLoading();
  278. that.order=res.order;
  279. that.payLimitTime=res.payLimitTime;
  280. //套餐订单处理
  281. if(res.productPackage!=null){
  282. this.payType=res.productPackage.payType;
  283. console.log(this.payType)
  284. if(this.order.payType==4){
  285. this.order.payType=1;
  286. }
  287. }
  288. this.editPayType(this.order.payType)
  289. }else{
  290. uni.showToast({
  291. icon:'none',
  292. title: res.msg,
  293. });
  294. }
  295. },
  296. rej => {}
  297. );
  298. },
  299. editPayType(payType){
  300. var data = {orderId:this.orderId,payType:payType};
  301. var that=this;
  302. uni.showLoading();
  303. editPayType(data).then(
  304. res => {
  305. if(res.code==200){
  306. console.log(res);
  307. uni.hideLoading();
  308. that.order=res.order;
  309. //this.payType=this.order.payType
  310. this.payMoney=this.order.payMoney;
  311. this.payDelivery=this.order.payDelivery;
  312. }else{
  313. uni.showToast({
  314. icon:'none',
  315. title: res.msg,
  316. });
  317. }
  318. },
  319. rej => {}
  320. );
  321. },
  322. otherPayOrder(){
  323. uni.navigateTo({
  324. url: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId
  325. })
  326. },
  327. payOrder(){
  328. var data = {
  329. orderId:this.order.id,
  330. payType:this.order.payType,
  331. appId:wx.getAccountInfoSync().miniProgram.appId
  332. };
  333. var that=this;
  334. uni.showLoading();
  335. pay(data).then(
  336. res => {
  337. if(res.code==200){
  338. console.log(res);
  339. if(res.payType==1||res.payType==2||res.payType==3){
  340. uni.requestPayment({
  341. provider: 'wxpay',
  342. timeStamp: res.result.timeStamp,
  343. nonceStr:res.result.nonceStr,
  344. package: res.result.packageValue,
  345. signType: res.result.signType,
  346. paySign: res.result.paySign,
  347. success: function(res) {
  348. console.log('yess:' + JSON.stringify(res));
  349. uni.hideLoading();
  350. uni.redirectTo({
  351. url:"success?order="+JSON.stringify(that.order)
  352. })
  353. },
  354. fail: function(err) {
  355. uni.showToast({
  356. icon:'none',
  357. title:'fail:' + JSON.stringify(err),
  358. });
  359. console.log('fail:' + JSON.stringify(err));
  360. uni.hideLoading();
  361. },
  362. complete: (err) => {
  363. console.log('fail:' + JSON.stringify(err));
  364. }
  365. });
  366. }
  367. // else if(res.payType==3){
  368. // uni.hideLoading();
  369. // if(that.order.isPrescribe){
  370. // //如果是处方订单开处方
  371. // uni.redirectTo({
  372. // url:"prescribe?orderId="+that.order.id
  373. // })
  374. // }
  375. // else{
  376. // //如果是普通订单
  377. // uni.redirectTo({
  378. // url:"success?order="+JSON.stringify(that.order)
  379. // })
  380. // }
  381. // }
  382. }else{
  383. uni.showToast({
  384. icon:'none',
  385. title: res.msg,
  386. });
  387. }
  388. },
  389. rej => {}
  390. );
  391. }
  392. }
  393. }
  394. </script>
  395. <style lang="scss">
  396. page{
  397. height: 100%;
  398. }
  399. .content{
  400. height: 100%;
  401. display: flex;
  402. flex-direction: column;
  403. justify-content: space-between;
  404. .inner{
  405. padding: 20upx;
  406. .time-price{
  407. box-sizing: border-box;
  408. padding: 50upx 0upx;
  409. background: #FFFFFF;
  410. border-radius: 16upx;
  411. display: flex;
  412. flex-direction: column;
  413. align-items: center;
  414. .time{
  415. font-size: 32upx;
  416. font-family: PingFang SC;
  417. font-weight: 500;
  418. color: #222222;
  419. line-height: 1;
  420. text-align: center;
  421. }
  422. .desc{
  423. margin: 30upx 0upx 15upx;
  424. font-size: 26upx;
  425. font-family: PingFang SC;
  426. color: #999999;
  427. line-height: 1;
  428. text-align: center;
  429. }
  430. .price-box{
  431. display: flex;
  432. align-items: flex-end;
  433. margin-top: 28upx;
  434. .unit{
  435. font-size: 32upx;
  436. font-family: PingFang SC;
  437. font-weight: bold;
  438. color: #FF6633;
  439. line-height: 1.3;
  440. margin-right: 10upx;
  441. }
  442. .num{
  443. font-size: 56upx;
  444. font-family: PingFang SC;
  445. font-weight: bold;
  446. color: #FF6633;
  447. line-height: 1;
  448. }
  449. }
  450. }
  451. .pay-type{
  452. box-sizing: border-box;
  453. background: #FFFFFF;
  454. border-radius: 16upx;
  455. margin-top: 20upx;
  456. padding: 40upx 30upx;
  457. display: flex;
  458. flex-direction: column;
  459. justify-content: space-between;
  460. .title{
  461. font-size: 28upx;
  462. font-family: PingFang SC;
  463. font-weight: 500;
  464. color: #999999;
  465. line-height: 1;
  466. margin-bottom: 10upx;
  467. }
  468. .item{
  469. padding: 15upx 0upx;
  470. display: flex;
  471. align-items: center;
  472. justify-content: space-between;
  473. .left{
  474. display: flex;
  475. align-items: center;
  476. image{
  477. width: 44upx;
  478. height: 44upx;
  479. margin-right: 20upx;
  480. }
  481. .text{
  482. font-size: 30upx;
  483. font-family: PingFang SC;
  484. font-weight: bold;
  485. color: #222222;
  486. line-height: 1;
  487. }
  488. }
  489. }
  490. }
  491. .order-info{
  492. margin-top: 20upx;
  493. background: #FFFFFF;
  494. border-radius: 16upx;
  495. padding: 40upx 30upx;
  496. .title{
  497. font-size: 30upx;
  498. font-family: PingFang SC;
  499. font-weight: bold;
  500. color: #222222;
  501. line-height: 1;
  502. }
  503. .item{
  504. margin-top: 40upx;
  505. display: flex;
  506. align-items: center;
  507. justify-content: space-between;
  508. .label{
  509. font-size: 26upx;
  510. font-family: PingFang SC;
  511. font-weight: 500;
  512. color: #666666;
  513. line-height: 1;
  514. }
  515. .text{
  516. font-size: 26upx;
  517. font-family: PingFang SC;
  518. font-weight: 500;
  519. color: #222222;
  520. line-height: 32upx;
  521. }
  522. .cont-text{
  523. font-size: 26upx;
  524. font-family: PingFang SC;
  525. font-weight: 500;
  526. color: #666666;
  527. .bold{
  528. color: #111111;
  529. }
  530. }
  531. .sn-box{
  532. display: flex;
  533. align-items: center;
  534. .copy-btn{
  535. width: 58upx;
  536. height: 32upx;
  537. line-height: 32upx;
  538. text-align: center;
  539. font-size: 22upx;
  540. font-family: PingFang SC;
  541. font-weight: 500;
  542. color: #222222;
  543. background: #F5F5F5;
  544. border-radius: 4upx;
  545. margin-left: 24upx;
  546. }
  547. }
  548. }
  549. .line{
  550. width: 100%;
  551. height: 1px;
  552. background: #F0F0F0;
  553. margin-top: 30upx;
  554. }
  555. }
  556. }
  557. .btn-box{
  558. height: 242upx;
  559. background: #FFFFFF;
  560. display: flex;
  561. align-items: center;
  562. justify-content: center;
  563. flex-direction: column;
  564. position: fixed;
  565. width: 100%;
  566. bottom: 0rpx;
  567. .btn{
  568. width: 91.73%;
  569. height: 88upx;
  570. line-height: 88upx;
  571. font-size: 30upx;
  572. font-family: PingFang SC;
  573. font-weight: bold;
  574. color: #FFFFFF;
  575. text-align: center;
  576. background: #2BC7B9;
  577. border-radius: 44upx;
  578. margin-bottom: 10rpx;
  579. }
  580. .other-btn{
  581. width: 91.73%;
  582. height: 88upx;
  583. line-height: 88upx;
  584. font-size: 30upx;
  585. font-family: PingFang SC;
  586. font-weight: bold;
  587. color: #2BC7B9;
  588. border: 1rpx solid #2BC7B9;
  589. text-align: center;
  590. background: #FFFFFF;
  591. border-radius: 44upx;
  592. margin-bottom: 10rpx;
  593. position: relative;
  594. .share{
  595. display: inline-block;
  596. position: absolute;
  597. top: 0;
  598. left: 0;
  599. width: 100%;
  600. height: 100%;
  601. opacity: 0;
  602. }
  603. }
  604. }
  605. }
  606. </style>