微信端处理服务器端返回值

在wx上建立global的变量,然后request的时候,发送出去

关键代码,在请求体外

const app = getApp();

在请求体内

 historyId:app.globalData.zhanbuYao.data.historyId,


在方法体第一行的console.log 可以看到,取值的路径。

zhanbuView:util.throttle(function(e){
//console.log(e);
// //获取到它的绑定id
// console.log(e.target.dataset.yao);
// console.log(e.target.dataset.author);
const app = getApp();
//console.log(app);
wx.request(
{
url: ‘https://www.xxxx.com/Wx/zhanbuView‘,
//  url: ‘http://127.0.0.1:8080/Wx/zhanbuView‘ , 

data:{
yaoId:e.target.dataset.yao,
author:e.target.dataset.author,
// historyId:e.target.
   historyId:app.globalData.zhanbuYao.data.historyId,
},
header:{
‘content-type‘:‘application/x-www-form-urlencoded‘
},
success:(res)=>{
// console.log(res.data);
//console.log(res.data.zhouyiAuthor.name);
const app = getApp();
this.setData({Shiyou:app.globalData.zhanbuShiyou});
//   console.log(Shiyou);

app.globalData.zhanbuViewAuthor=res.data.zhouyiAuthor.name,
app.globalData.zhanbuViewAuthorInfo=res.data.zhouyiAuthor.info,
app.globalData.zhanbuViewContent=res.data.content,
app.globalData.zhanbuViewXiang=res.data.xiang,
app.globalData.zhanbuViewYaoId=e.target.dataset.yao
wx.navigateTo({
url: ‘../zhanbuView/zhanbuView‘,
complete: (res) => {},
// events: events,
fail: (res) => {},
success: (result) => {},
})
}

微信端处理服务器端返回值

原文:https://www.cnblogs.com/sdgtxuyong/p/14647597.html

以上是微信端处理服务器端返回值的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>