examTeamApp/pageTwo/my/userInfo.vue

521 lines
14 KiB
Vue
Raw Permalink Normal View History

2024-05-02 15:59:36 +08:00
<template>
<view class="box">
<view class="lanBox">
<view class="headbox">
<view class="touxiang">
<image v-if="headimg" :src="headimg" class="headimage" />
2024-09-26 09:18:27 +08:00
<icon v-else class="iconfont icon-user-filling headimage"></icon>
2024-05-02 15:59:36 +08:00
</view>
</view>
<view class="lan border-bottom">
2025-04-18 14:53:38 +08:00
<view class="left">{{$t("common.infoNickname")}}</view>
2024-05-02 15:59:36 +08:00
<view class="right">
2025-04-18 14:53:38 +08:00
<input name="name" type="text" v-model="memInfo.nickname"
:placeholder="$t('tips.verifyNickName')" />
2024-06-13 18:03:50 +08:00
<uni-icons type="clear" color="#999" v-if="memInfo.nickname" @click="memInfo.nickname=''"
size="20"></uni-icons>
2024-05-02 15:59:36 +08:00
</view>
</view>
<view class="lan border-bottom">
2025-04-18 14:53:38 +08:00
<view class="left">{{$t("common.infoGender")}}</view>
2024-05-02 15:59:36 +08:00
<view class="right">
<view class="radio">
<uni-icons :type="memInfo.gender==1?'checkbox-filled':'circle'" @click="memInfo.gender=1"
2025-04-18 14:53:38 +08:00
size="24" :color="memInfo.gender==1?'#fea606':'#dfdfdf'"></uni-icons>
2025-04-26 13:35:30 +08:00
{{$t("common.infoMan")}}
</view>
<view class="radio ml-15">
<uni-icons :type="memInfo.gender==2?'checkbox-filled':'circle'" @click="memInfo.gender=2"
2025-04-26 13:35:30 +08:00
size="24" :color="memInfo.gender==2?'#fea606':'#dfdfdf'"></uni-icons>
{{$t("common.infoWoman")}}
</view>
<!-- <picker mode="selector" :range="sexItem" @change="onsexArr">
2024-05-29 16:35:45 +08:00
<view class="uni-input">{{memInfo.gender==0?'请选择':memInfo.gender==1?'男':'女'}}</view>
2024-05-02 15:59:36 +08:00
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker> -->
2024-05-02 15:59:36 +08:00
</view>
</view>
2024-06-13 18:03:50 +08:00
<view class="lan border-bottom">
2025-04-18 14:53:38 +08:00
<view class="left">{{$t("common.infoHeight")}}</view>
2024-06-13 18:03:50 +08:00
<view class="right">
2025-04-18 14:53:38 +08:00
<input name="name" class="mr-5" type="digit" v-model="memInfo.height"
:placeholder="$t('tips.verifyHeight')" />CM
2024-06-13 18:03:50 +08:00
<uni-icons type="clear" color="#999" v-if="memInfo.height" @click="memInfo.height=''"
size="20"></uni-icons>
</view>
</view>
<view class="lan border-bottom">
2025-04-18 14:53:38 +08:00
<view class="left">{{$t("common.infoWeight")}}</view>
2024-06-13 18:03:50 +08:00
<view class="right">
2025-04-18 14:53:38 +08:00
<input name="name" type="digit" class="mr-5" v-model="memInfo.weight"
:placeholder="$t('tips.verifyWeight')" />KG
2024-06-13 18:03:50 +08:00
<uni-icons type="clear" color="#999" v-if="memInfo.weight" @click="memInfo.weight=''"
size="20"></uni-icons>
</view>
</view>
2024-05-02 15:59:36 +08:00
<view class="lan border-bottom">
2025-04-18 14:53:38 +08:00
<view class="left">{{$t("common.infoBirthday")}}</view>
2024-05-02 15:59:36 +08:00
<view class="right">
2024-08-05 10:01:06 +08:00
<picker mode="date" :end="endDate" @change="maskClick"
2024-10-11 10:04:19 +08:00
:value="memInfo.birthday?memInfo.birthday:endDate" :fields="fields">
2025-04-18 14:53:38 +08:00
<view class="uni-input">{{memInfo.birthday?memInfo.birthday:$t("tips.verifyPicker")}}</view>
2024-07-22 14:13:19 +08:00
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker>
2024-10-11 10:04:19 +08:00
</view>
</view>
2025-04-18 14:53:38 +08:00
<view class="lan border-bottom" v-if="language=='zh-Hans'">
<view class="left">场景选择</view>
<view class="right">
<view class="radio">
<uni-icons :type="memInfo.measure_model==1?'checkbox-filled':'circle'"
@click="handleMeasureModel(1)" size="24"
:color="memInfo.measure_model==1?'#fea606':'#dfdfdf'"></uni-icons>
</view>
<view class="radio ml-15">
<uni-icons :type="memInfo.measure_model==2?'checkbox-filled':'circle'"
@click="handleMeasureModel(2)" size="24"
:color="memInfo.measure_model==2?'#fea606':'#dfdfdf'"></uni-icons>
</view>
</view>
</view>
2025-04-29 17:29:44 +08:00
<view class="lan border-bottom" v-if="memInfo.measure_model==1&&language=='zh-Hans'">
2024-10-11 10:04:19 +08:00
<view class="left">身份信息</view>
<view class="right">
<picker mode="selector" :range="identityList" :value="identityIndex" range-key="name"
@change="changegIdentity">
<view class="uni-input">{{identityList[identityIndex]?identityList[identityIndex].name:"请选择"}}
</view>
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker>
</view>
</view>
2025-04-29 17:29:44 +08:00
<view class="lan border-bottom" @click="handleCityList"
v-if="memInfo.measure_model==1 &&language=='zh-Hans'">
2024-10-11 10:04:19 +08:00
<view class="left">所属地区</view>
<view class="right">
<view class="mr-10">{{memInfo.address?memInfo.address:'请选择'}}</view>
<icon class="iconfont icon-arrow-down-bold"></icon>
2024-05-02 15:59:36 +08:00
</view>
</view>
2025-04-29 17:29:44 +08:00
<view class="lan border-bottom" v-if="memInfo.measure_model==1&&language=='zh-Hans'">
2024-05-02 15:59:36 +08:00
<view class="left">所在年级</view>
<view class="right">
2024-10-11 10:04:19 +08:00
<picker mode="selector" :range="gradeList" :value="gradeIndex" range-key="name"
@change="changegType">
<view class="uni-input">{{gradeList[gradeIndex]?gradeList[gradeIndex].name:"请选择"}}</view>
2024-05-29 16:35:45 +08:00
<icon class="iconfont icon-arrow-down-bold"></icon>
</picker>
2024-05-02 15:59:36 +08:00
</view>
</view>
</view>
2025-04-18 14:53:38 +08:00
<view class="btn" @click="confirmInfo">{{$t("tips.btnConfirm")}}</view>
2024-10-11 10:04:19 +08:00
<!-- 地区 -->
<view v-if="visible" class="visible" @click="visible=false">
<view @click.stop class="item">
<view class="groupBtn">
<view @click="visible=false">取消</view>
<view @click="handlesure()" class="sure">确定</view>
</view>
<picker-view @change="bindChange" :value="value" class="picker-view" :indicator-style="indicatorStyle">
<picker-view-column>
<view class="item" v-for="(item,index) in province" :key="index">{{item.name}}</view>
</picker-view-column>
<picker-view-column>
<view class="item" v-for="(item,index) in city" :key="index">{{item}}</view>
</picker-view-column>
</picker-view>
</view>
</view>
2024-05-02 15:59:36 +08:00
</view>
</template>
<script>
import {
mapState
} from "vuex";
export default {
data() {
return {
2024-05-29 16:35:45 +08:00
isEdit: false,
2024-10-11 10:04:19 +08:00
fields: "",
2024-05-02 15:59:36 +08:00
sexItem: [
"男",
"女"
],
2024-05-29 16:35:45 +08:00
memInfo: {
measure_model: 2,
2024-05-29 16:35:45 +08:00
birthday: "",
gender: 1,
2024-05-29 16:35:45 +08:00
nickname: "",
grade: "nothing",
2024-06-13 18:03:50 +08:00
height: "",
2024-10-11 10:04:19 +08:00
weight: "",
address: '',
identity_name: "陌生人",
2024-10-11 10:04:19 +08:00
identity_id: "P0",
2024-05-29 16:35:45 +08:00
},
2025-04-18 14:53:38 +08:00
language: "",
2024-10-11 10:04:19 +08:00
visible: false,
province: [], //省
city: [], //市
area: [], //区
value: [2, 0],
2024-05-02 15:59:36 +08:00
headimg: "",
2024-10-11 10:04:19 +08:00
identityIndex: 0,
gradeIndex: 0,
indicatorStyle: `height: 45px;`,
2024-05-02 15:59:36 +08:00
};
},
computed: {
2024-10-11 10:04:19 +08:00
...mapState(["user", "familayList", "cityList", "gradeList", "identityList"]),
2024-07-25 16:55:39 +08:00
endDate() {
return this.$tools.getDate("start")
},
2024-05-02 15:59:36 +08:00
startDate() {
2024-07-25 16:55:39 +08:00
return this.$tools.GetDateStr(-90);
2024-07-22 14:13:19 +08:00
},
2024-05-02 15:59:36 +08:00
},
2025-04-18 14:53:38 +08:00
onReady() {
2025-04-26 13:35:30 +08:00
uni.setNavigationBarTitle({
title: this.$t('common.titleMember'),
})
2025-04-29 17:29:44 +08:00
this.language = uni.getStorageSync('language')
2025-04-18 14:53:38 +08:00
},
2024-05-02 15:59:36 +08:00
onLoad(options) {
2024-06-13 18:03:50 +08:00
let that = this
2024-10-11 10:04:19 +08:00
that.handleIdentityList()
2024-05-29 16:35:45 +08:00
if (options.info) {
let info = JSON.parse(options.info)
that.memInfo = info
// if (info.measure_model == "1" || info.measure_model == 1) {
console.log("that.memInfo ", that.memInfo)
that.gradeIndex = that.gradeList.findIndex((profile) => profile.id === that.memInfo.grade);
that.memInfo.grade = that.gradeList[that.gradeIndex].id
that.identityIndex = that.identityList.findIndex((profile) => profile.id === that.memInfo.identity_id);
console.log("1111111111", that.identityList, that.identityIndex)
// }
2024-06-13 18:03:50 +08:00
that.isEdit = true
2024-05-29 16:35:45 +08:00
}
2024-10-11 10:04:19 +08:00
// #ifdef APP-PLUS
that.fields = "time"
// #endif
// #ifndef APP-PLUS
that.fields = "day"
// #endif
2024-05-02 15:59:36 +08:00
},
methods: {
// 提交
confirmInfo() {
let that = this
2024-05-29 16:35:45 +08:00
if (!that.memInfo.nickname) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t("tips.verifyNickName"))
2024-05-02 15:59:36 +08:00
return;
}
2024-06-13 18:03:50 +08:00
if (!that.memInfo.height) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t("tips.verifyHeight"))
2024-06-13 18:03:50 +08:00
return;
}
if (!that.memInfo.weight) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t("tips.verifyWeight"))
2024-06-13 18:03:50 +08:00
return;
}
2024-05-29 16:35:45 +08:00
if (!that.memInfo.birthday) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t("tips.verifyBirthday"))
2024-05-02 15:59:36 +08:00
return;
}
2025-04-29 17:29:44 +08:00
if (that.language=='zh-Hans'&&that.memInfo.measure_model == 1 && !that.memInfo.identity_id) {
2024-10-11 10:04:19 +08:00
that.$tools.msg("请选择身份信息")
return;
}
2025-04-29 17:29:44 +08:00
if (that.language=='zh-Hans'&&that.memInfo.measure_model == 1 && !that.memInfo.address) {
2024-10-11 10:04:19 +08:00
that.$tools.msg("请选择所属地区")
return;
}
2024-05-29 16:35:45 +08:00
let https = that.isEdit ? that.$model.getEditUser(that.memInfo) : that.$model.getAddUser(that.memInfo)
return https.then(res => {
console.log("成功", res)
2024-05-02 15:59:36 +08:00
if (res.code == 0) {
2025-04-18 14:53:38 +08:00
that.$tools.msg(that.$t("tips.msgSetSuccess"));
2024-06-13 18:03:50 +08:00
that.handleUserList(res.data.aud_id)
} else {
that.$tools.msg(res.msg);
}
});
},
handleUserList(id) {
let that = this
that.$model.getUserList({
type: 2
}).then(res => {
console.log("成员列表", res)
that.$store.commit('changeFamilay', res.data)
let aud_id = ""
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2]
2024-06-13 18:03:50 +08:00
// 修改用户
if (that.isEdit && that.memInfo.id == uni.getStorageSync('userid')) {
console.log("修改用户")
aud_id = uni.getStorageSync('userid')
2024-06-13 18:03:50 +08:00
}
// 添加用户
if (!that.isEdit) {
console.log("添加用户")
uni.setStorageSync('userid', id)
uni.setStorageSync('gender', that.memInfo.gender)
aud_id = id
2024-05-02 15:59:36 +08:00
}
that.handlePublicRecord(aud_id)
that.$store.dispatch('getUserInfo', {
aud_id: aud_id
})
that.$store.dispatch("getResult", {
aud_id: aud_id
})
console.log("familayList个数", that.familayList.length)
if (!that.isEdit && that.familayList.length == 1) {
uni.setStorageSync('isBle', true)
uni.switchTab({
url: "/pages/home/home"
})
} else {
uni.navigateBack()
}
2024-06-13 18:03:50 +08:00
}).catch(err => {})
2024-05-02 15:59:36 +08:00
},
// 公共手动记录内容
handlePublicRecord(id) {
let that = this
that.$model.getPublicRecord({
aud_id: id
}).then(res => {
console.log("公共手动记录", res)
if (res.code == 0) {
that.$store.commit('changePublicRecord', res.data)
}
})
},
2024-05-02 15:59:36 +08:00
//确定年龄
2024-06-13 18:03:50 +08:00
maskClick(e) {
2024-10-11 10:04:19 +08:00
console.log("出生日期", e.detail.value)
2024-07-22 14:13:19 +08:00
this.memInfo.birthday = e.detail.value
2024-05-02 15:59:36 +08:00
},
//确定性别
onsexArr(e) {
2025-04-18 14:53:38 +08:00
this.memInfo.gender = this.sexItem[e.target.value] == that.$t("common.infoMan") ? 1 : 2
2024-05-29 16:35:45 +08:00
},
// 年级
changegType(e) {
2024-10-11 10:04:19 +08:00
this.gradeIndex = e.detail.value
2024-05-29 16:35:45 +08:00
this.memInfo.grade = this.gradeList[e.target.value].id
2024-05-02 15:59:36 +08:00
},
2024-10-11 10:04:19 +08:00
// 身份
changegIdentity(e) {
let that = this
that.identityIndex = e.detail.value
that.memInfo.identity_id = that.identityList[e.detail.value].id
that.memInfo.identity_name = that.identityList[e.detail.value].name
},
// 地区
bindChange(e) {
2024-10-11 10:04:19 +08:00
let that = this
if (e.detail.value[0] != that.value[0]) {
e.detail.value[1] = 0
}
that.value = e.detail.value
that.city = that.province[that.value[0]].list
},
handlesure() {
let that = this
let defaultRegion = [that.province[that.value[0]].name, that.city[that.value[1]]]
that.memInfo.address = defaultRegion.join(",");
that.visible = false
},
handleCityList() {
let that = this
that.province = that.cityList
if (that.user.address != '') {
let str = that.user.address.split(',')[0]
let str2 = that.user.address.split(',')[1]
var Index0 = that.cityList.findIndex((profile) => profile.name === str);
var Index2 = that.cityList[Index0].list.findIndex((ite) => ite === str2);
that.value[0] = Index0
that.value[1] = Index2
that.city = that.cityList[Index0].list
} else {
that.value = [2, 0]
that.city = that.cityList[2].list
}
2024-10-11 10:04:19 +08:00
that.visible = true
},
// 获取年级
// handleGradeList() {
// let that = this
// if (that.isEdit == true) {
// that.gradeIndex = that.gradeList.findIndex(ite => ite.id == that.memInfo.grade)
// that.memInfo.grade = that.gradeList[that.gradeIndex].id
// }
// },
2024-10-11 10:04:19 +08:00
// 获取身份
handleIdentityList() {
let that = this
if (that.isEdit == true) {
that.identityIndex = that.identityList.findIndex(ite => ite.id == that.memInfo.identity_id)
that.memInfo.identity_id = that.identityList[that.identityIndex].id
that.memInfo.identity_name = that.identityList[that.identityIndex].name
}
},
// 场景选择
handleMeasureModel(ind) {
let that = this
that.memInfo.measure_model = ind
},
2024-05-02 15:59:36 +08:00
},
};
</script>
<style scoped="scoped" lang="scss">
.box {
height: 100vh;
background-color: #fff;
}
input {
border: none;
background: inherit;
}
.headbox {
2024-09-03 09:57:22 +08:00
height: 180rpx;
padding-top: 10px;
2024-05-29 16:35:45 +08:00
border-radius: 0 0 5px 5px;
2024-05-02 15:59:36 +08:00
background: $maincolor;
}
.headimage {
display: block;
padding-top: 10px;
width: 70px;
height: 70px;
border-radius: 50%;
2024-08-05 10:01:06 +08:00
font-size: 140rpx;
2024-05-02 15:59:36 +08:00
margin: auto;
2024-05-29 16:35:45 +08:00
color: #fff;
2024-05-02 15:59:36 +08:00
}
.lan {
display: flex;
align-items: center;
2024-08-05 10:01:06 +08:00
font-size: 32rpx;
2024-05-02 15:59:36 +08:00
padding: 5px 0;
margin: 5px 15px;
border-bottom: 1px solid #f7f7f7;
}
2024-06-13 18:03:50 +08:00
.left {
2024-05-02 15:59:36 +08:00
width: 24%;
text-align: left;
}
2024-06-13 18:03:50 +08:00
.right {
2024-05-02 15:59:36 +08:00
display: flex;
align-items: center;
justify-content: flex-end;
width: 72%;
2024-08-05 10:01:06 +08:00
height: 40px;
line-height: 40px;
2024-05-02 15:59:36 +08:00
box-sizing: border-box;
position: relative;
text-align: right;
.radio {
display: flex;
align-items: center;
}
2024-05-02 15:59:36 +08:00
picker {
width: 100%;
text-align: right;
border: none;
2024-08-05 10:01:06 +08:00
margin-right: 15px;
font-size: 32rpx;
color: #333333;
2024-05-02 15:59:36 +08:00
}
2024-06-13 18:03:50 +08:00
/deep/input {
height: 35px;
2024-08-05 10:01:06 +08:00
padding-top: 1px;
font-size: 32rpx;
color: #333333;
margin-right: 15px;
2024-06-13 18:03:50 +08:00
}
2024-05-02 15:59:36 +08:00
.iconfont {
color: #333333;
2024-08-05 10:01:06 +08:00
font-size: 32rpx;
2024-05-02 15:59:36 +08:00
position: absolute;
right: -10px;
top: 0;
}
}
.btn {
width: auto;
margin: 40px 15px 0;
background: $btncolor !important;
}
2024-10-11 10:04:19 +08:00
.visible {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
z-index: 9999;
background-color: rgba(0, 0, 0, 0.6);
.groupBtn {
height: 50px;
line-height: 50px;
background-color: #fff;
display: flex;
justify-content: space-between;
padding: 0 15px;
border-bottom: 1px solid #dfdfdf;
position: absolute;
left: 0;
right: 0;
bottom: 45%;
z-index: 999;
view {
height: 30px;
line-height: 30px;
padding: 0 10px;
background-color: #dfdfdf;
border-radius: 5px;
margin-top: 10px;
}
.sure {
background-color: $textcolor;
color: #fff !important;
}
}
.picker-view {
width: 100%;
height: 45%;
bottom: 0;
position: absolute;
background-color: #fff;
}
.item {
line-height: 45px;
text-align: center;
}
}
2024-05-02 15:59:36 +08:00
</style>