工行这里学车报名流程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.

457 lines
11 KiB

1 year ago
  1. <template>
  2. <view class="payMoney pageBg">
  3. <view class="topCon">
  4. <view class="price">
  5. <text></text> {{ $u.utils.priceTo(info.price) }}
  6. </view>
  7. <view class="schoolName">
  8. {{ info.schoolName}}
  9. </view>
  10. </view>
  11. <view class="cardInfoPadding">
  12. <view class="cardInfo">
  13. <view class="flex-box-s">
  14. <text>学车类型</text>
  15. <text>{{ info.trainingModel}}</text>
  16. </view>
  17. <view class="flex-box-s">
  18. <text>学车班型</text>
  19. <text>{{info.className}}</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="payWay">
  24. <view class="zfb" @click="changePayWay(2)">
  25. <view class="leftCon">
  26. <view class="icon">
  27. <image src="@/static/images/jiaofei_zfbIphone@2x.png" mode=""></image>
  28. </view>
  29. <view class="text">
  30. 支付宝支付
  31. </view>
  32. <view class="recommendIcon">
  33. <image src="@/static/images/third_img_tuijianIphone@2x.png" mode=""></image>
  34. </view>
  35. </view>
  36. <view class="rightStatusIcon">
  37. <image src="@/static/images/jiaofei_zhifu_selectIphone@2x.png" mode="" v-if="payWay==2">
  38. </image>
  39. <image src="@/static/images/jiaofei_zhifu_unselectIphone@2x.png" mode="" v-else></image>
  40. </view>
  41. </view>
  42. <view class="otherWay" @click="showOtherWay=true" v-if="!showOtherWay">
  43. <view class="txt">其它付款方式</view>
  44. <view class="icon">
  45. <image src="@/static/images/third_icon_gengduoIphone@2x.png" mode=""></image>
  46. </view>
  47. </view>
  48. <view class="zfb" @click="changePayWay(1)" v-else>
  49. <view class="leftCon">
  50. <view class="icon">
  51. <image src="@/static/images/jiaofei_wxIphone@2x.png" mode=""></image>
  52. </view>
  53. <view class="text">
  54. 微信支付
  55. </view>
  56. </view>
  57. <view class="rightStatusIcon">
  58. <image src="@/static/images/jiaofei_zhifu_selectIphone@2x.png" mode="" v-if="payWay==1">
  59. </image>
  60. <image src="@/static/images/jiaofei_zhifu_unselectIphone@2x.png" mode="" v-else></image>
  61. </view>
  62. </view>
  63. </view>
  64. <view class="payBtnBox">
  65. <view class="payBtn bgLinear" @click="goPay">确认支付</view>
  66. </view>
  67. </view>
  68. </template>
  69. <script>
  70. import indexApi from '@/api/index.js'
  71. let polling = null
  72. let timerNum = 0
  73. export default {
  74. data() {
  75. return {
  76. info: {
  77. schoolName: '翔力驾校',
  78. balance: 120,
  79. },
  80. payInfo: {},
  81. payWay: 2,
  82. isPoll: false,
  83. trainingApplyId: 'dddc910e7eac47ba8b6452f0629ff5f2',
  84. showOtherWay: false
  85. }
  86. },
  87. onLoad(options) {
  88. // trainingOrderId=832df06eff634376816c00e812a413c7&trainingApplyId=dddc910e7eac47ba8b6452f0629ff5f2
  89. this.getTrainingApplyDetailsFn()
  90. },
  91. onShow() {
  92. // 判断是否要轮询
  93. if(this.isPoll) this.isPoll()
  94. },
  95. methods: {
  96. // 轮询
  97. async getPrepaidResultFn() {
  98. const [err, res] = await learnDriveApi.getChangeModelPrepaidResult({outTradeNo: this.payInfo.outTradeNo})
  99. if(res.code==0) {
  100. uni.switchTab({
  101. url: '/pages/tabbar/userCenter/userCenter'
  102. })
  103. }
  104. console.log(res)
  105. },
  106. // 切换支付方式
  107. changePayWay(num) {
  108. this.payWay = num
  109. },
  110. // car://paymoney/carstep:8888
  111. // zlxcpay://
  112. // 创建培训费支付
  113. async createPrepaidFn() {
  114. const latLng = await this.$u.utils.getLocation()
  115. let obj = {
  116. clientIp: '127.0.0.1',
  117. deviceId: 'IMEI',
  118. deviceType: '1',
  119. ipType: '04',
  120. riskType: '01',
  121. verifyRt: '01',
  122. verifyTp: '01',
  123. latitude: latLng.lat,
  124. longitude: latLng.lng,
  125. payType: this.payWay,
  126. fromAppurl: 'paymoney://car:8898/carstep',
  127. trainingOrderId: this.info.trainingOrderId,
  128. }
  129. console.log(obj)
  130. setTimeout(()=>{
  131. uni.navigateTo({
  132. url: '/pages/application/success'
  133. })
  134. },2000)
  135. const [err, res] = await indexApi.createPrepaid(obj)
  136. if(res.code==0) {
  137. this.payInfo = res.data
  138. if (this.payWay == 1) {
  139. this.wxPay()
  140. } else {
  141. this.zfbPay()
  142. }
  143. }else {
  144. this.$u.toast(res.message)
  145. return false
  146. }
  147. uni.hideLoading()
  148. console.log('this.payInfo支付信息')
  149. console.log(res)
  150. },
  151. // 点击去支付培训费
  152. async goPay() {
  153. uni.showLoading({
  154. title: '创建订单...'
  155. })
  156. await this.createPrepaidFn()
  157. },
  158. // 轮询定时
  159. pollFn() {
  160. polling = setInterval(async ()=>{
  161. timerNum ++
  162. if(timerNum>30) {
  163. clearInterval(polling)
  164. polling = null
  165. }
  166. await this.getPrepaidResultFn()
  167. },1000)
  168. },
  169. zfbPay() {
  170. uni.hideLoading()
  171. let url = encodeURIComponent(this.payInfo.appURL)
  172. this.isPoll = true
  173. let urls = `alipays://platformapi/startapp?appId=10000007&qrcode=${url}`
  174. console.log('支付宝路径')
  175. console.log(this.payInfo.appURL)
  176. console.log(urls)
  177. // #ifdef APP-PLUS
  178. plus.runtime.openURL(urls)
  179. // #endif
  180. // #ifdef H5
  181. window.location.href = 'paymoney://car:8898/carstep'
  182. window.open(urls)
  183. // #endif
  184. },
  185. wxPay() {
  186. this.isPoll = true
  187. // #ifdef APP-PLUS
  188. this.sweixin ? this.sweixin.launchMiniProgram({
  189. // path: '/pages/payment/payment?paymoney='+this.info.price+'&ordersn='+this.payInfo.outTradeNo+'&tokenCode='+ this.payInfo.tokenCode, //跳转小程序页面路径 pages/index/index
  190. path: '/pages/payment/payment?tokenCode=' + this.payInfo.tokenCode, //跳转小程序页面路径 pages/index/index
  191. type: 0, //可取值: 0-正式版; 1-测试版; 2-体验版。 默认值为0。
  192. id: 'gh_012fd4bda1c2' //小程序的原始id
  193. }) : plus.nativeUI.alert('当前环境不支持微信操作!');
  194. // #endif
  195. //调⽤APP交互
  196. var par = {username:"gh_012fd4bda1c2",path:'/pages/payment/payment?tokenCode=' + this.payInfo.tokenCode,miniProgramType:"0"}
  197. this.$u.utils.appPostMessage("jumpWXMiniProgram",par);
  198. uni.hideLoading()
  199. },
  200. // 查询报名详情-
  201. async getTrainingApplyDetailsFn() {
  202. if(!this.trainingApplyId) return
  203. const [err, res] = await indexApi.getTrainingApplyDetails({ trainingApplyId: this.trainingApplyId })
  204. console.log('查询报名详情')
  205. console.log(res)
  206. this.schoolPayInfo = res.data
  207. this.trainingOrderId = res.data.trainingOrderId
  208. if(!this.trainingOrderId) {
  209. // // 创建订单
  210. let obj = {
  211. trainingApplyId: res.data.trainingApplyId,
  212. trainingClassId: res.data.trainingClassId,
  213. trainingSchoolId: res.data.trainingSchoolId,
  214. }
  215. const [err2, res2] = await indexApi.createOrder(obj)
  216. console.log('****创建的订单***')
  217. console.log(res2)
  218. this.trainingOrderId = res2.data
  219. setTimeout(()=>{
  220. this.getOrderDetailsFn()
  221. },1000)
  222. }
  223. await this.getOrderDetailsFn()
  224. },
  225. // 获取订单信息
  226. async getOrderDetailsFn(poll) {
  227. if(!this.trainingOrderId) return
  228. const [err, res] = await indexApi.getOrderDetails({
  229. trainingOrderId: this.trainingOrderId
  230. })
  231. console.log('******')
  232. console.log(res.data)
  233. this.info = res.data
  234. if(!poll) return
  235. if(this.info.orderStatus !=0&&this.currenPoll==1) {
  236. console.log('停止订单轮询')
  237. clearInterval(polling)
  238. polling = null
  239. timerNum = 1
  240. if(!info.examinationPrice) {
  241. uni.navigateTo({
  242. url: 'pages/learnDriveStep/payMoney/payMoneySuccess'
  243. })
  244. }else {
  245. }
  246. }
  247. if(this.info.examinationStatus !=0&&this.currenPoll==2) {
  248. console.log('停止考务轮询')
  249. console.log(polling)
  250. clearInterval(polling)
  251. polling = null
  252. uni.navigateTo({
  253. url: 'pages/learnDriveStep/payMoney/payMoneySuccess'
  254. })
  255. }
  256. console.log('订单详情')
  257. console.log(res)
  258. },
  259. }
  260. }
  261. </script>
  262. <style lang="scss" scoped>
  263. .payMoney {
  264. min-height: 100vh;
  265. .topCon {
  266. text-align: center;
  267. padding: 116rpx 0 72rpx 0;
  268. .price {
  269. font-size: 56rpx;
  270. color: #E63633;
  271. text {
  272. font-size: 24rpx;
  273. }
  274. }
  275. .schoolName {
  276. font-size: 28rpx;
  277. color: #666;
  278. }
  279. }
  280. .cardInfoPadding {
  281. padding: 20rpx 32rpx;
  282. }
  283. .cardInfo {
  284. background-color: #fff;
  285. border-radius: 16rpx;
  286. padding: 0 16px;
  287. .flex-box-s {
  288. height: 120rpx;
  289. line-height: 120rpx;
  290. display: flex;
  291. justify-content: space-between;
  292. &:last-child {
  293. border-top: 1px solid #f7f7f7;
  294. }
  295. text {
  296. font-size: 28rpx;
  297. color: #333;
  298. }
  299. }
  300. }
  301. .payWay {
  302. padding: 0 32rpx;
  303. .otherWay {
  304. display: flex;
  305. background-color: #fff;
  306. border-radius: 16rpx;
  307. padding: 0 16px;
  308. height: 120rpx;
  309. justify-content: center;
  310. align-items: center;
  311. .txt {
  312. font-size: 28rpx;
  313. color: #999;
  314. }
  315. .icon {
  316. width: 20rpx;
  317. height: 12rpx;
  318. image {
  319. width: 100%;
  320. height: 100%;
  321. display: block;
  322. }
  323. margin-left: 16rpx;
  324. }
  325. }
  326. .zfb {
  327. background-color: #fff;
  328. border-radius: 16rpx;
  329. padding: 0 16px;
  330. height: 120rpx;
  331. display: flex;
  332. justify-content: space-between;
  333. align-items: center;
  334. margin-bottom: 20rpx;
  335. .leftCon {
  336. display: flex;
  337. align-items: center;
  338. .icon {
  339. width: 48rpx;
  340. height: 48rpx;
  341. image {
  342. display: block;
  343. width: 100%;
  344. height: 100%;
  345. }
  346. }
  347. .text {
  348. font-size: 32rpx;
  349. color: #333;
  350. margin: 0 10rpx 0 20rpx;
  351. }
  352. .recommendIcon {
  353. width: 64rpx;
  354. height: 34rpx;
  355. image {
  356. width: 100%;
  357. height: 100%;
  358. display: block;
  359. }
  360. }
  361. }
  362. .rightStatusIcon {
  363. width: 42rpx;
  364. height: 42rpx;
  365. image {
  366. display: block;
  367. width: 100%;
  368. height: 100%;
  369. }
  370. }
  371. }
  372. }
  373. }
  374. .payBtnBox {
  375. position: fixed;
  376. bottom: 0;
  377. left: 0;
  378. padding: 32rpx;
  379. display: flex;
  380. align-items: center;
  381. width: 100vw;
  382. height: 128rpx;
  383. background: #FFFFFF;
  384. box-shadow: 0px -1px 0px 0px #E8E9EC;
  385. .payBtn {
  386. width: 100%;
  387. height: 96rpx;
  388. background: linear-gradient(180deg, #3593FB 0%, #53D3E5 100%);
  389. border-radius: 50rpx;
  390. line-height: 96rpx;
  391. text-align: center;
  392. font-size: 36rpx;
  393. color: #fff;
  394. }
  395. }
  396. .footBox {
  397. display: flex;
  398. padding: 0 32rpx;
  399. justify-content: space-between;
  400. .btn {
  401. width: 48%;
  402. height: 98rpx;
  403. background: #2168FC;
  404. border-radius: 16rpx;
  405. color: #fff;
  406. text-align: center;
  407. line-height: 98rpx;
  408. &.border {
  409. background: none;
  410. border: 1px solid #2168FC;
  411. color: #2168FC;
  412. }
  413. }
  414. }
  415. </style>