推广小程序前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

307 lines
8.3 KiB

<template>
<view>
<view class="head-box"></view>
<uv-navbar autoBack title="编辑资料" leftIconColor="#fff" :bgColor="bgColor" height="100rpx" :titleStyle="{color:'#fff'}"></uv-navbar>
<view class="content">
<view class="title-box">基础信息</view>
<view class="form-box">
<view class="form-box-line">
<view class="label-box">用户名称</view>
<view class="value-box">
<uv-input placeholder="请输入用户名称" inputAlign="right" v-model="info.nickName" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
<view class="form-box-line">
<view class="label-box">邮箱</view>
<view class="value-box">
<uv-input placeholder="请输入邮箱" inputAlign="right" v-model="info.email" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
<view class="form-box-line">
<view class="label-box">手机号</view>
<view class="value-box">
<uv-input placeholder="请输入手机号" inputAlign="right" v-model="info.phone" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
<view class="form-box-line">
<view class="label-box">性别</view>
<view class="value-box" @click="$refs.sexPicker.open();">
<uv-input placeholder="请选择性别" readonly inputAlign="right" v-model="info.sex" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
<view class="form-box-line">
<view class="label-box">国籍</view>
<view class="value-box" @click="$refs.cityPicker.open()">
<uv-input placeholder="请输入国籍" readonly inputAlign="right" v-model="info.city" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
<view class="form-box-line">
<view class="label-box">生日</view>
<view class="value-box" @click="$refs.datetimePicker.open()">
<uv-input placeholder="请输入生日" readonly inputAlign="right" v-model="info.yearDate" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
<view class="form-box-line">
<view class="label-box">现居住址</view>
<view class="value-box">
<uv-input placeholder="请输入现居住址" inputAlign="right" v-model="info.address" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
<view class="form-box-line">
<view class="label-box">个人状态</view>
<view class="value-box">
<uv-input placeholder="请输入个人状态" inputAlign="right" v-model="info.state" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
</view>
<view class="title-box">教育</view>
<view class="form-box">
<view class="form-title">学历</view>
<view class="choose-box">
<view class="choose-item" :class="info.shcool == item ? 'choose-class' :''" v-for="(item,i) in xueliList" :key="i" @click="info.shcool = item">{{item}}</view>
</view>
<view class="form-title">院校</view>
<view class="choose-box">
<view class="choose-item" :class="info.shcoolType == item.title ? 'choose-class' :''" v-for="(item,i) in yuanxiaoList" :key="i" @click="info.shcoolType = item.title">{{item.title}}</view>
</view>
</view>
<view class="title-box">工作</view>
<view class="form-box">
<view class="form-box-line">
<view class="label-box">行业</view>
<view class="value-box">
<uv-input placeholder="请输入行业" inputAlign="right" v-model="info.workValue" border="none" color="#CCCCCC"></uv-input>
</view>
</view>
</view>
<view class="title-box">关于我</view>
<view class="form-box">
<uv-textarea v-model="info.details" :customStyle="{background: 'transparent',border:'none'}" height="380rpx" placeholder="请输入自我介绍..."></uv-textarea>
</view>
</view>
<view class="btn-box">
<uv-button text="保存" @click="saveClick" color="#381615" shape="circle" :customStyle="btnCustomStyle"></uv-button>
</view>
<uv-picker ref="sexPicker" :columns="sexcolumns" @confirm="sexConfirm"></uv-picker>
<uv-picker ref="cityPicker" keyName="country" :columns="citycolumns" @confirm="cityConfirm"></uv-picker>
<uv-datetime-picker ref="datetimePicker" :minDate="0" :maxDate="maxDate" :formatter="formatter" v-model="value" mode="date" @confirm="dateConfirm"></uv-datetime-picker>
</view>
</template>
<script>
export default{
data() {
return {
bgColor:'transparent',
btnCustomStyle:{
color:'#FF5858'
},
info:{
nickName:'',
headImage:'',
phone:'',
email:'',
sex:'',
city:'',
yearDate:'',
address:'',
state:'',
shcool:'',
shcoolType:'',
workValue:'',
details:'',
},
xueliIndex:0,
yuanxiaoIndex:0,
xueliList:['本科','硕士','博士','其他'],
yuanxiaoList:[],
sexcolumns:[
['男','女']
],
citycolumns:[],
maxDate:new Date().getTime(),
value: Number(new Date())
}
},
onPageScroll(e) {
if(e.scrollTop > 50) {
this.bgColor = '#49070c'
}else{
this.bgColor = 'transparent'
}
},
onLoad() {
this.getUserInfo()
this.getnationalityPageList()
this.getlabelPageList()
},
methods:{
getlabelPageList() {
this.$api('labelPageList',{pageNo:1,pageSize:999},res=>{
this.yuanxiaoList = res.result.records
})
},
getnationalityPageList() {
this.$api('nationalityPageList',{pageNo:1,pageSize:999},res=>{
this.citycolumns = [res.result.records]
})
},
formatter(type, value) {
if (type === 'year') {
return `${value}年`
}
if (type === 'month') {
return `${value}月`
}
if (type === 'day') {
return `${value}日`
}
return value
},
saveClick() {
for (let k in this.info) {
if((!this.info[k] && this.info[k] != 0)
|| this.info[k] == 'null'){
this.info[k] = ''
}
}
this.$api('updateInfo',this.info, res => {
if (res.code == 200) {
uni.showToast({
title:'保存成功',
icon:'none'
})
setTimeout(()=>{
uni.navigateBack()
},1500)
}
})
},
getUserInfo() {
this.$api('getInfo', res => {
if (res.code == 200 && res.result) {
this.info = res.result
}
})
},
sexConfirm(val) {
this.info.sex = val.value[0]
},
cityConfirm(val) {
this.info.city = val.value[0].country
},
dateConfirm(val) {
const date = new Date(val.value);
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
this.info.yearDate = `${year}-${month}-${day}`;
}
}
}
</script>
<style lang="scss">
page {
background-color: #060504;
}
</style>
<style lang="scss" scoped>
.head-box {
background: url('@/static/image/nav-bg.png') no-repeat;
background-size: 100% 100%;
width: 100%;
height: 534rpx;
position: absolute;
z-index: -1;
}
.content {
margin-top: 40rpx;
padding: 0 30rpx 170rpx;
padding-top: calc(var(--status-bar-height) + 110rpx);
.title-box {
font-weight: 500;
font-size: 27rpx;
color: #666666;
}
.form-box {
background: #1B1713;
border-radius: 27rpx;
padding:0 40rpx;
margin-top: 20rpx;
margin-bottom: 44rpx;
.form-box-line {
height: 112rpx;
border-bottom: 1px solid #403D3A;
display: flex;
align-items: center;
&:last-child {
border: none;
}
.label-box {
font-weight: 500;
font-size: 29rpx;
color: #CCCCCC;
margin-right: 34rpx;
}
.value-box {
display: flex;
align-items: center;
justify-content: space-between;
flex: 1;
.uv-input {
}
}
}
.form-title {
font-weight: 500;
font-size: 28rpx;
color: #CCCCCC;
padding-top: 32rpx;
}
.choose-box {
margin-top: 28rpx;
display: flex;
flex-wrap: wrap;
.choose-item {
width: 137rpx;
height: 67rpx;
border-radius: 13rpx;
border: 1rpx solid #CCCCCC;
text-align: center;
line-height: 67rpx;
font-weight: 500;
font-size: 26rpx;
color: #CCCCCC;
margin-right: 15rpx;
margin-bottom: 24rpx;
&:nth-child(4n){
margin-right: 0;
}
}
.choose-class {
background-color: #341616;
color: #FF4747;
border: 1rpx solid #FF4747;
}
}
}
}
.btn-box {
background-color: #060504;
position: fixed;
bottom: 0;
left: 0;
right: 0;
padding: 20rpx 40rpx;
height: 150rpx;
z-index: 999;
box-sizing: border-box;
}
</style>