index.js 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. // index.js
  2. // 获取应用实例
  3. import http from '../../base/httputil'
  4. const app = getApp()
  5. Page({
  6. data: {
  7. host: app.globalData.host,
  8. current: 0, //当前所在页面的 index
  9. indicatorDots: true, //是否显示面板指示点
  10. autoplay: true, //是否自动切换
  11. interval: 3000, //自动切换时间间隔
  12. duration: 800, //滑动动画时长
  13. circular: true, //是否采用衔接滑动
  14. imgUrls: [
  15. // '../images/banner.jpg',
  16. // '../images/banner3.jpg',
  17. // '../images/banner2.jpg'
  18. ],
  19. links: [
  20. // '/pages/second/register',
  21. // '/pages/second/register',
  22. // '/pages/second/register'
  23. ],
  24. //功能数据-孙一石
  25. //记录首页点击-登录后继续跳转
  26. dofun: null,
  27. xunjianImgCount: '000,000',
  28. NoticeTitle: "登录查看公告"
  29. },
  30. onLoad() {
  31. this.setData({
  32. imgUrls: [
  33. this.data.host + '/images/banner.jpg',
  34. this.data.host + '/images/banner3.jpg',
  35. this.data.host + '/images/banner2.jpg'
  36. ]
  37. })
  38. },
  39. onShow() {
  40. let token = wx.getStorageSync('access_token')
  41. if (token == '' || token == null) {
  42. app.globalToken = null
  43. wx.showToast({
  44. title: '尚未登录,登录后即可使用',
  45. icon: 'none'
  46. })
  47. }
  48. this.initIndexPage();
  49. },
  50. // 待办跳转
  51. bindViewDaiBan() {
  52. // wx.navigateTo({
  53. // url: '../daiban/daiban'
  54. // })
  55. },
  56. // 企业跳转
  57. bindViewQiYe() {
  58. wx.navigateTo({
  59. url: '../qiye/qiye'
  60. })
  61. },
  62. // 巡查跳转
  63. bindViewXunCha() {
  64. wx.navigateTo({
  65. url: '../xuncha/xuncha'
  66. })
  67. },
  68. // 通知公告更多跳转
  69. bindViewGengDuo() {
  70. wx.navigateTo({
  71. url: '../notice/notice'
  72. })
  73. },
  74. //物资跳转
  75. bindViewWuZi() {
  76. wx.navigateTo({
  77. url: '../material/material',
  78. })
  79. },
  80. // 新手指南跳转
  81. bindViewNewComer() {
  82. wx.navigateTo({
  83. url: '../newcomer/newcomer',
  84. })
  85. },
  86. //巡检跳转
  87. bindViewXunJian() {
  88. // wx.navigateTo({
  89. // url: '../xunjian/xunjian',
  90. // })
  91. },
  92. // 使用攻略跳转
  93. bindViewIntroduction() {
  94. wx.navigateTo({
  95. url: '../Introduction/Introduction'
  96. })
  97. },
  98. bindViewXunjianimg() {
  99. wx.navigateTo({
  100. url: '../xunjianimg/xunjianimg'
  101. })
  102. },
  103. // 图片轮播
  104. //轮播图的切换事件
  105. swiperChange: function (e) {
  106. this.setData({
  107. swiperCurrent: e.detail.current
  108. })
  109. },
  110. //点击指示点切换
  111. chuangEvent: function (e) {
  112. this.setData({
  113. swiperCurrent: e.currentTarget.id
  114. })
  115. },
  116. //点击图片触发事件
  117. swipclick: function (e) {
  118. // console.log(this.data.swiperCurrent);
  119. wx.switchTab({
  120. // url: this.data.links[this.data.swiperCurrent]
  121. })
  122. },
  123. //首页功能js-孙一石
  124. init_userInfo(e) {
  125. this.data.dofun = e.currentTarget.dataset.fun
  126. // let that = this
  127. // if (app.globalToken == null) {
  128. // http.showLoading()
  129. // wx.getUserProfile({
  130. // desc: 'desc',
  131. // success: (res) => {
  132. // this.getSysUserInfo(res.userInfo)
  133. // },
  134. // fail: res => {
  135. // console.log(res)
  136. // },
  137. // })
  138. // } else {
  139. this.callByName(this.data.dofun)
  140. // }
  141. },
  142. callByName(name) {
  143. if (name == "bindViewDaiBan") {
  144. //待办
  145. this.bindViewDaiBan()
  146. } else if (name == "bindViewQiYe") {
  147. //企业
  148. this.bindViewQiYe()
  149. } else if (name == "bindViewXunCha") {
  150. this.bindViewXunCha()
  151. } else if (name == "bindViewXunjianimg") {
  152. this.bindViewXunjianimg()
  153. } else if (name == "bindViewGengDuo") {
  154. this.bindViewGengDuo()
  155. } else if (name == "bindViewWuZi") {
  156. this.bindViewWuZi()
  157. }
  158. },
  159. initIndexPage() {
  160. if (app.globalToken == null || app.globalToken == '') {
  161. return
  162. }
  163. http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess)
  164. },
  165. initIndexPageSuccess(res) {
  166. if (res.code == 200) {
  167. this.setData({
  168. xunjianImgCount: res.data.xunjianImgCount,
  169. })
  170. if (res.data.noticeList.length > 0) {
  171. this.setData({
  172. NoticeTitle: res.data.noticeList[0].noticeTitle
  173. })
  174. } else {
  175. this.setData({
  176. NoticeTitle: "暂无公告"
  177. })
  178. }
  179. }
  180. },
  181. // getSysUserInfo(info) {
  182. // let that = this
  183. // wx.login({
  184. // success(res) {
  185. // var code = res.code
  186. // var data = {
  187. // wxCode: code,
  188. // wxNickName: info.nickName,
  189. // wxAvatarUrl: info.avatarUrl
  190. // }
  191. // // http.send_post_login("/minapp/AppLoginController/appLogin",data)
  192. // http.send_post("/auth/applogin", data, that.loginSuccess)
  193. // },
  194. // fail(res) {
  195. // console.log("ffff", res)
  196. // }
  197. // })
  198. // },
  199. onTabItemTap(item) {
  200. console.log("$$$$$$$", item)
  201. }
  202. })