146 lines
2.9 KiB
JavaScript
146 lines
2.9 KiB
JavaScript
// pages/main/main.js
|
||
const app = getApp()
|
||
const api = require("../../utils/request.js");
|
||
Page({
|
||
|
||
/**
|
||
* 页面的初始数据
|
||
*/
|
||
data: {
|
||
Hei:0,
|
||
background: [],
|
||
indicatorDots: true,
|
||
vertical: false,
|
||
autoplay: true,
|
||
interval: 7000,
|
||
duration: 1500,
|
||
nowWork:null
|
||
},
|
||
imgH: function (e) {
|
||
let winWid = wx.getSystemInfoSync().windowWidth;
|
||
console.log(e) //获取当前屏幕的宽度
|
||
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;i<res.data.length;i++){
|
||
images.push(app.globalData.mediahost + res.data[i].path)
|
||
}
|
||
that.setData({
|
||
background: images
|
||
})
|
||
})
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面初次渲染完成
|
||
*/
|
||
onReady: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面显示
|
||
*/
|
||
onShow: function () {
|
||
// if(wx.getStorageSync('nowWork')){
|
||
// this.setData({
|
||
// nowWork: wx.getStorageSync('nowWork')
|
||
// })
|
||
// }
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面隐藏
|
||
*/
|
||
onHide: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 生命周期函数--监听页面卸载
|
||
*/
|
||
onUnload: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面相关事件处理函数--监听用户下拉动作
|
||
*/
|
||
onPullDownRefresh: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 页面上拉触底事件的处理函数
|
||
*/
|
||
onReachBottom: function () {
|
||
|
||
},
|
||
|
||
/**
|
||
* 用户点击右上角分享
|
||
*/
|
||
onShareAppMessage: function () {
|
||
|
||
},
|
||
// chooseWork: function () {
|
||
// wx.navigateTo({
|
||
// url: '/pages/workscope/index',
|
||
// })
|
||
// },
|
||
goLianxi: function () {
|
||
if (getApp().globalData.userinfo.workscope){
|
||
wx.navigateTo({
|
||
url: '/pages/lianxi/index',
|
||
})
|
||
}else{
|
||
wx.showToast({
|
||
title: '未开通权限\r\n请联系课程顾问',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
}
|
||
},
|
||
goMoni: function () {
|
||
if (getApp().globalData.userinfo.workscope) {
|
||
wx.navigateTo({
|
||
url: '/pages/moni/index',
|
||
})
|
||
} else {
|
||
wx.showToast({
|
||
title: '未开通权限\r\n请联系课程顾问',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
}
|
||
},
|
||
goYati: function () {
|
||
if (getApp().globalData.userinfo.workscope) {
|
||
wx.navigateTo({
|
||
url: '/pages/yati/index',
|
||
})
|
||
} else {
|
||
wx.showToast({
|
||
title: '未开通权限\r\n请联系课程顾问',
|
||
icon: 'none',
|
||
duration: 2000
|
||
})
|
||
}
|
||
},
|
||
testList: function (){
|
||
wx.navigateTo({
|
||
url: '/pages/test/list',
|
||
})
|
||
}
|
||
}) |