// pages/jz/jz.js //获取应用实例 const app = getApp() var WxParse = require('../../wxParse/wxParse.js');//主要为了能够显示获取的html代码 Page({ data: { items1: [], }, //事件处理函数 bindViewTap: function () { wx.navigateTo({ url: '../logs/logs' }) }, onLoad: function (options) { let item = options.jsonStr; var that = this; wx.request({ url: app.gw.hostUrl + '/mall/web/goods/detail', method: 'get', data: { goodsNo: item }, header: { 'Content-Type': 'application/x-www-form-urlencoded' }, success: function (res) { //--init data var data = res.data; var status = data.code; if (status != 0) { wx.showToast({ title: data.msg, icon: 'none', duration: 3000 }); return; } /** * WxParse.wxParse(bindName , type, data, target,imagePadding) * 1.bindName绑定的数据名(必填) * 2.type可以为html或者md(必填) * 3.data为传入的具体数据(必填) * 4.target为Page对象,一般为this(必填) * 5.imagePadding为当图片自适应是左右的单一padding(默认为0,可选) */ that.setData({ product: data.response }) let serviceDesc = data.response.serviceDesc; WxParse.wxParse('serviceDesc', 'html', serviceDesc, that, 5); }, fail: function (e) { wx.showToast({ title: '网络异常!err:authlogin', icon: 'none', duration: 2000 }); }, }); if (app.globalData.userInfo) { this.setData({ userInfo: app.globalData.userInfo, hasUserInfo: true }) } else if (this.data.canIUse) { // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回 // 所以此处加入 callback 以防止这种情况 app.userInfoReadyCallback = res => { this.setData({ userInfo: res.userInfo, hasUserInfo: true }) } } else { // 在没有 open-type=getUserInfo 版本的兼容处理 wx.getUserInfo({ success: res => { app.globalData.userInfo = res.userInfo this.setData({ userInfo: res.userInfo, hasUserInfo: true }) } }) } }, getUserInfo: function (e) { console.log(e) app.globalData.userInfo = e.detail.userInfo this.setData({ userInfo: e.detail.userInfo, hasUserInfo: true }) } })