index.js 4.7 KB

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