index.js 3.8 KB

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