帖子
帖子
用户
博客
课程
2
帖子
0
勋章
703
Y币
  1. model.uploadFile({
  2.     report: false,
  3.     data: {
  4.         file: {
  5.             name: 'avatar.'+fileType,
  6.             url: locAvatar
  7.         }
  8.     }
  9. }, function(ret, err){
  10.     if( ret ){
  11.          console.log( JSON.stringify( ret ));
  12.          fnPost('user/'+userId, {
  13.              body:JSON.stringify({
  14.                    avatar:ret,
  15.                    city:locCity,
  16.                    birthday:locBirthday,
  17.                    gender:locGender,
  18.                    _method:'PUT'
  19.                 })
  20.          }, 'application/json', true, true, function(ret, err) {
  21.              if (err) {
  22.                api.alert({
  23.                    title: '提示',
  24.                    msg: JSON.stringify(err)
  25.                });
  26.              } else {
  27.                console.log(JSON.stringify(ret));
  28.              }
  29.          });
  30.     }else{
  31.          console.log( JSON.stringify( err ) );
  32.     }
  33. });
  34.                           
  35.                           
  36.                           
  37. function fnPost(path, data, contentType, isLogin, isPut, callback) {
  38.      var headers = {
  39.          "X-APICloud-AppId": appid,
  40.          "X-APICloud-AppKey": appKey
  41.      };

  42.      if (contentType) {
  43.          headers["Content-Type"] = contentType
  44.      }

  45.      var accessToken = $api.getStorage('accessToken');

  46.      if(accessToken){
  47.          headers["authorization"] = accessToken;
  48.      }

  49.      if (isLogin) {
  50.          if (!accessToken) {
  51.              api.openWin({
  52.                  name: 'login',
  53.                  url: 'widget://html/login.html'
  54.              });
  55.              return;
  56.          }
  57.      }

  58.      api.showProgress({
  59.          title: '拼命加载中...',
  60.          modal: false
  61.      });

  62.     //  alert(JSON.stringify(headers))
  63.     console.log('Path:'+'https://d.apicloud.com/mcm/api/' + path + 'Data:' + JSON.stringify(data));
  64.      api.ajax({
  65.          url: 'https://d.apicloud.com/mcm/api/' + path,
  66.          method: isPut ? 'put' : 'post',
  67.          timeout: 60,
  68.          dataType: 'json',
  69.          returnAll: false,
  70.          headers: headers,
  71.          cache: false,
  72.          data: data
  73.      }, function(ret, err) {
  74.          api.refreshHeaderLoadDone();
  75.          api.hideProgress();
  76.          callback(ret, err);
  77.      });
  78. };
复制代码


这个可以,我试过了。
2
帖子
0
勋章
703
Y币
13051490831 发表于 2020-3-28 22:58
这个可以,我试过了。

大家可以看看
75
帖子
0
勋章
657
Y币

谢谢老哥
11
帖子
0
勋章
292
Y币
厉害
10
帖子
0
勋章
164
Y币
楼主,Android的安装包二维码好像失效了
1 ...121314151617181920
您需要登录后才可以回帖 登录

本版积分规则