import common from '../../utils/util'; import server from '../../utils/main'; const innerAudioContext1 = wx.createInnerAudioContext(); const app = getApp() Page({ data: { version: app.globalData.version, FileUrl: app.globalData.fileUrl, }, onLoad: function () { var that = this; server.getLocalHost(function () { that.getEnumerationData(function () { that.getQuestionTypesList(function () { var data = wx.getStorageSync('QuestionTypeList'); that.setData({ QuestionCategory: data, Containnerheight: common.getSystemHeight(), }); }); }); }); var url = app.globalData.audioUrlBaidu; url = url.replace("[token]", "24.6dbece3e76e486120456e6f6fc5dee15.2592000.1531286017.282335-10850912"); url = url.replace("[word]", "答案:45,159,55,197,781,1456,745,159,55,197,781,1456,7"); url = encodeURI(url); innerAudioContext1.src=url; innerAudioContext1.play(); }, gotoList: function (e) { var questionTypeID = e.currentTarget.dataset.id; wx.navigateTo({ url: './list?id=' + questionTypeID }); }, //得到题型数据列表 getQuestionTypesList: function (callback) { server.getData('GetQuestionTypes', function (data) { var QuestionTypeList = data; QuestionTypeList[QuestionTypeList.length - 1].List[QuestionTypeList[QuestionTypeList.length - 1].List.length - 1].NextID = QuestionTypeList[0].List[0].ID for (var i = 0; i < QuestionTypeList.length; i++) { if (i > 0) QuestionTypeList[i - 1].List[QuestionTypeList[i - 1].List.length - 1].NextID = QuestionTypeList[i].List[0].ID for (var j = 1; j < QuestionTypeList[i].List.length; j++) { QuestionTypeList[i].List[j - 1].NextID = QuestionTypeList[i].List[j].ID; } } //格式化或补充数据 for (var i = 0; i < QuestionTypeList.length; i++) { for (var j = 0; j < QuestionTypeList[i].List.length; j++) { var item = QuestionTypeList[i].List[j]; item.DifficultyName = common.getEnumerationName(item.Difficulty, app.globalData.Enumeration); } } wx.setStorage({ key: "QuestionTypeList", data: data }); callback(); }); }, //得到枚举数据 getEnumerationData: function (callback) { server.getData('GetEnumerationList', function (data) { app.globalData.Enumeration = data; wx.setStorage({ key: "Enumeration", data: data }); callback(); }); }, updateProgram: function () { if (wx.canIUse("getUpdateManager")) { const updateManager = wx.getUpdateManager(); updateManager.onCheckForUpdate(function (res) { // 请求完新版本信息的回调 console.log(res.hasUpdate) }); updateManager.onUpdateReady(function () { wx.showModal({ title: '更新提示', content: '新版本已经准备好,是否重启应用?', success: function (res) { if (res.confirm) { // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 updateManager.applyUpdate() } } }); }); } }, onShareAppMessage: function () { return { title: '', path: 'pages/index/index', success: function (res) { }, fail: function (err) { console.log(err); }, complete: function (res) { console.log(res); }, } }, })