home.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. // pages/home/home.js
  2. var BASEURL = require('../../utils/wxconstant.js')
  3. var baseUrl = BASEURL.BaseUrl()
  4. var baseutils = require('../../utils/baseUtils.js')
  5. var netUtil = require('../../utils/network.js')
  6. var isregistered
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. imgUrls: [
  13. {
  14. "aa_urla": "../../img/home_banner.png"
  15. },
  16. {
  17. "aa_urla": "../../img/home_banner.png"
  18. },
  19. {
  20. "aa_urla": "../../img/home_banner.png"
  21. }
  22. ],
  23. indicatorDots: true,
  24. autoplay: true,
  25. interval: 5000,
  26. duration: 500,
  27. homedata:{},
  28. noticeContent:'这是公告',
  29. baseUrl: baseUrl
  30. },
  31. /**
  32. * 生命周期函数--监听页面加载
  33. */
  34. onLoad: function (options) {
  35. baseutils.getComOpenid() //获取openid
  36. // BASEURL.comLog('home','hme')
  37. },
  38. getAddata:function(){
  39. var that = this
  40. var data = { }
  41. var url = baseUrl + BASEURL.getUrl.getAd
  42. netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
  43. if (res.data.success){
  44. that.setData({
  45. homedata: res.data.data,
  46. noticeContent: res.data.data.announcement[0].noticeContent
  47. })
  48. // console.log('homedata', that.data.homedata)
  49. }
  50. }, function (res) {
  51. wx.showToast({
  52. title: '加载数据失败',
  53. icon: 'none',
  54. duration: 2000
  55. })
  56. })
  57. },
  58. /**
  59. * 生命周期函数--监听页面初次渲染完成
  60. */
  61. onReady: function () {
  62. },
  63. /**
  64. * 生命周期函数--监听页面显示
  65. */
  66. onShow: function () {
  67. var that = this
  68. isregistered = wx.getStorageSync('isregistered')
  69. var wxnickName = wx.getStorageSync('wxnickName')
  70. console.log('wxnickName', wxnickName)
  71. if (!wxnickName){
  72. wx.showModal({
  73. title: '提示',
  74. content: '您当前尚未进行微信授权登录,是否立即前往?',
  75. success: function (res) {
  76. if (res.confirm) {
  77. wx.switchTab({
  78. url: '../mine/mine',
  79. })
  80. } else if (res.cancel) {
  81. return
  82. }
  83. }
  84. })
  85. } else if (!isregistered){
  86. wx.showModal({
  87. title: '提示',
  88. content: '您当前尚未与企业关联绑定,是否立即去绑定?',
  89. success: function (res) {
  90. if (res.confirm) {
  91. wx.navigateTo({
  92. url: '../bindphone/bindphone',
  93. })
  94. } else if (res.cancel) {
  95. return
  96. }
  97. }
  98. })
  99. }else{
  100. baseutils.getPersonlEmp()
  101. baseutils.judgeisReg()
  102. }
  103. that.getAddata() //获取home广告信息
  104. },
  105. newsItemClick:function(event){
  106. var that = this
  107. var cid = event.currentTarget.dataset.newsid
  108. var title = event.currentTarget.dataset.newstitle
  109. // cid = 128
  110. var url = baseUrl + '/integral/blog/open/post/' + cid
  111. console.log('newsItemClick', url)
  112. wx.navigateTo({
  113. url: '../WebView/WebView?getUrl=' + url + '&getTitle=' + title
  114. })
  115. },
  116. /**
  117. * 生命周期函数--监听页面隐藏
  118. */
  119. onHide: function () {
  120. },
  121. /**
  122. * 生命周期函数--监听页面卸载
  123. */
  124. onUnload: function () {
  125. },
  126. /**
  127. * 页面相关事件处理函数--监听用户下拉动作
  128. */
  129. onPullDownRefresh: function () {
  130. },
  131. /**
  132. * 页面上拉触底事件的处理函数
  133. */
  134. onReachBottom: function () {
  135. },
  136. /**
  137. * 用户点击右上角分享
  138. */
  139. onShareAppMessage: function () {
  140. }
  141. })