paymentOrder.vue 16 KB

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