123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315 |
- <template>
- <div class="body">
- <van-swipe class="my-swipe" :autoplay="3000" :height="200" indicator-color="white">
- <van-swipe-item v-for="(item, index) in images" :key="index" class="swipe-img">
- <img :src="item"/>
- </van-swipe-item>
- </van-swipe>
- <van-grid :column-num="3">
- <van-grid-item v-for="(item,index) in routers" :key="index" :icon="item.icon" :text="item.name"
- :info="item.name=='消息记录'&&unreadNum>0?unreadNum:''"
- :to="item.url">
- </van-grid-item>
- </van-grid>
- <div class="tip" v-if="isCorpWX">
- 工时报表统计等更多功能,请从PC端企业微信进入
- </div>
- <div class="tip" v-if="!isCorpWX">
- 体验报表统计等更多功能,尽在PC端<br>
- 网页用户访问http://worktime.ttkuaiban.com,钉钉用户直接从钉钉PC端进入工时管家
- </div>
- <Footer page="index"></Footer>
- </div>
- </template>
- <script>
- import Footer from "@/components/Footer";
- export default {
- data() {
- return {
- isCorpWX:false,
- isWX:false,
- user: JSON.parse(localStorage.userInfo),
- unreadNum:0,
- images: [
- // require('../../assets/img/index/banner_1.png'),
- require('../../assets/img/index/banner4.jpeg'),
- // require('../../assets/img/index/banner_3.png'),
- ],
- routers: [
- {
- name: '查看日报',
- url: '/calendar',
- icon: 'description'
- },
-
- {
- name: '填写日报',
- url: '/edit',
- icon: 'edit'
- },
-
-
- ],
- };
- },
- created() {
- let index = this.active + 1;
- this.list = this[`list${index}`]; // this.list1
- },
- mounted() {
- var ua = navigator.userAgent.toLowerCase();
- if (ua.indexOf("wxwork") > 0) {
- this.isCorpWX = true;
- } else if (ua.indexOf("micromessenger") > 0) {
- this.isWX = true;
- }
- if (this.user.company.packageEngineering == 1) {
- this.routers.push(
- {
- name: '专业审核',
- url: '/profession_review',
- icon: 'todo-list-o'
- });
- }
- if (this.user.role == 0) {
- //普通员工
- if (this.user.manageDeptId != 0 && this.user.company.packageEngineering == 1) {
- this.routers.push(
- {
- name: '部门审核',
- url: '/department_review',
- icon: 'todo-list-o'
- });
- }
- if (this.user.leader) {
- this.routers.push({
- name: '项目报告审核',
- url: '/review',
- icon: 'todo-list-o'
- });
- }
- } else if (this.user.role == 1 || this.user.role == 2 || this.user.role == 5){
- // } else if (this.user.role == 1 || this.user.role == 2){
- if (this.user.company.packageEngineering == 1) {
- this.routers.push(
- {
- name: '部门审核',
- url: '/department_review',
- icon: 'todo-list-o'
- });
- }
-
- this.routers.push({
- name: '项目报告审核',
- url: '/review',
- icon: 'todo-list-o'
- });
- this.routers.push({
- name: '项目管理',
- url: '/project',
- icon: 'label-o'
- });
-
- // 自己加的
- // this.routers.push({
- // name: '导入日报审核',
- // url: '/audit',
- // icon: 'label-o'
- // });
- } else {
- if (this.user.manageDeptId != 0 && this.user.company.packageEngineering == 1) {
- this.routers.push(
- {
- name: '部门审核',
- url: '/department_review',
- icon: 'todo-list-o'
- });
- }
- if (this.user.role == 3||this.user.role == 5||this.user.role == 6) {//项目管理员,公司领导,公司高层
- this.routers.push({
- name: '项目管理',
- url: '/project',
- icon: 'label-o'
- });
- }
- if (this.user.leader) {
- this.routers.push({
- name: '项目报告审核',
- url: '/review',
- icon: 'todo-list-o'
- });
- }
- }
- if(this.user.role == 1 || this.user.role == 2) {
- this.routers.push({
- name: '导入日报审核',
- url: '/audit',
- icon: 'label-o'
- });
- } else {
- if(this.user.role == 6 && this.user.timeType.needDeptAudit == 1) {
- this.routers.push({
- name: '导入日报审核',
- url: '/audit',
- icon: 'label-o'
- });
- }
- }
- this.routers.push({
- name: '消息记录',
- url: '/msg',
- icon: 'todo-list-o',
- info: this.unreadNum
- });
- this.getMessage();
- this.bindIfNessary();
- if (localStorage.userInfo != null) {
- this.getAccountInfo();
- }
- this.routers.push({
- name: '自动计时',
- url: '/timetool',
- icon: 'clock-o',
- info: this.unreadNum
- });
- this.getMessage();
- this.bindIfNessary();
- if (localStorage.userInfo != null) {
- this.getAccountInfo();
- }
- },
- components: {
- Footer
- },
- methods: {
- //获取账户信息
- getAccountInfo() {
- this.$axios.get('/user/loginByUserId', {params:{userId: this.user.id}})
- .then(res => {
- console.log(res);
- if (res.code == 'error') {
- localStorage.errorMsg = res.msg;
- //账号信息有问题,不能使用。
- this.$router.push("/error");
- } else {
-
- localStorage.userInfo = JSON.stringify(res.data);
- this.user = res.data;
- }
- }).catch(err=> {
- alert('err=' + err);
- });
- },
- bindIfNessary() {
- let href = window.location.href;
- var requestUrl = "";
- if (this.isCorpWX && (this.user.corpwxUserid == null|| this.user.corpwxUserid == undefined || this.user.corpwxUserid == 'undefined')) {//优先检查企业微信环境
- requestUrl = "/wxcorp/bindCorpWeiXin";
- } else if (this.isWX && (this.user.wxOpenid == null || this.user.wxOpenid == undefined || this.user.wxOpenid == 'undefined')) {
- requestUrl = "/wechat/bindWeiXin";
- }
-
- if (requestUrl.length > 0) {
- // localStorage.openId = 'o1L3L5lOrOl3_UEJjONaoT2Rne1I';
- //会自动跳转到首页
- // let href = 'http://hq.tangusoft.com/?code=011Ptjgc2rx1eI09Irgc2Rvsgc2PtjgF&state=1#/index';
-
- if (href.includes("com/?code")) { //url包括 com/?code 证明为从微信跳转回来的
- var url = href; //vue自动在末尾加了 #/ 符号,截取去掉
- var jingPosit = url.indexOf("com/") + 4; //获取域名结束的位置
- // var urlLeft = url.substring(0, jingPosit);//url左侧部分
- var urlRight = url.substring(jingPosit, url.length); //url右侧部分
- console.log('urlRight=' + urlRight);
- // window.location = urlLeft + "#/home" + urlRight;//拼接跳转
- //获取code
- var code = urlRight.substring('?code='.length,urlRight.indexOf('#/index'));
- if (code.indexOf('&state=1') > 0) {
- code = code.substring(0, code.indexOf('&state=1'));
- }
- //调用后台接口,注册用户
- console.log('获取到code=='+code);
- this.$axios.get(requestUrl, {params:{code:code, userId: this.user.id}})
- .then(res => {
- console.log(res);
- if (res == null) {
- this.$toast.fail('绑定失败');
- } else if(res.errcode != null) {
- //报错了
- console.log(res.errmsg);
- } else {
- //获取openId
- if (res.data != null && ((this.isWX && res.data.wxOpenid != undefined)
- || (this.isCorpWX && res.data.corpwxUserid != undefined))) {
- localStorage.userInfo = JSON.stringify(res.data);
- console.log('绑定成功');
- this.user = res.data;
- window.location.href = '/#/my/center';
- }
- }
- }).catch(err=> {
- alert('err=' + err);
- });
- }
- }
- },
- getGoods() {
- let url = "/goods"; // /api/goods
- this.$axios
- .get(url)
- .then(res => {
- console.log("res", res);
- })
- .catch(err => {
- console.log("err", err);
- });
- },
- //获取消息
- getMessage() {
- this.$axios.post("/information/list", {
- })
- .then(res => {
- if(res.code == "ok") {
- var list = res.data;
- this.unreadNum = list.filter(l=>l.checked==0).length;
- console.log(this.unreadNum);
-
- }
- }).catch(err=> {toast.clear();});
- },
- },
- activated(){
- this.getMessage()
- }
- };
- </script>
- <style lang="less" scoped>
- .swipe-img {
- img {
- width: 100%;
- height: 100%;
- }
- }
- .body {
- height: calc(100vh - 50px);
- position: relative;
- }
- .tip {
- position: absolute;
- width: 100%;
- bottom: 5px;
- font-size: 14px;
- color: #8f8f8f;
- margin-top: 20px;
- text-align: center;
- line-height: 20px;
- }
- </style>
|