Commit 546e7ac8 by 宋冰琦

修改头像修改方式

parent 9a2f1321
...@@ -6,12 +6,14 @@ ...@@ -6,12 +6,14 @@
</view> </view>
<view class="page" :style="{'padding-top':(systemBarHeight.statusBarHeight+systemBarHeight.navigationBarHeight)+'px'}"> <view class="page" :style="{'padding-top':(systemBarHeight.statusBarHeight+systemBarHeight.navigationBarHeight)+'px'}">
<view class="avatarBox"> <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>
<view class="infoBox"> <view class="infoBox">
<view class="infoItem name"> <view class="infoItem name">
<view class="label">昵称</view> <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 class="tip" v-if="valate">{{valateText}}</view>
</view> </view>
<view class="infoItem phone"> <view class="infoItem phone">
...@@ -150,7 +152,7 @@ export default { ...@@ -150,7 +152,7 @@ export default {
}, },
async onLoad(option) { async onLoad(option) {
const {info} = option const {info} = option
if(info){ // if(info){
const {avatarUrl,gender=0,nickName='点点'} = info?JSON.parse(decodeURIComponent(info)):{} const {avatarUrl,gender=0,nickName='点点'} = info?JSON.parse(decodeURIComponent(info)):{}
const {data} = await Mine.getUserInfo() const {data} = await Mine.getUserInfo()
const { birthday, createTime, id, phone, sex, userName } = data.data const { birthday, createTime, id, phone, sex, userName } = data.data
...@@ -174,17 +176,17 @@ export default { ...@@ -174,17 +176,17 @@ export default {
canEditBirthday:this.canEditBirthday canEditBirthday:this.canEditBirthday
} }
Store.commit('setUserInfo', sendData); Store.commit('setUserInfo', sendData);
this.save(false) // this.save(false)
}else{ // }else{
const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage // const { avatarUrl,birthday, id, phone, sex, customerName, canEditBirthday } = this.userInfoStorage
this.canEditBirthday = canEditBirthday // this.canEditBirthday = canEditBirthday
this.userInfo.avatarUrl = avatarUrl // this.userInfo.avatarUrl = avatarUrl
this.userInfo.sex = sex?1:0 // this.userInfo.sex = sex?1:0
this.userInfo.name = customerName // this.userInfo.name = customerName
this.userInfo.birthday = birthday // this.userInfo.birthday = birthday
this.userInfo.id = id // this.userInfo.id = id
this.userInfo.phone = phone // this.userInfo.phone = phone
} // }
}, },
methods:{ methods:{
...@@ -202,20 +204,57 @@ export default { ...@@ -202,20 +204,57 @@ export default {
} }
this.timerShow = false this.timerShow = false
}, },
editAvatar(e) { // editAvatar(e) {
wx.getUserProfile({ // console.log(123)
desc:'用于完善用户资料', // wx.getUserProfile({
success:(res)=>{ // desc:'用于完善用户资料',
const {userInfo} = res // success:(res)=>{
const Info = { // const {userInfo} = res
avatarUrl:userInfo.avatarUrl, // const Info = {
nickName:userInfo.nickName // avatarUrl:userInfo.avatarUrl,
} // nickName:userInfo.nickName
this.userInfo.avatarUrl = Info.avatarUrl // }
this.userInfo.name = Info.nickName // this.userInfo.avatarUrl = Info.avatarUrl
this.save(false) // 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() { openTimer() {
this.birthdayModalShow = false this.birthdayModalShow = false
...@@ -308,13 +347,22 @@ export default { ...@@ -308,13 +347,22 @@ export default {
display: flex; display: flex;
align-items: center; align-items: center;
background: #FFFFFF; background: #FFFFFF;
.avatarBtn {
.avatar { border: 0px;
width: 200rpx; background: white;
height: 200rpx; height: 200rpx;
border-radius: 50%;
margin: 0 auto; .avatar {
width: 200rpx;
height: 200rpx;
border-radius: 50%;
margin: 0 auto;
}
} }
.avatarBtn::after {
border: none;
}
} }
.infoBox { .infoBox {
......
...@@ -214,9 +214,9 @@ export default { ...@@ -214,9 +214,9 @@ export default {
}, },
methods: { methods: {
getShareData(type) { getShareData(type) {
let title = "HL快乐咖啡,高品高效高性价比"; let title = "随手一杯好咖啡";
let path = `/pages/menu/menu`; let path = `/pages/menu/menu`;
let imageUrl = "../../static/imgs/wodezhanweitu.png"; let imageUrl = "../../static/imgs/shareImg.png";
return { return {
title, title,
imageUrl, imageUrl,
......
...@@ -133,7 +133,7 @@ export default { ...@@ -133,7 +133,7 @@ export default {
loginInfo:"", loginInfo:"",
img:'', img:'',
tickNum:0, tickNum:0,
dayTitle:'' dayTitle:'',
} }
}, },
computed: { computed: {
...@@ -146,9 +146,9 @@ export default { ...@@ -146,9 +146,9 @@ export default {
}, },
methods: { methods: {
getShareData(type) { getShareData(type) {
let title = "HL快乐咖啡,高品高效高性价比"; let title = "随手一杯好咖啡";
let path = `/pages/menu/menu`; let path = `/pages/menu/menu`;
let imageUrl = "../../static/imgs/wodezhanweitu.png"; let imageUrl = "../../static/imgs/shareImg.png";
return { return {
title, title,
imageUrl, imageUrl,
...@@ -179,23 +179,26 @@ export default { ...@@ -179,23 +179,26 @@ export default {
page == 'order' && uni.switchTab({ url: '/pages/order/order' }) page == 'order' && uni.switchTab({ url: '/pages/order/order' })
page == 'msg' && uni.navigateTo({ url: '/mineSubPackage/pages/msg/index' }) page == 'msg' && uni.navigateTo({ url: '/mineSubPackage/pages/msg/index' })
if(page == 'userInfo'){ if(page == 'userInfo'){
if(this.userInfo.avatarUrl){ // console.log(this.userInfo,'this.userInfo')
uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index'}) // if(this.userInfo.avatarUrl){
}else{ // uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index'})
wx.getUserProfile({ // }else{
desc:'用于完善用户资料', // wx.getUserProfile({
success:(res)=>{ // desc:'用于完善用户资料',
const {userInfo} = res // 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({ const Info = JSON.stringify({
avatarUrl:userInfo.avatarUrl, avatarUrl:userInfo.avatarUrl||defaultImg,
gender:userInfo.gender, gender:userInfo.gender,
nickName:userInfo.nickName nickName:userInfo.customerName
}) })
// console.log(res) // console.log(res)
page == 'userInfo' && uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index?info='+encodeURIComponent(Info) }) page == 'userInfo' && uni.navigateTo({ url: '/mineSubPackage/pages/userInfo/index?info='+encodeURIComponent(Info) })
} // }
}) // })
} // }
} }
} }
} }
......
...@@ -86,5 +86,7 @@ export default { ...@@ -86,5 +86,7 @@ export default {
.catch((err) => { .catch((err) => {
context.showToast({ title: '服务器错误', icon: 'none' }); 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