敢为人鲜小程序前端代码仓库
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.
 
 
 

244 lines
5.2 KiB

<template>
<view class="login">
<!-- <view class="logo">
<image :src="configList.logo_image" mode=""></image>
</view> -->
<view class="logo">
<image src="@/static/image/logo.webp" mode="aspectFill"></image>
</view>
<view class="title" v-if="configList.config_logo">
{{ configList.config_app_name }}
</view>
<view class="app-name" v-else>
敢为人鲜
</view>
<view class="title">
申请获取您的头像昵称
</view>
<button class=" reset-button" open-type="chooseAvatar" @chooseavatar="onChooseAvatar" style="margin-top: 80rpx;">
<view class="line" style="border-top: 2rpx solid #00000020;">
<view class="">
头像
</view>
<view class="">
<image :src="userInfoForm.headImage" v-if="userInfoForm.headImage" style="width: 60rpx;height: 60rpx;"
mode="" />
<image src="../static/auth/headImage.png" v-else style="width: 50rpx;height: 50rpx;" mode="" />
</view>
</view>
</button>
<view class="line">
<view class="">
昵称
</view>
<view class="">
<input type="nickname" placeholder="请输入昵称" style="text-align: right;" id="nickName"
v-model="userInfoForm.nickName" />
</view>
</view>
<view class="line">
<view class="">
手机号
</view>
<view class=""
v-if="userInfoForm.phone">
<input placeholder="请输入手机号" style="text-align: right;"
disabled
v-model="userInfoForm.phone" />
</view>
<view class=""
v-else>
<button
class="getPhoneNumber reset-button"
open-type="getPhoneNumber"
@getphonenumber="getPhone">
获取手机号
</button>
</view>
</view>
<view class="btn" @tap="submit">
确定
</view>
</view>
</template>
<script>
export default {
data() {
return {
userInfoForm: {
headImage: '',
nickName: '',
phone : '',
}
};
},
onShow() {},
onLoad() {
this.userInfoForm.phone = this.userInfo.phone || ''
this.userInfoForm.nickName = this.userInfo.nickName || ''
this.userInfoForm.headImage = this.userInfo.headImage || ''
},
computed: {},
methods: {
onChooseAvatar(res) {
this.$Oss.ossUpload(res.target.avatarUrl)
.then(url => {
this.userInfoForm.headImage = url
})
},
getPhone(e){
this.$api('bindPhone', {
phoneCode : e.detail.code
}, res => {
if(res.code == 200){
let phoneObj = JSON.parse(res.result)
console.log(phoneObj);
if (phoneObj.errmsg == 'ok'){
this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
}
// let phoneObj = JSON.parse(res.result)
// if(phoneObj.errmsg == 'ok'){
// this.userInfoForm.phone = phoneObj.phone_info.phoneNumber
// }else{
// uni.showModal({
// title: phoneObj.errmsg
// })
// }
// console.log(phoneObj);
}
})
},
submit() {
let self = this
uni.createSelectorQuery().in(this)
.select("#nickName")
.fields({
properties: ["value"],
})
.exec((res) => {
const nickName = res?.[0]?.value
self.userInfoForm.nickName = nickName
if (self.$utils.verificationAll(self.userInfoForm, {
headImage: '请选择头像',
nickName: '请填写昵称',
phone: '请填写手机号',
})) {
return
}
// 更新个人资料函数
self.$api('updateUser', {
headImage : self.userInfoForm.headImage,
nickName : self.userInfoForm.nickName,
phone : self.userInfoForm.phone,
}, res => {
if (res.code == 200) {
this.$store.commit('getUserInfo')
uni.reLaunch({
url:'/pages/index/index'
})
}
})
// uni.reLaunch({
// url:'/pages/index/category'
// })
})
},
}
}
</script>
<style lang="scss" scoped>
.login {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
height: 90vh;
.app-name{
font-size: 40rpx;
color: black;
font-weight: 500;
margin-bottom: 20rpx;
}
.logo{
height: 300rpx;
width: 300rpx;
image{
height: 300rpx;
width: 300rpx;
border-radius: 50%;
}
margin: 30rpx 0;
}
.title {
line-height: 45rpx;
// font-weight: 900;
}
.line {
display: flex;
justify-content: space-between;
align-items: center;
width: 80%;
border-bottom: 2rpx solid #00000020;
padding: 25rpx 0;
margin: 0 auto;
}
.reset-button {
width: 100%;
padding: 0;
margin: 0;
margin-top: 6vh;
// background-color: transparent;
// padding: 0;
margin: 0;
line-height: normal;
font-size: inherit;
color: inherit;
}
/* 去除按钮边框 */
.reset-button::after {
border: none;
}
.btn {
// background: $uni-linear-gradient-btn-color;
background: $uni-color;
color: #fff;
width: 76%;
padding: 30rpx 0;
text-align: center;
border-radius: 50rpx;
margin-top: 10vh;
}
.getPhoneNumber{
// all: unset;
display: flex;
justify-content: center;
align-items: center;
// background: $uni-linear-gradient-btn-color;
background: $uni-color;
color: #fff;
width: 200rpx;
height: 90rpx;
border-radius: 45rpx;
font-size: 24rpx;
}
}
</style>