代码如下
<template>
<view class="content">
<image class="top_back_img" src="../../static/user-setting/set-top-bg.png" mode="aspectFit"></image>
<view class="top">
<view class="circle">
<image class="head" v-bind:src="photo" mode="widthFix"></image>
</view>
<view class="top-texts">
<text class="name">{{userName}}</text>
<image class="set-top-hr" src="../../static/user-setting/set-top-hr.png" mode=""></image>
<text class="depart">{{office}}</text>
<view>
<text>{{mobile}}</text>
</view>
</view>
<view class="top-changeInfo">
<text>修改</text>
</view>
</view>
<!-- 下半部分 -->
<view class="index">
<view class="cell" @click="changeGray">
<view class="cell-left">
<image class="cell_icon" src="../../static/user-setting/account.png"></image>
<text class="cell-text">修改密码</text>
</view>
<view class="cell-right">
<image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>
</view>
</view>
<view class="cell" @click="changeGray">
<view class="cell-left">
<image class="cell_icon" src="../../static/user-setting/account.png"></image>
<text class="cell-text">当前版本</text>
</view>
<view class="cell-right">
<image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>
</view>
</view>
<view class="cell" @click="changeGray">
<view class="cell-left">
<image class="cell_icon" src="../../static/user-setting/account.png"></image>
<text class="cell-text">检查更新</text>
</view>
<view class="cell-right">
<image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>
</view>
</view>
<view class="cell" @click="changeGray">
<view class="cell-left">
<image class="cell_icon" src="../../static/user-setting/account.png"></image>
<text class="cell-text">清除缓存</text>
</view>
<view class="cell-right">
<image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>
</view>
</view>
<view class="cell" @click="changeGray">
<view class="cell-left">
<image class="cell_icon" src="../../static/user-setting/account.png"></image>
<text class="cell-text">关于</text>
</view>
<view class="cell-right">
<image class="right-arrow" src="../../static/user-setting/right-arrow.png"></image>
</view>
</view>
</view>
<!-- 退出登录 -->
<!-- <view class="logout" style="width:80%;margin-top: 50upx;">
<button type="warn" @click="logout">退出登录</button>
</view> -->
<view class="logout" style="width:100%;margin-top: 50upx;">
<button v-if="!hasLogin" type="primary" class="primary" @tap="bindLogin">登录</button>
<button v-if="hasLogin" type="default" class="primary" @tap="bindLogout">退出登录</button>
</view>
</view>
<!-- <view class="content">
<view class="btn-row">
<button v-if="!hasLogin" type="primary" class="primary" @tap="bindLogin">登录</button>
<button v-if="hasLogin" type="default" @tap="bindLogout">退出登录</button>
</view>
</view> -->
</template>
<script>
import {
mapState,
mapMutations
} from 'vuex'
export default {
computed: {
...mapState(['userInfo', 'basicIP','userName', 'hasLogin', 'forcedLogin'])
},
onLoad() {
this.mobile=this.userInfo["mobile"];
this.phone=this.userInfo["phone"],
this.email=this.userInfo["email"],
this.office=this.userInfo["office"]["name"],
this.company=this.userInfo["company"]["name"],
this.photo=this.basicIP+this.userInfo["photo"],
console.log(this.photo);
console.log(this.mobile);
console.log(this.office);
},
methods: {
...mapMutations(['logout']),
data() {
return {
mobile: "1234",
phone: "",
email:"",
office: "",
company:"",
photo:"",
}
},
bindLogin() {
uni.navigateTo({
url: '../login/login',
});
},
bindLogout() {
this.logout();
/**
* 如果需要强制登录跳转回登录页面
*/
if (this.forcedLogin) {
uni.reLaunch({
url: '../login/login',
});
}
this.bindLogin();
}
}
}
</script>
{{mobile}}和{{office}}已正常赋值
4***@qq.com (作者)
测试代码地址如下,直接clone
https://gitee.com/wndayday/dev
代码直接放在hbuilderx里:
2019-01-21 14:46