paymentOrder.vue 16 KB

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