feat: 透传request和uploadFile参数给原生wx接口
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
const weRequest = require('./request');
|
||||
import weRequest from './request';
|
||||
|
||||
Page({
|
||||
data: {},
|
||||
@@ -11,23 +11,12 @@ Page({
|
||||
data: {
|
||||
id: id
|
||||
},
|
||||
enableHttp2: true,
|
||||
timeout: 1000,
|
||||
showLoading: true,
|
||||
success: function (data) {
|
||||
console.log(data);
|
||||
},
|
||||
codeToSessionFail: function() {
|
||||
|
||||
},
|
||||
fail:function(obj, res) {
|
||||
if(codeToSessionFail) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
// code to session
|
||||
|
||||
// ...
|
||||
}
|
||||
})
|
||||
},
|
||||
upload: function() {
|
||||
@@ -6,7 +6,7 @@ weRequest.init({
|
||||
// [可选] 请求URL的固定前缀;可不配置,默认为空
|
||||
urlPerfix: "https://www.example.com/",
|
||||
// [必填] 触发重新登录的条件,res为CGI返回的数据
|
||||
loginTrigger: function (res) {
|
||||
loginTrigger: function (res: any) {
|
||||
// 此处例子:当返回数据中的字段errcode等于-1,会自动触发重新登录
|
||||
return res.errcode == -1;
|
||||
},
|
||||
@@ -33,22 +33,22 @@ weRequest.init({
|
||||
// [可选] 登录重试次数,当连续请求登录接口返回失败次数超过这个次数,将不再重试登录;可不配置,默认为重试3次
|
||||
reLoginLimit: 2,
|
||||
// [必填] 触发请求成功的条件
|
||||
successTrigger: function (res) {
|
||||
successTrigger: function (res: any) {
|
||||
// 此处例子:当返回数据中的字段errcode等于0时,代表请求成功,其他情况都认为业务逻辑失败
|
||||
return res.errcode == 0;
|
||||
},
|
||||
// [可选] 成功之后返回数据;可不配置
|
||||
successData: function (res) {
|
||||
successData: function (res: any) {
|
||||
// 此处例子:返回数据中的字段data为业务接受到的数据
|
||||
return res.data;
|
||||
},
|
||||
// [可选] 当CGI返回错误时,弹框提示的标题文字
|
||||
errorTitle: function(res) {
|
||||
errorTitle: function(res: any) {
|
||||
// 此处例子:当返回数据中的字段errcode等于0x10040730时,错误弹框的标题是“温馨提示”,其他情况下则是“操作失败”
|
||||
return res.errcode == 0x10040730 ? '温馨提示' : '操作失败'
|
||||
},
|
||||
// [可选] 当CGI返回错误时,弹框提示的内容文字
|
||||
errorContent: function(res) {
|
||||
errorContent: function(res: any) {
|
||||
// 此处例子:返回数据中的字段msg为错误弹框的提示内容文字
|
||||
return res.msg ? res.msg : '服务可能存在异常,请稍后重试'
|
||||
},
|
||||
Reference in New Issue
Block a user