|
@@ -9,8 +9,11 @@
|
|
|
<u-avatar :src="userAvatarUrl" size="100" class="avatar"></u-avatar>
|
|
|
</view>
|
|
|
<view class="user-info">
|
|
|
- <text class="user-name">{{$store.state.vuex_userData.userNameCN}}</text>
|
|
|
- <text class="user-phone">{{$store.state.vuex_userData.username}}</text>
|
|
|
+ <text class="user-name">{{userData.orgName}}</text>
|
|
|
+ <text class="user-phone">{{userData.username}}</text>
|
|
|
+ </view>
|
|
|
+ <view class="user-org" @click="show = true" v-if="orglist&&orglist.length">
|
|
|
+ 切换 <u-icon name="arrow-right"></u-icon>
|
|
|
</view>
|
|
|
</view>
|
|
|
<!-- 列表 -->
|
|
@@ -26,36 +29,94 @@
|
|
|
<view class="user-btn">
|
|
|
<u-button type="success" :custom-style="{background:$config('primaryColor')}" hover-class="none" @click="quitOutSys" shape="circle">退出登录</u-button>
|
|
|
</view>
|
|
|
+ <u-action-sheet :list="orglist" v-model="show" @click="changeAcount" :tips="tips" :cancel-btn="true"></u-action-sheet>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
- import { getUserInfo, logout } from '@/api/user.js'
|
|
|
+ import { getUserInfo, logout, login } from '@/api/user.js'
|
|
|
import { getSysVersion } from '@/api/data.js'
|
|
|
import { checkVersionToLoadUpdate, clzConfirm } from '@/libs/tools';
|
|
|
import market from "@/js_sdk/dc-market/market.js"
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ isRemember: false,
|
|
|
+ show:false,
|
|
|
+ tips: {
|
|
|
+ text: '切换账户',
|
|
|
+ color: '#999',
|
|
|
+ fontSize: 32
|
|
|
+ },
|
|
|
userInfoData: null, // 用户信息
|
|
|
userAvatarUrl: '' ,// 用户头像
|
|
|
curVer: null
|
|
|
};
|
|
|
},
|
|
|
onShow() {
|
|
|
- this.getUserInfo()
|
|
|
+ // this.getUserInfo()
|
|
|
+ console.log(this.userData)
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ orglist() {
|
|
|
+ // 当前连锁账户
|
|
|
+ const orgs = this.$store.state.vuex_authOrgs;
|
|
|
+ const user = this.$store.state.vuex_userData;
|
|
|
+ orgs.map(item => {
|
|
|
+ item.text = item.orgName
|
|
|
+ })
|
|
|
+ return orgs.filter(item => item.orgSn != user.orgSn)
|
|
|
+ },
|
|
|
+ userData () {
|
|
|
+ return this.$store.state.vuex_userData;
|
|
|
+ }
|
|
|
},
|
|
|
onLoad() {
|
|
|
uni.setNavigationBarColor({
|
|
|
frontColor: '#ffffff',
|
|
|
backgroundColor: this.$config('primaryColor')
|
|
|
})
|
|
|
+ this.isRemember = this.$store.state.vuex_isRemember;
|
|
|
this.curVer = getApp().globalData.version;
|
|
|
},
|
|
|
methods:{
|
|
|
- // 获取用户信息
|
|
|
- getUserInfo(){
|
|
|
- console.log(this.$store.state.vuex_userData)
|
|
|
+ // 过滤权限code
|
|
|
+ fiterAuthCode(data) {
|
|
|
+ data.permCodes = data.permCodes.filter(item => item.indexOf('_mobile') > 0);
|
|
|
+ return data;
|
|
|
+ },
|
|
|
+ // 切换账户
|
|
|
+ changeAcount(index){
|
|
|
+ const _this = this
|
|
|
+ const item = this.orglist[index]
|
|
|
+ console.log(index,item)
|
|
|
+ this.$store.state.vuex_changeOrg = item.orgSn
|
|
|
+ this.$set(getApp().globalData,'changeOrg',item.orgSn)
|
|
|
+ setTimeout(()=>{
|
|
|
+ // 登录
|
|
|
+ login({ username: '', password: '' }).then(res => {
|
|
|
+ console.log(res)
|
|
|
+ uni.hideLoading();
|
|
|
+ if (res.status == 200) {
|
|
|
+ _this.$u.vuex('vuex_userData', _this.fiterAuthCode(res.data.auth_user));
|
|
|
+ _this.$u.vuex('vuex_token', res.data.access_token);
|
|
|
+ _this.$u.vuex('vuex_authOrgs',res.data.auth_orgs);
|
|
|
+ getApp().globalData.token = res.data.access_token;
|
|
|
+ uni.setStorageSync('loginTimeOut', 'NO');
|
|
|
+ this.toMain()
|
|
|
+ uni.$emit("refreshSalesBL")
|
|
|
+ uni.showToast({ icon: 'none', title: '切换成功!' });
|
|
|
+ }else{
|
|
|
+ uni.showToast({ icon: 'none', title: res.message });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },100)
|
|
|
+ },
|
|
|
+ // 跳转到首页
|
|
|
+ toMain() {
|
|
|
+ uni.switchTab({
|
|
|
+ url: '/pages/sales/index'
|
|
|
+ });
|
|
|
},
|
|
|
// 打开对应的页面
|
|
|
toPage(index){
|
|
@@ -93,6 +154,9 @@
|
|
|
// this.$store.commit("$closeWebsocket")
|
|
|
this.$store.state.vuex_token = '';
|
|
|
this.$store.state.vuex_userData = '';
|
|
|
+ this.$u.vuex('vuex_authOrgs','');
|
|
|
+ getApp().globalData.token = '';
|
|
|
+ this.$set(getApp().globalData,'changeOrg','')
|
|
|
uni.setStorageSync('setStatusIndexFunc', 0);
|
|
|
setTimeout(function() {
|
|
|
uni.reLaunch({
|
|
@@ -131,6 +195,9 @@
|
|
|
flex-shrink: 0;
|
|
|
margin-right: 5rpx;
|
|
|
}
|
|
|
+ .user-org{
|
|
|
+ color: #fff;
|
|
|
+ }
|
|
|
.user-info{
|
|
|
flex-grow: 1;
|
|
|
padding: 0 20rpx;
|