Browse Source

Merge branch 'master' of gitee.com:platinum_forest/his-answer

magic v 4 years ago
parent
commit
ea0fbf3c2f
2 changed files with 36 additions and 17 deletions
  1. 35 17
      src/pages/FormVolume/mixins/index.js
  2. 1 0
      src/utils/jweixin-1.3.2.js

+ 35 - 17
src/pages/FormVolume/mixins/index.js

@@ -3,6 +3,7 @@ import Custom from '../js/custom'
 import Layout1 from '../Layout1'
 import Layout2 from '../Layout2'
 import Layoutileads1 from '../Layoutileads1'
+require('@/utils/jweixin-1.3.2.js')
 export default {
   props: {
     edata: {
@@ -53,18 +54,18 @@ export default {
     };
   },
   computed: {
-    putLayoutCurrent () {
+    putLayoutCurrent() {
       let layout_type = this.data ? this.data.topic.layout_type : ''
       return this.layoutType[layout_type] || 'van-empty'
     }
   },
   watch: {
-    $route (to, from) {
+    $route(to, from) {
       if (from.name === 'FormVolume') {
         clearInterval(this.codeMess.t)
       }
     },
-    edata () {
+    edata() {
       this.inData()
     }
   },
@@ -75,7 +76,7 @@ export default {
     this.vueWatchRoute()
   },
   methods: {
-    vueWatchRoute () {
+    vueWatchRoute() {
       this.inQuery()
       this.inData()
     },
@@ -99,13 +100,13 @@ export default {
       loopNum.call(this)
       this.codeMess.t = setInterval(() => loopNum.call(this), 1000)
     },
-    inQuery () {
+    inQuery() {
       let { title } = this.$route.query
       if (title) {
         this.TITLE = title
       }
     },
-    isForm (callback) {
+    isForm(callback) {
       return new Promise((resolve, reject) => {
         let state = this.data.result.some(item => {
           if (!item.required) {
@@ -133,9 +134,9 @@ export default {
           let res = await pm
           data = res.data
         }
-        
+
         this.inTopicComponent(data, Custom)
-        
+
         this.$set(this, 'data', data)
       } catch (error) {
         this.loading.empty = true
@@ -144,7 +145,7 @@ export default {
       this.loading.data = false
     },
     // 问卷组件初始化
-    inTopicComponent (data, callback) {
+    inTopicComponent(data, callback) {
       data = data || this.data
       data.result.forEach(item => {
         typeof callback === 'function' && callback(item)
@@ -184,9 +185,9 @@ export default {
         })
         ld = this.$toast.loading({ message: '提交中...', duration: 0 })
         let result = this.data.result.map(item => {
-          return { 
-            detail_id: item.detail_id, 
-            val: item.val 
+          return {
+            detail_id: item.detail_id,
+            val: item.val
           }
         })
         // 表单类型为 iLeads活动 - 2,时,额外爬取参数 -----------
@@ -211,7 +212,7 @@ export default {
             })
             return rst
           }).filter(it => it)
-          
+
           objs.forEach(({ key, val }) => {
             if (!patient[key]) {
               patient[key] = val
@@ -236,10 +237,27 @@ export default {
     },
     btnLinkBack() {
       clearInterval(this.codeMess.t)
-      let { go, replace } = this.$route.query
-      replace
-        ? location.replace(replace)
-        : this.$router.go(go || -1)
+      var ua = navigator.userAgent.toLowerCase();
+      if (ua.match(/MicroMessenger/i) == "micromessenger") {
+        //ios的ua中无miniProgram,但都有MicroMessenger(表示是微信浏览器)
+        wx.miniProgram.getEnv((res) => {
+          if (res.miniprogram) {
+            // 在小程序里
+            console.log('miniprogram')
+            wx.miniProgram.switchTab({ url: '/pages/index/index' })
+          } else {
+            // 不在小程序里
+            console.log('micromessenger')
+            this.$router.go(-1)
+          }
+        })
+      } else {
+        console.log('browser')
+        let { go, replace } = this.$route.query
+        replace
+          ? location.replace(replace)
+          : this.$router.go(go || -1)
+      }
     }
   }
 }

File diff suppressed because it is too large
+ 1 - 0
src/utils/jweixin-1.3.2.js