index.js 4.1 KB

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