index.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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. noticeItem: '',
  30. // mList: null,
  31. },
  32. onReady() {
  33. // this.popup = this.selectComponent("#popup");
  34. },
  35. // showPopup() {
  36. // this.setData({
  37. // mList: this.data.mList
  38. // })
  39. // this.popup.showPopup();
  40. // },
  41. //取消事件
  42. // _error() {
  43. // console.log('你点击了取消');
  44. // this.popup.hidePopup();
  45. // },
  46. // //确认事件
  47. // _success() {
  48. // console.log('你点击了确定');
  49. // this.popup.hidePopup();
  50. // },
  51. onLoad() {
  52. this.setData({
  53. imgUrls: [
  54. this.data.host + '/images/banner.jpg',
  55. this.data.host + '/images/banner3.jpg',
  56. this.data.host + '/images/banner2.jpg'
  57. ]
  58. })
  59. },
  60. // requestPopupData() {
  61. // // wx.navigateTo({
  62. // // url: '../early_warning_list/early_warning_list',
  63. // // })
  64. // if (app.globalToken == null || app.globalToken == '') {
  65. // return
  66. // }
  67. // http.send_get("/system/AppIndexController/getLateInspectionList", null, this.getListSuccess)
  68. // },
  69. // menuItemClick(res) {
  70. // let busInspectionId = res.detail.iteminfo.busInspectionId
  71. // let buslogid = res.detail.iteminfo.busLogId
  72. // wx.navigateTo({
  73. // url: '../zhenggaijindu/zhenggaijindu?busInspectionId=' + busInspectionId + "&buslogId=" + buslogid,
  74. // })
  75. // },
  76. onShow() {
  77. // if (app.globalToken == null) {
  78. // wx.showToast({
  79. // title: '尚未登录,登录后即可使用',
  80. // icon: 'none'
  81. // })
  82. // }
  83. // this.requestPopupData()
  84. this.initIndexPage();
  85. },
  86. // 待办跳转
  87. bindViewDaiBan() {
  88. // wx.navigateTo({
  89. // url: '../daiban/daiban'
  90. // })
  91. },
  92. // 企业跳转
  93. bindViewQiYe() {
  94. if (app.globalToken == null) {
  95. wx.showToast({
  96. title: '尚未登录,登录后即可使用',
  97. icon: 'none'
  98. })
  99. return
  100. }
  101. wx.navigateTo({
  102. url: '../qiye/qiye'
  103. })
  104. },
  105. // 巡查跳转
  106. bindViewXunCha() {
  107. if (app.globalToken == null) {
  108. wx.showToast({
  109. title: '尚未登录,登录后即可使用',
  110. icon: 'none'
  111. })
  112. return
  113. }
  114. wx.navigateTo({
  115. url: '../xuncha/xuncha'
  116. })
  117. },
  118. // 通知公告更多跳转
  119. bindViewGengDuo() {
  120. if (app.globalToken == null) {
  121. wx.showToast({
  122. title: '尚未登录,登录后即可使用',
  123. icon: 'none'
  124. })
  125. return
  126. }
  127. wx.navigateTo({
  128. url: '../notice/notice'
  129. })
  130. },
  131. //物资跳转
  132. bindViewWuZi() {
  133. if (app.globalToken == null) {
  134. wx.showToast({
  135. title: '尚未登录,登录后即可使用',
  136. icon: 'none'
  137. })
  138. return
  139. }
  140. wx.navigateTo({
  141. url: '../material/material',
  142. })
  143. },
  144. //队伍跳转
  145. bindViewDuiWu() {
  146. if (app.globalToken == null) {
  147. wx.showToast({
  148. title: '尚未登录,登录后即可使用',
  149. icon: 'none'
  150. })
  151. return
  152. }
  153. wx.navigateTo({
  154. url: '../teamlist/teamlist',
  155. })
  156. },
  157. //仓库跳转
  158. bindViewCangKu() {
  159. if (app.globalToken == null) {
  160. wx.showToast({
  161. title: '尚未登录,登录后即可使用',
  162. icon: 'none'
  163. })
  164. return
  165. }
  166. wx.navigateTo({
  167. url: '../warehouselist/warehouselist',
  168. })
  169. },
  170. // 新手指南跳转
  171. bindViewNewComer() {
  172. wx.navigateTo({
  173. url: '../newcomer/newcomer',
  174. })
  175. },
  176. //巡检跳转
  177. bindViewXunJian() {
  178. if (app.globalToken == null) {
  179. wx.showToast({
  180. title: '尚未登录,登录后即可使用',
  181. icon: 'none'
  182. })
  183. return
  184. }
  185. wx.navigateTo({
  186. url: '../search/search',
  187. })
  188. },
  189. //巡更跳转
  190. bindViewXungeng() {
  191. if (app.globalToken == null) {
  192. wx.showToast({
  193. title: '尚未登录,登录后即可使用',
  194. icon: 'none'
  195. })
  196. return
  197. }
  198. this.scan()
  199. },
  200. scan() {
  201. wx.scanCode({
  202. onlyFromCamera: true,
  203. success: (res) => {
  204. wx.navigateTo({
  205. url: '../xungengdetails/xungengdetails?id=' + res.result,
  206. })
  207. },
  208. fail: (res) => {
  209. // console.log(res);
  210. // wx.showToast({
  211. // title: '扫描失败',
  212. // icon:'none'
  213. // })
  214. }
  215. })
  216. },
  217. // 使用攻略跳转
  218. bindViewIntroduction() {
  219. wx.navigateTo({
  220. url: '../Introduction/Introduction'
  221. })
  222. },
  223. bindViewXunjianimg() {
  224. if (app.globalToken == null) {
  225. wx.showToast({
  226. title: '尚未登录,登录后即可使用',
  227. icon: 'none'
  228. })
  229. return
  230. }
  231. wx.navigateTo({
  232. url: '../xunjianimg/xunjianimg'
  233. })
  234. },
  235. // 图片轮播
  236. //轮播图的切换事件
  237. swiperChange: function (e) {
  238. this.setData({
  239. swiperCurrent: e.detail.current
  240. })
  241. },
  242. //点击指示点切换
  243. chuangEvent: function (e) {
  244. this.setData({
  245. swiperCurrent: e.currentTarget.id
  246. })
  247. },
  248. //点击图片触发事件
  249. swipclick: function (e) {
  250. // console.log(this.data.swiperCurrent);
  251. wx.switchTab({
  252. // url: this.data.links[this.data.swiperCurrent]
  253. })
  254. },
  255. //首页功能js-孙一石
  256. init_userInfo(e) {
  257. this.data.dofun = e.currentTarget.dataset.fun
  258. // let that = this
  259. // if (app.globalToken == null) {
  260. // http.showLoading()
  261. // wx.getUserProfile({
  262. // desc: 'desc',
  263. // success: (res) => {
  264. // this.getSysUserInfo(res.userInfo)
  265. // },
  266. // fail: res => {
  267. // console.log(res)
  268. // },
  269. // })
  270. // } else {
  271. this.callByName(this.data.dofun)
  272. // }
  273. },
  274. callByName(name) {
  275. if (name == "bindViewDaiBan") {
  276. //待办
  277. this.bindViewDaiBan()
  278. } else if (name == "bindViewQiYe") {
  279. //企业
  280. this.bindViewQiYe()
  281. } else if (name == "bindViewXunCha") {
  282. this.bindViewXunCha()
  283. } else if (name == "bindViewXunjianimg") {
  284. this.bindViewXunjianimg()
  285. } else if (name == "bindViewGengDuo") {
  286. this.bindViewGengDuo()
  287. } else if (name == "bindViewWuZi") {
  288. this.bindViewWuZi()
  289. } else if (name == "bindViewDuiWu") {
  290. this.bindViewDuiWu()
  291. } else if (name == "bindViewCangKu") {
  292. this.bindViewCangKu()
  293. }
  294. },
  295. initIndexPage() {
  296. if (app.globalToken == null || app.globalToken == '') {
  297. return
  298. }
  299. http.send_post("/system/AppIndexController/getIndexPageData", null, this.initIndexPageSuccess)
  300. },
  301. initIndexPageSuccess(res) {
  302. if (res.code == 200) {
  303. this.setData({
  304. xunjianImgCount: res.data.xunjianImgCount,
  305. })
  306. if (res.data.noticeList.length > 0) {
  307. this.setData({
  308. NoticeTitle: res.data.noticeList[0].noticeTitle,
  309. noticeItem: res.data.noticeList[0]
  310. })
  311. } else {
  312. this.setData({
  313. NoticeTitle: "暂无公告"
  314. })
  315. }
  316. }
  317. },
  318. getListSuccess(res) {
  319. if (res.code == 200) {
  320. var popInfo = res.data.late_inspection_list
  321. console.log(popInfo)
  322. if (res.data != null && res.data.late_inspection_list != null && res.data.late_inspection_list.length > 0) {
  323. // this.data.mList = res.data.late_inspection_list
  324. // // this.showPopup()
  325. // this.popup.showPopup()
  326. // this.setData({
  327. // mList: this.data.mList
  328. // })
  329. // setTimeout(() => {
  330. // this.popup.hidePopup();
  331. // }, 2000)
  332. wx.showModal({
  333. title: '是否需要确认预警?',
  334. content: '',
  335. complete: (res) => {
  336. if (res.cancel) {
  337. }
  338. if (res.confirm) {
  339. wx.navigateTo({
  340. url: '../early_warning_list/early_warning_list',
  341. })
  342. }
  343. }
  344. })
  345. } else {
  346. }
  347. }
  348. },
  349. goNoticeDetails(e) {
  350. let details = e.currentTarget.dataset.item
  351. if (app.globalToken == null) {
  352. wx.showToast({
  353. title: '尚未登录,登录后即可使用',
  354. icon: 'none'
  355. })
  356. return
  357. }
  358. if (details == null || details == '') {
  359. wx.showToast({
  360. title: '暂无公告',
  361. icon: 'none'
  362. })
  363. return
  364. }
  365. wx.navigateTo({
  366. url: '../notice/notice_details?details=' + JSON.stringify(details)
  367. })
  368. },
  369. // getSysUserInfo(info) {
  370. // let that = this
  371. // wx.login({
  372. // success(res) {
  373. // var code = res.code
  374. // var data = {
  375. // wxCode: code,
  376. // wxNickName: info.nickName,
  377. // wxAvatarUrl: info.avatarUrl
  378. // }
  379. // // http.send_post_login("/minapp/AppLoginController/appLogin",data)
  380. // http.send_post("/auth/applogin", data, that.loginSuccess)
  381. // },
  382. // fail(res) {
  383. // console.log("ffff", res)
  384. // }
  385. // })
  386. // },
  387. onTabItemTap(item) {
  388. }
  389. })