paymentOrder.vue 16 KB

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