123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <div id="app">
- <cube-button @click="goTo('service')" v-show="isService">进入微信服务台</cube-button>
- <cube-button @click="goTo('user')" v-show="isUser">进入微信运维端</cube-button>
- <cube-button @click="goTo('req')" v-show="isReq">进入微信报修端</cube-button>
- </div>
- </template>
- <script>
- export default {
- name: "App",
- data() {
- return {
- baseUrl: document.location.protocol + "//" + document.domain,
- isService:false,//服务台
- isUser:false,//运维端
- isReq:false,//报修端
- };
- },
- methods: {
- // 判断角色
- roleHandler(user,requester){
- let userRoles = user.role.map(v=>({id:v.id,rolecode:v.rolecode}));
- if(userRoles.length){
- this.isService = userRoles.some(v=>(v.rolecode === 'call center' || v.rolecode === 'call center admin'))
- this.isUser = userRoles.some(v=>(v.rolecode === 'first-line support' || v.rolecode === 'second-line support' || v.rolecode === 'incident manager' || v.rolecode === 'inspectman' || v.rolecode === 'incident-category-manager'))
- }else{
- this.isService = false;
- this.isUser = false;
- }
- this.isReq = requester ? true : false;
- },
- // 跳转应用
- goTo(type) {
- switch (type) {
- case "service":
- location.href = this.baseUrl + "/serviceApp";
- break;
- case "user":
- location.href = this.baseUrl + "/user";
- break;
- case "req":
- location.href = this.baseUrl + "/req";
- break;
- }
- },
- // 登陆
- login() {
- this.$http.post("service/auth/wechatAuth", {}).then((res) => {
- if (res.data.url) {
- window.location.href = res.data.url;
- } else {
- if (res.data.user) {
- this.roleHandler(res.data.user.user,res.data.user.requester);
- }
- }
- });
- },
- // 获取code
- getCode() {
- var url = window.location.href.split("?");
- if (!url[1]) {
- this.login();
- } else {
- var code = {
- code: url[1],
- };
- this.$http.post("service/auth/wechatLoginEncrypt", code).then(res => {
- if (res.data.state == 200) {
- if (res.data.user) {
- this.roleHandler(res.data.user.user,res.data.user.requester);
- }
- } else if (res.data.state == 501) {
- this
- .$createDialog({
- type: "alert",
- title: "您的账号被删除,请联系管理员",
- icon: "cubeic-alert"
- })
- .show();
- } else {
- this
- .$createDialog({
- type: "alert",
- title: res.data.remarks,
- icon: "cubeic-alert"
- })
- .show();
- }
- });
- }
- },
- },
- created() {
- this.getCode();
- },
- };
- </script>
- <style lang="less">
- #app {
- height: 100vh;
- background: url('./assets/imgs/weChartBackImage.jpg') no-repeat;
- background-size: cover;
- button{
- background-color: #005395;
- margin-bottom: 0.2rem;
- }
- }
- </style>
|