index.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  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. },
  31. onLoad() {
  32. this.setData({
  33. imgUrls: [
  34. this.data.host + '/images/banner.jpg',
  35. this.data.host + '/images/banner3.jpg',
  36. this.data.host + '/images/banner2.jpg'
  37. ]
  38. })
  39. },
  40. onShow() {
  41. // if (app.globalToken == null) {
  42. // wx.showToast({
  43. // title: '尚未登录,登录后即可使用',
  44. // icon: 'none'
  45. // })
  46. // }
  47. this.initIndexPage();
  48. },
  49. // 待办跳转
  50. bindViewDaiBan() {
  51. // wx.navigateTo({
  52. // url: '../daiban/daiban'
  53. // })
  54. },
  55. // 企业跳转
  56. bindViewQiYe() {
  57. if (app.globalToken == null) {
  58. wx.showToast({
  59. title: '尚未登录,登录后即可使用',
  60. icon: 'none'
  61. })
  62. return
  63. }
  64. wx.navigateTo({
  65. url: '../qiye/qiye'
  66. })
  67. },
  68. // 巡查跳转
  69. bindViewXunCha() {
  70. if (app.globalToken == null) {
  71. wx.showToast({
  72. title: '尚未登录,登录后即可使用',
  73. icon: 'none'
  74. })
  75. return
  76. }
  77. wx.navigateTo({
  78. url: '../xuncha/xuncha'
  79. })
  80. },
  81. // 通知公告更多跳转
  82. bindViewGengDuo() {
  83. if (app.globalToken == null) {
  84. wx.showToast({
  85. title: '尚未登录,登录后即可使用',
  86. icon: 'none'
  87. })
  88. return
  89. }
  90. wx.navigateTo({
  91. url: '../notice/notice'
  92. })
  93. },
  94. //物资跳转
  95. bindViewWuZi() {
  96. if (app.globalToken == null) {
  97. wx.showToast({
  98. title: '尚未登录,登录后即可使用',
  99. icon: 'none'
  100. })
  101. return
  102. }
  103. wx.navigateTo({
  104. url: '../material/material',
  105. })
  106. },
  107. //队伍跳转
  108. bindViewDuiWu() {
  109. if (app.globalToken == null) {
  110. wx.showToast({
  111. title: '尚未登录,登录后即可使用',
  112. icon: 'none'
  113. })
  114. return
  115. }
  116. wx.navigateTo({
  117. url: '../teamlist/teamlist',
  118. })
  119. },
  120. //仓库跳转
  121. bindViewCangKu() {
  122. if (app.globalToken == null) {
  123. wx.showToast({
  124. title: '尚未登录,登录后即可使用',
  125. icon: 'none'
  126. })
  127. return
  128. }
  129. wx.navigateTo({
  130. url: '../warehouselist/warehouselist',
  131. })
  132. },
  133. // 新手指南跳转
  134. bindViewNewComer() {
  135. wx.navigateTo({
  136. url: '../newcomer/newcomer',
  137. })
  138. },
  139. //巡检跳转
  140. bindViewXunJian() {
  141. if (app.globalToken == null) {
  142. wx.showToast({
  143. title: '尚未登录,登录后即可使用',
  144. icon: 'none'
  145. })
  146. return
  147. }
  148. wx.navigateTo({
  149. url: '../search/search',
  150. })
  151. },
  152. //巡更跳转
  153. bindViewXungeng(){
  154. if (app.globalToken == null) {
  155. wx.showToast({
  156. title: '尚未登录,登录后即可使用',
  157. icon: 'none'
  158. })
  159. return
  160. }
  161. this.scan()
  162. },
  163. scan() {
  164. wx.scanCode({
  165. onlyFromCamera: true,
  166. success: (res) => {
  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. noticeItem: res.data.noticeList[0]
  273. })
  274. } else {
  275. this.setData({
  276. NoticeTitle: "暂无公告"
  277. })
  278. }
  279. }
  280. },
  281. goNoticeDetails(e){
  282. let details = e.currentTarget.dataset.item
  283. if (app.globalToken == null) {
  284. wx.showToast({
  285. title: '尚未登录,登录后即可使用',
  286. icon: 'none'
  287. })
  288. return
  289. }
  290. if(details==null||details==''){
  291. wx.showToast({
  292. title: '暂无公告',
  293. icon: 'none'
  294. })
  295. return
  296. }
  297. wx.navigateTo({
  298. url: '../notice/notice_details?details='+JSON.stringify(details)
  299. })
  300. },
  301. // getSysUserInfo(info) {
  302. // let that = this
  303. // wx.login({
  304. // success(res) {
  305. // var code = res.code
  306. // var data = {
  307. // wxCode: code,
  308. // wxNickName: info.nickName,
  309. // wxAvatarUrl: info.avatarUrl
  310. // }
  311. // // http.send_post_login("/minapp/AppLoginController/appLogin",data)
  312. // http.send_post("/auth/applogin", data, that.loginSuccess)
  313. // },
  314. // fail(res) {
  315. // console.log("ffff", res)
  316. // }
  317. // })
  318. // },
  319. onTabItemTap(item) {
  320. }
  321. })