index.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376
  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: '000,000',
  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. // if (app.globalToken == null) {
  41. // wx.showToast({
  42. // title: '尚未登录,登录后即可使用',
  43. // icon: 'none'
  44. // })
  45. // }
  46. this.initIndexPage();
  47. },
  48. // 待办跳转
  49. bindViewDaiBan() {
  50. // wx.navigateTo({
  51. // url: '../daiban/daiban'
  52. // })
  53. },
  54. // 企业跳转
  55. bindViewQiYe() {
  56. if (app.globalToken == null) {
  57. wx.showToast({
  58. title: '尚未登录,登录后即可使用',
  59. icon: 'none'
  60. })
  61. return
  62. }
  63. wx.navigateTo({
  64. url: '../qiye/qiye'
  65. })
  66. },
  67. // 巡查跳转
  68. bindViewXunCha() {
  69. if (app.globalToken == null) {
  70. wx.showToast({
  71. title: '尚未登录,登录后即可使用',
  72. icon: 'none'
  73. })
  74. return
  75. }
  76. wx.navigateTo({
  77. url: '../xuncha/xuncha'
  78. })
  79. },
  80. // 通知公告更多跳转
  81. bindViewGengDuo() {
  82. if (app.globalToken == null) {
  83. wx.showToast({
  84. title: '尚未登录,登录后即可使用',
  85. icon: 'none'
  86. })
  87. return
  88. }
  89. wx.navigateTo({
  90. url: '../notice/notice'
  91. })
  92. },
  93. //物资跳转
  94. bindViewWuZi() {
  95. if (app.globalToken == null) {
  96. wx.showToast({
  97. title: '尚未登录,登录后即可使用',
  98. icon: 'none'
  99. })
  100. return
  101. }
  102. wx.navigateTo({
  103. url: '../material/material',
  104. })
  105. },
  106. //队伍跳转
  107. bindViewDuiWu() {
  108. if (app.globalToken == null) {
  109. wx.showToast({
  110. title: '尚未登录,登录后即可使用',
  111. icon: 'none'
  112. })
  113. return
  114. }
  115. wx.navigateTo({
  116. url: '../teamlist/teamlist',
  117. })
  118. },
  119. //仓库跳转
  120. bindViewCangKu() {
  121. if (app.globalToken == null) {
  122. wx.showToast({
  123. title: '尚未登录,登录后即可使用',
  124. icon: 'none'
  125. })
  126. return
  127. }
  128. wx.navigateTo({
  129. url: '../warehouselist/warehouselist',
  130. })
  131. },
  132. // 新手指南跳转
  133. bindViewNewComer() {
  134. wx.navigateTo({
  135. url: '../newcomer/newcomer',
  136. })
  137. },
  138. //巡检跳转
  139. bindViewXunJian() {
  140. if (app.globalToken == null) {
  141. wx.showToast({
  142. title: '尚未登录,登录后即可使用',
  143. icon: 'none'
  144. })
  145. return
  146. }
  147. wx.navigateTo({
  148. url: '../search/search',
  149. })
  150. },
  151. //巡更跳转
  152. bindViewXungeng(){
  153. if (app.globalToken == null) {
  154. wx.showToast({
  155. title: '尚未登录,登录后即可使用',
  156. icon: 'none'
  157. })
  158. return
  159. }
  160. this.scan()
  161. },
  162. scan() {
  163. wx.scanCode({
  164. onlyFromCamera: true,
  165. success: (res) => {
  166. console.log("$$$",res.result);
  167. wx.navigateTo({
  168. url: '../xungengdetails/xungengdetails?id='+res.result,
  169. })
  170. },
  171. fail: (res) => {
  172. // console.log(res);
  173. wx.showToast({
  174. title: '扫描失败',
  175. icon:'none'
  176. })
  177. }
  178. })
  179. },
  180. // 使用攻略跳转
  181. bindViewIntroduction() {
  182. wx.navigateTo({
  183. url: '../Introduction/Introduction'
  184. })
  185. },
  186. bindViewXunjianimg() {
  187. if (app.globalToken == null) {
  188. wx.showToast({
  189. title: '尚未登录,登录后即可使用',
  190. icon: 'none'
  191. })
  192. return
  193. }
  194. wx.navigateTo({
  195. url: '../xunjianimg/xunjianimg'
  196. })
  197. },
  198. // 图片轮播
  199. //轮播图的切换事件
  200. swiperChange: function (e) {
  201. this.setData({
  202. swiperCurrent: e.detail.current
  203. })
  204. },
  205. //点击指示点切换
  206. chuangEvent: function (e) {
  207. this.setData({
  208. swiperCurrent: e.currentTarget.id
  209. })
  210. },
  211. //点击图片触发事件
  212. swipclick: function (e) {
  213. // console.log(this.data.swiperCurrent);
  214. wx.switchTab({
  215. // url: this.data.links[this.data.swiperCurrent]
  216. })
  217. },
  218. //首页功能js-孙一石
  219. init_userInfo(e) {
  220. this.data.dofun = e.currentTarget.dataset.fun
  221. // let that = this
  222. // if (app.globalToken == null) {
  223. // http.showLoading()
  224. // wx.getUserProfile({
  225. // desc: 'desc',
  226. // success: (res) => {
  227. // this.getSysUserInfo(res.userInfo)
  228. // },
  229. // fail: res => {
  230. // console.log(res)
  231. // },
  232. // })
  233. // } else {
  234. this.callByName(this.data.dofun)
  235. // }
  236. },
  237. callByName(name) {
  238. if (name == "bindViewDaiBan") {
  239. //待办
  240. this.bindViewDaiBan()
  241. } else if (name == "bindViewQiYe") {
  242. //企业
  243. this.bindViewQiYe()
  244. } else if (name == "bindViewXunCha") {
  245. this.bindViewXunCha()
  246. } else if (name == "bindViewXunjianimg") {
  247. this.bindViewXunjianimg()
  248. } else if (name == "bindViewGengDuo") {
  249. this.bindViewGengDuo()
  250. } else if (name == "bindViewWuZi") {
  251. this.bindViewWuZi()
  252. } else if (name == "bindViewDuiWu") {
  253. this.bindViewDuiWu()
  254. } else if (name == "bindViewCangKu") {
  255. this.bindViewCangKu()
  256. }
  257. },
  258. initIndexPage() {
  259. if (app.globalToken == null || app.globalToken == '') {
  260. return
  261. }
  262. http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess)
  263. },
  264. initIndexPageSuccess(res) {
  265. if (res.code == 200) {
  266. this.setData({
  267. xunjianImgCount: res.data.xunjianImgCount,
  268. })
  269. if (res.data.noticeList.length > 0) {
  270. this.setData({
  271. NoticeTitle: res.data.noticeList[0].noticeTitle
  272. })
  273. } else {
  274. this.setData({
  275. NoticeTitle: "暂无公告"
  276. })
  277. }
  278. }
  279. },
  280. // getSysUserInfo(info) {
  281. // let that = this
  282. // wx.login({
  283. // success(res) {
  284. // var code = res.code
  285. // var data = {
  286. // wxCode: code,
  287. // wxNickName: info.nickName,
  288. // wxAvatarUrl: info.avatarUrl
  289. // }
  290. // // http.send_post_login("/minapp/AppLoginController/appLogin",data)
  291. // http.send_post("/auth/applogin", data, that.loginSuccess)
  292. // },
  293. // fail(res) {
  294. // console.log("ffff", res)
  295. // }
  296. // })
  297. // },
  298. onTabItemTap(item) {
  299. console.log("$$$$$$$", item)
  300. }
  301. })