import common from '../../utils/util'; import server from '../../utils/main'; var app = getApp(); var category = 0; Page({ /** * 页面的初始数据 */ data: { FileUrl: app.globalData.fileUrl, }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { this.setData({ Containnerheight: server.getWindowHeight(), }); category = options.id; console.log(category); this.getList(); }, onPullDownRefresh: function () { this.getList(); }, onShow: function () { var that = this; that.getList(); }, getList: function () { this.setData({ Level: category, }); var data = wx.getStorageSync('QuestionTypeList'); for (var i = 0; i < data.length; i++) { if (data[i].ID == category) { this.setData({ QuestionTypeList: data[i].List, }); wx.setNavigationBarTitle({ title: data[i].Name, }); break; } } }, gotoDetail: function (e) { var questionTypeID = e.currentTarget.dataset.id; wx.navigateTo({ url: './detail?id=' + questionTypeID }); }, gotoPrint: function (e) { var that=this; var id = e.currentTarget.dataset.id; server.getData('GetQuestionTypesPrint?ID='+id, function (data) { that.downImage(data); }); }, downImage:function(filename){ var that = this; wx.showLoading({ title: '下载中', }); setTimeout(function(){ wx.downloadFile({ url: "https://print-1253256735.file.myqcloud.com/" + filename + ".png", success: function (res) { wx.hideLoading(); wx.previewImage({ current: res.tempFilePath, // 当前显示图片的http链接 urls: [res.tempFilePath] // 需要预览的图片http链接列表 }) }, fail: function () { wx.hideLoading(); that.downImage(filename); } }); },2000); }, onShareAppMessage: function () { var that = this; return { title: '', path: 'pages/index/start?UserID=' + app.globalData.userInfo.UserID, imageUrl: app.globalData.fileUrl + 'images3/Extend/02.png', success: function (res) { }, fail: function (err) { console.log(err); }, complete: function (res) { console.log("shareComplete:" + res); }, } }, })