paymentOrder.vue 15 KB

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