// index.js // 获取应用实例 import http from '../../base/httputil' const app = getApp() Page({ data: { host: app.globalData.host, current: 0, //当前所在页面的 index indicatorDots: true, //是否显示面板指示点 autoplay: true, //是否自动切换 interval: 3000, //自动切换时间间隔 duration: 800, //滑动动画时长 circular: true, //是否采用衔接滑动 imgUrls: [ // '../images/banner.jpg', // '../images/banner3.jpg', // '../images/banner2.jpg' ], links: [ // '/pages/second/register', // '/pages/second/register', // '/pages/second/register' ], //功能数据-孙一石 //记录首页点击-登录后继续跳转 dofun: null, xunjianImgCount: '000,000', NoticeTitle: "登录查看公告", noticeItem: '', // mList: null, }, onReady() { // this.popup = this.selectComponent("#popup"); }, // showPopup() { // this.setData({ // mList: this.data.mList // }) // this.popup.showPopup(); // }, //取消事件 // _error() { // console.log('你点击了取消'); // this.popup.hidePopup(); // }, // //确认事件 // _success() { // console.log('你点击了确定'); // this.popup.hidePopup(); // }, onLoad() { this.setData({ imgUrls: [ this.data.host + '/images/banner.jpg', this.data.host + '/images/banner3.jpg', this.data.host + '/images/banner2.jpg' ] }) }, // requestPopupData() { // // wx.navigateTo({ // // url: '../early_warning_list/early_warning_list', // // }) // if (app.globalToken == null || app.globalToken == '') { // return // } // http.send_get("/system/AppIndexController/getLateInspectionList", null, this.getListSuccess) // }, // menuItemClick(res) { // let busInspectionId = res.detail.iteminfo.busInspectionId // let buslogid = res.detail.iteminfo.busLogId // wx.navigateTo({ // url: '../zhenggaijindu/zhenggaijindu?busInspectionId=' + busInspectionId + "&buslogId=" + buslogid, // }) // }, onShow() { // if (app.globalToken == null) { // wx.showToast({ // title: '尚未登录,登录后即可使用', // icon: 'none' // }) // } // this.requestPopupData() this.initIndexPage(); }, // 待办跳转 bindViewDaiBan() { // wx.navigateTo({ // url: '../daiban/daiban' // }) }, // 企业跳转 bindViewQiYe() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } wx.navigateTo({ url: '../qiye/qiye' }) }, // 巡查跳转 bindViewXunCha() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } wx.navigateTo({ url: '../xuncha/xuncha' }) }, // 通知公告更多跳转 bindViewGengDuo() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } wx.navigateTo({ url: '../notice/notice' }) }, //物资跳转 bindViewWuZi() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } wx.navigateTo({ url: '../material/material', }) }, //队伍跳转 bindViewDuiWu() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } wx.navigateTo({ url: '../teamlist/teamlist', }) }, //仓库跳转 bindViewCangKu() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } wx.navigateTo({ url: '../warehouselist/warehouselist', }) }, // 新手指南跳转 bindViewNewComer() { wx.navigateTo({ url: '../newcomer/newcomer', }) }, //巡检跳转 bindViewXunJian() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } wx.navigateTo({ url: '../search/search', }) }, //巡更跳转 bindViewXungeng() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } this.scan() }, scan() { wx.scanCode({ onlyFromCamera: true, success: (res) => { wx.navigateTo({ url: '../xungengdetails/xungengdetails?id=' + res.result, }) }, fail: (res) => { // console.log(res); // wx.showToast({ // title: '扫描失败', // icon:'none' // }) } }) }, // 使用攻略跳转 bindViewIntroduction() { wx.navigateTo({ url: '../Introduction/Introduction' }) }, bindViewXunjianimg() { if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } wx.navigateTo({ url: '../xunjianimg/xunjianimg' }) }, // 图片轮播 //轮播图的切换事件 swiperChange: function (e) { this.setData({ swiperCurrent: e.detail.current }) }, //点击指示点切换 chuangEvent: function (e) { this.setData({ swiperCurrent: e.currentTarget.id }) }, //点击图片触发事件 swipclick: function (e) { // console.log(this.data.swiperCurrent); wx.switchTab({ // url: this.data.links[this.data.swiperCurrent] }) }, //首页功能js-孙一石 init_userInfo(e) { this.data.dofun = e.currentTarget.dataset.fun // let that = this // if (app.globalToken == null) { // http.showLoading() // wx.getUserProfile({ // desc: 'desc', // success: (res) => { // this.getSysUserInfo(res.userInfo) // }, // fail: res => { // console.log(res) // }, // }) // } else { this.callByName(this.data.dofun) // } }, callByName(name) { if (name == "bindViewDaiBan") { //待办 this.bindViewDaiBan() } else if (name == "bindViewQiYe") { //企业 this.bindViewQiYe() } else if (name == "bindViewXunCha") { this.bindViewXunCha() } else if (name == "bindViewXunjianimg") { this.bindViewXunjianimg() } else if (name == "bindViewGengDuo") { this.bindViewGengDuo() } else if (name == "bindViewWuZi") { this.bindViewWuZi() } else if (name == "bindViewDuiWu") { this.bindViewDuiWu() } else if (name == "bindViewCangKu") { this.bindViewCangKu() } }, initIndexPage() { if (app.globalToken == null || app.globalToken == '') { return } http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess) }, initIndexPageSuccess(res) { if (res.code == 200) { this.setData({ xunjianImgCount: res.data.xunjianImgCount, }) if (res.data.noticeList.length > 0) { this.setData({ NoticeTitle: res.data.noticeList[0].noticeTitle, noticeItem: res.data.noticeList[0] }) } else { this.setData({ NoticeTitle: "暂无公告" }) } } }, getListSuccess(res) { if (res.code == 200) { var popInfo = res.data.late_inspection_list console.log(popInfo) if (res.data != null && res.data.late_inspection_list != null && res.data.late_inspection_list.length > 0) { // this.data.mList = res.data.late_inspection_list // // this.showPopup() // this.popup.showPopup() // this.setData({ // mList: this.data.mList // }) // setTimeout(() => { // this.popup.hidePopup(); // }, 2000) wx.showModal({ title: '是否需要确认预警?', content: '', complete: (res) => { if (res.cancel) { } if (res.confirm) { wx.navigateTo({ url: '../early_warning_list/early_warning_list', }) } } }) } else { } } }, goNoticeDetails(e) { let details = e.currentTarget.dataset.item if (app.globalToken == null) { wx.showToast({ title: '尚未登录,登录后即可使用', icon: 'none' }) return } if (details == null || details == '') { wx.showToast({ title: '暂无公告', icon: 'none' }) return } wx.navigateTo({ url: '../notice/notice_details?details=' + JSON.stringify(details) }) }, // getSysUserInfo(info) { // let that = this // wx.login({ // success(res) { // var code = res.code // var data = { // wxCode: code, // wxNickName: info.nickName, // wxAvatarUrl: info.avatarUrl // } // // http.send_post_login("/minapp/AppLoginController/appLogin",data) // http.send_post("/auth/applogin", data, that.loginSuccess) // }, // fail(res) { // console.log("ffff", res) // } // }) // }, onTabItemTap(item) { } })