Commit 546e7ac8 by 宋冰琦

修改头像修改方式

parent 9a2f1321
......@@ -6,12 +6,14 @@
</view>
<view class="page" :style="{'padding-top':(systemBarHeight.statusBarHeight+systemBarHeight.navigationBarHeight)+'px'}">
<view class="avatarBox">
<image class="avatar" @click="editAvatar" :src="userInfo.avatarUrl"/>
<button class="avatarBtn" open-type="chooseAvatar" @chooseavatar="onChooseAvatar">
<image class="avatar" :src="userInfo.avatarUrl"/>
</button>
</view>
<view class="infoBox">
<view class="infoItem name">
<view class="label">昵称</view>
<view class="input"><input type="text" v-model="userInfo.name"></view>
<view class="input"><input type="nickname" v-model="userInfo.name"></view>
<view class="tip" v-if="valate">{{valateText}}</view>
</view>
<view class="infoItem phone">
......@@ -150,7 +152,7 @@ export default {
},
async onLoad(option) {
const {info} = option
if(info){
// if(info){
const {avatarUrl,gender=0,nickName='点点'} = info?JSON.parse(decodeURIComponent(info)):{}
const {data} = await Mine.getUserInfo()
const { birthday, createTime, id, phone, sex, userName } = data.data
......@@ -174,17 +176,17 @@ export default {
canEditBirthday:this.canEditBirthday
}
Store.commit('setUserInfo', sendData);
this.save(false)
}else{
const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage
this.canEditBirthday = canEditBirthday
this.userInfo.avatarUrl = avatarUrl
this.userInfo.sex = sex?1:0
this.userInfo.name = customerName
this.userInfo.birthday = birthday
this.userInfo.id = id
this.userInfo.phone = phone
}
// this.save(false)
// }else{
// const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage
// this.canEditBirthday = canEditBirthday
// this.userInfo.avatarUrl = avatarUrl
// this.userInfo.sex = sex?1:0
// this.userInfo.name = customerName
// this.userInfo.birthday = birthday
// this.userInfo.id = id
// this.userInfo.phone = phone
// }
},
methods:{
......@@ -202,20 +204,57 @@ export default {
}
this.timerShow = false
},
editAvatar(e) {
wx.getUserProfile({
desc:'用于完善用户资料',
success:(res)=>{
const {userInfo} = res
const Info = {
avatarUrl:userInfo.avatarUrl,
nickName:userInfo.nickName
}
this.userInfo.avatarUrl = Info.avatarUrl
this.userInfo.name = Info.nickName
this.save(false)
}
})
// editAvatar(e) {
// console.log(123)
// wx.getUserProfile({
// desc:'用于完善用户资料',
// success:(res)=>{
// const {userInfo} = res
// const Info = {
// avatarUrl:userInfo.avatarUrl,
// nickName:userInfo.nickName
// }
// this.userInfo.avatarUrl = Info.avatarUrl
// this.userInfo.name = Info.nickName
// this.save(false)
// }
// })
// },
async onChooseAvatar(e) {
const { detail } = e
const { avatarUrl } = detail
this.userInfo.avatarUrl = avatarUrl
let Authorization = uni.getStorageSync(`Authorization`);
// await Mine.upLoadImg(formData)
// 上传头像接口
uni.uploadFile({
url:`${this.getBaseUrl()}/common/uploadOss`,
filePath:avatarUrl,
name:'file',
header: {
'Authorization':Authorization
},
success: (uploadFileRes)=>{
const { data } =uploadFileRes
this.userInfo.avatarUrl = data
}
})
},
getBaseUrl() {
let path = process.env.ENV_PATH == undefined?require('../../../env/dev.js'): require(process.env.ENV_PATH)
// #ifdef MP-WEIXIN
// ---------------- 根据微信开发环境配置请求地址 --------------------
// 获取当前帐号信息
const accountInfo = wx.getAccountInfoSync();
// env类型 develop:开发版、trial:体验版、release:正式版
const envWx = accountInfo.miniProgram.envVersion;
if(envWx === 'release'){
path = 'https://api.ihaoin.com'
}else{
path = 'https://hooloo-dev-api.gdatac.com'
}
// #endif
return path
},
openTimer() {
this.birthdayModalShow = false
......@@ -308,13 +347,22 @@ export default {
display: flex;
align-items: center;
background: #FFFFFF;
.avatar {
width: 200rpx;
.avatarBtn {
border: 0px;
background: white;
height: 200rpx;
border-radius: 50%;
margin: 0 auto;
.avatar {
width: 200rpx;
height: 200rpx;
border-radius: 50%;
margin: 0 auto;
}
}
.avatarBtn::after {
border: none;
}
}
.infoBox {
......
......@@ -214,9 +214,9 @@ export default {
},
methods: {
getShareData(type) {
let title = "HL快乐咖啡,高品高效高性价比";
let title = "随手一杯好咖啡";
let path = `/pages/menu/menu`;
let imageUrl = "../../static/imgs/wodezhanweitu.png";
let imageUrl = "../../static/imgs/shareImg.png";
return {
title,
imageUrl,
......
......@@ -133,7 +133,7 @@ export default {
loginInfo:"",
img:'',
tickNum:0,
dayTitle:''
dayTitle:'',
}
},
computed: {
......@@ -146,9 +146,9 @@ export default {
},
methods: {
getShareData(type) {
let title = "HL快乐咖啡,高品高效高性价比";
let title = "随手一杯好咖啡";
let path = `/pages/menu/menu`;
let imageUrl = "../../static/imgs/wodezhanweitu.png";
let imageUrl = "../../static/imgs/shareImg.png";
return {
title,
imageUrl,
......@@ -179,23 +179,26 @@ export default {
page == 'order' && uni.switchTab({ url: '/pages/order/order' })
page == 'msg' && uni.navigateTo({ url: '/mineSubPackage/pages/msg/index' })
if(page == 'userInfo'){
if(this.userInfo.avatarUrl){
uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index'})
}else{
wx.getUserProfile({
desc:'用于完善用户资料',
success:(res)=>{
const {userInfo} = res
// console.log(this.userInfo,'this.userInfo')
// if(this.userInfo.avatarUrl){
// uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index'})
// }else{
// wx.getUserProfile({
// desc:'用于完善用户资料',
// success:(res)=>{
const {userInfo} = this
console.log(userInfo,'userInfo')
let defaultImg = "https://hooloo-mp.oss-cn-shanghai.aliyuncs.com/resources/touxiang.png";
const Info = JSON.stringify({
avatarUrl:userInfo.avatarUrl,
avatarUrl:userInfo.avatarUrl||defaultImg,
gender:userInfo.gender,
nickName:userInfo.nickName
nickName:userInfo.customerName
})
// console.log(res)
page == 'userInfo' && uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index?info='+encodeURIComponent(Info) })
}
})
}
// }
// })
// }
}
}
}
......
......@@ -86,5 +86,7 @@ export default {
.catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' });
});
}
},
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment