From 44daeb43fecda93c1a6a1f0e37ad420291f29b0d Mon Sep 17 00:00:00 2001 From: jiangping <jp@doumee.com> Date: 星期四, 17 七月 2025 12:06:59 +0800 Subject: [PATCH] 前端 --- small-program/pages/set-up/set-up.vue | 79 ++++++++++++++++++++++++++++++++++----- 1 files changed, 68 insertions(+), 11 deletions(-) diff --git a/small-program/pages/set-up/set-up.vue b/small-program/pages/set-up/set-up.vue index 4fc27be..26c1813 100644 --- a/small-program/pages/set-up/set-up.vue +++ b/small-program/pages/set-up/set-up.vue @@ -2,27 +2,22 @@ <view class="setup"> <div class="setup-tx"> <view class="setup-tx-image"> - <image src="/static/logo.png" mode="widthFix"></image> + <image v-if="fullCoverImage && fullCoverImage !=''" :src="fullCoverImage" mode="widthFix"></image> + <image v-else src="/static/logo.png" mode="widthFix"></image> </view> - <button open-type="chooseAvatar" class="setup-tx-btn">鏇存崲澶村儚</button> + <button open-type="chooseAvatar" @chooseavatar="onChooseAvatar" class="setup-tx-btn">鏇存崲澶村儚</button> </div> <view class="setup-list"> <view class="setup-list-item"> <view class="label">鏄电О</view> <view class="val"> - <input type="text" placeholder="璇疯緭鍏�" /> + <input type="text" v-model='nickname' placeholder="璇疯緭鍏�" /> </view> </view> <view class="setup-list-item"> <view class="label">鐪熷疄濮撳悕</view> <view class="val"> - <input type="text" placeholder="璇疯緭鍏�" /> - </view> - </view> - <view class="setup-list-item"> - <view class="label">缁戝畾鎵嬫満</view> - <view class="val"> - <button open-type="getPhoneNumber">鎺堟潈</button> + <input type="text" v-model='name' placeholder="璇疯緭鍏�" /> </view> </view> </view> @@ -31,11 +26,73 @@ </template> <script> + import { mapState } from 'vuex' export default { + computed: { + ...mapState(['navHeight', 'statusbarHeight','userInfo','token','openid']) + }, data() { return { - + name:null, + coverImage:null, + nickname:null, + fullCoverImage:null }; + }, + onShow(options){ + this.coverImage = this.userInfo.coverImage + this.nickname = this.userInfo.nickname + this.fullCoverImage = this.userInfo.fullCoverImage + this.name = this.userInfo.name + }, + methods: { + onChooseAvatar(e){ + const { detail } = e + var that =this + uni.compressImage({ + src: detail.avatarUrl, + quality: 80, + success: res => { + that.uploadFile(res.tempFilePath); + } + }) + }, + uploadFile(fileUrl) { + var that = this + console.log(fileUrl, 'fileUrl') + uni.uploadFile({ + url: `web/public/upload?folder=member` , + filePath: fileUrl, + name: 'file', + success:(data)=>{ + const res = JSON.parse(data.data) + that.coverImage = res.data.imgaddr + that.fullCoverImage = res.data.url + that.updateMemberInfo() + }, + fail:(e)=>{ + uni.showToast({ + title: '涓婁紶澶辫触', + duration: 2000, + icon: "none" + }); + } + }) + }, + updateMemberInfo() { + var that = this + this.$u.api.editMemberInfo({ + name:that.name, + coverImage:that.nickname, + coverImage:that.coverImage, + }).then(res =>{ + uni.showToast({ + title: '鏇存柊鎴愬姛', + icon: "none", + duration: 2000 + }); + }) + } } } </script> -- Gitblit v1.9.3