|
@@ -6,11 +6,11 @@
|
|
|
<view class="data-icon">
|
|
|
<u-icon name="camera-fill" custom-prefix="custom-icon" color="#fff" size="32"></u-icon>
|
|
|
</view>
|
|
|
- <u-avatar src="/static/img/head.png" size="216"></u-avatar>
|
|
|
+ <u-avatar :src="form.headImg+'?x-oss-process=image/resize,m_fill,w_256,h_256'" size="216" @click="uploadPhoto"></u-avatar>
|
|
|
</view>
|
|
|
<view class="data-input">
|
|
|
<u-form :model="form" ref="uForm" >
|
|
|
- <u-form-item label-position="top" label="昵称"><u-input v-model="form.name" /></u-form-item>
|
|
|
+ <u-form-item label-position="top" label="昵称"><u-input v-model="form.nickName" /></u-form-item>
|
|
|
</u-form>
|
|
|
</view>
|
|
|
<u-button class="login-btn" type="success" shape="circle" @click="submit">提交</u-button>
|
|
@@ -19,21 +19,93 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
+ import * as userApi from '@/apis/user.js'
|
|
|
+ import * as loginApi from '@/apis/login.js'
|
|
|
+
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
userId: '',
|
|
|
form: {
|
|
|
- name: '',
|
|
|
+ nickName: '',
|
|
|
+ headImg: '',
|
|
|
},
|
|
|
}
|
|
|
},
|
|
|
- onReady() {
|
|
|
- if(this.carhelp.getPersonInfo() != null) {
|
|
|
- this.userId = this.carhelp.getPersonInfo().id;
|
|
|
- }
|
|
|
+ onReady() {
|
|
|
+ this.getUserInfo();
|
|
|
},
|
|
|
methods: {
|
|
|
+ getUserInfo() {
|
|
|
+ uni.showLoading({
|
|
|
+ title: "加载中",
|
|
|
+ mask: true,
|
|
|
+ })
|
|
|
+ loginApi.findByOpenId({
|
|
|
+ openId: this.carhelp.getOpenId(),
|
|
|
+ }).then((res) => {
|
|
|
+ uni.hideLoading();
|
|
|
+
|
|
|
+ this.form.headImg = res.data.regUser.headImg;
|
|
|
+ this.form.nickName = res.data.regUser.nickName;
|
|
|
+ }).catch(error => {
|
|
|
+ uni.showToast({
|
|
|
+ title: error,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ })
|
|
|
+ },
|
|
|
+ uploadPhoto() {
|
|
|
+ // 上传图片
|
|
|
+ let _self = this;
|
|
|
+ uni.chooseImage({
|
|
|
+ count: 1, //默认9
|
|
|
+ sourceType: ['album', 'camera'], //从相册选择
|
|
|
+ success: (res) => {
|
|
|
+ let imgFile = res.tempFilePaths;
|
|
|
+
|
|
|
+ var token = this.carhelp.getToken()
|
|
|
+ for (let i = 0; i < imgFile.length; i++) {
|
|
|
+
|
|
|
+ wx.uploadFile({
|
|
|
+ url: process.car.BASE_URL + "uploadPicture",
|
|
|
+ name: 'photoFile',
|
|
|
+ header: {
|
|
|
+ 'Authorization': token,
|
|
|
+ 'accept': 'application/json',
|
|
|
+ //#ifdef MP-WEIXIN
|
|
|
+ "Content-Type": "multipart/form-data", //记得设置
|
|
|
+ //#endif
|
|
|
+
|
|
|
+ },
|
|
|
+ filePath: imgFile[0],
|
|
|
+ success: function(result) {
|
|
|
+ let imgUrls = JSON.parse(result.data)
|
|
|
+ _self.form.headImg = imgUrls.data;
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
+ },
|
|
|
+ submit() {
|
|
|
+ uni.showLoading({
|
|
|
+ title: "加载中",
|
|
|
+ mask: true,
|
|
|
+ })
|
|
|
+ userApi.updatePersonInformation(this.form).then((res) => {
|
|
|
+ uni.hideLoading();
|
|
|
+
|
|
|
+ uni.redirectTo({
|
|
|
+ url: '/pages/user/index'
|
|
|
+ })
|
|
|
+ }).catch(error => {
|
|
|
+ uni.showToast({
|
|
|
+ title: error,
|
|
|
+ icon: "none"
|
|
|
+ })
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
</script>
|