paymentOrder.vue 16 KB

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