paymentOrder.vue 18 KB

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