// pages/main/main.js const app = getApp() const api = require("../../utils/request.js"); Page({ /** * 页面的初始数据 */ data: { Hei:0, wrongnum: 0, collectnum: 0, background: [app.globalData.mediahost + '/media/banner/1.jpg'], indicatorDots: true, vertical: false, autoplay: true, interval: 7000, duration: 1500, nowWork:null, msgList: [ { title: "欢迎使用辐射学堂!" }, { title: "QQ交流群:1072443859" }, { title: "如有疑问,请致电课程顾问" }, ] }, imgH: function (e) { let winWid = wx.getSystemInfoSync().windowWidth; //获取当前屏幕的宽度 let imgh = e.detail.height;                //图片高度 let imgw = e.detail.width; let swiperH = winWid * imgh / imgw + "px"; this.setData({ Hei: swiperH        //设置高度 }) }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { var that = this api.request('/examtest/banner/', 'GET').then(res => { let images = [] for(var i=0;i0){ wx.showModal({ title: '暂未开通权限!', content: '您有' + remain_count + '次体验次数.', confirmText: '体验一下', success(res) { if (res.confirm) { that.genPaper2() } } }) }else{ wx.showModal({ title: '未开通权限!', content: '体验次数已用完', showCancel: false, }) } } }, goYati: function () { if (getApp().globalData.userinfo.workscope) { wx.navigateTo({ url: '/pages/yati/index', }) } else { wx.showModal({ title: '暂未开通权限!', content: '查看各地区课程顾问联系方式。', confirmText: '查看', success(res) { if (res.confirm) { wx.navigateTo({ url: '/pages/article/detail?id=6', }) } } }) } }, testList: function (){ wx.navigateTo({ url: '/pages/test/list', }) }, genPaper: function (workId) { wx.showLoading({ title: '正在生成试卷', mask:true }) api.request('/examtest/workscope/' + workId + '/monitest/', 'GET').then(res => { wx.hideLoading() try { wx.setStorageSync('examtest', res.data) } catch (e) { } wx.navigateTo({ url: '/pages/moni/note', }) }) }, genPaper2: function () { wx.showLoading({ title: '正在生成试卷', mask: true }) api.request('/examtest/workscope/monitest2/', 'GET').then(res => { wx.hideLoading() try { wx.setStorageSync('examtest', res.data) getApp().globalData.userinfo.remain_count = res.data.remain_count } catch (e) { } wx.navigateTo({ url: '/pages/moni/note', }) }) }, Baoming: function (){ wx.navigateToMiniProgram({ appId: 'wxdcf5bbfb50dbbac8', path: '', success(res) { // 打开其他小程序成功同步触发 // wx.showToast({ // title: '跳转成功' // }) } }) }, search: function (value) { return new Promise((resolve, reject) => { api.request('/question/question/', 'GET', {search:value,page:1,limit:20}).then(res => { if(res.data && res.data.results){ for(var i=0; i','').replace('

','').substring(0,18)+'...' res.data.results[i].value = res.data.results[i].id } resolve(res.data.results) }else{ resolve([{text: '无搜索结果', value: 0}]) } }) }) }, selectResult: function (e) { console.log(e.detail) wx.navigateTo({ url: `/pages/question/detail?id=${e.detail.item.id}`, }) }, getNum: function(){ try{ const ctms = wx.getStorageSync('ctms') this.setData({ wrongnum:ctms.length }) }catch(e){} } })