Browse Source

用户头像

master
chenlong 1 year ago
parent
commit
26e509e413
  1. 2
      api/other.js
  2. 2
      config/host.js
  3. 4
      pages/UserDetail/components/index.scss
  4. 27
      pages/UserDetail/index.vue

2
api/other.js

@ -8,7 +8,7 @@ import {host} from "@/config/host";
export function getSTS(data) {
return request({
url: `${host}/other/get-aliyun-sts`,
url: `/get-aliyun-sts`,
method: "get",
data
});

2
config/host.js

@ -4,6 +4,6 @@ const host='http://47.109.60.201:9501/api'
// const host='http://192.168.2.92:9503/api'
const imghost='http://live.admin.jinghkb.com'
const title = '汪汪行天下'
const oss = 'https://fanyi-guanjia-1.'+'oss-cn-chengdu.aliyuncs.com'
const oss = 'https://pet-feed.'+'oss-cn-chengdu.aliyuncs.com'
// const codehost='http://code.baomingle.cn'
export {host,imghost,title,oss}

4
pages/UserDetail/components/index.scss

@ -112,3 +112,7 @@
}
}
}
.avatarBtn::after{
border:none;
}

27
pages/UserDetail/index.vue

@ -9,8 +9,9 @@
<view class="detail-content-item">
<view class="detail-item-title">头像</view>
<view class="detail-item-content">
<view class="detail-item-background"></view>
<button open-type="chooseAvatar" class="avatarBtn" @chooseavatar="chooseAvatar">
<image class="img" mode="aspectFill" :src="user.avatar"/>
</button>
</view>
</view>
<view class="detail-content-item">
@ -105,11 +106,25 @@
id:88685,
birthday:'2002-05-11',
},
writeWaitTime:1000,
writeHandler:null,
},
onLoad() {
this.setSexTitle();
this.getUserDetail();
},
watch:{
user:{
handler(value) {
this.writeHandler && clearTimeout(this.writeHandler);
this.writeHandler = setTimeout(() => {
this.submit();
}, this.writeWaitTime)
},
deep: true,
}
},
methods: {
getUserDetail() {
userDetail().then(({data}) => {
@ -134,16 +149,18 @@
}
updateUserDetail(this.user).then((data) => {
uni.setStorageSync('user', data.data);
functions.success("修改成功").then(() =>{
uni.navigateBack();
})
});
},
setSexTitle(v) {
log(v);
this.sexTitle = [0, '男', '女'][v ? v : this.user.sex];
log(this.sexTitle);
}
},
chooseAvatar(v) {
api.uploadOssFile(v.detail.avatarUrl).then(res => {
this.user.avatar = res.show_path;
})
},
},
onPageScroll(res) {

Loading…
Cancel
Save