227 lines
4.7 KiB
Vue
227 lines
4.7 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="t-icon t-icon-touxiang headimage" @click="handleUpImg"></icon>
|
|
</view>
|
|
</view>
|
|
<view class="lan border-bottom">
|
|
<view class="left">姓名</view>
|
|
<view class="right">
|
|
<input name="name" type="text" v-model="name" placeholder="请输入姓名" />
|
|
</view>
|
|
</view>
|
|
<view class="lan border-bottom">
|
|
<view class="left">性别</view>
|
|
<view class="right">
|
|
<picker mode="selector" :range="sexItem" @change="onsexArr">
|
|
<view class="uni-input">{{sex==0?'请选择':sex==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">
|
|
<picker class="picker" mode="date" :end="startDate" :value="birthday" @change="bindDateChange">
|
|
<view class="uni-input">{{birthday?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">
|
|
<input name="name" type="text" v-model="name" placeholder="请输入所在年级" />
|
|
</view>
|
|
</view>
|
|
</view>
|
|
<view class="btn" @click="confirmInfo">提交</view>
|
|
</view>
|
|
</template>
|
|
|
|
<script>
|
|
import {
|
|
mapState
|
|
} from "vuex";
|
|
export default {
|
|
data() {
|
|
return {
|
|
sexItem: [
|
|
"男",
|
|
"女"
|
|
],
|
|
sex: 0,
|
|
name: null,
|
|
headimg: "",
|
|
birthday: "",
|
|
};
|
|
},
|
|
computed: {
|
|
...mapState(["user"]),
|
|
userInfo() {
|
|
return this.user
|
|
},
|
|
startDate() {
|
|
return this.$tools.getDate('start');
|
|
}
|
|
},
|
|
onLoad(options) {
|
|
var agedata = []
|
|
for (var i = 3; i <= 80; i++) {
|
|
agedata.push(i);
|
|
}
|
|
this.name = this.userInfo.nickname ? this.userInfo.nickname : this.userInfo.name
|
|
},
|
|
methods: {
|
|
// 提交
|
|
confirmInfo() {
|
|
let that = this
|
|
if (!this.name) {
|
|
this.$tools.msg("请输入姓名")
|
|
return;
|
|
}
|
|
if (!this.sex) {
|
|
this.$tools.msg("请选择性别")
|
|
return;
|
|
}
|
|
if (!this.birthday) {
|
|
this.$tools.msg("请选择出生日期")
|
|
return;
|
|
}
|
|
|
|
that.$model.getsubmit({
|
|
name: this.name,
|
|
sex: this.sex,
|
|
birthday: this.birthday,
|
|
}).then(res => {
|
|
if (res.code == 0) {
|
|
that.$tools.msg("提交成功");
|
|
uni.reLaunch({
|
|
url: "/pages/index/index"
|
|
})
|
|
} else {
|
|
that.$tools.msg(res.message);
|
|
}
|
|
});
|
|
},
|
|
//确定年龄
|
|
bindDateChange(e) {
|
|
this.birthday = e.target.value
|
|
},
|
|
//确定性别
|
|
onsexArr(e) {
|
|
this.sex = this.sexItem[e.target.value] == "男" ? 1 : 2
|
|
},
|
|
handleUpImg() {
|
|
let that = this
|
|
uni.chooseImage({
|
|
count: 1, //默认9
|
|
sourceType: ['album', 'camera'], //从相册选择
|
|
success: function(res) {
|
|
uni.showLoading({
|
|
title: '识别中...'
|
|
})
|
|
uni.uploadFile({
|
|
header: {
|
|
'Authorization': "Bearer " + uni.getStorageSync('token'),
|
|
'X-Authorization': "Bearer " + uni.getStorageSync('refreshtoken'),
|
|
},
|
|
url: that.$http.baseUrl + '/api/app/wxopen/uploadimg',
|
|
filePath: res.tempFilePaths[0],
|
|
name: 'file',
|
|
success: (res) => {
|
|
let attr = JSON.parse(res.data)
|
|
uni.hideLoading()
|
|
if (attr.code == 0) {
|
|
that.headimg = attr.data.url
|
|
} else {
|
|
that.$tools.msg("不支持该图像")
|
|
}
|
|
}
|
|
})
|
|
}
|
|
})
|
|
},
|
|
},
|
|
|
|
};
|
|
</script>
|
|
|
|
<style scoped="scoped" lang="scss">
|
|
.box {
|
|
height: 100vh;
|
|
background-color: #fff;
|
|
}
|
|
|
|
input {
|
|
border: none;
|
|
background: inherit;
|
|
}
|
|
|
|
.headbox {
|
|
height:85px;
|
|
padding-top: 15px;
|
|
border-radius: 0 0 10px 10px;
|
|
background: $maincolor;
|
|
}
|
|
|
|
.headimage {
|
|
display: block;
|
|
padding-top: 10px;
|
|
width: 70px;
|
|
height: 70px;
|
|
border-radius: 50%;
|
|
font-size: 70px;
|
|
margin: auto;
|
|
}
|
|
|
|
.lan {
|
|
display: flex;
|
|
align-items: center;
|
|
font-size: 14px;
|
|
padding: 5px 0;
|
|
margin: 5px 15px;
|
|
border-bottom: 1px solid #f7f7f7;
|
|
}
|
|
|
|
.lan .left {
|
|
width: 24%;
|
|
text-align: left;
|
|
}
|
|
|
|
.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;
|
|
|
|
picker {
|
|
width: 100%;
|
|
text-align: right;
|
|
border: none;
|
|
margin-right: 8px;
|
|
}
|
|
|
|
.iconfont {
|
|
color: #333333;
|
|
font-size: 16px;
|
|
position: absolute;
|
|
right: -10px;
|
|
top: 0;
|
|
}
|
|
}
|
|
|
|
.btn {
|
|
width: auto;
|
|
margin: 40px 15px 0;
|
|
background: $btncolor !important;
|
|
}
|
|
</style> |