index.js 3.9 KB

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