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

160 lines
4.4 KiB

  1. <template>
  2. <view class="page-web">
  3. <!-- <uni-nav-bar left-icon="back" title="签署" left-text="返回" @clickLeft="navigateBack" statusBar="true"></uni-nav-bar> -->
  4. <view class="page-inner">
  5. <web-view :src="$store.state.webViewUrl" @message="message" @onPostMessage="handlePostMessage"></web-view>
  6. </view>
  7. </view>
  8. </template>
  9. <script>
  10. import learnDriveApi from '@/api/learnDrive.js'
  11. export default {
  12. data() {
  13. return {
  14. title: '加载中...',
  15. trainingApplyId: ''
  16. }
  17. },
  18. onLoad(options) {
  19. this.trainingApplyId = options.id
  20. let _this = this
  21. // const currentWebview = _this.$mp.page.$getAppWebview();
  22. this.shang()
  23. },
  24. mounted() {
  25. },
  26. methods: {
  27. shang() {
  28. let _this = this
  29. var currentWebview = this.$scope.$getAppWebview();
  30. setTimeout(()=>{
  31. console.log('currentWebview')
  32. console.log(currentWebview)
  33. let wv = currentWebview.children()[0]
  34. wv.addEventListener('loaded', async function () {
  35. let webVeiwUrl = wv.getURL()
  36. console.log(webVeiwUrl)
  37. var reg = RegExp(/wait/i);
  38. if(reg.test(webVeiwUrl)){
  39. console.log('匹配成功了')
  40. // const [err, res] = await learnDriveApi.getTrainingApplyDetails({ trainingApplyId: _this.trainingApplyId })
  41. // let newTrainingOrderId = res.data.trainingApplyId
  42. // // 创建订单
  43. // let obj = {
  44. // trainingApplyId: res.data.trainingApplyId,
  45. // trainingClassId: res.data.trainingClassId,
  46. // trainingSchoolId: res.data.trainingSchoolId,
  47. // }
  48. // console.log(res1)
  49. // const [err2, res2] = await learnDriveApi.createOrder(obj)
  50. // console.log(res2)
  51. // if(!res2.data||!res.data2.trainingOrderId) return _this.$u.toast('创建订单失败')
  52. uni.navigateTo({
  53. url: '/pages/learnDriveStep/payMoney/payMoney?trainingApplyId='+_this.trainingApplyId
  54. })
  55. }
  56. console.log('监听到了————————————————————')
  57. console.log(wv.getURL()) //获取url
  58. console.log(wv.getTitle()) //获取标题
  59. }, false);
  60. },500)
  61. },
  62. // 监听title是安卓原生事件
  63. shang1() { // 上传
  64. let _this = this
  65. // 获取所有的webview对象
  66. const currentWebview = _this.$mp.page.$getAppWebview();
  67. setTimeout(function() {
  68. // 获取当前页面的webview对象
  69. var web = currentWebview.children()[0];
  70. // 监听当前页面webview对象的title
  71. web.addEventListener('titleUpdate', (e) => {
  72. console.log('titleUpdate监听的什么呀', )
  73. let webVeiwUrl = web.getURL()
  74. console.log(webVeiwUrl)
  75. var reg = RegExp(/signaturecallback/i);
  76. if(reg.test(webVeiwUrl)){
  77. uni.redirectTo({
  78. url: '/pages/learnDriveStep/learnDriveStep?id='+_this.trainingApplyId
  79. })
  80. }
  81. }, false)
  82. web.addEventListener('loaded', (e) => {
  83. console.log('loaded监听的什么呀', )
  84. let webVeiwUrl = web.getURL()
  85. console.log(webVeiwUrl)
  86. var reg = RegExp(/signaturecallback/i);
  87. if(reg.test(webVeiwUrl)){
  88. uni.redirectTo({
  89. url: '/pages/learnDriveStep/learnDriveStep?id='+_this.trainingApplyId
  90. })
  91. }
  92. }, false)
  93. }, 200)
  94. },
  95. navigateBack() {
  96. uni.navigateBack()
  97. },
  98. onPullStateChange(e) {
  99. console.log('onPullStateChange 事件' + e)
  100. },
  101. onOverride() {
  102. console.log('onOverride 事件' + e)
  103. },
  104. message(e) {
  105. console.log('消息' + e)
  106. },
  107. handlePostMessage(e) {
  108. console.log('好消息' + e)
  109. }
  110. },
  111. onReady() {
  112. // #ifdef APP-PLUS
  113. var wv;
  114. var height = 0;
  115. uni.getSystemInfo({
  116. //成功获取的回调函数,返回值为系统信息
  117. success: (sysinfo) => {
  118. height = sysinfo.windowHeight; //自行修改,自己需要的高度 此处如底部有其他内容,可以直接---(-50)这种
  119. },
  120. complete: () => {}
  121. });
  122. var currentWebview = this.$scope
  123. .$getAppWebview() //此对象相当于html5plus里的plus.webview.currentWebview()。在uni-app里vue页面直接使用plus.webview.currentWebview()无效
  124. console.log(height)
  125. setTimeout(function() {
  126. wv = currentWebview.children()[0]
  127. wv.setStyle({
  128. top: 70,
  129. height: height
  130. })
  131. }, 1000); //如果是页面初始化调用时,需要延时一下
  132. // #endif
  133. }
  134. }
  135. </script>
  136. <style>
  137. .page-web {
  138. flex: 1;
  139. width: 100%;
  140. flex-direction: column;
  141. }
  142. .page-inner {
  143. flex: 1;
  144. }
  145. </style>