Files
czg_business_wechat/pages/shop/indexes.vue
2024-03-21 15:38:10 +08:00

171 lines
3.6 KiB
Vue

<template>
<view class="index flex-colum">
<view class="index_text">
点击头像切换店铺账号
</view>
<view class="index_box">
<view class="index_item flex-between" v-for="(item,index) in list" :key="index" @click="clickes(item)">
<view class="index_itemone flex-start">
<image class="index_itemoneimage" :src="item.avatar" mode=""></image>
<view class="flex-colum-start">
<view class="index_itemone_one">
{{item.title}}
</view>
<view class="index_itemone_tow">
{{item.class}}
</view>
</view>
</view>
<view class="index_itemonetext" v-if="item.store_id==storeid">
当前使用
</view>
</view>
</view>
</view>
</template>
<script>
export default {
data() {
return {
screenheight: '',
list: [],
storeid: uni.cache.get('user').store_id
}
},
onLoad() {
this.useraccountlist()
uni.getSystemInfo({
success: (e) => {
let screenHeight = 0
console.log(e)
screenHeight = e.windowHeight
this.screenheight = {
'height': screenHeight + 'px'
}
}
})
},
methods: {
async useraccountlist() {
let res = await this.api.useraccountlist()
if (res.code = 1) {
this.list = res.data
}
},
async clickes(e) {
if (e.store_id != this.storeid) {
uni.login({
provider: 'weixin',
success: async (data) => {
let res = await this.api.userautollogin({
code: data.code,
type: e.type,
syb_m_id: e.syb_m_id,
mobile: e.mobile,
sign: uni.utils.md5('wgpdZW1YEqNlUuvJfrB2nkjRVOHIeC' + e.type + e
.syb_m_id + e.mobile)
})
try {
if (res.code == 1) {
uni.cache.set('user', res.data.userinfo);
uni.cache.set("token", res.data.userinfo.token);
if (res.data.userinfo.group_id == 2) {
uni.pro.switchTab('order/index')
} else {
setTimeout(res => {
uni.reLaunch({
url: '/pages/login/login'
})
}, 2000)
}
} else {
setTimeout(res => {
uni.reLaunch({
url: '/pages/login/login'
})
}, 2000)
}
} catch (e) {
setTimeout(res => {
uni.reLaunch({
url: '/pages/login/login'
})
}, 2000)
}
}
});
}
}
}
}
</script>
<style lang="scss">
page {
background: #EDEDED;
}
.index {
height: 100%;
.index_text {
font-size: 52rpx;
font-family: SourceHanSansCN-Regular, SourceHanSansCN;
font-weight: 400;
color: #333333;
margin-top: 220rpx;
}
.index_box {
padding: 0 48rpx;
width: 100%;
.index_item {
margin-top: 56rpx;
width: 100%;
padding: 40rpx 45rpx;
background: #FFFFFF;
border-radius: 44rpx;
.index_itemone {
.index_itemoneimage {
width: 114rpx;
height: 114rpx;
}
.flex-colum-start {
margin-left: 32rpx;
.index_itemone_one {
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
width: 240rpx;
font-size: 32rpx;
font-family: SourceHanSansCN-Bold, SourceHanSansCN;
font-weight: bold;
color: #333333;
}
.index_itemone_tow {
margin-top: 10rpx;
font-size: 32rpx;
font-family: SourceHanSansCN-Regular, SourceHanSansCN;
font-weight: 400;
color: #999999;
}
}
}
.index_itemonetext {
font-size: 32rpx;
font-family: SourceHanSansCN-Regular, SourceHanSansCN;
font-weight: 400;
color: #2F87FD;
}
}
}
}
</style>