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. <!-- 改价订单只能选择微信支付和物流代收 -->
  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://ysy-1329817240.cos.ap-guangzhou.myqcloud.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://ysy-1329817240.cos.ap-guangzhou.myqcloud.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" v-if="order.payType=='1'">
  40. <view class="left" >
  41. <image src="https://ysy-1329817240.cos.ap-guangzhou.myqcloud.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" v-if="order.payType=='2'">
  49. <view class="left">
  50. <image src="https://ysy-1329817240.cos.ap-guangzhou.myqcloud.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" v-if="order.payType=='3'">
  59. <view class="left">
  60. <image src="https://ysy-1329817240.cos.ap-guangzhou.myqcloud.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://ysy-1329817240.cos.ap-guangzhou.myqcloud.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://ysy-1329817240.cos.ap-guangzhou.myqcloud.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://ysy-1329817240.cos.ap-guangzhou.myqcloud.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://ysy-1329817240.cos.ap-guangzhou.myqcloud.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,userCancelPay} 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: this.$store.state.imgpath+'/app/image/logo.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持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. console.log(123)
  269. this.editPayType(this.order.payType)
  270. }else{
  271. uni.showToast({
  272. icon:'none',
  273. title: res.msg,
  274. });
  275. }
  276. },
  277. rej => {}
  278. );
  279. },
  280. editPayType(payType){
  281. var data = {orderId:this.orderId,payType:payType};
  282. var that=this;
  283. uni.showLoading();
  284. editPayType(data).then(
  285. res => {
  286. if(res.code==200){
  287. console.log(res);
  288. uni.hideLoading();
  289. that.order=res.order;
  290. //this.payType=this.order.payType
  291. this.payMoney=this.order.payMoney;
  292. this.payDelivery=this.order.payDelivery;
  293. }else{
  294. uni.showToast({
  295. icon:'none',
  296. title: res.msg,
  297. });
  298. }
  299. },
  300. rej => {}
  301. );
  302. },
  303. otherPayOrder(){
  304. uni.navigateTo({
  305. url: '/pages_user/user/otherPaymentOrder?orderId='+this.orderId
  306. })
  307. },
  308. getcanle(){
  309. var that=this;
  310. var data = {orderId:this.order.id,payType:this.order.payType};
  311. userCancelPay(data).then(res=>{
  312. if(res.code==200){
  313. console.log(res)
  314. }else{
  315. }
  316. })
  317. },
  318. payOrder(){
  319. var data = {orderId:this.order.id,payType:this.order.payType,appId:wx.getAccountInfoSync().miniProgram.appId};
  320. var that=this;
  321. uni.showLoading();
  322. pay(data).then(
  323. res => {
  324. if(res.code==200){
  325. console.log(res);
  326. if(res.payType==1||res.payType==2){
  327. uni.requestPayment({
  328. provider: 'wxpay',
  329. timeStamp: res.result.timeStamp,
  330. nonceStr:res.result.nonceStr,
  331. package: res.result.packageValue,
  332. signType: res.result.signType,
  333. paySign: res.result.paySign,
  334. success: function(res) {
  335. console.log('yess:' + JSON.stringify(res));
  336. uni.hideLoading();
  337. uni.redirectTo({
  338. url:"success?order="+JSON.stringify(that.order)
  339. })
  340. },
  341. fail: function(err) {
  342. uni.showToast({
  343. icon:'none',
  344. title:'fail:' + JSON.stringify(err),
  345. });
  346. console.log('fail:' + JSON.stringify(err));
  347. that.getcanle()
  348. uni.hideLoading();
  349. },
  350. complete: (err) => {
  351. console.log('fail:' + JSON.stringify(err));
  352. }
  353. });
  354. }else if(res.payType==3){
  355. uni.hideLoading();
  356. if(that.order.isPrescribe){
  357. //如果是处方订单开处方
  358. uni.redirectTo({
  359. url:"prescribe?orderId="+that.order.id
  360. })
  361. }
  362. else{
  363. //如果是普通订单
  364. uni.redirectTo({
  365. url:"success?order="+JSON.stringify(that.order)
  366. })
  367. }
  368. }
  369. // else if(res.payType==3){
  370. // uni.hideLoading();
  371. // if(that.order.isPrescribe){
  372. // //如果是处方订单开处方
  373. // uni.redirectTo({
  374. // url:"prescribe?orderId="+that.order.id
  375. // })
  376. // }
  377. // else{
  378. // //如果是普通订单
  379. // uni.redirectTo({
  380. // url:"success?order="+JSON.stringify(that.order)
  381. // })
  382. // }
  383. // }
  384. }else{
  385. uni.showToast({
  386. icon:'none',
  387. title: res.msg,
  388. });
  389. }
  390. },
  391. rej => {}
  392. );
  393. }
  394. }
  395. }
  396. </script>
  397. <style lang="scss">
  398. page{
  399. height: 100%;
  400. }
  401. .content{
  402. height: 100%;
  403. display: flex;
  404. flex-direction: column;
  405. justify-content: space-between;
  406. .inner{
  407. padding: 20upx;
  408. .time-price{
  409. box-sizing: border-box;
  410. padding: 50upx 0upx;
  411. background: #FFFFFF;
  412. border-radius: 16upx;
  413. display: flex;
  414. flex-direction: column;
  415. align-items: center;
  416. .time{
  417. font-size: 32upx;
  418. font-family: PingFang SC;
  419. font-weight: 500;
  420. color: #222222;
  421. line-height: 1;
  422. text-align: center;
  423. }
  424. .desc{
  425. margin: 30upx 0upx 15upx;
  426. font-size: 26upx;
  427. font-family: PingFang SC;
  428. color: #999999;
  429. line-height: 1;
  430. text-align: center;
  431. }
  432. .price-box{
  433. display: flex;
  434. align-items: flex-end;
  435. margin-top: 28upx;
  436. .unit{
  437. font-size: 32upx;
  438. font-family: PingFang SC;
  439. font-weight: bold;
  440. color: #FF6633;
  441. line-height: 1.3;
  442. margin-right: 10upx;
  443. }
  444. .num{
  445. font-size: 56upx;
  446. font-family: PingFang SC;
  447. font-weight: bold;
  448. color: #FF6633;
  449. line-height: 1;
  450. }
  451. }
  452. }
  453. .pay-type{
  454. box-sizing: border-box;
  455. background: #FFFFFF;
  456. border-radius: 16upx;
  457. margin-top: 20upx;
  458. padding: 40upx 30upx;
  459. display: flex;
  460. flex-direction: column;
  461. justify-content: space-between;
  462. .title{
  463. font-size: 28upx;
  464. font-family: PingFang SC;
  465. font-weight: 500;
  466. color: #999999;
  467. line-height: 1;
  468. margin-bottom: 10upx;
  469. }
  470. .item{
  471. padding: 15upx 0upx;
  472. display: flex;
  473. align-items: center;
  474. justify-content: space-between;
  475. .left{
  476. display: flex;
  477. align-items: center;
  478. image{
  479. width: 44upx;
  480. height: 44upx;
  481. margin-right: 20upx;
  482. }
  483. .text{
  484. font-size: 30upx;
  485. font-family: PingFang SC;
  486. font-weight: bold;
  487. color: #222222;
  488. line-height: 1;
  489. }
  490. }
  491. }
  492. }
  493. .order-info{
  494. margin-top: 20upx;
  495. background: #FFFFFF;
  496. border-radius: 16upx;
  497. padding: 40upx 30upx;
  498. .title{
  499. font-size: 30upx;
  500. font-family: PingFang SC;
  501. font-weight: bold;
  502. color: #222222;
  503. line-height: 1;
  504. }
  505. .item{
  506. margin-top: 40upx;
  507. display: flex;
  508. align-items: center;
  509. justify-content: space-between;
  510. .label{
  511. font-size: 26upx;
  512. font-family: PingFang SC;
  513. font-weight: 500;
  514. color: #666666;
  515. line-height: 1;
  516. }
  517. .text{
  518. font-size: 26upx;
  519. font-family: PingFang SC;
  520. font-weight: 500;
  521. color: #222222;
  522. line-height: 32upx;
  523. }
  524. .cont-text{
  525. font-size: 26upx;
  526. font-family: PingFang SC;
  527. font-weight: 500;
  528. color: #666666;
  529. .bold{
  530. color: #111111;
  531. }
  532. }
  533. .sn-box{
  534. display: flex;
  535. align-items: center;
  536. .copy-btn{
  537. width: 58upx;
  538. height: 32upx;
  539. line-height: 32upx;
  540. text-align: center;
  541. font-size: 22upx;
  542. font-family: PingFang SC;
  543. font-weight: 500;
  544. color: #222222;
  545. background: #F5F5F5;
  546. border-radius: 4upx;
  547. margin-left: 24upx;
  548. }
  549. }
  550. }
  551. .line{
  552. width: 100%;
  553. height: 1px;
  554. background: #F0F0F0;
  555. margin-top: 30upx;
  556. }
  557. }
  558. }
  559. .btn-box{
  560. height: 242upx;
  561. background: #FFFFFF;
  562. display: flex;
  563. align-items: center;
  564. justify-content: center;
  565. flex-direction: column;
  566. .btn{
  567. width: 91.73%;
  568. height: 88upx;
  569. line-height: 88upx;
  570. font-size: 30upx;
  571. font-family: PingFang SC;
  572. font-weight: bold;
  573. color: #FFFFFF;
  574. text-align: center;
  575. background: #409076;
  576. border-radius: 44upx;
  577. margin-bottom: 10rpx;
  578. }
  579. .other-btn{
  580. width: 91.73%;
  581. height: 88upx;
  582. line-height: 88upx;
  583. font-size: 30upx;
  584. font-family: PingFang SC;
  585. font-weight: bold;
  586. color: #409076;
  587. border: 1rpx solid #409076;
  588. text-align: center;
  589. background: #FFFFFF;
  590. border-radius: 44upx;
  591. margin-bottom: 10rpx;
  592. position: relative;
  593. .share{
  594. display: inline-block;
  595. position: absolute;
  596. top: 0;
  597. left: 0;
  598. width: 100%;
  599. height: 100%;
  600. opacity: 0;
  601. }
  602. }
  603. }
  604. }
  605. </style>