184 lines
4.5 KiB
Vue
Raw Normal View History

2025-06-06 03:08:19 +08:00
<template>
<view class="page">
2025-06-10 00:51:49 +08:00
<uni-nav-bar @clickLeft="goto(1, 1)" left-icon="back" :border="false" :shadow="false" :fixed="true"
2025-06-10 17:10:40 +08:00
:title="$t('personal.title')" backgroundColor="#fff" :statusBar="true"></uni-nav-bar>
2025-06-06 03:08:19 +08:00
<view class="cell_list" @click="dialogVisible = true">
2025-06-08 02:12:24 +08:00
<view class="cell_left txt">{{$t('personal.text1')}}</view>
2025-06-06 03:08:19 +08:00
<view class="cell_right arrow">
<image :src="avatar" mode="aspectFill"></image>
</view>
</view>
<z-prompt :value="nickname" options="nickname" text="Please enter a nickname" @confirm="onNameChange" :options="popupOptions">
<view class="cell_list">
2025-06-08 02:12:24 +08:00
<view class="cell_left txt">{{$t('personal.text2')}}</view>
2025-06-06 03:08:19 +08:00
<view class="cell_right arrow">{{ nickname }}</view>
</view>
</z-prompt>
<view class="cell_list">
2025-06-08 02:12:24 +08:00
<view class="cell_left txt">{{$t('personal.text3')}}</view>
2025-06-06 03:08:19 +08:00
<view class="cell_right ">{{id}}</view>
</view>
<view class="cell_list">
2025-06-08 02:12:24 +08:00
<view class="cell_left txt">{{$t('personal.text4')}}</view>
2025-06-06 03:08:19 +08:00
<view class="cell_right">{{account}}</view>
</view>
<view class="cell_list">
2025-06-08 02:12:24 +08:00
<view class="cell_left txt">{{$t('personal.text5')}}</view>
2025-06-06 03:08:19 +08:00
<view class="cell_right">{{identity}}</view>
</view>
<popup v-model="dialogVisible">
<view class="popup_content">
2025-06-08 02:12:24 +08:00
<view @click="takePhoto">{{$t('personal.text6')}}</view>
<view @click="onUnloadImg">{{$t('personal.text7')}}</view>
2025-06-06 03:08:19 +08:00
</view>
<view class="popup_content1">
2025-06-08 02:12:24 +08:00
<view>{{$t('buttonCancel')}}</view>
2025-06-06 03:08:19 +08:00
</view>
</popup>
</view>
</template>
<script>
import zPrompt from '@/components/common/prompt';
import Popup from '@/components/common/popup';
import {
mapState,
mapMutations
} from 'vuex';
export default {
components: {
Popup,
zPrompt
},
data() {
return {
popupOptions: {
placeholder: ''
},
avatar: '',
nickname: '',
id: '',
account: '',
identity: '',
dialogVisible: false,
};
},
computed: {
...mapState(['userInfo'])
},
//第一次加载
onLoad(e) {
this.avatar = this.userInfo.avatar || "/static/images/tx.png";
this.nickname = this.userInfo.nickname || "";
this.phone = this.userInfo.phone || "";
this.id = this.userInfo.id || "";
this.account = this.userInfo.username || "";
this.identity = this.userInfo.group;
this.$http.get('/api/role/detail?lang='+this.$i18n.locale).then(res => {
this.identity = res.data.name;
});
},
//页面显示
onShow() {},
//方法
methods: {
...mapMutations(['setUserInfo']),
//修改昵称
onNameChange(e) {
this.nickname = e.value;
e.close();
let data = {
nickname: e.value
};
this.$http.post('/api/user/profile', data).then(res => {
if(res.code == 0){
this.userInfo.nickname = e.value;
this.setUserInfo(this.userInfo);
}
});
},
2025-06-10 00:51:49 +08:00
goto(url, type) {
if (type == 2) {
return uni.switchTab({ url: url })
}
if (type == 1) {
return uni.navigateBack({ delta: url });
}
uni.navigateTo({
url: url
})
},
2025-06-06 03:08:19 +08:00
takePhoto() {
uni.chooseImage({
count: 1, // 默认9, 设置图片的最大选择数设置为1表示拍一张照片
sourceType: ['camera'], // 可以设置拍照或相册选择,这里只设置拍照
success: (res) => {
const tempFilePaths = res.tempFilePaths; // 临时路径
this.onUnloadImg(tempFilePaths[0]); // 上传图片
}
});
},
//修改头像
onUnloadImg() {
this.$http.urlImgUpload("/api/user/avatar", {
count: 1
}).then(res => {
this.avatar = res[0].url;
});
},
},
//页面隐藏
onHide() {},
//页面卸载
onUnload() {},
//页面下来刷新
onPullDownRefresh() {},
//页面上拉触底
onReachBottom() {},
//用户点击分享
onShareAppMessage(e) {
return this.wxShare();
}
};
</script>
<style lang="scss" scoped>
@import '@/style/mixin.scss';
.cell_list {
padding: 30rpx 30rpx;
margin: 20rpx 30rpx 0 30rpx;
border-radius: 8rpx;
}
.popup_content {
padding: 20rpx 10rpx;
background-color: #FFFFFF;
text-align: center;
width: 90vw;
margin-left: 5vw;
2025-06-10 00:51:49 +08:00
border-radius: 20rpx;
line-height: 120rpx;
margin-bottom: 20rpx;
font-size: 34rpx;
2025-06-06 03:08:19 +08:00
font-weight: 500;
color:#333;
}
.popup_content1 {
background-color: #FFFFFF;
text-align: center;
width: 90vw;
margin-left: 5vw;
2025-06-10 00:51:49 +08:00
border-radius: 20rpx;
line-height: 120rpx;
margin-bottom: 40rpx;
font-size: 34rpx;
2025-06-06 03:08:19 +08:00
font-weight: 500;
color:#333;
}
.cell_right image {
width: 140rpx;
height: 140rpx;
border-radius: 50%;
}
</style>