factory_mp_old/pages/my/my_.vue

101 lines
2.5 KiB
Vue

<template>
<view>
<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
<view class="u-m-r-10">
<!-- #ifdef MP-WEIXIN -->
<view class="avatarImg">
<open-data type="userAvatarUrl" default-avatar="/static/other/timg.jpg"></open-data>
</view>
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<u-avatar :src="vuex_user.avatar" size="140"></u-avatar>
<!-- #endif -->
</view>
<view class="u-flex-1">
<view class="u-font-18 u-p-b-20">
{{vuex_user.name}}
<u-tag text="企业员工" v-if="vuex_user.type == 'employee'"/>
<u-tag text="相关方" v-if="vuex_user.type == 'remployee'"/>
<u-tag text="访客" v-if="vuex_user.type == 'visitor'"/>
</view>
<view class="u-font-14 u-type-info">{{vuex_user.username}}-{{vuex_user.belong_dept_name}}-{{vuex_user.post_name}}</view>
<view class="u-font-14 u-type-info" v-if="vuex_user.wxmp_openid">已绑定微信小程序</view>
<view class="u-font-14 u-type-info" v-if="vuex_user.wx_openid">已绑定公众号通知</view>
</view>
</view>
<view class="u-m-t-20">
<u-cell-group>
<u-cell-item icon="weixin-fill" title="绑定微信" :arrow="false" @click="bindMP" v-if="!vuex_user.wxmp_openid"></u-cell-item>
<u-cell-item icon="close" title="退出账号" @click="Logout"></u-cell-item>
</u-cell-group>
</view>
</view>
</template>
<script>
export default {
data() {
return {
pic:'https://uviewui.com/common/logo.png',
show:true
}
},
onLoad() {
},
methods: {
Logout(){
this.$u.api.unbindmp().then(res=>{
this.$u.vuex('vuex_token', '')
uni.redirectTo({
url: '/pages/login/login'
});
}
)
},
bindMP(){
let data = {openid: uni.getStorageSync('wxmp_openid')}
this.$u.api.bindmp(data).then(res=>{})
// uni.login({
// provider: 'weixin',
// success: (loginRes)=>{
// this.$u.api.bindmp({code:loginRes.code}).then(res=>{
// this.$u.toast('绑定成功');
// this.$u.vuex('vuex_user.wxmp_openid', res.data.wxmp_openid)
// uni.reLaunch({
// url:'/pages/my/my'
// })
// }).catch(e=>{})
// }
// });
}
}
}
</script>
<style lang="scss">
page{
background-color: #ededed;
}
.camera{
width: 54px;
height: 44px;
&:active{
background-color: #ededed;
}
}
.user-box{
background-color: #fff;
padding-top:24rpx;
}
.avatarImg {
width: 148rpx;
height: 148rpx;
border-radius: 20rpx;
overflow: hidden;
}
</style>
c