Showing
1 changed file
with
28 additions
and
14 deletions
@@ -49,7 +49,7 @@ | @@ -49,7 +49,7 @@ | ||
49 | <view class="item" v-if="info.data.isThirdLogin"> | 49 | <view class="item" v-if="info.data.isThirdLogin"> |
50 | <button class="submit" size="default" @click="clearAccountFunc" :style="{ background: InfoColor }"><text class="un-bind-text">解绑</text></button> | 50 | <button class="submit" size="default" @click="clearAccountFunc" :style="{ background: InfoColor }"><text class="un-bind-text">解绑</text></button> |
51 | </view> | 51 | </view> |
52 | - <view class="item" style="margin-right: 60rpx;" :style="[{ position: info.data.isThirdLogin ? '' : 'relative' }, { right: info.data.isThirdLogin ? '' : '-158rpx' }]"> | 52 | + <view class="item" style="margin-right: 60rpx;" :style="[{ position: info.data.isThirdLogin ? '' : 'relative' }, { right: info.data.isThirdLogin ? '' : '-190rpx' }]"> |
53 | <button class="submit" size="default" @click="onSubmitFunc" :style="{ background: PrimaryColor }"><text class="un-bind-text">确认</text></button> | 53 | <button class="submit" size="default" @click="onSubmitFunc" :style="{ background: PrimaryColor }"><text class="un-bind-text">确认</text></button> |
54 | </view> | 54 | </view> |
55 | </view> | 55 | </view> |
@@ -72,6 +72,8 @@ | @@ -72,6 +72,8 @@ | ||
72 | 72 | ||
73 | <script> | 73 | <script> |
74 | import { mapMutations } from 'vuex'; | 74 | import { mapMutations } from 'vuex'; |
75 | +import baseUrl from '@/config/baseUrl.js'; | ||
76 | +import { mapState } from 'vuex'; | ||
75 | 77 | ||
76 | export default { | 78 | export default { |
77 | data() { | 79 | data() { |
@@ -116,6 +118,9 @@ export default { | @@ -116,6 +118,9 @@ export default { | ||
116 | this.openIds = getOpenId; | 118 | this.openIds = getOpenId; |
117 | } | 119 | } |
118 | }, | 120 | }, |
121 | + computed: { | ||
122 | + ...mapState(['userInfo']) | ||
123 | + }, | ||
119 | methods: { | 124 | methods: { |
120 | ...mapMutations(['setUserInfo']), | 125 | ...mapMutations(['setUserInfo']), |
121 | confrimBind(e) { | 126 | confrimBind(e) { |
@@ -144,8 +149,13 @@ export default { | @@ -144,8 +149,13 @@ export default { | ||
144 | this.showBind = true; | 149 | this.showBind = true; |
145 | }, | 150 | }, |
146 | // 修改头像 | 151 | // 修改头像 |
147 | - upAvatar() { | ||
148 | - var that = this; | 152 | + async upAvatar() { |
153 | + let token; | ||
154 | + token = this.userInfo.isToken || uni.getStorageSync('userInfo').isToken || undefined; | ||
155 | + // #ifdef H5 | ||
156 | + token = window.sessionStorage.getItem('userInfo').isToken; | ||
157 | + // #endif | ||
158 | + if (!token) return uni.$u.toast('请登录后上传图片'); | ||
149 | uni.chooseImage({ | 159 | uni.chooseImage({ |
150 | count: 1, | 160 | count: 1, |
151 | sourceType: ['camera', 'album'], | 161 | sourceType: ['camera', 'album'], |
@@ -174,17 +184,21 @@ export default { | @@ -174,17 +184,21 @@ export default { | ||
174 | }); | 184 | }); |
175 | return; | 185 | return; |
176 | } | 186 | } |
177 | - uni.$u.http | ||
178 | - .upload('/yt/oss/upload', { | ||
179 | - filePath: tempFilePaths[0], | ||
180 | - name: 'file' | ||
181 | - }) | ||
182 | - .then(res => { | ||
183 | - if (res) { | ||
184 | - that.avatar = res.fileStaticUri; | ||
185 | - return uni.$u.toast('头像上传成功'); | ||
186 | - } | ||
187 | - }); | 187 | + uni.uploadFile({ |
188 | + url: `${baseUrl.baseUrl}/yt/oss/upload`, | ||
189 | + filePath: tempFilePaths[0], | ||
190 | + name: 'file', | ||
191 | + header: { | ||
192 | + 'content-type': 'multipart/form-data', | ||
193 | + Authorization: 'Bearer ' + token | ||
194 | + }, | ||
195 | + formData: {}, | ||
196 | + success: res => { | ||
197 | + let objImage = JSON.parse(res.data); | ||
198 | + this.avatar = objImage.fileStaticUri; | ||
199 | + uni.$u.toast('头像上传成功'); | ||
200 | + } | ||
201 | + }); | ||
188 | } | 202 | } |
189 | }); | 203 | }); |
190 | }, | 204 | }, |