<template>
|
<view class="page_bg">
|
<uv-navbar title=" " :placeholder="true" :autoBack="true" bgColor="rgba(0,0,0,0)"
|
titleStyle="color:#fff"></uv-navbar>
|
|
<view class="head_ph">
|
<uv-upload :fileList="fileList1" name="1" :maxCount="1" width="200rpx" height="200rpx"
|
@afterRead="afterRead" @delete="deletePic">
|
<image class="ico_head" src="/static/img/ico_head.png" mode="widthFix"
|
style="width: 200rpx;height: 200rpx;"></image>
|
</uv-upload>
|
<view class="name">
|
上传头像
|
</view>
|
</view>
|
|
<view class="register">
|
<view class="item">
|
<uv-input placeholder="请输入手机号/邮箱" border="none" v-model="userName"></uv-input>
|
</view>
|
<view class="item">
|
<uv-input placeholder="请输入密码" :password="isEye" border="none" v-model="password"></uv-input>
|
<view class="eye" @click="isEye = !isEye">
|
<uv-icon v-if="isEye" name="eye-off" color="#666" size="40rpx"></uv-icon>
|
<uv-icon v-else name="eye" color="#666" size="40rpx"></uv-icon>
|
</view>
|
</view>
|
<view class="item">
|
<uv-input placeholder="请输入昵称" border="none" v-model="nickName"></uv-input>
|
</view>
|
<view class="item">
|
<uv-input placeholder="请输入微信号" border="none" v-model="wx"></uv-input>
|
</view>
|
|
<view class="item_login">
|
<navigator class="link" url="/pages/login/login" hover-class="none">
|
已有账号?去登录
|
</navigator>
|
</view>
|
<view class="item_agree">
|
<checkbox-group @change="changeAgree">
|
<label class="item_agree_info">
|
<checkbox value="agree" :checked="false" style="transform:scale(0.75)" ></checkbox>
|
同意本应用
|
<navigator class="link" url="/pages/policy/policy?id=1" hover-class="none">《用户协议》</navigator>
|
和
|
<navigator class="link" url="/pages/policy/policy?id=2" hover-class="none">《隐私政策》</navigator>
|
</label>
|
</checkbox-group>
|
</view>
|
<view class="item_btn">
|
<uv-button text="注册" color="linear-gradient( 142deg, #6FD2FF 0%, #268DFF 100%)" shape="circle" size="large" @click="clickRegister()"></uv-button>
|
</view>
|
</view>
|
|
</view>
|
</template>
|
|
<script>
|
import { register } from '@/api/api.js'
|
export default {
|
data() {
|
return {
|
userName: '',
|
password: '',
|
nickName: '',
|
wx: '',
|
avatar: '',
|
fileList1: [],
|
baseURL: '',
|
agree: 0,
|
isEye: true
|
}
|
},
|
onLoad() {
|
this.baseURL = uni.$uv.http.config.baseURL
|
console.log(this.baseURL)
|
|
},
|
methods: {
|
clickRegister(){
|
if(this.fileList1.length == 0){
|
uni.showToast({
|
title: '请上传头像',
|
duration: 2000,
|
icon: 'none'
|
});
|
return
|
}
|
if(!this.userName){
|
uni.showToast({
|
title: '请输入账号',
|
duration: 2000,
|
icon: 'none'
|
});
|
return
|
}
|
if(!this.password){
|
uni.showToast({
|
title: '请输入密码',
|
duration: 2000,
|
icon: 'none'
|
});
|
return
|
}
|
if(!this.nickName){
|
uni.showToast({
|
title: '请输入昵称',
|
duration: 2000,
|
icon: 'none'
|
});
|
return
|
}
|
if(!this.agree){
|
uni.showToast({
|
title: '请勾选用户协议和隐私政策',
|
duration: 2000,
|
icon: 'none'
|
});
|
return
|
}
|
|
register({
|
userName: this.userName,
|
password: this.password,
|
nickName: this.nickName,
|
wx: this.wx,
|
avatar: this.fileList1[0].url,
|
}).then(res=>{
|
console.log('注册----',res)
|
uni.showToast({
|
title: res.msg,
|
duration: 2000,
|
icon: 'none'
|
});
|
if(res.code == 200){
|
uni.reLaunch({
|
url: '/pages/login/login'
|
});
|
}
|
else{
|
|
}
|
})
|
},
|
changeAgree(e){
|
//console.log(e.detail.value.length)
|
this.agree = e.detail.value.length
|
},
|
// 删除图片
|
deletePic(event) {
|
this[`fileList${event.name}`].splice(event.index, 1)
|
},
|
// 新增图片
|
async afterRead(event) {
|
console.log('event---',event)
|
// 当设置 multiple 为 true 时, file 为数组格式,否则为对象格式
|
let lists = [].concat(event.file)
|
let fileListLen = this[`fileList${event.name}`].length
|
lists.map((item) => {
|
this[`fileList${event.name}`].push({
|
...item,
|
status: 'uploading',
|
message: '上传中'
|
})
|
})
|
for (let i = 0; i < lists.length; i++) {
|
const result = await this.uploadFilePromise(lists[i].url)
|
let item = this[`fileList${event.name}`][fileListLen]
|
this[`fileList${event.name}`].splice(fileListLen, 1, Object.assign(item, {
|
status: 'success',
|
message: '',
|
url: result
|
}))
|
fileListLen++
|
}
|
},
|
uploadFilePromise(url) {
|
return new Promise((resolve, reject) => {
|
let a = uni.uploadFile({
|
url: this.baseURL+'/common/uploadFileByAnny', // 仅为示例,非真实的接口地址
|
filePath: url,
|
name: 'file',
|
success: (res) => {
|
console.log('图片-----',JSON.parse(res.data).fileName)
|
setTimeout(() => {
|
resolve(JSON.parse(res.data).fileName)
|
}, 1000)
|
}
|
});
|
})
|
}
|
}
|
}
|
</script>
|
|
<style lang="scss" scoped>
|
|
.register{
|
padding:0 60rpx;
|
.item_agree{
|
display: flex;
|
align-items: center;
|
font-size: 27rpx;
|
color: rgba(0,0,0,0.85);
|
line-height: 30rpx;
|
margin-top: 80rpx;
|
.link{
|
font-size: 27rpx;
|
color: #3086F3;
|
}
|
.item_agree_info{
|
display: flex;
|
align-items: center;
|
}
|
}
|
.item_btn{
|
margin-top: 40rpx;
|
}
|
.item{
|
margin-top: 46rpx;
|
height: 100rpx;
|
background: #ECEFF6;
|
border-radius: 23rpx 23rpx 23rpx 23rpx;
|
display: flex;
|
align-items: center;
|
justify-content: space-between;
|
box-sizing: border-box;
|
padding:0 20rpx;
|
}
|
.item_login{
|
padding:20rpx 0;
|
.link{
|
font-size: 27rpx;
|
color: #3086F3;
|
line-height: 40rpx;
|
}
|
}
|
}
|
.head_ph {
|
flex-shrink: 0;
|
width: 200rpx;
|
margin: 50rpx auto;
|
.name{
|
text-align: center;
|
font-size: 28rpx;
|
line-height: 40rpx;
|
margin-top: 20rpx;
|
}
|
.ico_head {
|
width: 200rpx;
|
height: 200rpx;
|
border-radius: 50%;
|
|
}
|
}
|
|
.page_bg {
|
width: 100%;
|
min-height: calc(100vh - var(--window-bottom));
|
background: url('/static/img/bg_2.jpg') no-repeat center top;
|
background-size: 100% auto;
|
}
|
</style>
|