哥哥玩剑魂呢 3 éve
szülő
commit
4c1f7b1360

+ 3 - 1
config/dev.env.js

@@ -4,7 +4,9 @@ const prodEnv = require('./prod.env')
 
 module.exports = merge(prodEnv, {
   NODE_ENV: '"development"',
-  BASE_API: '"http://test.qywx.g107.net"', // wechatgdy.vaiwan.com
+  // BASE_API: '"http://test.qywx.g107.net"', // wechatgdy.vaiwan.com
+  BASE_API: '"http://qywx.1024win.cn"',
+  
  
   // BASE_API: '"https://oa.g107.com"',
   BASE_API_KQ: '"https://nkaoqin.g107.net"',

+ 2 - 1
config/prod.env.js

@@ -1,7 +1,8 @@
 'use strict'
 module.exports = {
   NODE_ENV: '"production"',
-  BASE_API: '"https://oa.g107.com"',
+  // BASE_API: '"https://oa.g107.com"',
+  BASE_API: '"http://qywx.1024win.cn"',
   BASE_API_KQ: '"https://ad.g107.com"',
   APP_NAME: '"功道云-绩效版"',
   APP_VER: '"7.0"',

+ 29 - 29
index.html

@@ -75,37 +75,37 @@
             'setKeyboardDisplayRequiresUserAction': false
           })
         }
-        var webview = plus.webview.all();
-        webview = webview[webview.length - 1]
-        plus.key.addEventListener('backbutton', function(e) {
-          if (plus.storage.getItem('qr_scaning')) {
-            return false;
-          }
-          webview.canBack(function(e) {
-            if (e.canBack) {
-              webview.back()
-            } else {
-              if (webview.id == plus.runtime.appid) {
-                //首次按键,提示‘再按一次退出应用’
-                if (!first) {
-                  first = new Date().getTime()
-                  plus.nativeUI.toast("再按一次退出应用");
-                  setTimeout(function() {
-                    first = null
-                  }, 1000)
-                } else {
-                  if (new Date().getTime() - first < 1500) {
-                    plus.runtime.quit()
-                  }
-                }
+        // var webview = plus.webview.all();
+        // webview = webview[webview.length - 1]
+        // plus.key.addEventListener('backbutton', function(e) {
+        //   if (plus.storage.getItem('qr_scaning')) {
+        //     return false;
+        //   }
+        //   webview.canBack(function(e) {
+        //     if (e.canBack) {
+        //       webview.back()
+        //     } else {
+        //       if (webview.id == plus.runtime.appid) {
+        //         //首次按键,提示‘再按一次退出应用’
+        //         if (!first) {
+        //           first = new Date().getTime()
+        //           plus.nativeUI.toast("再按一次退出应用");
+        //           setTimeout(function() {
+        //             first = null
+        //           }, 1000)
+        //         } else {
+        //           if (new Date().getTime() - first < 1500) {
+        //             plus.runtime.quit()
+        //           }
+        //         }
 
-              } else {
-                webview.close();
-              }
+        //       } else {
+        //         webview.close();
+        //       }
 
-            }
-          })
-        })
+        //     }
+        //   })
+        // })
 
         var wgtVer = null;
         plus.runtime.getProperty(plus.runtime.appid, function(inf) {

+ 9 - 9
src/components/body/department.vue

@@ -509,15 +509,15 @@ export default {
     new_employee () {
       let self = this
       const data = {status: 0, page: 1}
-      request('get', '/api/join/index', data).then((res) => {
-        if (res.data.code == 1) {
-          if (res.data.data.total > 0) {
-            self.new_employee_num = res.data.data.total
-          }
-        } else {
-          self.$toast(res.data.msg)
-        }
-      })
+      // request('get', '/api/join/index', data).then((res) => {
+      //   if (res.data.code == 1) {
+      //     if (res.data.data.total > 0) {
+      //       self.new_employee_num = res.data.data.total
+      //     }
+      //   } else {
+      //     self.$toast(res.data.msg)
+      //   }
+      // })
     }
   },
   keep_alive_update: {

+ 3 - 2
src/components/body/management.vue

@@ -1,6 +1,6 @@
 <template>
   <div style="height: 100%;">
-    <van-nav-bar class="headerbar no-down-icon left-text-bold" left-text="管理中心"></van-nav-bar>
+    <!-- <van-nav-bar class="headerbar no-down-icon left-text-bold" left-text="管理中心"></van-nav-bar> -->
     <scroller ref="work_box_scroller" class="all" style="position: relative">
       <header class="header" v-if="isShowImg">
        <van-swipe class="my-swipe" :autoplay="3000" indicator-color="#228dfa">
@@ -361,7 +361,8 @@ export default {
 
 /* header */
 .all {
-  height: calc(100% - 0.92rem);
+  /* height: calc(100% - 0.92rem); */
+  height: calc(100%);
   position: relative;
   background-color: #fff;
 }

+ 4 - 3
src/components/body/message_list.vue

@@ -1,10 +1,10 @@
 <template>
   <div style="height: 100%;">
-    <van-nav-bar class="headerbar no-down-icon left-text-bold" :left-text="'消息通知'">
+    <!-- <van-nav-bar class="headerbar no-down-icon left-text-bold" :left-text="'消息通知'">
       <template slot="right">
         <van-icon v-if="is_app" name="scan" @click="$router.push({ name: 'scanqr' })"></van-icon>
       </template>
-    </van-nav-bar>
+    </van-nav-bar> -->
     <div class="work_body_com">
       <scroller :on-refresh="chat_msg_session_list">
         <div class="message-header-box"></div>
@@ -250,7 +250,8 @@ export default {
 }
 
 .work_body_com {
-  height: calc(100% - 0.92rem);
+  /* height: calc(100% - 0.92rem); */
+  height: calc(100%);
   position: relative;
 }
 

+ 4 - 3
src/components/body/statistics.vue

@@ -1,6 +1,6 @@
 <template>
   <div style="height: 100%;">
-    <van-nav-bar class="headerbar no-down-icon left-text-bold" left-text="首页"></van-nav-bar>
+    <!-- <van-nav-bar class="headerbar no-down-icon left-text-bold" left-text="首页"></van-nav-bar> -->
     <scroller ref="scroller" class="all" style="position: relative" :on-refresh="refresh">
       <!-- 我的积分 我的绩效 -->
       <template v-if="getRole_three">
@@ -462,7 +462,7 @@ export default {
   background-color: #fff;
   border-radius: 6px;
   position: fixed;
-  top: 1.3rem;
+  top: 1.5rem;
   left: 0.3rem;
   right: 0.3rem;
   box-shadow: 0px 2px 6px 0px rgba(0, 0, 0, 0.05);
@@ -583,7 +583,8 @@ export default {
 
 /* header */
 .all {
-  height: calc(100% - 0.92rem) !important;
+  // height: calc(100% - 0.92rem) !important;
+  height: calc(100%) !important;
   position: relative !important;
   background-color: #f5f7fa;
 }

+ 22 - 22
src/components/ems/new_employee.vue

@@ -124,29 +124,29 @@ export default {
     // 获取列表
     get_list (done) {
       let self = this
-      request('get', '/api/join/index', self.filter).then((res) => {
-        done()
-        if (res.data.code == 1) {
-          var list = res.data.data.list
-          for (let i in list) {
-            if (list[i].invitee) {
-              if (list[i].invitee.employee_detail.dept_list == null) {
-                list[i].invitee.employee_detail.dept_list = []
-              }
-            }
-          }
-          if (self.filter.page === 1) {
-            self.list = list
-          } else {
-            self.list = self.list.concat(list)
-          }
-          self.$refs.my_scroller.finishInfinite(list.length != '10') // 停止上滚加载下一页,由于服务器端没有统一空数据和正常数据的格式,所以通过total字段来判定数据是否存在下一页
-        } else {
-          self.$refs.my_scroller.finishInfinite(true)
-        }
-      }).finally(() => {
+      // request('get', '/api/join/index', self.filter).then((res) => {
+      //   done()
+      //   if (res.data.code == 1) {
+      //     var list = res.data.data.list
+      //     for (let i in list) {
+      //       if (list[i].invitee) {
+      //         if (list[i].invitee.employee_detail.dept_list == null) {
+      //           list[i].invitee.employee_detail.dept_list = []
+      //         }
+      //       }
+      //     }
+      //     if (self.filter.page === 1) {
+      //       self.list = list
+      //     } else {
+      //       self.list = self.list.concat(list)
+      //     }
+      //     self.$refs.my_scroller.finishInfinite(list.length != '10') // 停止上滚加载下一页,由于服务器端没有统一空数据和正常数据的格式,所以通过total字段来判定数据是否存在下一页
+      //   } else {
+      //     self.$refs.my_scroller.finishInfinite(true)
+      //   }
+      // }).finally(() => {
 
-      })
+      // })
     },
     refresh (done) {
       let self = this

+ 3 - 0
src/components/ems/registration_experience.vue

@@ -60,6 +60,7 @@ import Vue from 'vue'
 import invite_newbusiness from '@/components/ems/invite_newbusiness'
 import {RadioGroup, Radio, Popup} from 'vant'
 import request_user from '@/utils/request-user'
+import Cookies from 'js-cookie'
 
 Vue.use(Radio)
 Vue.use(RadioGroup)
@@ -264,8 +265,10 @@ export default {
         if (res.data.code == 1) {
           if (window.plus) {
             plus.storage.clear()
+	          Cookies.remove('Admin-Token')
           } else {
             localStorage.clear()
+	          Cookies.remove('Admin-Token')
           }
           self.$router.replace({name: 'login'})
         } else {

+ 3 - 0
src/components/integral/event_list.vue

@@ -7,6 +7,9 @@
         <DateSelectorDropdown :title.sync="dateItemTitle" @onConfirm="onConfirmDate"/>
       </van-dropdown-item>
       <van-dropdown-item :title="deptDropdownItemTitle" ref="deptDropdownItem">
+        <template slot="title">
+          <Wxopendata type="departmentName" :openid="deptDropdownItemTitle"></Wxopendata>
+        </template>
         <DeptSelectorDropdown @onConfirm="onConfirmDept"/>
       </van-dropdown-item>
       <van-dropdown-item title="规则分类" ref="ruleDropdownItem">

+ 6 - 1
src/components/integral/integral_rank.vue

@@ -16,7 +16,12 @@
           <van-button class="button-border-none" block square type="info" @click="onConfirmDate">确认</van-button>
         </div>
       </van-dropdown-item>
-      <van-dropdown-item :title="deptDropdownItemTitle" ref="deptDropdownItem"><DeptSelectorDropdown @onConfirm="onConfirmDept" /></van-dropdown-item>
+      <van-dropdown-item :title="deptDropdownItemTitle" ref="deptDropdownItem">
+        <template slot="title">
+          <Wxopendata type="departmentName" :openid="deptDropdownItemTitle"></Wxopendata>
+        </template>
+        <DeptSelectorDropdown @onConfirm="onConfirmDept" />
+      </van-dropdown-item>
 
       <van-dropdown-item title="规则分类" ref="ruleDropdownItem"><RuleCategorySelDropdown @onConfirm="onConfirmRule" @onCancel="rule = null" /></van-dropdown-item>
 

+ 6 - 1
src/components/integral/manager_reward_deduction_new.vue

@@ -14,7 +14,12 @@
           <van-button class="button-border-none" block square type="info" @click="onConfirmDate">确认</van-button>
         </div>
       </van-dropdown-item>
-      <van-dropdown-item :title="deptDropdownItemTitle" ref="deptDropdownItem"><DeptSelectorDropdown @onConfirm="onConfirmDept" /></van-dropdown-item>
+      <van-dropdown-item :title="deptDropdownItemTitle" ref="deptDropdownItem">
+        <template slot="title">
+          <Wxopendata type="departmentName" :openid="deptDropdownItemTitle"></Wxopendata>
+        </template>
+        <DeptSelectorDropdown @onConfirm="onConfirmDept" />
+      </van-dropdown-item>
       <van-dropdown-item v-model="sort" :options="sortArr" />
     </van-dropdown-menu>
 

+ 6 - 1
src/components/integral/rankB.vue

@@ -3,7 +3,12 @@
     <van-nav-bar :title="title" left-text="返回" @click-left="$route_back" left-arrow></van-nav-bar>
 
     <van-dropdown-menu>
-      <van-dropdown-item :title="deptDropdownItemTitle" ref="deptDropdownItem"><DeptSelectorDropdown @onConfirm="onConfirmDept" /></van-dropdown-item>
+      <van-dropdown-item :title="deptDropdownItemTitle" ref="deptDropdownItem">
+        <template slot="title">
+          <Wxopendata type="departmentName" :openid="deptDropdownItemTitle"></Wxopendata>
+        </template>
+        <DeptSelectorDropdown @onConfirm="onConfirmDept" />
+      </van-dropdown-item>
       <div @click="sortNumber" class="dropdown-menu__item">
         <span :class="{ 'asc-order': !sort }">{{ sort ? '降序' : '升序' }}</span>
       </div>

+ 3 - 0
src/components/integral/team_data.vue

@@ -6,6 +6,9 @@
     <div class="team-search__bar">
       <van-dropdown-menu>
         <van-dropdown-item :title="deptTitle" ref="deptDropdownItem">
+          <template slot="title">
+            <Wxopendata type="departmentName" :openid="deptTitle"></Wxopendata>
+          </template>
           <DeptSelectorDropdown @onConfirm="onConfirmDept" content-height="3.5rem"/>
         </van-dropdown-item>
         <div class="dropdown-menu__item" @click.stop="pointSort(1,2)">

+ 3 - 0
src/components/task/efficiency_task.vue

@@ -55,6 +55,9 @@
             <scroller>
               <van-cell-group>
                 <van-cell v-for="(item,index) in list" :key="index" :title="item.target" :label="item.msg || item.rule_item" >
+                  <template slot="title">
+                    <Wxopendata type="userName" :openid="item.target"></Wxopendata>
+                  </template>
                   <template #value>
                     <span v-if="item.point != 0" :class="item.point>0?'color_blue':'color_red'">{{item.point}}</span>
                   </template>

+ 6 - 0
src/components/user/index.vue

@@ -131,6 +131,12 @@ export default {
           this.$refs.management.get_notice_list()
         }
       }
+      window.document.title =
+      val == 0 ? '首页':
+      val == 1 ? '管理中心':
+      val == 2 ? '通知':
+      val == 3 ? '我的':
+      '功道云'
       this.tabs = val
     }
   },

+ 83 - 82
src/components/user/login1.vue

@@ -3,21 +3,20 @@
     <div class="all" style="">
       <div class="data-all" style="text-align:center;margin-top:50px;">
         <transition name="fade">
-          <img
+          <!-- <img
             src="/static/images/login300.png"
             v-if="logImage"
             style="margin:48px auto;width:104px;height:104px;"
             alt=""
-          />
+          /> -->
           <img
             src="/static/images/init.gif"
-            v-if="!logImage"
             style="margin:0 auto;"
             alt=""
           />
         </transition>
         <div>管理执行难,就用功道云</div>
-        <transition name="fade">
+        <!-- <transition name="fade">
           <van-button
             class="refresh"
             type="info"
@@ -26,7 +25,7 @@
             style="border-radius:5px;margin-top:10px;"
             >{{ logButText }}</van-button
           >
-        </transition>
+        </transition> -->
       </div>
     </div>
   </div>
@@ -36,11 +35,12 @@
 import Vue from "vue";
 import { Divider } from "vant";
 import request_user from "@/utils/request-user";
+import Cookies from 'js-cookie'
 
+import request from '@/utils/request'
 import { getToken, setToken } from "@/utils/auth";
 
 import { wxAuth } from "@/utils/wx-auth-two.js";
-import Cookies from "js-cookie";
 import axios from "axios";
 Vue.use(Divider);
 export default {
@@ -53,98 +53,99 @@ export default {
     };
   },
   activated() {//activated()每次进入页面都会执行,代替created
-    var url = window.location.href; //获取url中"?"符后的字串
-    let codesif = false;
-    let codes = "";
-    if (url) {
-      if (url.split("?")[1]) {//判断有无?参数
-        var strs = url.split("?")[1].split("&");
-        for (var i = 0; i < strs.length; i++) {
-          if (strs[i].split("=")[0] == "code") {
-            this.loginButton = false;
-            this.logImage = false;
-            codesif = true;
-            codes = strs[i].split("=")[1].split("&")[0];
+    if(Cookies.get('Admin-Token')){
+      console.log('Admin-Token')
+      const user_info = this.$store.getters.user_info || JSON.parse(localStorage.getItem('user_info')).data || JSON.parse(plus.storage.getItem('user_info')).data
+      console.log(user_info)
+      if(user_info){
+        wxAuth(true);
+      }else{
+        this.detailAxiox()
+      }
+    }else{
+      console.log('222222')
+      var url = window.location.href; //获取url中"?"符后的字串
+      let tokenif = false
+      var token = ''
+      if(url){
+        if (url.split("?")[1]) {//判断有无?参数
+          let str = url.split("?")[1]
+          console.log(str)
+          if(str.split("=")[0] == 'token'){
+            token = str.split("=")[1].split("#")[0]
+            console.log(str.split("=")[1])
+            tokenif = true
           }
         }
-      } else {//没有就清空缓存并放出登录按钮
-        this.clone();
-        this.loginButton = true;
-        this.logImage = true;
       }
-    }
-
-    if (!codesif) {
-      this.logImage = true;
-      this.loginButton = true;
-    } else {
-        this.clone();
-      let params = { code: codes };
-      axios.get(process.env.BASE_API + "/api/wechat/minAuth", { params: params })
-        .then(res => {
-          if (res.data.code == 1) {
-            if (res.data.data.user.is_official == 1) {
-              setToken(res.data.data.token);
-              this.$store.commit("SET_USERINFO", res.data.data.user); // 设置员工信息
-              window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/']))
-              window.sessionStorage.setItem('routers', '/')
-              console.log(getToken());
-              wxAuth(true);
-            } else if (res.data.data.user.is_official == 0) {
-              this.clone();
-              this.$router.push({name: 'noAccess',params: { status: 0 }})
-            }
-          } else if (res.data.code == 4444){
-            this.$router.push({name: 'noAccess',params: { status: 4444 }})
-          } else {
-            this.logButText = "重新登录";
-            this.loginButton = true;
-            this.logImage = true;
-          }
-        }).catch((err)=>{
-        });
+      if(tokenif){
+        setToken(token);
+        this.detailAxiox(token)
+      }else{
+        window.location.href = 'http://test.qywx.g107.net/wechat/authorize?platform='+ this.isPcOrApp() +'#wechat_redirect'
+      }
     }
   },
   mounted() {
-    console.log('登录页mounted')
   },
   watch: {},
   methods: {
-    LoginBut() {
-      // if(this.logButText == "重新登录"){
-      //   window.location.href = 'http://wechatdimgs.vaiwan.com'
-      // }else{
-        console.log(process.env.APPID);
-        console.log(process.env.REDIRECT_URI);
-        var appid, redirect_uri, response_type, scope, state, wechat, agentid;
-        appid = 'ww4065f0d4bb232a6a';
-        redirect_uri = 'http%3A%2F%2Fwechatdings.vaiwan.com';
-        response_type = "code";
-        scope = "snsapi_privateinfo";
-        state = "a";
-        wechat = "#wechat_redirect";
-        let link =
-          "appid=" +
-          appid +
-          "&redirect_uri=" +
-          redirect_uri +
-          "&response_type=" +
-          response_type +
-          "&scope=" +
-          scope +
-          "&state=" +
-          state +
-          wechat;
-        window.location.href =
-          "https://open.weixin.qq.com/connect/oauth2/authorize?" + link;
-      // }
+    detailAxiox(){
+      request('get',process.env.BASE_API+'/api/employee/detail')
+      .then(res => {
+        if(res.data.code == 1){
+          this.$store.commit("SET_USERINFO", res.data.data.user); // 设置员工信息
+          window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/']))
+          window.sessionStorage.setItem('routers', '/')
+          console.log(getToken());
+          wxAuth(true);
+        }
+      })
+    },
+    // LoginBut() {
+    //   // if(this.logButText == "重新登录"){
+    //   //   window.location.href = 'http://wechatdimgs.vaiwan.com'
+    //   // }else{
+    //     console.log(process.env.APPID);
+    //     console.log(process.env.REDIRECT_URI);
+    //     var appid, redirect_uri, response_type, scope, state, wechat, agentid;
+    //     appid = 'ww4065f0d4bb232a6a';
+    //     redirect_uri = 'http%3A%2F%2Fwechatdings.vaiwan.com';
+    //     response_type = "code";
+    //     scope = "snsapi_privateinfo";
+    //     state = "a";
+    //     wechat = "#wechat_redirect";
+    //     let link =
+    //       "appid=" +
+    //       appid +
+    //       "&redirect_uri=" +
+    //       redirect_uri +
+    //       "&response_type=" +
+    //       response_type +
+    //       "&scope=" +
+    //       scope +
+    //       "&state=" +
+    //       state +
+    //       wechat;
+    //     window.location.href =
+    //       "https://open.weixin.qq.com/connect/oauth2/authorize?" + link;
+    //   // }
+    // },
+    isPcOrApp(){
+      if(/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
+        return 'app'
+      } else {
+        return 'pc'
+      }
     },
 
     clone() {
       if (window.plus) {
         plus.storage.clear()
+	      Cookies.remove('Admin-Token')
       } else {
         window.localStorage.clear()
+	      Cookies.remove('Admin-Token')
       }
     }
   }

+ 173 - 0
src/components/user/login2.vue

@@ -0,0 +1,173 @@
+<template>
+  <div class="login-box-parent">
+    <div class="all" style="">
+      <div class="data-all" style="text-align:center;margin-top:50px;">
+        <transition name="fade">
+          <img
+            src="/static/images/login300.png"
+            v-if="logImage"
+            style="margin:48px auto;width:104px;height:104px;"
+            alt=""
+          />
+          <img
+            src="/static/images/init.gif"
+            v-if="!logImage"
+            style="margin:0 auto;"
+            alt=""
+          />
+        </transition>
+        <div>管理执行难,就用功道云</div>
+        <transition name="fade">
+          <van-button
+            class="refresh"
+            type="info"
+            @click="LoginBut"
+            v-show="loginButton"
+            style="border-radius:5px;margin-top:10px;"
+            >{{ logButText }}</van-button
+          >
+        </transition>
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import Vue from "vue";
+import { Divider } from "vant";
+import request_user from "@/utils/request-user";
+import Cookies from 'js-cookie'
+
+import { getToken, setToken } from "@/utils/auth";
+
+import { wxAuth } from "@/utils/wx-auth-two.js";
+import Cookies from "js-cookie";
+import axios from "axios";
+Vue.use(Divider);
+export default {
+  name: "login1",
+  data() {
+    return {
+      logImage: true,
+      logButText: "登录",
+      loginButton: true
+    };
+  },
+  activated() {//activated()每次进入页面都会执行,代替created
+    var url = window.location.href; //获取url中"?"符后的字串
+    let codesif = false;
+    let codes = "";
+    if (url) {
+      if (url.split("?")[1]) {//判断有无?参数
+        var strs = url.split("?")[1].split("&");
+        for (var i = 0; i < strs.length; i++) {
+          if (strs[i].split("=")[0] == "code") {
+            this.loginButton = false;
+            this.logImage = false;
+            codesif = true;
+            codes = strs[i].split("=")[1].split("&")[0];
+          }
+        }
+      } else {//没有就清空缓存并放出登录按钮
+        this.clone();
+        this.loginButton = true;
+        this.logImage = true;
+      }
+    }
+
+    if (!codesif) {
+      this.logImage = true;
+      this.loginButton = true;
+    } else {
+        this.clone();
+      let params = { code: codes };
+      axios.get(process.env.BASE_API + "/api/wechat/minAuth", { params: params })
+        .then(res => {
+          if (res.data.code == 1) {
+            if (res.data.data.user.is_official == 1) {
+              setToken(res.data.data.token);
+              this.$store.commit("SET_USERINFO", res.data.data.user); // 设置员工信息
+              window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/']))
+              window.sessionStorage.setItem('routers', '/')
+              console.log(getToken());
+              wxAuth(true);
+            } else if (res.data.data.user.is_official == 0) {
+              this.clone();
+              this.$router.push({name: 'noAccess',params: { status: 0 }})
+            }
+          } else if (res.data.code == 4444){
+            this.$router.push({name: 'noAccess',params: { status: 4444 }})
+          } else {
+            this.logButText = "重新登录";
+            this.loginButton = true;
+            this.logImage = true;
+          }
+        }).catch((err)=>{
+        });
+    }
+  },
+  mounted() {
+    console.log('登录页mounted')
+  },
+  watch: {},
+  methods: {
+    LoginBut() {
+      // if(this.logButText == "重新登录"){
+      //   window.location.href = 'http://wechatdimgs.vaiwan.com'
+      // }else{
+        console.log(process.env.APPID);
+        console.log(process.env.REDIRECT_URI);
+        var appid, redirect_uri, response_type, scope, state, wechat, agentid;
+        appid = 'ww4065f0d4bb232a6a';
+        redirect_uri = 'http%3A%2F%2Fwechatdings.vaiwan.com';
+        response_type = "code";
+        scope = "snsapi_privateinfo";
+        state = "a";
+        wechat = "#wechat_redirect";
+        let link =
+          "appid=" +
+          appid +
+          "&redirect_uri=" +
+          redirect_uri +
+          "&response_type=" +
+          response_type +
+          "&scope=" +
+          scope +
+          "&state=" +
+          state +
+          wechat;
+        window.location.href =
+          "https://open.weixin.qq.com/connect/oauth2/authorize?" + link;
+      // }
+    },
+
+    clone() {
+      if (window.plus) {
+        plus.storage.clear()
+	      Cookies.remove('Admin-Token')
+      } else {
+        window.localStorage.clear()
+	      Cookies.remove('Admin-Token')
+      }
+    }
+  }
+};
+</script>
+
+<style rel="stylesheet/scss" lang="scss" scoped>
+.all {
+  margin: 0 auto;
+  position: relative;
+  top: 50%;
+  margin-top: -325px;
+}
+.login-box-parent{
+  position: relative;
+  width: 100vw;
+  height: 100vh;
+  overflow: auto;
+  cursor: default;
+  /* background-color: #f5f6f9; */
+  background-color: #FFF;
+}
+</style>

+ 101 - 0
src/components/user/login3.vue

@@ -0,0 +1,101 @@
+<template>
+  <div class="login-box-parent">
+    <div class="all" style="">
+      <div class="data-all" style="text-align:center;margin-top:50px;">
+        <transition name="fade">
+          <!-- <img
+            src="/static/images/login300.png"
+            v-if="logImage"
+            style="margin:48px auto;width:104px;height:104px;"
+            alt=""
+          /> -->
+          <img
+            src="/static/images/init.gif"
+            style="margin:0 auto;"
+            alt=""
+          />
+        </transition>
+        <div>管理执行难,就用功道云</div>
+        <!-- <transition name="fade">
+          <van-button
+            class="refresh"
+            type="info"
+            @click="LoginBut"
+            v-show="loginButton"
+            style="border-radius:5px;margin-top:10px;"
+            >{{ logButText }}</van-button
+          >
+        </transition> -->
+      </div>
+    </div>
+  </div>
+</template>
+
+<script>
+import Vue from "vue";
+import { Divider } from "vant";
+import request_user from "@/utils/request-user";
+import Cookies from 'js-cookie'
+
+import request from '@/utils/request'
+import { getToken, setToken, cookGetToken } from "@/utils/auth";
+
+import { wxAuth } from "@/utils/wx-auth-two.js";
+import axios from "axios";
+Vue.use(Divider);
+export default {
+  name: "login1",
+  data() {
+    return {
+      logImage: true,
+      logButText: "登录",
+      loginButton: true
+    };
+  },
+  activated() {
+    console.log('进入登录页')
+    if(cookGetToken()){
+      setToken(cookGetToken());
+      this.detailAxiox()
+    }else{
+      console.log('无Token')
+      window.location.href = process.env.BASE_API;//重新授权
+    }
+  },
+  mounted() {
+  },
+  watch: {},
+  methods: {
+    detailAxiox(){
+      request('get',process.env.BASE_API+'/api/employee/detail')
+      .then(res => {
+        if(res.data.code == 1){
+          this.$store.commit("SET_USERINFO", res.data.data.user); // 设置员工信息
+          window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/']))
+          window.sessionStorage.setItem('routers', '/')
+          console.log(getToken());
+          wxAuth(true);
+        }
+      })
+    },
+  }
+};
+</script>
+
+<style rel="stylesheet/scss" lang="scss" scoped>
+.all {
+  margin: 0 auto;
+  position: relative;
+  top: 50%;
+  margin-top: -325px;
+}
+.login-box-parent{
+  position: relative;
+  width: 100vw;
+  height: 100vh;
+  overflow: auto;
+  cursor: default;
+  /* background-color: #f5f6f9; */
+  background-color: #FFF;
+}
+</style>

+ 53 - 21
src/permission.js

@@ -1,7 +1,8 @@
 import Vue from 'vue'
 import router from './router'
 import store from './store'
-import {getToken} from '@/utils/auth'
+import request from '@/utils/request'
+import {getToken, setToken, cookGetToken} from '@/utils/auth'
 const whiteList = ['/login', '/reg', '/pwdforget'] // no redirect whitelist
 import { wxAuth } from "@/utils/wx-auth-two.js";
 router.beforeEach((to, from, next) => {
@@ -10,24 +11,13 @@ router.beforeEach((to, from, next) => {
       item('interrupt'); //给个标志,中断请求
     })
   }
-  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 {
-      window.document.title = '管理中心'
-    }
-    // 初始一些数据
-    init(to);
-    // next();
-    console.log('wxAuth12')
-    console.log(router.history.current.name)
-    wxAuth('',next,to)
+
+  if (getToken()) {//local中A-Token
+    thens(to, from, next)
+  } else if (cookGetToken()){//Cook中A-Token
+    setToken(cookGetToken())
+    detailAxiox()//员工详细信息
+    thens(to, from, next)
   } else {
       if (!window.$routes_map[to.name].need_login) { // 在免登录白名单,直接进入
         if(to.name=='init'&&localStorage.getItem('init')){
@@ -46,6 +36,38 @@ router.beforeEach((to, from, next) => {
   }
 })
 
+function thens(to, from, next){
+  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 {
+    window.document.title = '管理中心'
+  }
+  console.log(window.$routes_map)
+  
+  //首页按返回到登录 或 初始化时--直接退出
+  if(to.path == '/login' && from.path == '/home' || to.path == '/init' && from.path == '/home'){
+    wx.closeWindow();//关闭当前网页窗口
+    return false
+  }
+  
+  if (to.path == '/login' || to.name == 'init') { // 在免登录白名单,直接进入
+    next({ name: 'home'})
+  }
+  // 初始一些数据
+  init(to);
+  // next();
+  console.log('wxAuth12121221121221666')
+  console.log(router.history.current.name)
+  wxAuth('',next,to)
+
+}
+
 function init(to) {
 
   store.dispatch('get_user_info', getToken()).then((res) => { //获取用户信息
@@ -66,6 +88,16 @@ function init(to) {
   store.dispatch('get_employee_map').then((res) => {}); //获取人员列表
   // store.dispatch('get_account_info').then((res) => {}); //获取公司信息
 
-  
-  
+}
+
+function detailAxiox(){
+  request('get',process.env.BASE_API+'/api/employee/detail')
+  .then(res => {
+    if(res.data.code == 1){
+      this.$store.commit("SET_USERINFO", res.data.data.user); // 设置员工信息
+      window.sessionStorage.setItem('__VCKEEPALIVE__', JSON.stringify(['/']))
+      window.sessionStorage.setItem('routers', '/')
+      console.log(getToken());
+    }
+  })
 }

+ 1 - 1
src/router/index.js

@@ -27,7 +27,7 @@ let routes = [
   {
     path: '/login',
     name: 'login',
-    component: () => import('@/components/user/login1'),
+    component: () => import('@/components/user/login3'),
     label: '用户登录',
     need_login: false
   },

+ 8 - 0
src/utils/auth.js

@@ -1,14 +1,20 @@
 const TokenKey = 'Admin-Token'
 const UserIdKey = 'uidkey'
+import Cookies from 'js-cookie'
 import store from '@/store';
 
 export function getToken() {
   if (window.plus) {
     return plus.storage.getItem(TokenKey)
+    // return Cookies.get(TokenKey)
   } else {
     return localStorage.getItem(TokenKey)
+    // return Cookies.get(TokenKey)
   }
 }
+export function cookGetToken() {
+  return Cookies.get(TokenKey)
+}
 
 export function getUserId() {
   if (window.plus) {
@@ -23,10 +29,12 @@ export function setToken(token) {
     var timestamp = parseInt((new Date()).valueOf() / 1000)
     plus.storage.setItem('token-expire', timestamp + 7200)
     return plus.storage.setItem(TokenKey, token)
+    // return Cookies.set(TokenKey, token)
   } else {
     var timestamp = parseInt((new Date()).valueOf() / 1000)
     localStorage.setItem('token-expire', timestamp + 7200)
     return localStorage.setItem(TokenKey, token)
+    // return Cookies.set(TokenKey, token)
   }
 }
 

+ 5 - 0
src/utils/request-kq.js

@@ -7,6 +7,7 @@ import {
 } from '@/utils/auth'
 import qs from 'qs'
 import Vue from 'vue'
+import Cookies from 'js-cookie'
 import {
   Dialog,
   Toast,
@@ -73,8 +74,10 @@ service.interceptors.response.use(
       }).then(() => {
         if (window.plus) {
           plus.storage.clear()
+          Cookies.remove('Admin-Token')
         } else {
           window.localStorage.clear()
+          Cookies.remove('Admin-Token')
         }
         router.push({
           name: 'login'
@@ -131,8 +134,10 @@ service.interceptors.response.use(
       }).then(() => {
         if (window.plus) {
           plus.storage.clear()
+          Cookies.remove('Admin-Token')
         } else {
           window.localStorage.clear()
+          Cookies.remove('Admin-Token')
         }
         router.replace({name: 'login'});
       });

+ 5 - 0
src/utils/request-user.js

@@ -2,6 +2,7 @@ import router from '@/router'
 import axios from 'axios'
 import qs from 'qs'
 import Vue from 'vue'
+import Cookies from 'js-cookie'
 import {
   Dialog,
   Toast,
@@ -48,8 +49,10 @@ request.interceptors.response.use(
       }).then(() => {
         if (window.plus) {
           plus.storage.clear()
+          Cookies.remove('Admin-Token')
         } else {
           window.localStorage.clear()
+          Cookies.remove('Admin-Token')
         }
         router.push({
           name: 'login'
@@ -106,8 +109,10 @@ request.interceptors.response.use(
        }).then(() => {
          if (window.plus) {
            plus.storage.clear()
+           Cookies.remove('Admin-Token')
          } else {
            window.localStorage.clear()
+           Cookies.remove('Admin-Token')
          }
          router.replace({name: 'login'});
        });

+ 4 - 0
src/utils/request.js

@@ -7,6 +7,7 @@ import {
 } from '@/utils/auth'
 import qs from 'qs'
 import Vue from 'vue'
+import Cookies from 'js-cookie'
 import {
   Dialog,
   Toast,
@@ -68,6 +69,7 @@ service.interceptors.response.use(
       Dialog.alert({
         message: '当前登录授权时间已经过期,请重新授权登录',
       }).then(() => {
+        Cookies.remove('Admin-Token')
         if (window.plus) {
           plus.storage.clear()
         } else {
@@ -130,8 +132,10 @@ service.interceptors.response.use(
         theme: 'round-button',
       }).then(() => {
         if (window.plus) {
+          Cookies.remove('Admin-Token')
           plus.storage.clear()
         } else {
+          Cookies.remove('Admin-Token')
           window.localStorage.clear()
         }
         router.replace({name: 'login'});

+ 15 - 107
src/utils/wx-auth-two.js

@@ -5,39 +5,25 @@ import {
 } from '@/api/configget';
 import Router from '@/router'
 // import {withoutCodeLoad} from '@/utils/wxconfiguration.js'
-import moment from 'moment' // 时间库
 import {
   getToken
 } from '@/utils/auth'
 
 export const wxAuth = async (ifHome, next, to) => {
   const wechatConfigUrl = location.href.split('#')[0]
-  console.log('获取url')
+  console.log('--获取url--')
   console.log(wechatConfigUrl)
   console.log(window.wechatConfigUrl)
-  if (window.wechatConfigUrl === wechatConfigUrl) {
+  if (window.wechatConfigUrl === wechatConfigUrl && window.WWOpenData) {
     if (getToken()) {
-      console.log('进入getToken')
-      // console.log(to)
-      // console.log(!to)
-      // console.log('R你XR')
-      // console.log(Router.history.current.name)
-      // console.log(to.name)
-      // if (Router.history.current.name == 'login' && !to) {
-      //   console.log('执行跳转?')
-      //   Router.push({
-      //     name: 'home'
-      //   })
-      // }
+      console.log('--满足跳转条件--')
       if (ifHome) {
-        console.log('login跳转?')
+        console.log('--跳转首页--')
         Router.push({
           name: 'home'
         })
       } else {
-        console.log(next)
         if (next) {
-          console.log('1111111111111')
           next()
         }
       }
@@ -58,7 +44,7 @@ async function wxConfigByCorp(ifHome, body, next) {
   var data;
   await allocations(body).then((res) => {
     if (res.data.code == 1) {
-      console.log("请求配置成功")
+      console.log("--请求配置成功--")
       data = res.data.data
     } else {}
   }).catch(() => {
@@ -68,7 +54,7 @@ async function wxConfigByCorp(ifHome, body, next) {
   const appSignature = data.agentConfig
   console.log(wxConfigParams)
   console.log(appSignature)
-  console.log('wxConfig开始')
+  console.log('--wxConfig开始--')
   await Vue.prototype.$wx.config({ // 鉴权(企业的身份与权限)
     beta: true, // 必须这么写,否则wx.invoke调用形式的jsapi会有问题
     debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
@@ -87,53 +73,14 @@ async function wxConfigByCorp(ifHome, body, next) {
     ] // 必填,需要使用的JS接口列表,凡是要调用的接口都需要传进来
   });
   await Vue.prototype.$wx.ready(function () {
-    console.log('wxConfig成功')
-    console.log('wx.agentConfig开始')
-    console.log('wx.agentConfig:BEGIN');
+    console.log('--wxConfig成功--')
+    console.log('--wx.agentConfig开始--')
+    console.log('--wx.agentConfig:BEGIN--');
     const u = navigator.userAgent;
     const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1; // 安卓
     const isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); // ios终端
     if (isAndroid) {
-      console.log('安卓手机');
-      // Vue.prototype.$wx.invoke('agentConfig', {
-      // Vue.prototype.$wx.agentConfig({
-      //   corpid: appSignature.appId, // 必填,企业微信的corpid,必须与当前登录的企业一致
-      //   agentid: appSignature.agentid, // 必填,企业微信的应用id (e.g. 1000247)生产环境 写自己环境的agentid
-      //   timestamp: appSignature.timestamp, // 必填,生成签名的时间戳
-      //   nonceStr: appSignature.nonceStr, // 必填,生成签名的随机串
-      //   signature: appSignature.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
-      //   jsApiList: [
-      //     'openUserProfile',
-      //     'previewFile'
-      //   ], // 必填
-      //   success(res) {
-      //     console.log('agentConfig', res);
-      //     console.log('agentConfig成功')
-      //     console.log('回调')
-      //     console.log(res)
-      //     console.log('window.WWOpenData')
-      //     console.log(window.WWOpenData)
-      //     if (next) {
-      //       next()
-      //     }
-      //     if (pushindex) {
-      //       console.log('跳转首页')
-      //       Router.push({
-      //         path: '/'
-      //       }) //跳转首页
-      //     }
-      //   },
-      //   fail(res) {
-      //     console.log('err', res);
-      //     if (res.errMsg.indexOf('function not exist') > -1) {
-      //       alert('版本过低请升级');
-      //     }
-      //   }
-      // }, function (res) {
-      //   console.log('result', res);
-      // });
-
-
+      console.log('--安卓手机--');
       Vue.prototype.$wx.agentConfig({ //鉴权(应用的身份与权限)
         corpid: appSignature.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
         agentid: appSignature.agentid, // 必填,企业微信的应用id (e.g. 1000247)
@@ -142,10 +89,10 @@ async function wxConfigByCorp(ifHome, body, next) {
         signature: appSignature.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
         jsApiList: ['selectExternalContact'], //必填
         success: function (res) { // 回调  //  wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
-          console.log('agentConfig成功')
-          console.log('回调')
+          console.log('--agentConfig成功--')
+          console.log('--回调--')
           console.log(res)
-          console.log('window.WWOpenData')
+          console.log('--window.WWOpenData--')
           console.log(window.WWOpenData)
           console.log(next)
           if (next) {
@@ -154,7 +101,7 @@ async function wxConfigByCorp(ifHome, body, next) {
           console.log(getToken())
           console.log(ifHome)
           if (ifHome) {
-            console.log('跳转首页')
+            console.log('--跳转首页--')
             Router.push({
               name: 'home'
             })
@@ -205,44 +152,5 @@ async function wxConfigByCorp(ifHome, body, next) {
         }
       });
     }
-
-
-
-
-    if (/Android|webOS|iPhone|iPod|BlackBerry/i.test(navigator.userAgent)) {
-
-    } else {
-      console.log('pc端')
-      Vue.prototype.$wx.agentConfig({ //鉴权(应用的身份与权限)
-        corpid: appSignature.corpid, // 必填,企业微信的corpid,必须与当前登录的企业一致
-        agentid: appSignature.agentid, // 必填,企业微信的应用id (e.g. 1000247)
-        timestamp: appSignature.timestamp, // 必填,生成签名的时间戳
-        nonceStr: appSignature.nonceStr, // 必填,生成签名的随机串
-        signature: appSignature.signature, // 必填,签名,见附录-JS-SDK使用权限签名算法
-        jsApiList: ['selectExternalContact'], //必填
-        success: function (res) { // 回调  //  wx.agentConfig成功回调后,WWOpenData 才会注入到 window 对象上面
-          console.log('agentConfig成功')
-          console.log('回调')
-          console.log(res)
-          console.log('window.WWOpenData')
-          console.log(window.WWOpenData)
-          if (next) {
-            next()
-          }
-          if (ifHome) {
-            console.log('跳转首页')
-            Router.push({
-              name: 'home'
-            })
-          }
-        },
-        fail: function (res) {
-          console.log(res)
-          if (res.errMsg.indexOf('function not exist') > -1) {
-            alert('版本过低请升级')
-          }
-        }
-      });
-    }
   });
-}
+}