index.js 4.3 KB

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