<template>
|
<view>
|
<view class="login_bg"></view>
|
<view class="login_box animated">
|
<image class="head" src="https://ossacmall.bluedeer.com.cn/app/static/images/app_headDefault.png"></image>
|
<view class="title">悦养商城 获取您的头像和昵称</view>
|
<view class="input_box">
|
<view class="avatar">
|
<image :src="newAvatar ? newAvatar :'https://ossacmall.bluedeer.com.cn/app/static/images/userHead_defaultNew.png'"></image>
|
</view>
|
|
<!-- #ifdef MP -->
|
<button class="input_btn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar"
|
@click="checkPrivacy">获取微信头像</button>
|
<!-- #endif -->
|
<!-- #ifdef H5 -->
|
<view class="input_btn" @click.stop='uploadpic'></view>
|
<!-- #endif -->
|
</view>
|
<view class="input_box">
|
<!-- #ifdef MP -->
|
<input class="input" type="nickname" name="nickname" v-model="nickName" placeholder="请输入您的昵称"></input>
|
<!-- #endif -->
|
<!-- #ifdef H5 -->
|
<input class="input" type="text" name="nickname" v-model="nickName" placeholder="请输入您的昵称"></input>
|
<!-- #endif -->
|
</view>
|
<view class="submit" @click="submit">确定</view>
|
<view class="cancel" @click="cancel">取消</view>
|
</view>
|
</view>
|
|
</template>
|
|
<script>
|
const app = getApp();
|
import {
|
userEdit
|
} from '@/api/user.js';
|
import {
|
mapGetters
|
} from "vuex";
|
export default {
|
name: 'mp_info',
|
data() {
|
const userInfo = this.$store.getters.userInfo;
|
return {
|
newAvatar: userInfo.avatar||'',
|
nickName:userInfo.nickname||'',
|
}
|
},
|
components: {},
|
onLoad(options) {
|
},
|
onShow() {
|
},
|
methods: {
|
onChooseAvatar: function(e) {
|
console.log('头像', e)
|
this.uploadAvatar(e.detail.avatarUrl);
|
},
|
checkPrivacy: function() {
|
wx.getPrivacySetting({
|
success: (res) => {
|
console.log(res);
|
if (res.needAuthorization) {
|
wx.requirePrivacyAuthorize();
|
}
|
},
|
fail: (res) => {
|
console.log(res);
|
},
|
complete: (res) => {
|
console.log(res);
|
}
|
})
|
},
|
|
/**
|
* 上传文件
|
*
|
*/
|
uploadAvatar: function(filePath) {
|
let that = this;
|
that.$util.uploadImageOne({
|
url: 'user/upload/image',
|
name: 'multipart',
|
model: "user",
|
pid: 8,
|
isWxPath: true,
|
filePath: filePath
|
}, function(uploadFileRes) {
|
that.newAvatar = uploadFileRes.data.url;
|
});
|
},
|
cancel(){
|
this.$emit('close')
|
},
|
|
/**
|
* 提交修改
|
*/
|
submit: function(e) {
|
let that = this;
|
if (!that.nickName) {
|
that.$util.Tips({
|
title: '用户姓名不能为空'
|
});
|
return false;
|
}
|
if (!that.newAvatar){
|
uni.showToast({
|
title: '请上传头像',
|
})
|
return false;
|
}
|
userEdit({
|
nickname:that.nickName,
|
avatar:that.newAvatar
|
}).then(res => {
|
that.$emit('close',{
|
nickname:that.nickName,
|
avatar:that.newAvatar
|
})
|
uni.showToast({
|
title: '保存成功',
|
icon: 'success'
|
})
|
}).catch(msg => {
|
uni.showToast({
|
title: '保存失败',
|
})
|
});
|
}
|
}
|
}
|
</script>
|
|
<style scoped lang="scss">
|
.login_bg {
|
position: fixed;
|
left: 0;
|
top: 0;
|
width: 100%;
|
height: 100%;
|
background: rgba(0, 0, 0, .7);
|
z-index: 9999;
|
}
|
|
.login_box {
|
z-index: 9999;
|
width: 100%;
|
box-sizing: border-box;
|
padding: 290rpx 60rpx 60rpx 60rpx;
|
position: absolute;
|
left: 0;
|
bottom: 0;
|
background: url("https://ossacmall.bluedeer.com.cn/app/static/images/login_top2.png") center top/100% auto no-repeat;
|
background-color: #FFE20E;
|
border-radius: 40rpx 40rpx 0 0;
|
.head{
|
width: 85rpx;
|
height: 85rpx;
|
left: 57rpx;
|
top: 57rpx;
|
position: absolute;
|
border: 1rpx solid #F5F5F5;
|
border-radius: 50%;
|
border: 1rpx solid #F5F5F5;
|
border-radius: 50%;
|
}
|
.title{
|
font-size: 34rpx;
|
line-height: 85rpx;
|
position: absolute;
|
left: 178rpx;
|
top: 60rpx;
|
color: #ffffff;
|
}
|
.avatar{
|
width: 90rpx;
|
height: 90rpx;
|
border-radius: 50%;
|
overflow: hidden;
|
margin-top: 15rpx;
|
background-color: #f5f5f5;
|
position: absolute;
|
left: 0;
|
top: 10rpx;
|
image{
|
width: 90rpx;
|
height: 90rpx;
|
}
|
}
|
.input_box{
|
position: relative;
|
font-size: 30rpx;
|
height: 133rpx;
|
line-height: 133rpx;
|
color: #000000;
|
border-bottom: 2rpx solid #ffffff;
|
.input_label{
|
position: absolute;
|
left: 0;
|
top: 0;
|
}
|
.input{
|
width: 100%;
|
height: 100%;
|
::-webkit-input-placeholder{
|
color: #979797;
|
}
|
}
|
.input_btn{
|
position: absolute;
|
right: 0;
|
top: 50%;
|
margin-top: -29rpx;
|
width: 250rpx;
|
line-height: 57rpx;
|
text-align: center;
|
background: none;
|
color: #016DCC;
|
}
|
}
|
.submit{
|
margin-top: 96rpx;
|
font-size: 30rpx;
|
line-height: 72rpx;
|
text-align: center;
|
color: #ffffff;
|
border-radius: 36rpx;
|
background-color: #016DCC;
|
}
|
.cancel{
|
// font-size: 30rpx;
|
// line-height: 72rpx;
|
// text-align: center;
|
// margin:24rpx auto 0 auto;
|
// color: #016DCC;
|
// border-radius: 36rpx;
|
// border: 1px solid #ffffff;
|
font-size: 30rpx;
|
width: max-content;
|
margin: 24rpx auto 0 auto;
|
color: #000000;
|
}
|
}
|
|
.animated {
|
animation-duration: .4s
|
}
|
</style>
|