paymentOrder.vue 15 KB

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