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