kitchendDevice/pageTwo/me/userEdit.vue

299 lines
6.9 KiB
Vue
Raw Normal View History

2023-09-08 15:17:21 +08:00
<template>
<view class="content">
<view class="lanBox">
<view class="headbox">
2025-11-08 16:50:26 +08:00
<view class="touxiang" v-if="user.head_pic">
2025-03-25 10:17:30 +08:00
<image :src="user.head_pic" class="headimage" />
2023-09-08 15:17:21 +08:00
</view>
2025-11-08 16:50:26 +08:00
<view class="touxiang" v-else>
<image src="/static/tou.png" class="headimage" />
</view>
2023-09-08 15:17:21 +08:00
</view>
<view class="lan border-bottom">
2025-12-22 09:34:09 +08:00
<view class="left">{{$t('infoNickname')}}</view>
2023-09-08 15:17:21 +08:00
<view class="right">
2025-12-22 09:34:09 +08:00
<input name="name" type="text" v-model="memInfo.nickname" :placeholder="$t('verifyRecord')"
class="name" />
2025-03-25 10:17:30 +08:00
<icon class="iconfont icon-bianji" v-if="!memInfo.nickname"></icon>
<icon class="iconfont icon-error" v-else @click="memInfo.nickname=''"></icon>
2023-09-08 15:17:21 +08:00
</view>
</view>
<view class="lan border-bottom">
2025-12-22 09:34:09 +08:00
<view class="left">{{$t('infoGender')}}</view>
2023-09-08 15:17:21 +08:00
<view class="right">
<picker mode="selector" :range="sexItem" @change="onsexArr">
2025-12-22 09:34:09 +08:00
<view class="uni-input">
{{memInfo.gender==0?$t('verifyPicker'):memInfo.gender==1? $t('infoMan'):$t('infoWoman')}}
</view>
2023-09-08 15:17:21 +08:00
<icon class="iconfont icon-arrow-down"></icon>
</picker>
</view>
</view>
<view class="lan border-bottom">
2025-12-22 09:34:09 +08:00
<view class="left">{{$t('infoBirthday')}}</view>
2025-11-08 16:50:26 +08:00
<view class="right">
<picker mode="date" :end="endDate" @change="maskClick"
2025-12-22 09:34:09 +08:00
:value="memInfo.birthday?memInfo.birthday:endDate" fields="day">
<view class="uni-input">{{memInfo.birthday?memInfo.birthday:$t('verifyPicker')}}</view>
2025-11-08 16:50:26 +08:00
<icon class="iconfont icon-arrow-down"></icon>
</picker>
</view>
</view>
<!-- <view class="lan border-bottom">
2023-09-08 15:17:21 +08:00
<view class="left">年龄</view>
<view class="right">
<picker mode="selector" :range="ageArr" @change="onageArr">
<view class="uni-input">{{!memInfo.age?'请选择年龄':memInfo.age+'岁'}}</view>
<icon class="iconfont icon-arrow-down"></icon>
</picker>
</view>
2025-11-08 16:50:26 +08:00
</view> -->
2023-09-08 15:17:21 +08:00
<view class="lan border-bottom">
2025-12-22 09:34:09 +08:00
<view class="left">{{$t('infoHeight')}}</view>
2023-09-08 15:17:21 +08:00
<view class="right">
2025-12-22 09:34:09 +08:00
<input type="digit" v-model="memInfo.height" :placeholder="$t('verifyRecord')" />
2023-09-08 15:17:21 +08:00
<text>cm</text>
</view>
</view>
<view class="lan border-bottom">
2025-12-22 09:34:09 +08:00
<view class="left">{{$t('infoWeight')}}</view>
2023-09-08 15:17:21 +08:00
<view class="right">
2025-12-22 09:34:09 +08:00
<input type="digit" v-model="memInfo.weight" :placeholder="$t('verifyRecord')" />
2023-09-08 15:17:21 +08:00
<text>kg</text>
</view>
</view>
2025-11-27 15:04:25 +08:00
<view class="lan border-bottom">
2025-12-22 09:34:09 +08:00
<view class="left">{{$t('infoActivityCoefficient')}}</view>
2025-11-27 15:04:25 +08:00
<view class="right">
2025-12-22 09:34:09 +08:00
<picker mode="selector" @change="changeClickType" :range="activityLevel" range-key="name"
:value="levelInd">
2025-11-27 15:04:25 +08:00
<view>
2025-12-29 16:54:56 +08:00
{{memInfo.activity_level?activityLevel[levelInd].name:$t('verifyRecord')}}
2025-11-27 15:04:25 +08:00
<icon class="iconfont icon-arrow-down"></icon>
</view>
</picker>
</view>
</view>
2023-09-08 15:17:21 +08:00
</view>
2025-12-22 09:34:09 +08:00
<view class="btn" @click="confirmInfo">{{$t('btnSubmit')}}</view>
2023-09-08 15:17:21 +08:00
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
sexItem: [
2025-12-29 16:54:56 +08:00
this.$t("infoMan"),
this.$t("infoWoman")
2023-09-08 15:17:21 +08:00
],
2025-11-27 15:04:25 +08:00
levelInd: 0,
2023-09-08 15:17:21 +08:00
isEdit: false,
memInfo: {
2025-11-08 16:50:26 +08:00
birthday: "",
2023-09-08 15:17:21 +08:00
height: "",
weight: "",
2025-11-08 16:50:26 +08:00
gender: 0,
2025-03-25 10:17:30 +08:00
nickname: "",
2025-12-29 16:54:56 +08:00
activity_level: "",
2023-09-08 15:17:21 +08:00
},
};
},
computed: {
2025-11-27 15:04:25 +08:00
...mapState(["user", "configInfo"]),
2025-11-08 16:50:26 +08:00
endDate() {
return this.$tools.getDate("start")
},
2025-11-27 15:04:25 +08:00
activityLevel() {
return this.configInfo.activity_level
}
2023-09-08 15:17:21 +08:00
},
2025-03-25 10:17:30 +08:00
onLoad(options) {
// 编辑
2025-12-22 09:34:09 +08:00
let that = this
uni.setNavigationBarTitle({
title: that.$t('infoPersonalProfile')
})
2025-03-25 10:17:30 +08:00
if (options.familayData) {
let info = options.familayData
this.memInfo = JSON.parse(info)
this.isEdit = true
2025-11-08 16:50:26 +08:00
} else if (this.user.aud_id) {
2025-03-25 10:17:30 +08:00
this.memInfo = this.user
2025-11-27 15:04:25 +08:00
this.levelInd = this.activityLevel.findIndex(ite => ite.val == this.memInfo.activity_level)
2025-12-29 16:54:56 +08:00
console.log("11111", this.levelInd, this.activityLevel, this.memInfo)
2025-11-27 15:04:25 +08:00
if (this.memInfo.activity_level == null) {
this.levelInd = 0
this.memInfo.activity_level = this.activityLevel[0].val
}
2025-03-25 10:17:30 +08:00
}
2025-11-27 15:04:25 +08:00
2025-03-25 10:17:30 +08:00
},
2023-09-08 15:17:21 +08:00
methods: {
// 提交
confirmInfo() {
let that = this
2025-11-27 15:04:25 +08:00
console.log("activity_level", this.memInfo)
2025-03-25 10:17:30 +08:00
if (!this.memInfo.nickname) {
2025-12-22 09:34:09 +08:00
this.$tools.msg(that.$t('verifyNickName'))
2023-09-08 15:17:21 +08:00
return;
}
2025-03-25 10:17:30 +08:00
if (!this.memInfo.gender) {
2025-12-22 09:34:09 +08:00
this.$tools.msg(that.$t('verifyGender'))
2023-09-08 15:17:21 +08:00
return;
}
2025-11-08 16:50:26 +08:00
if (!this.memInfo.birthday) {
2025-12-22 09:34:09 +08:00
this.$tools.msg(that.$t('verifyBirthday'))
2023-09-08 15:17:21 +08:00
return;
}
if (!this.memInfo.height) {
2025-12-22 09:34:09 +08:00
this.$tools.msg(that.$t('verifyHeight'))
2023-09-08 15:17:21 +08:00
return;
}
if (!this.memInfo.weight) {
2025-12-22 09:34:09 +08:00
this.$tools.msg(that.$t('verifyWeight'))
2023-09-08 15:17:21 +08:00
return;
}
2025-12-27 15:47:56 +08:00
// if (!this.memInfo.activity_level) {
// this.$tools.msg(that.$t('verifyActivityCoefficient'))
// return;
// }
2023-09-08 15:17:21 +08:00
that.subInfo(this.memInfo)
},
subInfo(data) {
let that = this
2025-03-25 10:17:30 +08:00
that.$model.getUserInfoEdit(data).then(res => {
2023-09-08 15:17:21 +08:00
if (res.code == 0) {
2025-12-29 16:54:56 +08:00
that.$store.dispatch("getUserInfo")
2023-09-08 15:17:21 +08:00
uni.navigateBack({
delta: 1
});
} else {
that.$tools.msg(res.message);
}
});
},
2025-11-08 16:50:26 +08:00
//确定年龄
maskClick(e) {
this.memInfo.birthday = e.detail.value
},
2023-09-08 15:17:21 +08:00
//确定性别
onsexArr(e) {
2025-12-29 16:54:56 +08:00
this.memInfo.gender = this.sexItem[e.target.value] == this.$t("infoMan") ? 1 : 2
2023-09-08 15:17:21 +08:00
},
2025-11-27 15:04:25 +08:00
changeClickType(e) {
this.levelInd = e.target.value
this.memInfo.activity_level = this.activityLevel[e.target.value].val
}
2023-09-08 15:17:21 +08:00
},
};
</script>
<style scoped="scoped" lang="scss">
.content {
2025-11-25 14:21:22 +08:00
padding: 0 30rpx;
2023-09-08 15:17:21 +08:00
}
.lanBox {
2025-11-25 14:21:22 +08:00
margin-top: 30rpx;
padding: 30rpx 30rpx 0;
width: calc(100% - 60rpx);
2023-09-08 15:17:21 +08:00
background: #fff;
2025-11-25 14:21:22 +08:00
border-radius: 20rpx;
2023-09-08 15:17:21 +08:00
.headbox {
text-align: center;
position: relative;
display: flex;
justify-content: center;
height: 65px;
2025-11-25 14:21:22 +08:00
margin-bottom: 30rpx;
2023-09-08 15:17:21 +08:00
.headimage {
display: block;
width: 65px;
height: 65px;
font-size: 65px;
border-radius: 50%;
}
}
}
.lan {
display: flex;
2025-12-27 15:47:56 +08:00
flex-wrap: wrap;
2023-09-08 15:17:21 +08:00
align-items: center;
font-size: 14px;
2025-12-27 15:47:56 +08:00
padding: 10px 0;
2023-09-08 15:17:21 +08:00
border-bottom: 1px solid #f7f7f7;
.left {
2025-12-27 15:47:56 +08:00
width: 25%;
2023-09-08 15:17:21 +08:00
text-align: left;
}
.right {
display: flex;
align-items: center;
justify-content: flex-end;
2025-12-27 15:47:56 +08:00
width: 75%;
2023-09-08 15:17:21 +08:00
position: relative;
text-align: right;
/deep/input {
2025-12-27 15:47:56 +08:00
height: 70rpx;
2023-09-08 15:17:21 +08:00
border: none;
background: inherit;
width: 100%;
}
.name {
2025-11-25 14:21:22 +08:00
padding-right: 50rpx;
2023-09-08 15:17:21 +08:00
}
picker {
width: 100%;
2025-12-27 15:47:56 +08:00
min-height: 70rpx;
2023-09-08 15:17:21 +08:00
text-align: right;
border: none;
margin-right: 8px;
2025-12-27 15:47:56 +08:00
display: flex;
align-items: center;
justify-content: flex-end;
2023-09-08 15:17:21 +08:00
view {
padding-right: 18px;
color: #828282;
font-size: 14px;
}
}
text {
display: inline-block;
2025-11-25 14:21:22 +08:00
width: 60rpx;
2023-09-08 15:17:21 +08:00
text-align: right;
color: #828282;
}
.iconfont {
color: #828282;
position: absolute;
right: 0px;
2025-12-27 15:47:56 +08:00
top: 10px;
2025-11-25 14:21:22 +08:00
width: 60rpx;
2023-09-08 15:17:21 +08:00
justify-content: flex-end;
}
}
}
.btn {
color: #fff;
width: 100%;
}
2025-03-25 10:17:30 +08:00
</style>