From 26e509e41344cceddf53b30dcad94cab79ea1923 Mon Sep 17 00:00:00 2001 From: chenlong Date: Wed, 13 Sep 2023 12:43:50 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=A4=B4=E5=83=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/other.js | 2 +- config/host.js | 2 +- pages/UserDetail/components/index.scss | 4 +++ pages/UserDetail/index.vue | 43 ++++++++++++++++++-------- 4 files changed, 36 insertions(+), 15 deletions(-) diff --git a/api/other.js b/api/other.js index 47307b9..a904552 100644 --- a/api/other.js +++ b/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 }); diff --git a/config/host.js b/config/host.js index caf77c6..9446029 100644 --- a/config/host.js +++ b/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} \ No newline at end of file diff --git a/pages/UserDetail/components/index.scss b/pages/UserDetail/components/index.scss index d760d12..613c66d 100644 --- a/pages/UserDetail/components/index.scss +++ b/pages/UserDetail/components/index.scss @@ -111,4 +111,8 @@ } } } +} + +.avatarBtn::after{ + border:none; } \ No newline at end of file diff --git a/pages/UserDetail/index.vue b/pages/UserDetail/index.vue index dba2a39..2eed225 100644 --- a/pages/UserDetail/index.vue +++ b/pages/UserDetail/index.vue @@ -9,8 +9,9 @@ 头像 - + @@ -105,14 +106,28 @@ 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 }) => { + getUserDetail() { + userDetail().then(({data}) => { this.user = data; this.birthday = this.user.birthday ? this.user.birthday : '2000-01-01' this.user.birthday = this.birthday @@ -120,30 +135,32 @@ this.setSexTitle(this.user.sex); }) }, - sexConfirm(v){ + sexConfirm(v) { log(v); this.user.sex = v.value[0].value; this.setSexTitle(v.value[0].value); }, - birthdayConfirm(v){ + birthdayConfirm(v) { this.birthday = uni.$u.timeFormat(v.value, 'yyyy-mm-dd'); }, - submit(){ - if(this.user.birthday ){ + submit() { + if (this.user.birthday) { this.user.birthday = uni.$u.timeFormat(this.user.birthday, 'yyyy-mm-dd') } - updateUserDetail(this.user).then((data) =>{ + updateUserDetail(this.user).then((data) => { uni.setStorageSync('user', data.data); - functions.success("修改成功").then(() =>{ - uni.navigateBack(); - }) }); }, - setSexTitle(v){ + 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) {