index.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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. if (app.globalToken == null) {
  41. wx.showToast({
  42. title: '尚未登录,登录后即可使用',
  43. icon: 'none'
  44. })
  45. }
  46. this.initIndexPage();
  47. },
  48. // 待办跳转
  49. bindViewDaiBan() {
  50. // wx.navigateTo({
  51. // url: '../daiban/daiban'
  52. // })
  53. },
  54. // 企业跳转
  55. bindViewQiYe() {
  56. wx.navigateTo({
  57. url: '../qiye/qiye'
  58. })
  59. },
  60. // 巡查跳转
  61. bindViewXunCha() {
  62. wx.navigateTo({
  63. url: '../xuncha/xuncha'
  64. })
  65. },
  66. // 通知公告更多跳转
  67. bindViewGengDuo() {
  68. wx.navigateTo({
  69. url: '../notice/notice'
  70. })
  71. },
  72. //物资跳转
  73. bindViewWuZi() {
  74. wx.navigateTo({
  75. url: '../material/material',
  76. })
  77. },
  78. // 新手指南跳转
  79. bindViewNewComer() {
  80. wx.navigateTo({
  81. url: '../newcomer/newcomer',
  82. })
  83. },
  84. //巡检跳转
  85. bindViewXunJian() {
  86. // wx.navigateTo({
  87. // url: '../xunjian/xunjian',
  88. // })
  89. },
  90. // 使用攻略跳转
  91. bindViewIntroduction() {
  92. wx.navigateTo({
  93. url: '../Introduction/Introduction'
  94. })
  95. },
  96. bindViewXunjianimg() {
  97. wx.navigateTo({
  98. url: '../xunjianimg/xunjianimg'
  99. })
  100. },
  101. // 图片轮播
  102. //轮播图的切换事件
  103. swiperChange: function (e) {
  104. this.setData({
  105. swiperCurrent: e.detail.current
  106. })
  107. },
  108. //点击指示点切换
  109. chuangEvent: function (e) {
  110. this.setData({
  111. swiperCurrent: e.currentTarget.id
  112. })
  113. },
  114. //点击图片触发事件
  115. swipclick: function (e) {
  116. // console.log(this.data.swiperCurrent);
  117. wx.switchTab({
  118. // url: this.data.links[this.data.swiperCurrent]
  119. })
  120. },
  121. //首页功能js-孙一石
  122. init_userInfo(e) {
  123. this.data.dofun = e.currentTarget.dataset.fun
  124. // let that = this
  125. // if (app.globalToken == null) {
  126. // http.showLoading()
  127. // wx.getUserProfile({
  128. // desc: 'desc',
  129. // success: (res) => {
  130. // this.getSysUserInfo(res.userInfo)
  131. // },
  132. // fail: res => {
  133. // console.log(res)
  134. // },
  135. // })
  136. // } else {
  137. this.callByName(this.data.dofun)
  138. // }
  139. },
  140. callByName(name) {
  141. if (name == "bindViewDaiBan") {
  142. //待办
  143. this.bindViewDaiBan()
  144. } else if (name == "bindViewQiYe") {
  145. //企业
  146. this.bindViewQiYe()
  147. } else if (name == "bindViewXunCha") {
  148. this.bindViewXunCha()
  149. } else if (name == "bindViewXunjianimg") {
  150. this.bindViewXunjianimg()
  151. } else if (name == "bindViewGengDuo") {
  152. this.bindViewGengDuo()
  153. } else if (name == "bindViewWuZi") {
  154. this.bindViewWuZi()
  155. }
  156. },
  157. initIndexPage() {
  158. if (app.globalToken == null || app.globalToken == '') {
  159. return
  160. }
  161. http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess)
  162. },
  163. initIndexPageSuccess(res) {
  164. if (res.code == 200) {
  165. this.setData({
  166. xunjianImgCount: res.data.xunjianImgCount,
  167. })
  168. if (res.data.noticeList.length > 0) {
  169. this.setData({
  170. NoticeTitle: res.data.noticeList[0].noticeTitle
  171. })
  172. } else {
  173. this.setData({
  174. NoticeTitle: "暂无公告"
  175. })
  176. }
  177. }
  178. },
  179. // getSysUserInfo(info) {
  180. // let that = this
  181. // wx.login({
  182. // success(res) {
  183. // var code = res.code
  184. // var data = {
  185. // wxCode: code,
  186. // wxNickName: info.nickName,
  187. // wxAvatarUrl: info.avatarUrl
  188. // }
  189. // // http.send_post_login("/minapp/AppLoginController/appLogin",data)
  190. // http.send_post("/auth/applogin", data, that.loginSuccess)
  191. // },
  192. // fail(res) {
  193. // console.log("ffff", res)
  194. // }
  195. // })
  196. // },
  197. onTabItemTap(item) {
  198. console.log("$$$$$$$", item)
  199. }
  200. })