inquiryPay.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701
  1. <template>
  2. <view class="content">
  3. <view class="cont">
  4. <view class="other-info">
  5. <view class="title">付款详情</view>
  6. <view class="item">
  7. <view class="left">
  8. <text class="label">订单号:</text>
  9. </view>
  10. <view class="right">
  11. <text class="text" v-if="order!=null">{{order.orderSn}}</text>
  12. </view>
  13. </view>
  14. <view class="item">
  15. <view class="left">
  16. <text class="label">订单类型:</text>
  17. </view>
  18. <view class="right">
  19. <text class="text" >
  20. <text >{{$getDictLabelName(inquiryTypeOptions,order.inquiryType)}}</text>
  21. <text >-{{$getDictLabelName(orderTypeOptions,order.orderType)}}</text>
  22. </text>
  23. </view>
  24. </view>
  25. <view class="item">
  26. <view class="left">
  27. <text class="label">订单金额:</text>
  28. </view>
  29. <view class="right">
  30. <text class="text">{{order.money.toFixed(2)}}</text>
  31. </view>
  32. </view>
  33. <view class="item" v-if="order!=null&&(order.userCouponId==null||order.userCouponId==0)" @click.stop="openCoupon()">
  34. <view class="left">
  35. <text class="label">优惠券:</text>
  36. </view>
  37. <view class="right">
  38. <text class="text">{{couponText}}</text>
  39. <image v-if="userCouponId!=0" @click.stop="delCoupon()" class="ic-close" src="/static/images/close.png"></image>
  40. <image class="ic-back" src="/static/images/arrow_gray.png"></image>
  41. </view>
  42. </view>
  43. <view class="item" v-if="order.userCouponId==null||order.userCouponId==0">
  44. <view class="left">
  45. <text class="label">优惠金额:</text>
  46. </view>
  47. <view class="right">
  48. <text class="text">{{discountMoney.toFixed(2)}}</text>
  49. </view>
  50. </view>
  51. <view class="item">
  52. <view class="left">
  53. <text class="label">支付金额:</text>
  54. </view>
  55. <view class="right">
  56. <text class="text">{{payMoney.toFixed(2)}}</text>
  57. </view>
  58. </view>
  59. <uni-popup ref="popCoupon" type="bottom" borderRadius="10rpx 10rpx 0px 0px">
  60. <view class="coupon">
  61. <view class="coupon-box" v-if="coupons.length>0" >
  62. <view @click="couponSelect(item)" class="coupon-item" v-for="(item) in coupons">
  63. <view class="left" >
  64. <image v-if="item.status==0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/004bcf24fc7641dea9f3247fa8d59ea2.png" mode="widthFix"></image>
  65. <image v-if="item.status!=0" src="https://fs-1319721001.cos.ap-chongqing.myqcloud.com/fs/20240229/3ce37842579c48e2b8e50e547adbfeb6.png" mode="widthFix"></image>
  66. <view style="z-index: 999;">
  67. ¥<span class="num">{{item.price.toFixed(2)}}</span>
  68. </view>
  69. <view class="pic-num" >满{{item.minPrice.toFixed(2)}}元可用</view>
  70. </view>
  71. <view class="right">
  72. <view class="title">
  73. {{item.title}}
  74. </view>
  75. <view class="btns">
  76. <view v-if="item.status==0||item.status==2" >{{item.limitTime}} 到期</view>
  77. <view v-if="item.status==1">使用时间 {{item.useTime}}</view>
  78. <view class="bnt gray" v-if="item.status==1" >已使用</view>
  79. <view class="bnt gray" v-if="item.status==2" >已过期</view>
  80. <view class="btn" v-if="item.status==0" >使用</view>
  81. </view>
  82. </view>
  83. </view>
  84. </view>
  85. <view class="empty" v-if="coupons.length==0">
  86. <image src="https://cos.his.cdwjyyh.com/fs/20240423/cf4a86b913a04341bb44e34bb4d37aa2.png"></image>
  87. </view>
  88. </view>
  89. </uni-popup>
  90. </view>
  91. </view>
  92. <view class="btn-box">
  93. <view class="btn" @click="payOrder()">支付{{payMoney.toFixed(2)}}元</view>
  94. </view>
  95. <uni-popup ref="popTip" type="dialog">
  96. <uni-popup-dialog cancelText="支付失败" confirmText="支付成功" mode="base" content="是否已支付成功?" title="提示" :duration="2000" :before-close="true" @close="confirmTip" @confirm="confirmTip"></uni-popup-dialog>
  97. </uni-popup>
  98. <uni-popup ref="popPayType" type="bottom" borderRadius="10rpx 10rpx 0px 0px">
  99. <view class="pay-box">
  100. <view class="title">请选择支付方式</view>
  101. <view class="pay-list">
  102. <view class="pay-item alipay" @click="doAlipay()">
  103. <image src="/static/images/alipay.png"></image>
  104. <view class="name">支付宝支付</view>
  105. </view>
  106. <view class="pay-item wx" @click="doWxPay()">
  107. <image src="/static/images/wx.png"></image>
  108. <view class="name" >微信支付</view>
  109. </view>
  110. </view>
  111. </view>
  112. </uni-popup>
  113. </view>
  114. </template>
  115. <script>
  116. import {getMyEnableCouponList} from '@/api/user.js'
  117. import {getDictByKey} from '@/api/common.js'
  118. import {pay,getInquiryOrderById,compute,zfbPayment} from '@/api/inquiryOrder.js'
  119. const tzCashier=uni.requireNativePlugin("TZBank-Cashier");
  120. export default {
  121. data() {
  122. return {
  123. order:null,
  124. orderId:null,
  125. orderTypeOptions:[],
  126. inquiryTypeOptions:[],
  127. couponText:"请选择优惠券",
  128. userCouponId:0,
  129. coupons:[],
  130. couponShow:false,
  131. payMoney:0,
  132. discountMoney:0
  133. }
  134. },
  135. onLoad(options) {
  136. this.orderId=options.orderId;
  137. this.getDictByKey("sys_inquiry_order_type");
  138. this.getDictByKey("sys_inquiry_type");
  139. this.getInquiryOrderById();
  140. this.getMyEnableCouponList();
  141. },
  142. onShow() {
  143. },
  144. //发送给朋友
  145. onShareAppMessage(res) {
  146. var that=this;
  147. if(this.$isLogin()){
  148. return {
  149. title: "订单支付",
  150. path: '/pages_order/inquiryPay?orderId='+that.orderId,
  151. imageUrl: 'https://hos-1309931967.cos.ap-chongqing.myqcloud.com/fs/20230106/6b459adfb1004c1a96219bcdf07e337c.png' //分享图标,路径可以是本地文件路径、代码包文件路径或者网络图片路径.支持PNG及JPG。显示图片长宽比是 5:4
  152. }
  153. }
  154. },
  155. methods: {
  156. closeTip(){
  157. this.$refs.popTip.close()
  158. },
  159. confirmTip() {
  160. uni.showLoading({title:"请稍侯...",mask:true});
  161. setTimeout(()=>{
  162. uni.hideLoading();
  163. this.getInquiryOrder();
  164. },2000);
  165. },
  166. getInquiryOrder(){
  167. var data = {orderId:this.orderId};
  168. var that=this;
  169. uni.showLoading();
  170. getInquiryOrderById(data).then(res => {
  171. this.$refs.popTip.close();
  172. if(res.code==200){
  173. this.order=res.data;
  174. if(res.data.status==1){ //1:代付款 2:已支付
  175. uni.showToast({title: '未支付成功',icon: 'none'});
  176. }
  177. else if(res.data.status==2){ //1:代付款 2:已支付
  178. this.$refs.popTip.close();
  179. //获取渠道标识
  180. // #ifdef APP-PLUS
  181. if(plus.runtime.channel=="baidu"){
  182. let bdCmdType=uni.getStorageSync("bdCmdType");
  183. if(bdCmdType!=null && parseInt(bdCmdType)<=2){
  184. //this.$registerIdCode("orders",2,res.data.payMoney.toString()); //已下单
  185. }
  186. }
  187. // #endif
  188. uni.redirectTo({
  189. url:"./inquiryOrderPaySuccess?orderId="+this.order.orderId
  190. })
  191. }
  192. }else{
  193. uni.showToast({
  194. icon:'none',
  195. title: res.msg,
  196. });
  197. }
  198. },
  199. rej => {}
  200. );
  201. },
  202. couponSelect(item){
  203. this.$refs.popCoupon.close()
  204. //计算金额
  205. this.userCouponId=item.id;
  206. console.log(item)
  207. this.couponText=item.price+"元优惠券"
  208. this.compute()
  209. },
  210. openCoupon(){
  211. this.$refs.popCoupon.open("bottom")
  212. },
  213. delCoupon(){
  214. this.userCouponId=0;
  215. this.couponText="请选择优惠券"
  216. this.compute()
  217. },
  218. compute(){
  219. var data={
  220. orderId:this.orderId,
  221. userCouponId:this.userCouponId
  222. }
  223. console.log(data)
  224. compute(data).then(
  225. res => {
  226. if(res.code==200){
  227. this.payMoney=res.data.payMoney;
  228. this.discountMoney=res.data.discountMoney;
  229. }
  230. else{
  231. this.userCouponId=0;
  232. this.couponText="请选择优惠券"
  233. uni.showToast({
  234. icon:'none',
  235. title: res.msg,
  236. });
  237. }
  238. },
  239. err => {
  240. }
  241. );
  242. },
  243. getMyEnableCouponList(){
  244. var data={couponType:3}
  245. getMyEnableCouponList(data).then(
  246. res => {
  247. if(res.code==200){
  248. this.coupons=res.data;
  249. }
  250. },
  251. err => {
  252. }
  253. );
  254. },
  255. getDictByKey(key){
  256. var data={key:key}
  257. getDictByKey(data).then(
  258. res => {
  259. if(res.code==200){
  260. if(key=="sys_inquiry_order_type"){
  261. this.orderTypeOptions=res.data;
  262. }
  263. if(key=="sys_inquiry_type"){
  264. this.inquiryTypeOptions=res.data;
  265. }
  266. }
  267. },
  268. err => {
  269. }
  270. );
  271. },
  272. getInquiryOrderById(){
  273. var data = {orderId:this.orderId};
  274. var that=this;
  275. uni.showLoading();
  276. getInquiryOrderById(data).then(
  277. res => {
  278. if(res.code==200){
  279. uni.hideLoading();
  280. that.order=res.data;
  281. this.compute();
  282. }else{
  283. uni.showToast({
  284. icon:'none',
  285. title: res.msg,
  286. });
  287. }
  288. },
  289. rej => {}
  290. );
  291. },
  292. doAlipay(){
  293. var data = {
  294. orderId:this.order.orderId,
  295. };
  296. var that=this;
  297. // #ifdef APP-PLUS
  298. uni.showLoading();
  299. zfbPayment(data).then(res => {
  300. uni.hideLoading()
  301. this.$refs.popPayType.close()
  302. this.$refs.popTip.open()
  303. if(res.code==200){
  304. if(res.type=="tz"){
  305. const match = res.data.body.url.match(/[\?&]businessCstNo=([^&]+)/);
  306. const businessCstNo = match ? match[1] : null;
  307. console.log("qxj tzCashier:"+tzCashier+" businessCstNo:"+businessCstNo);
  308. tzCashier.pay({
  309. env:0,
  310. wxMiniProgramType:0,
  311. wxAppId:'wx703c4bd07bbd1695',
  312. wxUniversalLink:"https://yjf.runtzh.com/",
  313. orderFlowNo:res.data.body.orderFlowNo,
  314. businessCstNo:businessCstNo,
  315. platMerCstNo:res.data.body.platMerCstNo
  316. },(res)=>{
  317. console.log("qxj 支付成功:"+JSON.stringify(res));
  318. });
  319. }
  320. else if(res.type=='hf'){
  321. if (uni.getSystemInfoSync().platform == 'android') {
  322. var alipayScheme ='alipays://platformapi/startApp?&saId=10000007&qrcode=' + res.data.qr_code;
  323. }else{
  324. var alipayScheme ='alipay://platformapi/startApp?&saId=10000007&qrcode=' + res.data.qr_code;
  325. }
  326. console.log(alipayScheme)
  327. // 在uni-app中使用plus.runtime.openURL打开URL
  328. plus.runtime.openURL(alipayScheme, function(error) {
  329. // console.error('打开支付宝失败: ' + error.message);
  330. // 处理打开支付宝失败的情况,比如提示用户或者跳转到其他支付方式
  331. });
  332. }
  333. }
  334. else{
  335. uni.showToast({
  336. title:res.msg,
  337. icon:'none'
  338. })
  339. }
  340. },
  341. rej => {}
  342. );
  343. // #endif
  344. },
  345. doWxPay(){
  346. var that=this;
  347. plus.share.getServices(function(res){
  348. var sweixin = null;
  349. for(var i=0;i<res.length;i++){
  350. var t = res[i];
  351. if(t.id == 'weixin'){
  352. sweixin = t;
  353. }
  354. }
  355. if(sweixin){
  356. that.$refs.popPayType.close()
  357. that.$refs.popTip.open()
  358. //唤起微信跳转小程序
  359. sweixin.launchMiniProgram({
  360. id:"gh_7a6a32e5ef61",
  361. path:'pages_order/inquiryPayment?orderId='+that.orderId+"&payMethod=app",
  362. type:0
  363. },function(){
  364. console.log("微信唤起成功");
  365. return true;
  366. },function(e){
  367. console.log("微信唤起失败",e);
  368. uni.showToast({
  369. title:'微信唤起失败,请检查是否有微信应用',
  370. icon:'none'
  371. })
  372. return false;
  373. })
  374. }else{
  375. uni.showToast({
  376. title:'微信唤起失败,请检查是否有微信应用',
  377. icon:'none',
  378. duration:3000
  379. })
  380. return false;
  381. }
  382. },function(res){
  383. console.log(JSON.stringify(res));
  384. });
  385. },
  386. payOrder(){
  387. var data = {
  388. orderId:this.order.orderId,
  389. userCouponId:this.userCouponId
  390. };
  391. var that=this;
  392. uni.showLoading();
  393. pay(data).then(
  394. res => {
  395. if(res.code==200){
  396. console.log(res)
  397. this.$refs.popPayType.open("bottom")
  398. }else{
  399. uni.showToast({
  400. icon:'none',
  401. title: res.msg,
  402. });
  403. }
  404. },
  405. rej => {}
  406. );
  407. }
  408. }
  409. }
  410. </script>
  411. <style lang="scss">
  412. page{
  413. background: #f6f6f6;
  414. }
  415. </style>
  416. <style scoped lang="scss">
  417. .content{
  418. position: relative;
  419. height: 100%;
  420. .cont{
  421. position: relative;
  422. padding: 0rpx 20rpx 160rpx;
  423. width: 100%;
  424. display: flex;
  425. flex-direction: column;
  426. }
  427. .other-info{
  428. margin-top: 20upx;
  429. background-color: #fff;
  430. border-radius: 20upx;
  431. overflow: hidden;
  432. padding: 0 30upx;
  433. .title{
  434. height: 80upx;
  435. line-height: 80upx;
  436. font-size: 30upx;
  437. color: #000;
  438. font-weight: bold;
  439. border-bottom: 2upx solid #eeeeee;
  440. }
  441. .item{
  442. height: 80upx;
  443. display: flex;
  444. align-items: center;
  445. justify-content: space-between;
  446. &:last-child{
  447. border-bottom: none;
  448. }
  449. .left{
  450. flex: 1;
  451. display: flex;
  452. align-items: center;
  453. .label{
  454. min-width: 140rpx;
  455. font-size: 28upx;
  456. color: #000;
  457. }
  458. .text{
  459. font-size: 28upx;
  460. color: #1b1b1b;
  461. }
  462. }
  463. .right{
  464. display: flex;
  465. align-items: center;
  466. justify-content: flex-end;
  467. .text{
  468. font-size: 28upx;
  469. color: #1b1b1b;
  470. }
  471. .ic-close{
  472. margin-left: 10rpx;
  473. width: 30rpx;
  474. height:30rpx;
  475. }
  476. .ic-back{
  477. margin-left: 10rpx;
  478. width: 15rpx;
  479. height:30rpx;
  480. }
  481. }
  482. .item-btn{
  483. max-width: 200rpx;
  484. padding: 0rpx 15rpx;
  485. height: 48upx;
  486. border-radius: 24upx;
  487. line-height: 48upx;
  488. font-size: 24upx;
  489. color: #000;
  490. border: 1upx solid #d8d8d8;
  491. display: flex;
  492. align-items: center;
  493. justify-content: center;
  494. }
  495. }
  496. }
  497. .btn-box{
  498. height: 140upx;
  499. width: 100%;
  500. padding: 0rpx 30upx;
  501. position: absolute;
  502. bottom: 0;
  503. left: 0;
  504. box-sizing: border-box;
  505. background-color: #ffffff;
  506. display: flex;
  507. align-items: center;
  508. justify-content: center;
  509. .btn{
  510. width: 100%;
  511. height: 88upx;
  512. line-height: 88upx;
  513. text-align: center;
  514. font-size: 34upx;
  515. font-family: PingFang SC;
  516. font-weight: 400;
  517. color: #FFFFFF;
  518. background: #FF5C03;
  519. border-radius: 10upx;
  520. }
  521. }
  522. }
  523. .coupon{
  524. border-radius: 30rpx 30rpx 0rpx 0rpx;
  525. background-color: #FFFFFF;
  526. height: 100%;
  527. .empty{
  528. display: flex;
  529. align-items: center;
  530. justify-content: center;
  531. height: 650rpx;
  532. width: 100%;
  533. image{
  534. width: 280rpx;
  535. height: 200rpx;
  536. }
  537. }
  538. }
  539. .coupon-box{
  540. overflow-y: auto;
  541. padding: 80rpx 20rpx 80rpx;
  542. height: 650rpx;
  543. width: 100%;
  544. display: flex;
  545. flex-direction: column;
  546. align-items: flex-start;
  547. justify-content: flex-start;
  548. box-sizing: border-box;
  549. .coupon-item{
  550. width: 100%;
  551. display: flex;
  552. align-items: center;
  553. justify-content: flex-start;
  554. margin-bottom: 16rpx;
  555. height:170rpx;
  556. &:last-child{
  557. margin-bottom: 0rpx;
  558. }
  559. .left{
  560. color: #fff;
  561. font-size: 36rpx;
  562. font-weight: bold;
  563. text-align: center;
  564. display: flex;
  565. flex-direction: column;
  566. align-items: center;
  567. justify-content: center;
  568. position: relative;
  569. width: 230rpx;
  570. image{
  571. position: absolute;
  572. width: 230rpx;
  573. height:170rpx;
  574. color: #fff;
  575. }
  576. .num{
  577. font-size: 40rpx;
  578. }
  579. .pic-num{
  580. font-size: 20rpx;
  581. z-index: 99;
  582. }
  583. }
  584. .right{
  585. display: flex;
  586. flex-direction: column;
  587. align-items: flex-start;
  588. justify-content: flex-start;
  589. height:170rpx;
  590. width: calc(100% - 230rpx);
  591. padding: 0 17rpx 0 24rpx;
  592. background-color: #fff;
  593. box-sizing: border-box;
  594. .title{
  595. width: 100%;
  596. font-size: 0.3 * 100rpx;
  597. color: #282828;
  598. height: 0.93 * 100rpx;
  599. line-height: 0.93 * 100rpx;
  600. border-bottom: 1px solid #f0f0f0;
  601. }
  602. .btns{
  603. display: flex;
  604. align-items: center;
  605. justify-content: space-between;
  606. width: 100%;
  607. font-size: 0.2 * 100rpx;
  608. color: #999;
  609. height: 0.76 * 100rpx;
  610. .btn{
  611. width: 1.36 * 100rpx;
  612. height: 0.44 * 100rpx;
  613. border-radius: 0.22 * 100rpx;
  614. font-size: 0.22 * 100rpx;
  615. color: #fff;
  616. text-align: center;
  617. line-height: 0.44 * 100rpx;
  618. background-color: #FF5C03;
  619. .gray{
  620. background-color: #ccc;
  621. }
  622. }
  623. }
  624. }
  625. }
  626. }
  627. .pay-box{
  628. border-radius: 30rpx 30rpx 0rpx 0rpx;
  629. padding: 30rpx;
  630. height: 350rpx;
  631. background-color: #fff;
  632. width: 100%;
  633. display:flex;
  634. flex-direction: column;
  635. text-align: center;
  636. justify-content: flex-start;
  637. .title{
  638. font-size: 32rpx;
  639. font-weight: bold;
  640. color: #111;
  641. }
  642. .pay-list{
  643. margin-top: 50rpx;
  644. display:flex;
  645. text-align: center;
  646. justify-content: center;
  647. .pay-item{
  648. margin: 10rpx;
  649. padding: 30rpx 0rpx;
  650. border-radius: 60rpx;
  651. background-color: green;
  652. flex: 1;
  653. display:flex;
  654. text-align: center;
  655. justify-content: center;
  656. image{
  657. width:40rpx;
  658. height:40rpx;
  659. }
  660. .name{
  661. margin-left: 15rpx;
  662. font-size: 32rpx;
  663. font-weight: bold;
  664. color: #fff;
  665. }
  666. }
  667. .wx{
  668. background-color: #09ba08;
  669. }
  670. .alipay{
  671. background-color: #04a9ed;
  672. }
  673. }
  674. }
  675. </style>