zhaoxiaoqiang
2021-08-31 20365ba048f4042dfdc223cf2a6fa8c2d5a699f3
src/views/mine/toggle-identity.vue
@@ -23,7 +23,7 @@
                            <svg class="icon" aria-hidden="true"  style="width:15px;height:15px;">
                                <use xlink:href="#iconshijian"></use>
                            </svg>
                            <time class='time'>创建时间:{{role.creTime | timeformat('yyyy-MM-dd HH:mm:ss')}}</time>
              <time class="time">创建时间:{{ role.creTime | timeformat("yyyy-MM-dd HH:mm:ss") }}</time>
                        </p>
                    </div>
                    <div @click="setRole(role)" v-if="role.status == 1 && role.supStatus == 1" >
@@ -37,84 +37,80 @@
</template>
<script>
import { mapActions, mapState } from 'vuex';
import { mapActions, mapState } from "vuex";
    export default {
        data() {
            return {
                roleList: [],//角色列表
                roleId: '',//radio的value
                role:null //当前选中的角色
            }
      roleId: "", //radio的value
      role: null, //当前选中的角色
    };
        },
        computed:{
            ...mapState(['userinfo'])
    ...mapState(["userinfo"]),
        },
        created() {
            this.roleId = this.userinfo.id;
            if(sessionStorage.isLoginByOpenId == 1){
                this.roleList = [{
                    title:'门店',
                    arr:JSON.parse(localStorage.storeList)
                }]
      this.roleList = [
        {
          title: "门店",
          arr: JSON.parse(localStorage.storeList),
        },
      ];
            }else{
                this.getRole();
            }
        },
        methods: {
            ...mapActions(['setUserMenu']),
    ...mapActions(["setUserMenu"]),
            // 设置当前选中的角色
            setRole(role){
                this.role = role;
            },
            // 获取角色
            getRole() {
                this.$api.getRole().then((res) => {
                    let {
                        agencyList,
                        chanList,
                        merchantList,
                        storeList
                    } = res.body;
      this.$api
        .getRole()
        .then((res) => {
          let { agencyList, chanList, merchantList, storeList } = res.body;
                    this.roleList.push({
                        title:'代理',
                        arr:agencyList || []
            title: "代理",
            arr: agencyList || [],
                    });
                    this.roleList.push({
                        title:'渠道',
                        arr:chanList || []
            title: "渠道",
            arr: chanList || [],
                    });
                    this.roleList.push({
                        title:'商户',
                        arr:merchantList || []
            title: "商户",
            arr: merchantList || [],
                    });
                    this.roleList.push({
                        title:'门店',
                        arr:storeList || []
            title: "门店",
            arr: storeList || [],
                    });
                }).catch((err) => {
                });
        })
        .catch((err) => {});
            },
            // 获取用户信息
            getRoleInfo(){
                if(!this.roleId){
                     this.$notify('请选择登录角色');
                    return
        this.$notify("请选择登录角色");
        return;
                }
                this.setUserMenu({
                    vm:this,
                    lastLoginMgrId:this.roleId,
                })
      });
                // this.$api.getPowerInfo(this.roleId).then((res) => {
                // }).catch((err) => {
                // });
            }
        },
    }
  },
};
</script>
<style lang="less" scoped>