123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- import Toast from '@vant/weapp/toast/toast';
- const {upLoad,chooseImage} = require('../../utils/util');
- const {modify} = require('../../API/appraise');
- Page({
-
- data: {
- changeAvatarUrl:'',
- changeNickName:'',
- changePhoneNumber:'',
- changePersonalSignatrue:''
- },
-
- onLoad(options) {
-
- },
-
- onReady() {
- },
-
- onShow() {
- },
-
- onHide() {
- },
-
- onUnload() {
- },
-
- onPullDownRefresh() {
- },
-
- onReachBottom() {
- },
-
- onShareAppMessage() {
- },
-
- chooseImage() {
- chooseImage().then((res)=>{
- this.uploadImage(res.tempFilePaths[0]);
- })
- },
- uploadImage(imagePath){
- upLoad( imagePath ).then((res) => {
- console.log(res);
- this.setData({
- changeAvatarUrl: res.Url
- });
- wx.setStorageSync('changeAvatarUrl', res.Url);
- })
- },
- onChangeUsername:function(e){
- wx.setStorageSync('changeNickName', e.detail);
- },
- onChangePhonenumber:function(e){
- wx.setStorageSync('changePhoneNumber', e.detail);
- },
-
-
-
- onChangePersonalSignatrue: function(e) {
- wx.setStorageSync('changePersonalSignatrue', e.detail);
- },
-
- changeInfo:function(){
- console.log(wx.getStorageSync('uid'));
- console.log(wx.getStorageSync('changePersonalSignatrue'));
-
-
-
-
-
-
-
- var modifyOption = {
- data: {
- avatar: wx.getStorageSync('changeAvatarUrl'),
- name: wx.getStorageSync('changeNickName'),
- phone: wx.getStorageSync('changePhoneNumber'),
- sign: wx.getStorageSync('changePersonalSignatrue'),
- uid: wx.getStorageSync('uid'),
- },
- }
- console.log(wx.getStorageSync('changeAvatarUrl'));
- console.log(wx.getStorageSync('changePersonalSignatrue'));
- console.log(modifyOption.data);
- modify(modifyOption).then((res)=>{
- console.log(res);
- console.log(res.data);
- console.log(res.data.data);
- wx.setStorageSync('avatarUrl', res.data.data.avatar);
- wx.setStorageSync('nickName', res.data.data.name);
- wx.setStorageSync('personalSignatrue', res.data.data.sign);
- wx.switchTab({
- url: '/pages/user/user',
- })
- }).catch((err) => {
- if(err.data.message == "fail to update"){
- Toast.fail('无效修改');
- }else if(err.data.message == "phone number already be used"){
- Toast.fail('手机号已被占用');
- }
- })
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- }
- })
|