UNPKG

xlb-main-login

Version:

``` yarn install ```

306 lines (285 loc) 9.04 kB
import { certigier } from '@/api/login' import { acquireWechat } from '@/api/wechatpay' import { getauth } from '@/api/weihome' import { axios } from '@/utils/request' import { wei_url } from '@/api/config' import store from '@/store' export async function getSCRMModal(router, _this) { const authSCRMWhiteList = ['/login', '/register', '/respwd'] //SCRM白名单 const disTributionWhiteList = [ '/distribution/home/disactivity', '/distribution/home/disactivity', '/distribution/home/disactivitycreate', '/distribution/analysis/distemanalysis', '/distribution/analysis/distemanalysisdetail', '/distribution/earning/disearnings', '/distribution/earning/disearningsdetail', '/distribution/manual/manual', ] if (authSCRMWhiteList.includes(router.path)) { return true } let userName await getUsername().then((res) => { userName = res }) let createTime await getRegisterTime().then((res) => { createTime = res }) await setSCRMInfo() let result = localStorage.getItem('isAuthSCRM' + userName) == 'true' //判断用户是否接入SCRM const get2021618 = 1623945600000 //2021年6.18 12:00:00 const is21618 = Date.parse(createTime) <= get2021618 //判断是否在6。18号之后 if (is21618) { result = true } if (disTributionWhiteList.includes(router.path)) { result = true } if (!result) { _this.$router.push({ name: 'authorization' }) } } export async function getAppModal(router) { let path if (router) { path = router.path } else { path = window.location.hash.substr(1).split('?')[0] } const authSCRMWhiteList = ['login', 'register', 'respwd', 'authDevelop'] //SCRM白名单 if (authSCRMWhiteList.includes(path.substr(1))) { return false } // 弹窗白名单 6.18 后 let whiteList = [] // 客户转化 const customLeaveWhiteList = [] // 公众号 const wechatAppWhiteList = [ '/wechat/account/weihome', '/wechat/draw/draw', '/wechat/account/weifans', '/wechat/account/weireply', '/wechat/account/weisoplist', '/wechat/account/weisopcreate', '/wechat/account/weicustom', '/wechat/account/weicustomreply', '/wechat/account/weimenu', '/wechat/account/ditchlist', '/wechat/account/ditchdata', '/wechat/spread/weispread', '/wechat/spread/weispreadsup', '/wechat/spread/weiformlist', '/wechat/analysis/weiformdatadetail', '/wechat/spread/weispreadcreate', '/wechat/spread/weispreadsupcreate', '/wechat/spread/weiconversion', '/wechat/spread/weiconversioncreate', '/wechat/spread/weigreat', '/wechat/spread/spreaddrawlist', '/wechat/spread/spreaddraw', '/wechat/share/share', '/wechat/share/shareactivity', '/wechat/spread/weiqrcodelist', '/wechat/holiday/holidaytaglist', '/wechat/account/ditchanalysis', '/conversion/goods/channel', '/wechat/holiday/holidaytag', 'lotteryanalysis', '/wechat/share/shareactivity', '/wechat/share/sharedetail', '/wechat/template/weitemplatesend', '/wechat/analysis/weiformdatadetail', '/wechat/draw/drawlist', '/wechat/template/weitemplate', '/wechat/template/weitemplatecreate', '/wechat/template/weicustoms', '/wechat/template/weicustomscreate', '/wechat/template/weicustomssend', '/wechat/analysis/weianalysis', '/wechat/analysis/weianalysisdetail', '/wechat/analysis/weimessagedetail', '/wechat/analysis/weiform', '/wechat/analysis/weiformdatadetail', '/wechat/spread/weiconversionedit', ] // 小程序 const smallAppWhiteList = [ '/program/home/accountManage', '/program/home/codeManage', '/program/activity/spreadBanner', '/program/activity/bannerCreate', '/program/activity/spreadActivity', '/program/activity/createActivity', '/program/template/templateMessage', '/program/template/createTemplateMessage', '/program/template/templateSend', '/program/analysis/activityData', '/program/analysis/activityDataDetail', '/program/manual/manual', ] // 分销 const disTributionWhiteList = [ '/distribution/home/disactivity', '/distribution/home/disactivity', '/distribution/home/disactivitycreate', '/distribution/analysis/distemanalysis', '/distribution/analysis/distemanalysisdetail', '/distribution/earning/disearnings', '/distribution/earning/disearningsdetail', '/distribution/manual/manual', ] // 裂变店铺 const storeWhiteList = [ '/store/home/pandect', '/store/management/shopset', '/store/management/payment', '/store/management/paymentFirst', '/store/management/paymentScend', '/store/management/paymentThree', '/store/management/advertising', '/store/management/addadvertising', '/store/management/market', '/store/activity/management', '/store/activity/verification', '/store/activity/channel', '/store/activity/dumpling', '/store/activity/group', '/store/order/indent', '/store/order/indent', '/store/order/approvedMemo', '/store/earnings/earnings', '/store/earnings/shopanalyze', '/store/earnings/shopdetails', '/store/manuel/manuel', '/store/earnings/shopfission', ] // 活码裂变 const communityWhiteList = [ '/community/home/community', '/community/statement/communityall', '/community/statement/accbrand', '/community/person/personcode', '/community/person/personcreate', '/community/person/personanalysisdetail', '/community/person/personanalysis', '/community/community/communitycode', '/community/community/communitycreate', '/community/community/communityanalysisdetail', '/community/community/communityanalysis', '/community/group/groupactivity', '/community/group/groupactivitycreate', '/community/group/grouptemanalysis', '/community/group/groupearnings', '/community/group/groupearningsdetail', '/community/group/grouptemanalysisdetail', ] let userName await getUsername().then((res) => { userName = res }) let createTime await getRegisterTime().then((res) => { createTime = res }) const get2021618 = 1623945600000 //2021年6.18 12:00:00 const is21618 = Date.parse(createTime) <= get2021618 //判断是否在6。18号之后 await setAcquireWechat() let result = localStorage.getItem('storevalue' + userName) == 'true' //判断用户是否接入SCRM whiteList = [ ...whiteList, ...wechatAppWhiteList, ...smallAppWhiteList, ...storeWhiteList, ...communityWhiteList, ...disTributionWhiteList, ] if (whiteList.includes(path)) { result = true } //6.18号之前不弹弹窗 if (customLeaveWhiteList.includes(path)) { if (is21618) { result = true } } return !result } /** * SCRM检测 * @returns {Promise<void>} */ export async function setSCRMInfo() { let user_link await getUsername().then((res) => { user_link = res }) await certigier().then((res) => { if (res.code == 200) { localStorage.setItem('isAuthSCRM' + user_link, res.value) } }) // } } /** * 判断是否授权企业微信应用 * @returns {Promise<void>} */ export async function setAcquireWechat() { let userName await getUsername().then((res) => { userName = res }) var item = localStorage.getItem('storevalue' + userName) if (!item) { await acquireWechat().then((res) => { if (res.success) { localStorage.setItem('storevalue' + userName, true) } else { localStorage.setItem('storevalue' + userName, false) } }) } } export async function getUsername() { let username = localStorage.getItem('username') if (!username) { await getauth().then((res) => { username = res.data.createBy localStorage.setItem('username', res.data.createBy) localStorage.setItem('createTime:' + res.data.createBy, res.data.createTime) }) } return username } export async function getRegisterTime() { const username = localStorage.getItem('username') let createTime = localStorage.getItem('createTime:' + username) if (!createTime) { await getauth().then((res) => { localStorage.setItem('username', res.data.createBy) localStorage.setItem('createTime:' + res.data.createBy, res.data.createTime) createTime = res.data.createTime }) } return createTime } //判断小裂变应用 export async function getSCRMAPP(_this) { //获取token if (!store.state.menuType) { let result = { code: 60001, } await acquireWechat().then((res) => { result = res }) if (result.code === 60001) { _this.$router.push({ name: 'authDevelop' }) } } else { return true } }