adultDeviceApp/pageTwo/me/adduser.vue

259 lines
6.4 KiB
Vue
Raw Normal View History

2022-05-03 21:35:39 +08:00
<template>
2022-05-13 09:22:34 +08:00
<view class="box">
<view class="lanBox">
<form action>
<view class="headbox">
<view class="touxiang">
<image v-if="memInfo.headimg" :src="memInfo.headimg" class="headimage" />
<icon v-else class="t-icon t-icon-touxiang headimage"></icon>
</view>
2022-05-03 21:35:39 +08:00
</view>
2022-05-13 09:22:34 +08:00
<view class="lan border-bottom">
<view class="left">用户名</view>
<view class="right">
<input name="name" type="text" v-model="memInfo.name" placeholder="请输入用户名/昵称" />
</view>
2022-05-03 21:35:39 +08:00
</view>
2022-05-13 09:22:34 +08:00
<view class="lan border-bottom">
<view class="left">性别</view>
<view class="right">
<picker mode="selector" :range="sexItem" @change="onsexArr">
<view class="uni-input">{{!memInfo.sex?'请选择':memInfo.sex==1?'男':'女'}}</view>
<icon class="iconfont icon-arrow-down"></icon>
</picker>
</view>
</view>
<view class="lan border-bottom">
<view class="left">身高</view>
<view class="right">
<input type="digit" class="mr-5" v-model="memInfo.height" placeholder="请输入身高" /> cm
</view>
</view>
<view class="lan border-bottom">
<view class="left">出生日期</view>
<view class="right">
<picker class="picker" mode="date" :end="startDate" :value="memInfo.birthday" @change="bindDateChange">
<view class="uni-input">{{memInfo.birthday?memInfo.birthday:"请选择"}}</view>
<icon class="iconfont icon-arrow-down"></icon>
</picker>
</view>
</view>
</form>
2022-05-03 21:35:39 +08:00
</view>
2022-05-13 09:22:34 +08:00
<view v-if="isHeight" class="slidePopup">
<view class="bg" @click="onTap">
<view class="slide-box" @click.stop>
<view class="btnGroup">
<view class="subtn close" @click="onTap">取消</view>
<view class="heightVal">{{memInfo.height}}cm</view>
<view class="subtn" @click="isHeight = false">确定</view>
</view>
<slide-choose v-model="memInfo.height" ref="slide"></slide-choose>
</view>
</view>
</view>
<view class="btn" @click="confirmInfo">提交</view>
</view>
2022-05-03 21:35:39 +08:00
</template>
<script>
2022-05-13 09:22:34 +08:00
import {
mapState
} from "vuex";
export default {
data() {
return {
ageArr: [],
sexItem: [
"男",
"女"
],
isHeight: false,
isEdit: false,
memInfo: {
birthday: "",
height: "",
sex: "",
name: ""
2022-05-03 21:35:39 +08:00
},
2022-05-13 09:22:34 +08:00
};
},
computed: {
...mapState(["user", "appTheme"]),
startDate() {
return this.$tools.getDate('start');
}
},
methods: {
// 提交
confirmInfo() {
let that = this
that.isHeight = false
if (!this.memInfo.name) {
this.$tools.msg("请输入用户名")
return;
}
if (!this.memInfo.sex) {
this.$tools.msg("请选择性别")
return;
}
if (!this.memInfo.height) {
this.$tools.msg("请选则身高")
return;
}
if (!this.memInfo.birthday) {
this.$tools.msg("请选择出生日期")
return;
}
// console.log("提交", this.memInfo)
that.subInfo(this.memInfo)
},
subInfo(data) {
let that = this
data.fansid = uni.getStorageSync("unionid");
that.$model.getsubmit(data).then(res => {
if (res.code == 0) {
if (that.isEdit) {
that.$store.dispatch("getUserInfo", {
familyid: that.user.id
})
2022-05-03 21:35:39 +08:00
}
2022-05-13 09:22:34 +08:00
that.$store.dispatch("getFamilyList")
that.$tools.msg("提交成功");
uni.navigateBack({
delta: 1
});
} else {
that.$tools.msg(res.message);
}
});
},
//确定年龄
bindDateChange(e) {
// console.log("年龄", e)
this.memInfo.birthday = e.target.value
},
//确定性别
onsexArr(e) {
// console.log("性别", e)
this.memInfo.sex = this.sexItem[e.target.value] == "男" ? 1 : 2
},
// 确定身份
ontypeArr(e) {
this.type = this.typeItem[e.target.value] == "成人" ? 1 : this.typeItem[e.target.value] == "儿童" ? 2 : 3
},
},
onLoad(options) {
// 导航栏颜色
uni.setNavigationBarColor({
frontColor: '#ffffff',
backgroundColor: this.appTheme,
})
//
var agedata = []
for (var i = 12; i <= 80; i++) {
agedata.push(i);
}
this.ageArr = agedata
// 编辑
if (options.familayData) {
let info = options.familayData
this.memInfo = JSON.parse(info)
this.isEdit = true
// console.log("编辑", this.memInfo)
}
// 添加
if (options.type) {
this.isEdit = false
this.memInfo = {
birthday: "",
height: "",
sex: "",
name: ""
}
}
},
};
2022-05-03 21:35:39 +08:00
</script>
<style scoped="scoped" lang="scss">
2022-05-13 09:22:34 +08:00
.box {
height: 100vh;
padding: 0 15px;
background-color: #fff;
}
2022-05-03 21:35:39 +08:00
2022-05-13 09:22:34 +08:00
.headimage,
.icontouxiang {
display: block;
width: 65px;
height: 65px;
font-size: 65px;
color: $btncolor;
border-radius: 50%;
}
2022-05-03 21:35:39 +08:00
2022-05-13 09:22:34 +08:00
.headbox {
text-align: center;
position: relative;
display: flex;
justify-content: center;
height: 65px;
margin: 15px;
}
2022-05-03 21:35:39 +08:00
2022-05-13 09:22:34 +08:00
.lanBox {
padding: 15px 0;
}
2022-05-03 21:35:39 +08:00
2022-05-13 09:22:34 +08:00
.lan {
display: flex;
align-items: center;
font-size: 14px;
padding: 5px 0;
margin: 4px auto;
border-bottom: 1px solid #f7f7f7;
2022-05-03 21:35:39 +08:00
2022-05-13 09:22:34 +08:00
input {
border: none;
background: inherit;
2022-05-03 21:35:39 +08:00
}
2022-05-13 09:22:34 +08:00
}
2022-05-03 21:35:39 +08:00
2022-05-13 09:22:34 +08:00
.lan .left {
width: 24%;
text-align: left;
}
2022-05-03 21:35:39 +08:00
2022-05-13 09:22:34 +08:00
.lan .right {
display: flex;
align-items: center;
justify-content: flex-end;
width: 72%;
min-height: 38px;
box-sizing: border-box;
line-height: 36px;
position: relative;
text-align: right;
2022-05-03 21:35:39 +08:00
2022-05-13 09:22:34 +08:00
picker {
width: 100%;
text-align: right;
border: none;
margin-right: 8px;
2022-05-03 21:35:39 +08:00
}
2022-05-13 09:22:34 +08:00
.iconfont {
color: #333333;
font-size: 16px;
position: absolute;
right: -10px;
top: 0;
2022-05-03 21:35:39 +08:00
}
2022-05-13 09:22:34 +08:00
}
.btn {
margin: 10px auto 0;
}
2022-05-03 21:35:39 +08:00
</style>