paymentOrder.vue 15 KB

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