登录后才可发布信息
data() { return { get_phone_popup_show: false, user_inform: { user_nickname: '', user_avatar: '' }, }; }; async onLoad() { // 获取用户信息,通过手机号判断是否需要弹出 this.get_user_info() }, methods: { get_phone_1(e) { uni.request({ url: `${this.__API__}/wechat/get_phone.html`, data: { code: e.detail.code }, method: 'POST', header: { 'content-type': 'application/json' }, success: (res) => { uni.request({ url: `${this.__API__}/user/edit.html`, method: 'post', data: { user_phone: res.data.phone, user_avatar: this.user_inform.user_avatar, user_nickname: this.user_inform.user_nickname, user_id: uni.getStorageSync('user_id') || "" }, header: { 'content-type': 'application/x-www-form-urlencoded' }, success: (res) => { this.get_user_info() } }) } }); }, get_user_name(e) { if (e.detail.value) { this.user_inform.user_nickname = e.detail.value } }, get_avatar(e) { new Promise((resolve, reject) => { uni.getImageInfo({ src: e.detail.avatarUrl, success: (res) => { resolve(res) }, fail: (err) => { reject(err) } }) }).then((res) => { return Promise.resolve({ tempFilePath: e.detail.avatarUrl }) }).then(res => { uni.uploadFile({ url: `${this.__API__}/base/upload`, filePath: res.tempFilePath, name: 'file', formData: { user: 'test' }, success: (res) => { let data = JSON.parse(res.data) this.user_inform.user_avatar = data.data.file } }); }) }, get_user_info() { uni.request({ url: `${this.__API__}/user/info.html`, method: 'post', data: { user_id: uni.getStorageSync('user_id') || "" }, header: { 'content-type': 'application/x-www-form-urlencoded' }, success: (res) => { const result = res.data if (result.data.user_phone == '') { this.get_phone_popup_show = true } else { this.get_phone_popup_show = false } if (result.status == 1) { this.user_inform.user_nickname = result.data.user_nickname this.user_inform.user_avatar = result.data.user_avatar } } }) } }