| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159 |
- // pages/home/home.js
- var BASEURL = require('../../utils/wxconstant.js')
- var baseUrl = BASEURL.BaseUrl()
- var baseutils = require('../../utils/baseUtils.js')
- var netUtil = require('../../utils/network.js')
- var isregistered
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrls: [
- {
- "aa_urla": "../../img/home_banner.png"
- },
- {
- "aa_urla": "../../img/home_banner.png"
- },
- {
- "aa_urla": "../../img/home_banner.png"
- }
- ],
- indicatorDots: true,
- autoplay: true,
- interval: 5000,
- duration: 500,
- homedata:{},
- noticeContent:'这是公告',
- baseUrl: baseUrl
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- baseutils.getComOpenid() //获取openid
- // BASEURL.comLog('home','hme')
- },
- getAddata:function(){
- var that = this
- var data = { }
- var url = baseUrl + BASEURL.getUrl.getAd
- netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
- if (res.data.success){
- that.setData({
- homedata: res.data.data,
- noticeContent: res.data.data.announcement[0].noticeContent
- })
- // console.log('homedata', that.data.homedata)
- }
- }, function (res) {
- wx.showToast({
- title: '加载数据失败',
- icon: 'none',
- duration: 2000
- })
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- var that = this
- isregistered = wx.getStorageSync('isregistered')
- var wxnickName = wx.getStorageSync('wxnickName')
- console.log('wxnickName', wxnickName)
- if (!wxnickName){
- wx.showModal({
- title: '提示',
- content: '您当前尚未进行微信授权登录,是否立即前往?',
- success: function (res) {
- if (res.confirm) {
- wx.switchTab({
- url: '../mine/mine',
- })
- } else if (res.cancel) {
- return
- }
- }
- })
- } else if (!isregistered){
- wx.showModal({
- title: '提示',
- content: '您当前尚未与企业关联绑定,是否立即去绑定?',
- success: function (res) {
- if (res.confirm) {
- wx.navigateTo({
- url: '../bindphone/bindphone',
- })
- } else if (res.cancel) {
- return
- }
- }
- })
- }else{
- baseutils.getPersonlEmp()
- baseutils.judgeisReg()
- }
- that.getAddata() //获取home广告信息
- },
- newsItemClick:function(event){
- var that = this
- var cid = event.currentTarget.dataset.newsid
- var title = event.currentTarget.dataset.newstitle
- // cid = 128
- var url = baseUrl + '/integral/blog/open/post/' + cid
- console.log('newsItemClick', url)
- wx.navigateTo({
- url: '../WebView/WebView?getUrl=' + url + '&getTitle=' + title
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- }
- })
|