492 lines
13 KiB
Vue
492 lines
13 KiB
Vue
<template>
|
|
<view class="box">
|
|
<view class="lanBox">
|
|
<view class="headbox">
|
|
<view class="touxiang">
|
|
<image v-if="headimg" :src="headimg" class="headimage" />
|
|
<icon v-else class="iconfont icon-user-filling headimage"></icon>
|
|
</view>
|
|
</view>
|
|
<view class="lan border-bottom">
|
|
<view class="left">姓名</view>
|
|
<view class="right">
|
|
<input name="name" type="text" v-model="memInfo.nickname" placeholder="请输入姓名" />
|
|
<uni-icons type="clear" color="#999" v-if="memInfo.nickname" @click="memInfo.nickname=''"
|
|
size="20"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="lan border-bottom">
|
|
<view class="left">性别</view>
|
|
<view class="right">
|
|
<view class="radio">
|
|
<uni-icons :type="memInfo.gender==1?'checkbox-filled':'circle'" @click="memInfo.gender=1"
|
|
size="24" :color="memInfo.gender==1?'#fea606':'#dfdfdf'"></uni-icons>男
|
|
</view>
|
|
<view class="radio ml-15">
|
|
<uni-icons :type="memInfo.gender==2?'checkbox-filled':'circle'" @click="memInfo.gender=2"
|
|
size="24" :color="memInfo.gender==2?'#fea606':'#dfdfdf'"></uni-icons>女
|
|
</view>
|
|
<!-- <picker mode="selector" :range="sexItem" @change="onsexArr">
|
|
<view class="uni-input">{{memInfo.gender==0?'请选择':memInfo.gender==1?'男':'女'}}</view>
|
|
<icon class="iconfont icon-arrow-down-bold"></icon>
|
|
</picker> -->
|
|
</view>
|
|
</view>
|
|
<view class="lan border-bottom">
|
|
<view class="left">身高</view>
|
|
<view class="right">
|
|
<input name="name" class="mr-5" type="digit" v-model="memInfo.height" placeholder="请输入身高" />CM
|
|
<uni-icons type="clear" color="#999" v-if="memInfo.height" @click="memInfo.height=''"
|
|
size="20"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="lan border-bottom">
|
|
<view class="left">体重</view>
|
|
<view class="right">
|
|
<input name="name" type="digit" class="mr-5" v-model="memInfo.weight" placeholder="请输入体重" />KG
|
|
<uni-icons type="clear" color="#999" v-if="memInfo.weight" @click="memInfo.weight=''"
|
|
size="20"></uni-icons>
|
|
</view>
|
|
</view>
|
|
<view class="lan border-bottom">
|
|
<view class="left">出生日期</view>
|
|
<view class="right">
|
|
<picker mode="date" :end="endDate" @change="maskClick"
|
|
:value="memInfo.birthday?memInfo.birthday:endDate" :fields="fields">
|
|
<view class="uni-input">{{memInfo.birthday?memInfo.birthday:'请选择'}}</view>
|
|
<icon class="iconfont icon-arrow-down-bold"></icon>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="lan border-bottom">
|
|
<view class="left">场景选择</view>
|
|
<view class="right">
|
|
<view class="radio">
|
|
<uni-icons :type="memInfo.measure_model==1?'checkbox-filled':'circle'"
|
|
@click="memInfo.measure_model=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="memInfo.measure_model=2" size="24"
|
|
:color="memInfo.measure_model==2?'#fea606':'#dfdfdf'"></uni-icons>体脂模式
|
|
</view>
|
|
</view>
|
|
</view>
|
|
|
|
<view class="lan border-bottom" v-if="memInfo.measure_model==1">
|
|
<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>
|
|
<view class="lan border-bottom" @click="handleCityList" v-if="memInfo.measure_model==1">
|
|
<view class="left">所属地区</view>
|
|
<view class="right">
|
|
<view class="mr-10">{{memInfo.address?memInfo.address:'请选择'}}</view>
|
|
<icon class="iconfont icon-arrow-down-bold"></icon>
|
|
</view>
|
|
</view>
|
|
<view class="lan border-bottom" v-if="memInfo.measure_model==1">
|
|
<view class="left">所在年级</view>
|
|
<view class="right">
|
|
<picker mode="selector" :range="gradeList" :value="gradeIndex" range-key="name"
|
|
@change="changegType">
|
|
<view class="uni-input">{{gradeList[gradeIndex]?gradeList[gradeIndex].name:"请选择"}}</view>
|
|
<icon class="iconfont icon-arrow-down-bold"></icon>
|
|
</picker>
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="btn" @click="confirmInfo">提交</view>
|
|
<!-- 地区 -->
|
|
<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>
|
|
</view>
|
|
</template>
|
|
<script>
|
|
import {
|
|
mapState
|
|
} from "vuex";
|
|
export default {
|
|
data() {
|
|
return {
|
|
isEdit: false,
|
|
fields: "",
|
|
sexItem: [
|
|
"男",
|
|
"女"
|
|
],
|
|
memInfo: {
|
|
measure_model: 2,
|
|
birthday: "",
|
|
gender: 1,
|
|
nickname: "",
|
|
grade: "nothing",
|
|
height: "",
|
|
weight: "",
|
|
address: '',
|
|
identity_name: "",
|
|
identity_id: "P0",
|
|
},
|
|
visible: false,
|
|
province: [], //省
|
|
city: [], //市
|
|
area: [], //区
|
|
value: [2, 0],
|
|
headimg: "",
|
|
identityIndex: 0,
|
|
gradeIndex: 0,
|
|
indicatorStyle: `height: 45px;`,
|
|
};
|
|
},
|
|
computed: {
|
|
...mapState(["user", "familayList", "cityList", "gradeList", "identityList"]),
|
|
endDate() {
|
|
return this.$tools.getDate("start")
|
|
},
|
|
startDate() {
|
|
return this.$tools.GetDateStr(-90);
|
|
},
|
|
},
|
|
onLoad(options) {
|
|
let that = this
|
|
that.handleIdentityList()
|
|
if (options.info) {
|
|
that.memInfo = JSON.parse(options.info)
|
|
if(options.measure_model=="1"){
|
|
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);
|
|
}
|
|
that.isEdit = true
|
|
}
|
|
// #ifdef APP-PLUS
|
|
that.fields = "time"
|
|
// #endif
|
|
// #ifndef APP-PLUS
|
|
that.fields = "day"
|
|
// #endif
|
|
},
|
|
methods: {
|
|
// 提交
|
|
confirmInfo() {
|
|
let that = this
|
|
if (!that.memInfo.nickname) {
|
|
that.$tools.msg("请输入姓名")
|
|
return;
|
|
}
|
|
if (!that.memInfo.height) {
|
|
that.$tools.msg("请选择身高")
|
|
return;
|
|
}
|
|
if (!that.memInfo.weight) {
|
|
that.$tools.msg("请选择体重")
|
|
return;
|
|
}
|
|
if (!that.memInfo.birthday) {
|
|
that.$tools.msg("请选择出生日期")
|
|
return;
|
|
}
|
|
if (that.memInfo.measure_model == 1 && !that.memInfo.identity_id) {
|
|
that.$tools.msg("请选择身份信息")
|
|
return;
|
|
}
|
|
if (that.memInfo.measure_model == 1 && !that.memInfo.address) {
|
|
that.$tools.msg("请选择所属地区")
|
|
return;
|
|
}
|
|
let https = that.isEdit ? that.$model.getEditUser(that.memInfo) : that.$model.getAddUser(that.memInfo)
|
|
return https.then(res => {
|
|
console.log("成功", res)
|
|
if (res.code == 0) {
|
|
that.$tools.msg("提交成功");
|
|
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 = ""
|
|
// 修改用户
|
|
if (that.isEdit && that.memInfo.id == uni.getStorageSync('userid')) {
|
|
console.log("修改用户")
|
|
aud_id = uni.getStorageSync('userid')
|
|
}
|
|
// 添加用户
|
|
if (!that.isEdit) {
|
|
console.log("添加用户")
|
|
uni.setStorageSync('userid', id)
|
|
uni.setStorageSync('gender', that.memInfo.gender)
|
|
aud_id = id
|
|
}
|
|
that.$store.dispatch('getUserInfo', {
|
|
aud_id: aud_id
|
|
})
|
|
that.$store.dispatch("getResult", {
|
|
aud_id: aud_id
|
|
})
|
|
that.handlePublicRecord(aud_id)
|
|
uni.navigateBack({
|
|
delta: 1
|
|
});
|
|
}).catch(err => {})
|
|
},
|
|
// 公共手动记录内容
|
|
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)
|
|
}
|
|
})
|
|
},
|
|
//确定年龄
|
|
maskClick(e) {
|
|
console.log("出生日期", e.detail.value)
|
|
this.memInfo.birthday = e.detail.value
|
|
},
|
|
//确定性别
|
|
onsexArr(e) {
|
|
this.memInfo.gender = this.sexItem[e.target.value] == "男" ? 1 : 2
|
|
},
|
|
// 年级
|
|
changegType(e) {
|
|
this.gradeIndex = e.detail.value
|
|
this.memInfo.grade = this.gradeList[e.target.value].id
|
|
},
|
|
// 身份
|
|
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) {
|
|
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
|
|
}
|
|
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
|
|
// }
|
|
// },
|
|
// 获取身份
|
|
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
|
|
}
|
|
},
|
|
|
|
},
|
|
|
|
};
|
|
</script>
|
|
|
|
<style scoped="scoped" lang="scss">
|
|
.box {
|
|
height: 100vh;
|
|
background-color: #fff;
|
|
}
|
|
|
|
input {
|
|
border: none;
|
|
background: inherit;
|
|
}
|
|
|
|
.headbox {
|
|
height: 180rpx;
|
|
padding-top: 10px;
|
|
border-radius: 0 0 5px 5px;
|
|
background: $maincolor;
|
|
}
|
|
|
|
.headimage {
|
|
display: block;
|
|
padding-top: 10px;
|
|
width: 70px;
|
|
height: 70px;
|
|
border-radius: 50%;
|
|
font-size: 140rpx;
|
|
margin: auto;
|
|
color: #fff;
|
|
}
|
|
|
|
.lan {
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 32rpx;
|
|
padding: 5px 0;
|
|
margin: 5px 15px;
|
|
border-bottom: 1px solid #f7f7f7;
|
|
}
|
|
|
|
.left {
|
|
width: 24%;
|
|
text-align: left;
|
|
}
|
|
|
|
.right {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: flex-end;
|
|
width: 72%;
|
|
height: 40px;
|
|
line-height: 40px;
|
|
box-sizing: border-box;
|
|
position: relative;
|
|
text-align: right;
|
|
|
|
.radio {
|
|
display: flex;
|
|
align-items: center;
|
|
}
|
|
|
|
picker {
|
|
width: 100%;
|
|
text-align: right;
|
|
border: none;
|
|
margin-right: 15px;
|
|
font-size: 32rpx;
|
|
color: #333333;
|
|
}
|
|
|
|
/deep/input {
|
|
height: 35px;
|
|
padding-top: 1px;
|
|
font-size: 32rpx;
|
|
color: #333333;
|
|
margin-right: 15px;
|
|
}
|
|
|
|
.iconfont {
|
|
color: #333333;
|
|
font-size: 32rpx;
|
|
position: absolute;
|
|
right: -10px;
|
|
top: 0;
|
|
}
|
|
}
|
|
|
|
.btn {
|
|
width: auto;
|
|
margin: 40px 15px 0;
|
|
background: $btncolor !important;
|
|
}
|
|
|
|
.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;
|
|
}
|
|
}
|
|
</style> |