工行这里学车报名流程h5
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

625 lines
17 KiB

  1. <template>
  2. <view class="payMoney">
  3. <view class="step_row">
  4. <!-- orderStatus1>0表示已支付 -->
  5. <view class="step" :class="{hui: info.orderStatus>0}"><text>驾校<br>培训费支付</text></view>
  6. <!-- examinationStatus 0-未支付1-已支付 2已开票 -->
  7. <view class="step step2" :class="{active: info.orderStatus>0&&info.examinationStatus==0}" v-if="info.examinationPrice"><text>场地<br>培训费支付</text></view>
  8. </view>
  9. <view class="ul">
  10. <view class="li">
  11. <view class="lab">驾校名称</view>
  12. <view class="txt">{{ info.schoolName}}</view>
  13. </view>
  14. <view class="li">
  15. <view class="lab">班型</view>
  16. <view class="txt">{{ info.className }}</view>
  17. </view>
  18. <view class="li" v-if="info.orderStatus<1||!info.examinationPrice">
  19. <view class="lab">学费</view>
  20. <view class="txt" v-if="schoolPayInfo.price">{{ $u.utils.priceTo(schoolPayInfo.price) }}</view>
  21. </view>
  22. <view class="li" v-if="info.orderStatus>0&&info.examinationPrice">
  23. <view class="lab">训练费</view>
  24. <view class="txt">{{ $u.utils.priceTo(info.examinationPrice) }}</view>
  25. </view>
  26. </view>
  27. <!-- <uni-link href="alipays://platformapi/startapp?qrcode=https://pay.hzbank.com.cn/ifsp-payweb/appPayReceive/F67A35324B6C4C2A9591642FD40B46F8" text="https://uniapp.dcloud.io/">666669999</uni-link> -->
  28. <!-- <a href="alipays://platformapi/startapp?qrcode=https://pay.hzbank.com.cn/ifsp-payweb/appPayReceive/F67A35324B6C4C2A9591642FD40B46F8">搜索720834239</a> -->
  29. <view class="payWay">
  30. <view class="h1">请选择支付方式</view>
  31. <view class="zfb" @click="changePayWay(2)">
  32. <view class="leftCon">
  33. <view class="icon">
  34. <image src="../../../static/images/icon/jiaofei_zfbIphone@2x.png" mode=""></image>
  35. </view>
  36. <view class="text">
  37. 支付宝支付
  38. </view>
  39. <view class="recommendIcon">
  40. <image src="../../../static/images/icon/third_img_tuijianIphone@2x.png" mode=""></image>
  41. </view>
  42. </view>
  43. <view class="rightStatusIcon">
  44. <image src="../../../static/images/icon/jiaofei_zhifu_selectIphone@2x.png" mode="" v-if="payWay==2">
  45. </image>
  46. <image src="../../../static/images/icon/jiaofei_zhifu_unselectIphone@2x.png" mode="" v-else></image>
  47. </view>
  48. </view>
  49. <view class="otherWay" @click="showOtherWay=true" v-if="!showOtherWay">
  50. <view class="txt">其它付款方式</view>
  51. <view class="icon">
  52. <image src="@/static/images/icon/third_icon_gengduoIphone@2x.png" mode=""></image>
  53. </view>
  54. </view>
  55. <view class="zfb" @click="changePayWay(1)" v-else>
  56. <view class="leftCon">
  57. <view class="icon">
  58. <image src="../../../static/images/icon/jiaofei_wxIphone@2x.png" mode=""></image>
  59. </view>
  60. <view class="text">
  61. 微信支付
  62. </view>
  63. </view>
  64. <view class="rightStatusIcon">
  65. <image src="../../../static/images/icon/jiaofei_zhifu_selectIphone@2x.png" mode="" v-if="payWay==1">
  66. </image>
  67. <image src="../../../static/images/icon/jiaofei_zhifu_unselectIphone@2x.png" mode="" v-else></image>
  68. </view>
  69. </view>
  70. </view>
  71. <view class="" v-if="info.examinationPrice&&info.orderStatus>0&&info.examinationStatus==0">
  72. <view class="infoTps" >
  73. <view class="redbg">
  74. 场训时间使用说明: <br>
  75. 您选择的场训时间可抵扣科目二培训学时在考前学员驾驶有教练员随车施教的教练车进入考场进行适应性训练: <br>
  76. 选择场训时间的学员可提前预约公安的科目二考试; <br>
  77. 享受优先安排进场考前训练
  78. </view>
  79. </view>
  80. <view class="footBox">
  81. <view class="btn border" @click="cancelPay" >取消本次支付</view>
  82. <view class="btn" @click="buyAdaptabilityOrderFn">确认支付</view>
  83. </view>
  84. </view>
  85. <!-- <a href='alipays://platformapi/startapp?appId=20000067&url=支付宝收款码支付地址'> 跳转支付宝支付</a> -->
  86. <view class="payBtnBox" v-if="info.orderStatus==0">
  87. <!-- <view class="payBtn" @click="goPay">支付</view> -->
  88. <oneBtn text="支付" @oneBtnClick="goPay"></oneBtn>
  89. </view>
  90. </view>
  91. </template>
  92. <script>
  93. import learnDriveApi from '@/api/learnDrive.js'
  94. import businessHanldApi from '@/api/businessHandling'
  95. var UPPay = uni.requireNativePlugin('UP-Pay');
  96. let polling = null
  97. let timerNum = 0
  98. export default {
  99. data() {
  100. return {
  101. trainingOrderId: '',
  102. trainingApplyId: '',
  103. info: {},
  104. schoolPayInfo: {},
  105. payWay: 2,
  106. payInfo: {},
  107. sweixin: null,
  108. currenPoll: 1,//1轮询培训费, 2轮询场地
  109. showOtherWay: false,
  110. }
  111. },
  112. computed: {
  113. showStep2() {
  114. if(this.info.examinationPrice) return true
  115. return false
  116. }
  117. },
  118. onLoad(options) {
  119. // this.trainingOrderId = options.trainingOrderId
  120. this.trainingApplyId = options.trainingApplyId
  121. this.getTrainingApplyDetailsFn()
  122. this.initWx()
  123. },
  124. onBackPress() {
  125. },
  126. onShow() {
  127. },
  128. beforeDestroy() {
  129. clearInterval(polling)
  130. polling = null
  131. console.log('stop停stop停stop停stop停stop停stop停stop停')
  132. },
  133. onPullDownRefresh() {
  134. this.getTrainingApplyDetailsFn()
  135. setTimeout(()=>{
  136. uni.stopPullDownRefresh()
  137. },1200)
  138. },
  139. methods: {
  140. // 轮询
  141. async getPrepaidResultFn() {
  142. if(this.currenPoll==1) {
  143. await learnDriveApi.getPrepaidResult({trainingOrderId: this.trainingOrderId})
  144. }else {
  145. await learnDriveApi.getKwzxPrepaidResult({trainingOrderId: this.trainingOrderId})
  146. }
  147. await this.getOrderDetailsFn('poll')
  148. },
  149. initWx() {
  150. // #ifdef APP-PLUS
  151. console.log("...........");
  152. plus.share.getServices((s) => {
  153. var shares = {};
  154. for (var i = 0; i < s.length; i++) {
  155. var t = s[i];
  156. console.log("...........", t);
  157. shares[t.id] = t;
  158. }
  159. var sweixin = shares['weixin'];
  160. this.sweixin = sweixin
  161. }, function(e) {
  162. console.log("获取分享服务列表失败:" + e.message);
  163. });
  164. //初始化场地支付插件
  165. UPPay.initialize({
  166. appId:"wx4689f34e374ae2e",//开放平台appid
  167. universalLink:"https://payconfig.jaxc.cn/",//微信通用连接(ios端),
  168. aliMiniPayScheme: 'kwZxProject',//支付宝小程序AppScheme(ios端),
  169. });
  170. // #endif
  171. },
  172. // 获取订单信息
  173. async getOrderDetailsFn(poll) {
  174. if(!this.trainingOrderId) return
  175. const [err, res] = await learnDriveApi.getOrderDetails({
  176. trainingOrderId: this.trainingOrderId
  177. })
  178. console.log('******')
  179. console.log(res.data)
  180. this.info = res.data
  181. if(!poll) return
  182. if(this.info.orderStatus !=0&&this.currenPoll==1) {
  183. console.log('停止订单轮询')
  184. clearInterval(polling)
  185. polling = null
  186. timerNum = 1
  187. if(!info.examinationPrice) {
  188. uni.navigateTo({
  189. url: 'pages/learnDriveStep/payMoney/payMoneySuccess'
  190. })
  191. }else {
  192. }
  193. }
  194. if(this.info.examinationStatus !=0&&this.currenPoll==2) {
  195. console.log('停止考务轮询')
  196. console.log(polling)
  197. clearInterval(polling)
  198. polling = null
  199. uni.navigateTo({
  200. url: 'pages/learnDriveStep/payMoney/payMoneySuccess'
  201. })
  202. }
  203. console.log('订单详情')
  204. console.log(res)
  205. },
  206. // 切换支付方式
  207. changePayWay(num) {
  208. this.payWay = num
  209. },
  210. // 创建培训费支付
  211. async createPrepaidFn() {
  212. const latLng = await this.$u.utils.getLocation()
  213. let obj = {
  214. clientIp: '127.0.0.1',
  215. deviceId: 'IMEI',
  216. deviceType: '1',
  217. ipType: '04',
  218. riskType: '01',
  219. verifyRt: '01',
  220. verifyTp: '01',
  221. latitude: latLng.lat,
  222. longitude: latLng.lng,
  223. payType: this.payWay,
  224. fromAppurl: 'paymoney://car:8898/carstep',
  225. rechargeAmount: this.schoolPayInfo.price,
  226. trainingOrderId: this.trainingOrderId,
  227. // adaptability: this.info.adaptability,
  228. // adaptabilityGround: this.info.adaptabilityGround,
  229. }
  230. console.log(obj)
  231. const [err, res] = await learnDriveApi.createPrepaid(obj)
  232. this.payInfo = res.data
  233. console.log('this.payInfo支付信息')
  234. console.log(this.payInfo)
  235. },
  236. // 点击去支付培训费
  237. async goPay() {
  238. // window.location.href = oehurl
  239. // this.$store.commit('updateWebVeiwUrl', url)
  240. // uni.navigateTo({
  241. // url: '/pages/commeWebView/indexBusWebView'
  242. // })
  243. console.log('点击了支付')
  244. uni.showLoading({
  245. title: '创建订单...'
  246. })
  247. await this.createPrepaidFn()
  248. if (this.payWay == 1) {
  249. this.wxPay()
  250. } else {
  251. this.zfbPay()
  252. }
  253. },
  254. // 轮询定时
  255. pollFn() {
  256. polling = setInterval(async ()=>{
  257. timerNum ++
  258. if(timerNum>30) {
  259. clearInterval(polling)
  260. polling = null
  261. }
  262. await this.getPrepaidResultFn()
  263. },1000)
  264. },
  265. zfbPay() {
  266. uni.hideLoading()
  267. this.currenPoll = 1
  268. let url = encodeURIComponent(this.payInfo.appURL)
  269. this.pollFn()
  270. // this.pollFn() &scope=auth_base&redirect_uri=回调网址(用于跳转返回app)&state=init'
  271. // let urls = `alipays://platformapi/startapp?appId=10000007&redirect_uri=com.junan.zhelixueche&scope=auth_base&state=init&qrcode=${url}`
  272. let urls = `alipays://platformapi/startapp?appId=10000007&qrcode=${url}`
  273. // let url = encodeURIComponent(this.payInfo.appURL)
  274. console.log('支付宝路径')
  275. console.log(this.payInfo.appURL)
  276. console.log(urls)
  277. // #ifdef APP-PLUS
  278. plus.runtime.openURL(urls)
  279. // #endif
  280. // let qrcode = 'https://pay.hzbank.com.cn/ifsp-payweb/appPayReceive/8904853EF97242D09DC1D7F6EE8F3B9D'
  281. // let urlencodeUrls = encodeURIComponent(qrcode)
  282. // let url = `alipays://platformapi/startapp?appId=10000007&qrcode=${urlencodeUrls}`
  283. // #ifdef H5
  284. window.open(urls)
  285. // #endif
  286. },
  287. wxPay() {
  288. this.currenPoll = 1
  289. this.pollFn()
  290. // #ifdef APP-PLUS
  291. this.sweixin ? this.sweixin.launchMiniProgram({
  292. // path: '/pages/payment/payment?paymoney='+this.info.price+'&ordersn='+this.payInfo.outTradeNo+'&tokenCode='+ this.payInfo.tokenCode, //跳转小程序页面路径 pages/index/index
  293. path: '/pages/payment/payment?tokenCode=' + this.payInfo.tokenCode, //跳转小程序页面路径 pages/index/index
  294. type: 0, //可取值: 0-正式版; 1-测试版; 2-体验版。 默认值为0。
  295. id: 'gh_012fd4bda1c2' //小程序的原始id
  296. }) : plus.nativeUI.alert('当前环境不支持微信操作!');
  297. // #endif
  298. uni.hideLoading()
  299. },
  300. openApp() {
  301. this.isIos = uni.getSystemInfoSync().platform //判断是否安卓、ios
  302. if (this.isIos == 'android') {
  303. let ifr = document.createElement("iframe");
  304. ifr.src =
  305. "hbuilder://"; // 这里的hbuilder在manifest.json中配置->“App常用其它设置” -> “Android设置” -> “UrlSchemes” 项中进行设置
  306. ifr.style.display = "none";
  307. document.body.appendChild(ifr);
  308. } else {
  309. // window.location = "https://apps.apple.com/cn/app/idxxxxxxx" //你的苹果应用app链接
  310. }
  311. },
  312. // 查询报名详情-
  313. async getTrainingApplyDetailsFn() {
  314. if(!this.trainingApplyId) return
  315. const [err, res] = await learnDriveApi.getTrainingApplyDetails({ trainingApplyId: this.trainingApplyId })
  316. console.log('查询报名详情')
  317. console.log(res)
  318. this.schoolPayInfo = res.data
  319. this.trainingOrderId = res.data.trainingOrderId
  320. if(!this.trainingOrderId) {
  321. // // 创建订单
  322. let obj = {
  323. trainingApplyId: res.data.trainingApplyId,
  324. trainingClassId: res.data.trainingClassId,
  325. trainingSchoolId: res.data.trainingSchoolId,
  326. }
  327. const [err2, res2] = await learnDriveApi.createOrder(obj)
  328. console.log('****创建的订单***')
  329. console.log(res2)
  330. this.trainingOrderId = res2.data
  331. setTimeout(()=>{
  332. this.getOrderDetailsFn()
  333. },1000)
  334. }
  335. await this.getOrderDetailsFn()
  336. },
  337. // 取消本次训场支付
  338. cancelPay() {
  339. uni.showModal({
  340. content: '确认要取消适应性训练订单吗?',
  341. success: async function (res) {
  342. if (res.confirm) {
  343. const [err, res] = await learnDriveApi.cancelAdaptabilityOrder({trainingApplyId: this.trainingApplyId})
  344. console.log('用户点击了取消训场订单');
  345. console.log(res)
  346. if(res.code==0) {
  347. uni.navigateTo({
  348. url: 'pages/learnDriveStep/payMoney/payMoneySuccess'
  349. })
  350. }
  351. }
  352. }
  353. });
  354. },
  355. // 点击训场支付 创建订单
  356. async buyAdaptabilityOrderFn() {
  357. const latLng = await this.$u.utils.getLocation()
  358. let obj = {
  359. deviceId: 'IMEI',
  360. clientIp: '127.0.0.1',
  361. deviceType: '1',
  362. ipType: '04',
  363. riskType: '01',
  364. verifyRt: '01',
  365. verifyTp: '01',
  366. latitude: latLng.lat+'',
  367. longitude: latLng.lng+'',
  368. payType: this.payWay,
  369. fromAppurl: 'com.junan.zhelixueche',
  370. rechargeAmount: this.info.examinationPrice,
  371. trainingOrderId: this.info.trainingOrderId,
  372. }
  373. const [err, res] = await learnDriveApi.createKwzxPrepaid(obj)
  374. console.log('创建厂地订单信息')
  375. console.log(res)
  376. if(res.code!=0) return
  377. let resInfo = res.data.appPayRequest
  378. var payChannel = this.payWay==1?'01':'04'
  379. this.currenPoll = 2
  380. this.pollFn()
  381. //支付渠道 01微信 04支付宝小程序
  382. var payData = JSON.stringify(resInfo);//服务端下单获取
  383. UPPay.upPay(payChannel, payData, function(res){
  384. // 这是支付成功的回调吗?
  385. console.log('这是训场支付成功的回调吗?')
  386. console.log(res);
  387. if(res.resultCode=='0000') {
  388. _this.$u.toast(res.resultInfo)
  389. setTimeout(()=>{
  390. uni.navigateTo({
  391. url: 'pages/learnDriveStep/payMoney/payMoneySuccess'
  392. })
  393. },1500)
  394. }
  395. });
  396. }
  397. }
  398. }
  399. </script>
  400. <style lang="scss" scoped>
  401. .payMoney {
  402. min-height: 100vh;
  403. .step_row {
  404. display: flex;
  405. align-items: center;
  406. padding: 0 30rpx;
  407. background-color: #fff;
  408. .step {
  409. width: 188rpx;
  410. height: 86rpx;
  411. background: url('../../../static/images/icon/leimuyiIphone@2x.png');
  412. background-size: 100% 100%;
  413. text-align: center;
  414. font-size: 24rpx;
  415. color: #fff;
  416. display: flex;
  417. align-items: center;
  418. justify-content: center;
  419. &.hui {
  420. background: url('../../../static/images/icon/third_bg_huizhi@2x.png');
  421. background-size: 100% 100%;
  422. color: #333;
  423. }
  424. &.step2 {
  425. background: url('../../../static/images/icon/leimuyi2Iphone@2x.png');
  426. background-size: 100% 100%;
  427. color: #333;
  428. &.active {
  429. background: url('../../../static/images/icon/jinxingzhongiphone@2x.png');
  430. background-size: 100% 100%;
  431. color: #fff;
  432. }
  433. }
  434. }
  435. }
  436. .ul {
  437. width: 100%;
  438. padding: 0 30rpx;
  439. background-color: #fff;
  440. .li {
  441. width: 100%;
  442. font-size: 26rpx;
  443. height: 78rpx;
  444. line-height: 78rpx;
  445. display: flex;
  446. justify-content: space-between;
  447. .lab {}
  448. .txt {}
  449. }
  450. }
  451. .payWay {
  452. padding: 0 32rpx;
  453. .h1 {
  454. padding: 40rpx 0 20rpx 0;
  455. }
  456. .otherWay {
  457. display: flex;
  458. background-color: #fff;
  459. border-radius: 16rpx;
  460. padding: 0 16px;
  461. height: 100rpx;
  462. justify-content: center;
  463. align-items: center;
  464. .txt {
  465. font-size: 28rpx;
  466. color: #999;
  467. }
  468. .icon {
  469. width: 20rpx;
  470. height: 12rpx;
  471. image {
  472. width: 100%;
  473. height: 100%;
  474. display: block;
  475. }
  476. margin-left: 16rpx;
  477. }
  478. }
  479. .zfb {
  480. background-color: #fff;
  481. border-radius: 16rpx;
  482. padding: 0 16px;
  483. height: 110rpx;
  484. display: flex;
  485. justify-content: space-between;
  486. align-items: center;
  487. margin-bottom: 20rpx;
  488. .leftCon {
  489. display: flex;
  490. align-items: center;
  491. .icon {
  492. width: 48rpx;
  493. height: 48rpx;
  494. image {
  495. display: block;
  496. width: 100%;
  497. height: 100%;
  498. }
  499. }
  500. .text {
  501. font-size: 32rpx;
  502. color: #333;
  503. margin: 0 10rpx 0 20rpx;
  504. }
  505. .recommendIcon {
  506. width: 64rpx;
  507. height: 34rpx;
  508. image {
  509. width: 100%;
  510. height: 100%;
  511. display: block;
  512. }
  513. }
  514. }
  515. .rightStatusIcon {
  516. width: 42rpx;
  517. height: 42rpx;
  518. image {
  519. display: block;
  520. width: 100%;
  521. height: 100%;
  522. }
  523. }
  524. }
  525. }
  526. }
  527. .payBtnBox {
  528. position: fixed;
  529. bottom: 0;
  530. left: 0;
  531. padding: 32rpx;
  532. width: 100vw;
  533. // .payBtn {
  534. // width: 100%;
  535. // height: 110rpx;
  536. // border-radius: 8rpx;
  537. // background-color: #5d47ff;
  538. // line-height: 110rpx;
  539. // text-align: center;
  540. // font-size: 32rpx;
  541. // color: #fff;
  542. // }
  543. }
  544. .infoTps {
  545. padding: 32rpx ;
  546. .redbg {
  547. background: #FFEFEF;
  548. font-size: 26rpx;
  549. color: #FE5859;
  550. padding: 16rpx;
  551. border-radius: 8rpx;
  552. line-height: 1.5em;
  553. }
  554. }
  555. .footBox {
  556. display: flex;
  557. padding: 0 32rpx;
  558. justify-content: space-between;
  559. .btn {
  560. width: 48%;
  561. height: 98rpx;
  562. background: #2168FC;
  563. border-radius: 16rpx;
  564. color: #fff;
  565. text-align: center;
  566. line-height: 98rpx;
  567. &.border {
  568. background: none;
  569. border: 1px solid #2168FC;
  570. color: #2168FC;
  571. }
  572. }
  573. }
  574. </style>