index.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  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: '../notice/notice'
  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. }else if(name=="bindViewGengDuo"){
  136. this.bindViewGengDuo()
  137. }
  138. },
  139. initIndexPage() {
  140. http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess)
  141. },
  142. initIndexPageSuccess(res) {
  143. this.setData({
  144. xunjianImgCount: res.data.xunjianImgCount
  145. })
  146. http.hideLoading()
  147. },
  148. loginSuccess(res) {
  149. if (res.data.code != 200) {
  150. wx.showToast({
  151. title: res.data.msg,
  152. icon: "none"
  153. })
  154. } else {
  155. app.globalToken = res.data.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. })