347617796@qq.com 3 years ago
parent
commit
16d3fcd638
4 changed files with 1 additions and 473 deletions
  1. 1 358
      src/App.vue
  2. 0 10
      src/main.js
  3. 0 7
      src/permission.js
  4. 0 98
      src/utils/analytics.js

+ 1 - 358
src/App.vue

@@ -1,32 +1,6 @@
 <template>
   <div style="width:100%; height: 100%; position: relative;">
     <vc-keep-alive :ignorePaths="['/help_detail']" :ignoreParams="[]"><router-view :style="'width:100%; height: 100%;'"></router-view></vc-keep-alive>
-    <!-- <div class="suspendButton" v-if="buyPopup" id="moveDiv" @mousedown="down" @touchstart="down" @mousemove="move" @touchmove.prevent="move" @mouseup="end" @touchend="end">
-      <div class="yuanqiu" @click.stop="applyBuyButton">
-        <van-icon name="shopping-cart" size="0.5rem" />
-        <div>申请购买</div>
-      </div>
-      <van-popup v-model="buyPopupPage" :close-on-click-overlay="false" style="border-radius: 0.15rem; background: #fff0;" @closed="getItemBuyPopupPage">
-        <div class="buyPopupBody" style="width: 85vw;">
-          <div class="buyPopupContent" style="position: relative;background: white;padding: 0 5vw 5vw 5vw;border-radius: 0.15rem;">
-            <div
-              class="buyPopupTitle"
-              style="background: #1a89fa;position: absolute;left: 0.6rem;right: 0.6rem;top: -0.3rem;text-align: center;border-radius: 0.1rem;line-height: 2;font-weight: normal;font-size: 0.36rem;color: #fff;"
-            >
-              请购买正式版
-            </div>
-            <p style="font-size: 0.32rem;line-height: 1.8;padding-top: 0.8rem;color: rgb(44, 41, 41)">
-              亲爱的用户,欢迎使用功道云。我们已预置部分体验数据,如需购买完整版请点击【申请购买】,或拨打电话:
-            </p>
-            <p style="color: #1a89fa;font-weight: bold;">400-6877-880</p>
-            <van-row gutter="20">
-              <van-col span="12"><van-button block type="info" @click="applyButton">申请购买</van-button></van-col>
-              <van-col span="12"><van-button block type="default" @click="getItemBuyPopupPage">我知道了</van-button></van-col>
-            </van-row>
-          </div>
-        </div>
-      </van-popup>
-    </div> -->
   </div>
 </template>
 
@@ -48,8 +22,6 @@ export default {
   name: 'App',
   data () {
     return {
-      // buyPopupPage: false,
-      // buyPopup: false,
       empty_webview_loaded: false,
       transitionName: '',
       view_height: window.innerHeight + 'px',
@@ -79,156 +51,6 @@ export default {
     }
   },
   methods: {
-    // 实现移动端拖拽
-    // down () {
-    //   this.flags = true
-    //   var touch
-    //   if (event.touches) {
-    //     touch = event.touches[0]
-    //   } else {
-    //     touch = event
-    //   }
-    //   this.position.x = touch.clientX
-    //   this.position.y = touch.clientY
-    //   this.dx = moveDiv.offsetLeft
-    //   this.dy = moveDiv.offsetTop
-    // },
-    // move () {
-    //   if (this.flags) {
-    //     var touch
-    //     if (event.touches) {
-    //       touch = event.touches[0]
-    //     } else {
-    //       touch = event
-    //     }
-    //     this.nx = touch.clientX - this.position.x
-    //     this.ny = touch.clientY - this.position.y
-    //     this.xPum = this.dx + this.nx
-    //     this.yPum = this.dy + this.ny
-    //     moveDiv.style.left = this.xPum + 'px'
-    //     moveDiv.style.top = this.yPum + 'px'
-    //     // 阻止页面的滑动默认事件;如果碰到滑动问题,1.2 请注意是否获取到 touchmove
-    //     document.addEventListener(
-    //       'touchmove',
-    //       function () {
-    //         event.preventDefault()
-    //       },
-    //       false
-    //     )
-    //   }
-    // },
-    // 鼠标释放时候的函数
-    // end () {
-    //   this.flags = false
-    // },
-    // downWgt (wgtUrl) {
-    //   let self = this
-    //   if (!window.plus) {
-    //     return false
-    //   }
-    //   plus.downloader
-    //     .createDownload(wgtUrl, { filename: '_doc/update/' }, function (d, status) {
-    //       if (status == 200) {
-    //         self.installWgt(d.filename)
-    //       } else {
-    //         self.$toast.clear()
-    //       }
-    //     })
-    //     .start()
-    // },
-    // installWgt (path) {
-    //   if (!window.plus) {
-    //     return false
-    //   }
-    //   this.$toast.clear()
-    //   plus.runtime.install(
-    //     path,
-    //     { force: true },
-    //     function () {
-    //       // plus.runtime.restart()
-    //     },
-    //     function (e) {
-    //       // plus.runtime.restart()
-    //     }
-    //   )
-    // },
-    // 检查更新
-    // get_ver () {
-    //   let self = this
-    //   if (!window.plus) {
-    //     return false
-    //   }
-    //   plus.runtime.getProperty(plus.runtime.appid, function (inf) {
-    //     wgtVer = inf.version
-    //     if (!localStorage.getItem('a-token-temp')) {
-    //       return false
-    //     }
-    //     if (plus.webview.currentWebview().id != plus.runtime.appid) {
-    //       return false
-    //     }
-    //     request_user('post', '/api/version/check', { version: wgtVer.toString() }).then(res => {
-    //       self.info = res.data.data
-    //       localStorage.setItem('Admin-Token', res.data.refresh_token)// 避免退出登录
-    //       // console.log('更新信息...................')
-    //       // console.log(wgtVer.toString())
-    //       // console.log(JSON.stringify(res.data.data))
-
-    //       if (res.data.code == 1) {
-    //         if (!res.data.data.status) {
-    //           // self.$dialog.confirm({
-    //           //   title: '发现新版本' + res.data.data.new_version.version,
-    //           //   message: '确定要更新吗?(更新完成将自动重启)'
-    //           // }).then(() => {
-    //           //   self.$toast.loading({
-    //           //     mask: true,
-    //           //     type: 'loading',
-    //           //     message: '更新中...'
-    //           //   })
-    //           self.downWgt(res.data.data.new_version.app_path)
-    //           // })
-    //         }
-    //       }
-    //     })
-    //   })
-    // },
-    update_components () {
-      if (window.plus) {
-        let all_view = plus.webview.all()
-        for (let i = 0; i < all_view.length; i++) {
-          all_view[i].evalJS('window.VueObj.$root.$children[0].parse_com(window.VueObj.$root.$children);window.VueObj.$root.$children[0].keep_alive_update_data = {}')
-        }
-      } else {
-        this.parse_com(this.$root.$children)
-        this.keep_alive_update_data = {}
-      }
-    },
-    flush_cache () {
-      if (window.plus) {
-        let all_view = plus.webview.all()
-        for (let i = 0; i < all_view.length; i++) {
-          all_view[i].evalJS('window.VueObj.$store.dispatch("clear_cache")')
-        }
-      } else {
-        this.$store.dispatch('clear_cache')
-      }
-    },
-    // login2 (site_id, callback) {
-    //   let self = this
-    //   self.$toast.loading({
-    //     mask: false,
-    //     message: '正在切换组织'
-    //   })
-    //   request_user('post', '/api/employee-login', { site_id: site_id }).then(res => {
-    //     self.$toast.clear()
-    //     if (res.data.code == 1) {
-    //       self.$store.dispatch('clear_cache')
-    //       setToken(res.data.data.token)
-    //       callback()
-    //     } else {
-    //       self.$toast(res.data.msg)
-    //     }
-    //   })
-    // },
     create_params (p) {
       let ret = []
       for (let i in p) {
@@ -342,7 +164,6 @@ export default {
         }
       }
     },
-
     create_web_view (new_view) {
       let self = this
       if (new_view && window.plus) {
@@ -377,173 +198,14 @@ export default {
     set_keep_alive_update_data (key, value) {
       this.keep_alive_update_data[key] = value
     },
-    socket_io_init () {
-      let echo = new Echo({
-        broadcaster: 'socket.io',
-        host: process.env.WEBSOCKET_API
-      })
-
-      // xmx    网址:https://laravel.com/docs/7.x/broadcasting#listening-for-events
-      echo.channel('integral:employee:' + this.$store.getters.user_info.id).listen('.server.info', e => {
-        // 通知前端用户信息有更新
-        // console.log('用户更新了' + e)
-        this.$keep_alive_update('update_user_info', e)
-      })
-
-      echo.channel('integral:site:' + this.$store.getters.user_info.site_id).listen('.server.employeeInvitation', e => {
-        // 通知前端员工新朋友有更新
-        // console.log('新朋友' + e)
-        this.$keep_alive_update('update_new_employee', e)
-        this.update_components()
-      })
-
-      echo.channel('integral:employee:' + this.$store.getters.user_info.id).listen('.server.msgA', e => {
-        // 通知前端A分通知有更新
-        this.$keep_alive_update('update_msgInformation', e)
-        this.update_components()
-      })
-
-      echo.channel('integral:employee:' + this.$store.getters.user_info.id).listen('.server.msgB', e => {
-        // 通知前端B分通知有更新
-        this.$keep_alive_update('update_msgInformation', e)
-        this.update_components()
-      })
-
-      // 加入新公司
-      echo.channel('integral:account:' + this.$store.getters.user_info.account_id).listen('.server.inviteAgree', e => {
-        // 通知前端平台账号申请通过了
-        // console.log(e)
-      })
-      echo.channel('integral:account:' + this.$store.getters.user_info.account_id).listen('.server.CrateSite', e => {
-        // 通知前端异步创建公司结果。
-        // console.log(e)
-      })
-
-      echo.channel('integral:employee:' + this.$store.getters.user_info.id).listen('.server.msgTask', e => {
-        // 通知前端任务消息有更新
-        this.$keep_alive_update('update_task_num', e)
-        this.update_components()
-      })
-      echo.channel('integral:site:' + this.$store.getters.user_info.site_id).listen('.server.siteEmployee', e => {
-        // 通知前端公司所有用户信息有更新(基础数据、权限等)
-        // 更新缓存
-        this.$keep_alive_update('clear_app_cache', {})
-      })
-      echo.channel('integral:employee:' + this.$store.getters.user_info.id).listen('.server.msgInformation', e => {
-        // 通知前端公告通知有更新
-        this.$keep_alive_update('update_msgInformation', e)
-        this.update_components()
-      })
-
-      echo.channel('integral:employee:' + this.$store.getters.user_info.id).listen('.server.msgPerformance', e => {
-        // 通知前端绩效分消息有更新
-        this.$keep_alive_update('update_msgInformation', e)
-        this.update_components()
-      })
-
-      // echo.channel('integral:employee:' + this.$store.getters.user_info.id).listen('.server.msgTask', (e) => { // 通知前端任务消息有更新
-      //   this.$keep_alive_update('update_msgInformation', e)
-      //   this.update_components()
-      // })
-
-      // // 更新公司
-      // echo.channel('integral:site:' + this.$store.getters.user_info.site_id).listen('.server.siteEmployee', (e) => {
-      //   this.flush_cache()
-      // })
-    },
-    // get_site_list () {
-    //   request_user('get', '/api/account/site').then(res => {
-    //     if (res.data.code === 1) {
-    //       if (res.data.data !== null && res.data.data.length && res.data.data.length != 0) {
-    //         this.$dialog.alert({ message: '您已成功加入' + res.data.data[0].site.name }).then(() => {
-    //           window.plus ? plus.storage.removeItem('user_info') : localStorage.removeItem('user_info')
-    //           this.login(res.data.data[0].site.id)
-    //         })
-    //       } else {
-    //         setTimeout(() => {
-    //           this.get_site_list()
-    //         }, 10000)
-    //       }
-    //     }
-    //   })
-    // },
-    // login (id) {
-    //   let self = this
-    //   self.$toast.loading({ mask: false, message: '正在登录' })
-    //   request_user('post', '/api/employee-login', { site_id: id })
-    //     .then(res => {
-    //       if (res.data.code === 1) {
-    //         this.$store.dispatch('clear_cache')
-    //         setToken(res.data.data.token)
-    //         this.$store.dispatch('get_user_info', getToken())
-    //         this.$keep_alive_update('update_message_list', {}) // 列新消息列表的数据
-    //         window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/']))
-    //         window.sessionStorage.setItem('routers', '/')
-    //         window.location.href = window.location.href.split('#')[0]
-    //         window.location.reload()
-    //       } else {
-    //         this.$toast(res.data.msg)
-    //       }
-    //     })
-    //     .finally(() => this.$toast.clear())
-    // },
-    // applyBuyButton () {
-    //   this.buyPopupPage = true
-    // },
-    // getItemBuyPopupPage () {
-    //   localStorage.setItem('buyPopupPage', true)
-    //   this.buyPopupPage = false
-    // },
-    // applyButton () {
-    //   let self = this
-    //   let data = {
-    //     account_id: this.$store.getters.account_info.id,
-    //     // account_id: '114',
-    //     source_type: 1,
-    //     apply_type: 1
-    //   }
-    //   request_user('post', '/api/intentions/addbuy', data).then(res => {
-    //     if (res.data.code == 1) {
-    //       self.$toast(res.data.msg)
-    //     } else {
-    //       self.$toast(res.data.msg)
-    //     }
-    //   })
-    //     .finally(() => {
-    //       this.buyPopupPage = false
-    //     })
-    // },
-    // 刷新token
-    refreshToken () {
-      var refreshTime = localStorage.getItem('refreshTime')
-      console.log(refreshTime + '更新token')
-      if (!refreshTime) { // 如果没有时间,存储当前日期
-        localStorage.setItem('refreshTime', moment().format('YYYY-MM-DD'))
-      } else if (getToken()) {
-        var Time = moment().format('YYYY-MM-DD')// 当前时间
-        var expireDate = moment(Time).diff(moment(refreshTime), 'days')// 获取两个时间的差值
-        if (expireDate > 6 && expireDate < 15) {
-          request('get', '/api/fresh_token').then(res => {
-            if (res.data.code == 1) {
-              localStorage.setItem('a-token-temp', res.data.data.account_token)
-              localStorage.setItem('Admin-Token', res.data.data.employee_token)
-              localStorage.setItem('refreshTime', moment().format('YYYY-MM-DD'))
-            }
-          })
-        }
-      }
-    }
   },
   mounted () {
     if (window.plus) {
       this.user_info = JSON.parse(plus.storage.getItem('user_info'))
       if (plus.webview.currentWebview().id == plus.runtime.appid) {
-        // APP只要主窗口监听就好了
-        this.socket_io_init()
       }
     } else {
       this.user_info = JSON.parse(localStorage.getItem('user_info'))
-      this.socket_io_init()
     }
     let self = this
     FastClick.attach(document.body)
@@ -660,28 +322,10 @@ export default {
       },
       true
     )
-    // this.$nextTick(() => {
-    //   if (this.user_info) {
-    //     if (this.user_info.data.try_user && localStorage.getItem('a-token-temp')) {
-    //       this.get_site_list()
-    //     }
-    //   }
-    // })
-  },
-  watch: {
-    // '$store.getters.buyPopup': {
-    //   handler (newName, oldName) {
-    //     this.buyPopup = this.$store.getters.buyPopup
-    //   },
-    //   deep: true,
-    //   immediate: true
-    // }
   },
   created () {
     let self = this
-    // self.get_ver()
-    self.refreshToken()
-    self.create_web_view(false)
+    self.create_web_view(false);
     self.$router.beforeEach((to, from, next) => {
       let view_id = ''
       if (window.plus) {
@@ -779,7 +423,6 @@ export default {
       }
       sessionStorage.setItem('routers', routersArr.join(','))
     })
-
     if (window.plus) {
       if (plus.webview.currentWebview().id == plus.runtime.appid) {
         // Webview窗口的标识

+ 0 - 10
src/main.js

@@ -5,21 +5,11 @@ import router from './router'
 import store from './store'
 import './permission'
 import './utils/validator'
-// import './utils/analytics'  //报错收集
 import '../css/reset.css'
 import echarts from 'echarts'
 
-// import Vconsole from 'vconsole'
-// Vue.use(new Vconsole())
 import VConsole from 'vconsole'
 new VConsole()
-// window.addEventListener("unhandledrejection",e=>{
-//   throw e.reason
-// })
-// window.addEventListener('error',e=>{
-//   console.log('error event:',e);
-//   return true
-// },true)
 
 import {
   Tabbar,Empty, TabbarItem,Grid, GridItem,Field,NavBar,Row, Col,Cell, CellGroup,Toast,Popup,Dialog,RadioGroup, Radio,Notify,

+ 0 - 7
src/permission.js

@@ -13,10 +13,6 @@ router.beforeEach((to, from, next) => {
   if (getToken()) {
     console.log(to.path)
     console.log(to.name)
-    // if (to.path == '/login'||to.name == 'init') { // 在免登录白名单,直接进入
-    //   next({ name: 'home'})
-    //   return false
-    // }
     if (typeof(window.$routes_map[to.name]) != 'undefined') {
       window.document.title = window.$routes_map[to.name].label
     } else {
@@ -65,7 +61,4 @@ function init(to) {
   // 数据更新,每两分钟更新一次
   store.dispatch('get_employee_map').then((res) => {}); //获取人员列表
   // store.dispatch('get_account_info').then((res) => {}); //获取公司信息
-
-  
-  
 }

+ 0 - 98
src/utils/analytics.js

@@ -1,98 +0,0 @@
-import html2canvas from 'html2canvas'
-import {
-  getToken,
-  getUserId
-} from '@/utils/auth'
-import Vue from 'vue'
-import request from '@/utils/request';
-(function() {
-  let tools = {
-    setImage(callback) {
-      if (window.plus) {
-        var ws = plus.webview.currentWebview()
-        var bitmap = new plus.nativeObj.Bitmap('test');
-        // 将webview内容绘制到Bitmap对象中
-        ws.draw(bitmap, function() {
-          callback(bitmap.toBase64Data());
-        }, function(e) {
-          console.log('截屏绘制图片失败:' + JSON.stringify(e));
-        });
-      } else {
-        html2canvas(document.body, {
-          useCORS: true
-        }).then(function(canvas) {
-          var extra_canvas = document.createElement("canvas");
-          var w = canvas.width
-          var h = canvas.height
-          extra_canvas.setAttribute('width', 320);
-          extra_canvas.setAttribute('height', (320 * h / w));
-          var ctx = extra_canvas.getContext('2d');
-          ctx.drawImage(canvas, 0, 0, canvas.width, canvas.height, 0, 0, 320, (320 * h / w));
-          var dataURL = extra_canvas.toDataURL();
-          callback(dataURL)
-        });
-      }
-    },
-    getBlob(canvas) { //获取blob对象
-      var data = canvas.toDataURL("image/jpeg", 0.1);
-      var dataurl = data
-      return dataurl
-    }
-  }
-
-  document.body.addEventListener('click', function(e) {
-    tools.setImage(function(image) {
-      var error_msg = ""
-      var user_token = getToken()
-      var user_id = getUserId()
-      let _canvas = document.body;
-      var timestamp = (new Date()).valueOf() / 1000;
-      var w = parseInt(window.getComputedStyle(_canvas).width);
-      var h = parseInt(window.getComputedStyle(_canvas).height);
-      request('post','/api/error/push', {
-        event_time: timestamp,
-        sw: w,
-        sh: h,
-        error_msg: error_msg,
-        image: image,
-        user_token: user_token,
-        user_id: user_id,
-        click_left: e.clientX,
-        click_top: e.clientY,
-        url: window.location.href
-      }).then((res) => {
-
-      })
-    })
-  }, false)
-
-
-  const errorHandler = (error, vm, info) => {
-    tools.setImage(function(image) {
-      var error_msg = ""
-      error_msg += "vm: " + vm.$vnode.tag + "\n"
-      error_msg += "URL: " + location.href + "\n"
-      error_msg += "Error: " + error.name + ':' + error.message + "" + info
-
-      var timestamp = (new Date()).valueOf() / 1000;
-      var user_token = getToken()
-      var user_id = getUserId()
-      let _canvas = document.body;
-      var w = parseInt(window.getComputedStyle(_canvas).width);
-      var h = parseInt(window.getComputedStyle(_canvas).height);
-
-      request('post','/api/error/push', {
-        event_time: timestamp,
-        sw: w,
-        sh: h,
-        error_msg: error_msg,
-        image: image,
-        user_token: user_token,
-        user_id: user_id,
-        url: window.location.href
-      }).then((res) => {})
-    })
-  }
-  Vue.config.warnHandler = errorHandler
-  Vue.config.errorHandler = errorHandler;
-})(window)