苹果6 plus onLoad获取不到数据
开发小程序遇到一个bug,在苹果6 plus上(IOS系统10.1.1,微信6.5.7),在首页下订单传了两个值到订单页,订单页在onLoad的时候获取不到首页传过来的值,console.log(this)打印出来的只有data(真机上)没有options,开发者工具上没问题,后来我升级了微信版本(6.5.10)就没问题了,在6s plus上也没问题(IOS 10.3.2, 微信 6.5.9);
var that = this; var token = wx.getStorageSync('token'); var product_type = e.currentTarget.dataset.type if(token == ""){ wx.navigateTo({ url: "userlogin" }) }else{ wx.request({ url: app.urls + 'api/applet/v1/promotion/service', data: { token: token, product_type: product_type }, header: { 'Content-Type': 'application/json' }, method: "GET", success: function (res) { var order = JSON.stringify(res.data.data);//返回订单的价格,标志,类型,没有订单id if(res.data.retCode==0){ if (res.data.data.product_type==9&res.data.data.used==1){ console.log(res.data) wx.showToast({ title: '只能购买一次', image: "../../images/warring.png" }) }else{ wx.navigateTo({ url: "place-order?order=" + order + "&type=" + product_type //把返回来的订单信息和服务包类型传到订单页 }) } }else{ wx.showToast({ title: res.data.msg, image: "../../images/warring.png" }) } } }) }
|
onLoad: function (e) { console.log(this) //在真机环境下打印出来的只有data var that = this; var types = this.options.type; if(types){ this.placeAnOrder() }else{ this.favourable() }; wx.login({ success: function (res) { if (res.code) { wx.request({ //发起网络请求 url: app.urls + 'api/v1/wechat/get_openid', method: "POST", header: { 'Content-Type':'application/x-www-form-urlencoded' }, data:{ code:res.code }, success: function (res) { that.setData({ openid: res.data.data.openid }) } }) } else { console.log('获取用户登录态失败!' + res.errMsg) } } }); } |




