微信小程序 常用方法 汇总
微信小程序,常用方法汇总:
1.网络请求:
//注册 regMember: function(){ return new Promise((resolve, reject) => { var sendData = {}; sendData.openid = app.globalData.userInfo.openid; sendData.phone = app.globalData.userInfo.mobile; wx.showLoading();//请求开始前显示loading wx.request({ url: app.globalData.apiPath + '/wxapi/member/reg', header: { 'content-type': 'application/json' }, method: 'POST', //'GET','POST' dataType: 'json', data: sendData, success: (res) => { if (res.statusCode == 200 && res.data.code == 1) { resolve(res.data.memberInfo); } else { resolve(0); } }, fail: (err) => { resolve(0); }, complete: () => { wx.hideLoading();//请求完成关闭loading } }) }); },