import common from '../utils/util'; import constant from '../utils/constant'; var app = getApp(); var dataSendTimeout = 0; function getData(url, callback) { if (!app.globalData.IsProduction) console.log("加密前的结果为===", url); var url = common.Encrypt(url); //console.log("加密后的结果为===",url); wx.request({ url: app.globalData.serverUrl + url, timeout:120000, success: function (res) { if (res.statusCode) common.checkError(res.statusCode); var data = res.data.result; callback(data); }, fail: function () { wx.showToast({ title: '系统忙请稍候', // image: "../images/universalpic_warning_white_126x120.png", duration: 3000 }); var err={}; err.errCode=100; err.errMsg="网络错误"; callback(null,err); }, }); } function postData(url, postData, callback) { console.log("加密前的结果为===", url); var url = common.Encrypt(url); //console.log("加密后的结果为===",url); wx.request({ url: app.globalData.serverUrl + url, method: "POST", timeout:120000, data: postData, success: function (res) { if (res.statusCode) common.checkError(res.statusCode); var data = res.data.result; callback(data); }, fail: function () { wx.showToast({ title: '系统忙请稍候', duration: 3000 }); }, }); } function getLocalHost(callback) { if (!app.globalData.IsProduction) { var url = common.Encrypt("Ping"); wx.request({ url: app.globalData.serverUrlLocalhost + url, success: function (res) { app.globalData.serverUrl = app.globalData.serverUrlLocalhost; callback(); }, fail: function () { app.globalData.serverUrl = app.globalData.serverUrlServer; callback(); }, }); } else { app.globalData.serverUrl = app.globalData.serverUrlServer; callback(); } } function getWindowHeight() { var height = app.globalData.systemInfo.windowHeight; //console.log("app.globalData.systemInfo.windowHeight:" + app.globalData.systemInfo.windowHeight * 2); if (app.globalData.systemInfo.model) { if (height == 504 && ( app.globalData.systemInfo.model.indexOf("iPhone 6<") >= 0 || app.globalData.systemInfo.model.indexOf("iPhone 7<") >= 0 || app.globalData.systemInfo.model.indexOf("iPhone 6s<") >= 0 || app.globalData.systemInfo.model.indexOf("iPhone 5") >= 0 || app.globalData.systemInfo.model.indexOf("iPhone SE") >= 0 )) { height = 596; } else if (app.globalData.systemInfo.model.indexOf("iPad") >= 0) { height = 470; } } height = height * 2; if (app.globalData.systemInfo.system && app.globalData.systemInfo.system.indexOf("Android") >= 0) { height = height + 168; } else { height = height + 50; } //console.log("height:" + height); //var height = app.globalData.systemInfo.screenHeight * 2; return height; } function onSelect(obj,event,callback){ var result=false; var str=event.currentTarget.dataset.object; var index=event.currentTarget.dataset.index; var clickType=event.currentTarget.dataset.clicktype; if (clickType=="checkbox"){ if (obj.data[str][index].CSS) obj.data[str][index].CSS=""; else{ obj.data[str][index].CSS="Selected"; result=true; } } else{ for(var i=0;i { if (res.confirm) { let next='article?ID=MAX'; wx.reLaunch({ url: 'index', complete:function(){ wx.navigateTo({ url: next, }) } }) } } }) } },1000); } } module.exports = { getData: getData, postData: postData, getLocalHost: getLocalHost, getWindowHeight: getWindowHeight, onSelect:onSelect, checkGenerating:checkGenerating, }