index1.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  1. var app = getApp()
  2. var token = wx.getStorageSync('token')
  3. Page({
  4. data: {
  5. option1: [{
  6. text: '全部区域',
  7. value: 0,
  8. areaID: ''
  9. }],
  10. value1: 0, //第一个显示什么
  11. active: 0, //当前tab切换的下标
  12. bike: [], //车辆
  13. work_order: [], //工单
  14. user: [], //用户
  15. orderProfit: [], //收益
  16. order: [], //订单
  17. bikeList: [], //车辆
  18. work_orderList: [], //工单
  19. userList: [], //用户
  20. orderProfitList: [], //收益
  21. orderList: [], //订单
  22. areaID: '', //首页的区域变量
  23. page: 1, //当前页数
  24. name: '', //车辆管理的局部筛选
  25. curPage: 1, //默认显示普通订单
  26. userUrl: ''
  27. },
  28. onLoad: function(options) {
  29. var that = this;
  30. app.request('index', '', 'GET').then(res => {
  31. console.log(res.data)
  32. var data = res.data
  33. for (var i = 0; i < data.wx_area.length; i++) {
  34. data.wx_area[i].value = i + 1
  35. }
  36. console.log(data)
  37. that.setData({
  38. option1: that.data.option1.concat(data.wx_area)
  39. })
  40. })
  41. this.tongji();
  42. this.list()
  43. },
  44. //点击手机号拨打用户电话
  45. phoneCall(e) {
  46. console.log(33333)
  47. wx.makePhoneCall({
  48. phoneNumber: e.currentTarget.dataset.phone
  49. })
  50. },
  51. choose(e) {
  52. var that = this;
  53. this.setData({
  54. curPage: e.currentTarget.dataset.idx
  55. })
  56. if (e.currentTarget.dataset.idx == 1) {
  57. app.request('order/list/?page=1', '', 'GET').then(res => {
  58. console.log(res, '订单')
  59. that.setData({
  60. orderList: res.data.data
  61. })
  62. })
  63. } else {
  64. app.request('orderRent/list/?page=1', '', 'GET').then(res => {
  65. console.log(res, '日租订单')
  66. that.setData({
  67. orderList: res.data.data
  68. })
  69. })
  70. }
  71. },
  72. tongji: function() {
  73. var that = this;
  74. var areaId = ''
  75. if (that.data.areaID != '') {
  76. areaId = '?put_area_id=' + that.data.areaID
  77. }
  78. app.request('user/userStatistics' + areaId, '', 'GET').then(res => {
  79. //用户统计
  80. console.log(res)
  81. that.setData({
  82. user: res.data
  83. })
  84. })
  85. app.request('bike/statistics' + areaId, '', 'GET').then(res => {
  86. console.log(res)
  87. //车辆统计
  88. that.setData({
  89. bike: res.data
  90. })
  91. })
  92. app.request('order/orderStatistics' + areaId, '', 'GET').then(res => {
  93. //订单统计
  94. console.log(res)
  95. that.setData({
  96. order: res.data
  97. })
  98. })
  99. app.request('work_order/workOrderStatistics' + areaId, '', 'POST').then(res => {
  100. //工单统计
  101. console.log(res)
  102. that.setData({
  103. work_order: res.data
  104. })
  105. })
  106. app.request('order/orderProfitStatistics' + areaId, '', 'GET').then(res => {
  107. //收益统计
  108. console.log(res)
  109. that.setData({
  110. orderProfit: res.data
  111. })
  112. })
  113. },
  114. list: function() {
  115. //获取所有tab切换的值
  116. var that = this;
  117. app.request('user/list/?page=1', '', 'GET').then(res => {
  118. console.log(res, '用户')
  119. that.setData({
  120. userList: res.data.data
  121. })
  122. })
  123. app.request('bike/list/?page=1', '', 'GET').then(res => {
  124. console.log(res, '车辆')
  125. that.setData({
  126. bikeList: res.data.data
  127. })
  128. })
  129. app.request('order/list/?page=1', '', 'GET').then(res => {
  130. console.log(res, '订单')
  131. that.setData({
  132. orderList: res.data.data
  133. })
  134. })
  135. app.request('work_order/list?page=1', '', 'GET').then(res => {
  136. console.log(res, '工单')
  137. that.setData({
  138. work_orderList: res.data.data
  139. })
  140. })
  141. },
  142. localscreen: function(e) {
  143. //车辆管理的局部筛选
  144. this.setData({
  145. name: e.currentTarget.dataset.name
  146. });
  147. this.screen();
  148. },
  149. //切换tab按钮
  150. onChange(event) {
  151. var that = this;
  152. console.log(that.data.areaID)
  153. this.setData({
  154. active: event.detail.name,
  155. page: 1
  156. })
  157. that.screen();
  158. if (event.detail.name == 4) {
  159. app.request('work_order/list?page=1', '', 'GET').then(res => {
  160. console.log(res, '工单')
  161. that.setData({
  162. work_orderList: res.data.data
  163. })
  164. })
  165. }
  166. },
  167. screen1: function(e) {
  168. console.log(e)
  169. var index = Number(e.currentTarget.dataset.index)
  170. this.setData({
  171. active: index,
  172. page: 1
  173. })
  174. },
  175. skipNext() {
  176. wx.navigateTo({
  177. url: '/pages/statistics/statistics',
  178. })
  179. },
  180. //选择区域事件
  181. change(event) {
  182. var that = this;
  183. this.setData({
  184. page: 1
  185. })
  186. var options = this.data.option1;
  187. var areaId = options[event.detail].areaID
  188. var url = '';
  189. this.setData({
  190. areaID: areaId
  191. })
  192. if (this.data.active == 0) {
  193. that.tongji()
  194. } else if (this.data.active == 1) {
  195. url = 'user/userStatistics?put_area_id=' + areaId
  196. } else if (this.data.active == 2) {
  197. url = 'bike/statistics?put_area_id=' + areaId
  198. } else if (this.data.active == 3) {
  199. url = 'order/orderStatistics?put_area_id=' + areaId
  200. } else if (this.data.active == 4) {
  201. url = {
  202. put_area_id: areaId
  203. }
  204. app.request('work_order/workOrderStatistics', url, 'POST').then(res => {
  205. //工单统计
  206. console.log(res)
  207. that.setData({
  208. work_order: res.data
  209. })
  210. })
  211. }
  212. that.screen()
  213. if (that.data.active == 1 || that.data.active == 2 || that.data.active == 3) {
  214. app.request(url, '', 'GET').then(res => {
  215. //用户统计
  216. console.log(res)
  217. if (this.data.active == 1) {
  218. that.setData({
  219. user: res.data
  220. })
  221. } else if (this.data.active == 2) {
  222. that.setData({
  223. bike: res.data
  224. })
  225. } else if (this.data.active == 3) {
  226. that.setData({
  227. order: res.data
  228. })
  229. }
  230. })
  231. }
  232. },
  233. screen: function() {
  234. //点击筛选 点击区域 上拉刷新的公共方法
  235. var that = this;
  236. var active = that.data.active;
  237. if (active == 0) {
  238. //当前是全部管理不需要加载
  239. return;
  240. }
  241. wx.showLoading({
  242. title: '加载中...',
  243. })
  244. var url = '';
  245. var data = '';
  246. var name = '';
  247. if (that.data.name != '') {
  248. name = '&' + that.data.name
  249. }
  250. if (active == 1) {
  251. //用户管理
  252. if (that.data.areaID != '') {
  253. data = '&put_area_id=' + that.data.areaID
  254. }
  255. url = 'user/list?page=1' + that.data.userUrl;
  256. } else if (active == 2) {
  257. //车辆管理
  258. if (that.data.areaID != '') {
  259. data = '&put_area_id=' + that.data.areaID
  260. }
  261. url = 'bike/list?page=1';
  262. } else if (active == 3) {
  263. //订单管理
  264. if (that.data.areaID != '') {
  265. data = '&put_area_id=' + that.data.areaID
  266. }
  267. if (that.data.curPage == 1) {
  268. url = 'order/list?page=';
  269. } else {
  270. url = 'orderRent/list?page=';
  271. }
  272. } else if (active == 4) {
  273. //工单管理
  274. if (that.data.areaID != '') {
  275. data = '&put_area_id=' + that.data.areaID
  276. }
  277. url = 'work_order/list?page=1';
  278. }
  279. app.request(url + data + name, '', 'GET').then(res => {
  280. console.log(res)
  281. if (res.statusCode == 200) {
  282. wx.hideLoading()
  283. if (active == 1) {
  284. that.setData({
  285. userList: res.data.data
  286. })
  287. } else if (active == 2) {
  288. that.setData({
  289. bikeList: res.data.data
  290. })
  291. } else if (active == 3) {
  292. that.setData({
  293. orderList: res.data.data
  294. })
  295. } else if (active == 4) {
  296. that.setData({
  297. work_orderList: res.data.data
  298. })
  299. }
  300. }
  301. })
  302. },
  303. loadmore: function() {
  304. //上拉加载更多的公共方法
  305. var that = this;
  306. var active = that.data.active;
  307. if (active == 0) {
  308. //当前是全部管理不需要加载
  309. return;
  310. }
  311. wx.showLoading({
  312. title: '加载中...',
  313. })
  314. var url = '';
  315. var page = that.data.page + 1;
  316. var data = '';
  317. var name = '';
  318. if (that.data.name != '') {
  319. name = '&' + that.data.name
  320. }
  321. if (active == 1) {
  322. //用户管理
  323. if (that.data.areaID != '') {
  324. data = '&put_area_id=' + that.data.areaID
  325. }
  326. url = 'user/list?page=' + that.data.userUrl;
  327. } else if (active == 2) {
  328. //车辆管理
  329. if (that.data.areaID != '') {
  330. data = '&put_area_id=' + that.data.areaID
  331. }
  332. url = 'bike/list?page=';
  333. } else if (active == 3) {
  334. //订单管理
  335. if (that.data.areaID != '') {
  336. data = '&put_area_id=' + that.data.areaID
  337. }
  338. if (that.data.curPage == 1) {
  339. url = 'order/list?page=';
  340. } else {
  341. url = 'orderRent/list?page=';
  342. }
  343. } else if (active == 4) {
  344. //工单管理
  345. if (that.data.areaID != '') {
  346. data = '&put_area_id=' + that.data.areaID
  347. }
  348. url = 'work_order/list?page=';
  349. }
  350. app.request(url + page + data + name, '', 'GET').then(res => {
  351. console.log(res)
  352. if (res.statusCode == 200) {
  353. if (res.data.data.length > 0) {
  354. wx.hideLoading()
  355. that.setData({
  356. page
  357. })
  358. if (active == 1) {
  359. that.setData({
  360. userList: that.data.userList.concat(res.data.data)
  361. })
  362. } else if (active == 2) {
  363. that.setData({
  364. bikeList: that.data.bikeList.concat(res.data.data)
  365. })
  366. } else if (active == 3) {
  367. that.setData({
  368. orderList: that.data.orderList.concat(res.data.data)
  369. })
  370. } else if (active == 4) {
  371. that.setData({
  372. work_orderList: that.data.work_orderList.concat(res.data.data)
  373. })
  374. }
  375. } else {
  376. wx.showToast({
  377. title: '暂无更多数据',
  378. icon: 'none'
  379. })
  380. }
  381. }
  382. })
  383. },
  384. users: function(e) {
  385. var that = this;
  386. var url = e.currentTarget.dataset.url;
  387. var data = ''
  388. if (url != '') {
  389. data = '&' + url
  390. }
  391. app.request('user/list/?page=1' + data, '', 'GET').then(res => {
  392. console.log(res, '用户')
  393. that.setData({
  394. userList: res.data.data,
  395. userUrl: data
  396. })
  397. })
  398. },
  399. detail: function(e) {
  400. //用户详情
  401. wx.navigateTo({
  402. url: '/pages/userDetail/userDetail?id=' + e.currentTarget.dataset.id,
  403. })
  404. },
  405. bike_detail: function(e) {
  406. //车辆详情
  407. var event = e.currentTarget.dataset
  408. wx.navigateTo({
  409. url: '/pages/carDetails/carDetails?id=' + event.id + '&bike_no=' + event.bike_no,
  410. })
  411. },
  412. orderDetail: function(e) {
  413. //订单详情
  414. wx.navigateTo({
  415. url: '/pages/orderDetail/orderDetail?id=' + e.currentTarget.dataset.id + '&index=' + this.data.curPage,
  416. })
  417. },
  418. wordDetail: function(e) {
  419. //工单详情
  420. wx.navigateTo({
  421. url: '/pages/workDetail/workDetail?id=' + e.currentTarget.dataset.id,
  422. })
  423. },
  424. onReady: function() {
  425. },
  426. onShow: function() {
  427. token = wx.getStorageSync('token')
  428. },
  429. onHide: function() {
  430. },
  431. onUnload: function() {
  432. },
  433. onPullDownRefresh: function() {
  434. wx.showNavigationBarLoading();
  435. this.screen(), wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
  436. },
  437. onReachBottom: function() {
  438. this.loadmore()
  439. },
  440. onShareAppMessage: function() {
  441. }
  442. })