123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448 |
- var app = getApp()
- var token = wx.getStorageSync('token')
- Page({
- data: {
- option1: [{
- text: '全部区域',
- value: 0,
- areaID: ''
- }],
- value1: 0, //第一个显示什么
- active: 0, //当前tab切换的下标
- bike: [], //车辆
- work_order: [], //工单
- user: [], //用户
- orderProfit: [], //收益
- order: [], //订单
- bikeList: [], //车辆
- work_orderList: [], //工单
- userList: [], //用户
- orderProfitList: [], //收益
- orderList: [], //订单
- areaID: '', //首页的区域变量
- page: 1, //当前页数
- name: '', //车辆管理的局部筛选
- curPage: 1, //默认显示普通订单
- userUrl: ''
- },
- onLoad: function(options) {
- var that = this;
- app.request('index', '', 'GET').then(res => {
- console.log(res.data)
- var data = res.data
- for (var i = 0; i < data.wx_area.length; i++) {
- data.wx_area[i].value = i + 1
- }
- console.log(data)
- that.setData({
- option1: that.data.option1.concat(data.wx_area)
- })
- })
- this.tongji();
- this.list()
- },
- //点击手机号拨打用户电话
- phoneCall(e) {
- console.log(33333)
- wx.makePhoneCall({
- phoneNumber: e.currentTarget.dataset.phone
- })
- },
- choose(e) {
- var that = this;
- this.setData({
- curPage: e.currentTarget.dataset.idx
- })
- if (e.currentTarget.dataset.idx == 1) {
- app.request('order/list/?page=1', '', 'GET').then(res => {
- console.log(res, '订单')
- that.setData({
- orderList: res.data.data
- })
- })
- } else {
- app.request('orderRent/list/?page=1', '', 'GET').then(res => {
- console.log(res, '日租订单')
- that.setData({
- orderList: res.data.data
- })
- })
- }
- },
- tongji: function() {
- var that = this;
- var areaId = ''
- if (that.data.areaID != '') {
- areaId = '?put_area_id=' + that.data.areaID
- }
- app.request('user/userStatistics' + areaId, '', 'GET').then(res => {
- //用户统计
- console.log(res)
- that.setData({
- user: res.data
- })
- })
- app.request('bike/statistics' + areaId, '', 'GET').then(res => {
- console.log(res)
- //车辆统计
- that.setData({
- bike: res.data
- })
- })
- app.request('order/orderStatistics' + areaId, '', 'GET').then(res => {
- //订单统计
- console.log(res)
- that.setData({
- order: res.data
- })
- })
- app.request('work_order/workOrderStatistics' + areaId, '', 'POST').then(res => {
- //工单统计
- console.log(res)
- that.setData({
- work_order: res.data
- })
- })
- app.request('order/orderProfitStatistics' + areaId, '', 'GET').then(res => {
- //收益统计
- console.log(res)
- that.setData({
- orderProfit: res.data
- })
- })
- },
- list: function() {
- //获取所有tab切换的值
- var that = this;
- app.request('user/list/?page=1', '', 'GET').then(res => {
- console.log(res, '用户')
- that.setData({
- userList: res.data.data
- })
- })
- app.request('bike/list/?page=1', '', 'GET').then(res => {
- console.log(res, '车辆')
- that.setData({
- bikeList: res.data.data
- })
- })
- app.request('order/list/?page=1', '', 'GET').then(res => {
- console.log(res, '订单')
- that.setData({
- orderList: res.data.data
- })
- })
- app.request('work_order/list?page=1', '', 'GET').then(res => {
- console.log(res, '工单')
- that.setData({
- work_orderList: res.data.data
- })
- })
- },
- localscreen: function(e) {
- //车辆管理的局部筛选
- this.setData({
- name: e.currentTarget.dataset.name
- });
- this.screen();
- },
- //切换tab按钮
- onChange(event) {
- var that = this;
- console.log(that.data.areaID)
- this.setData({
- active: event.detail.name,
- page: 1
- })
- that.screen();
- if (event.detail.name == 4) {
- app.request('work_order/list?page=1', '', 'GET').then(res => {
- console.log(res, '工单')
- that.setData({
- work_orderList: res.data.data
- })
- })
- }
- },
- screen1: function(e) {
- console.log(e)
- var index = Number(e.currentTarget.dataset.index)
- this.setData({
- active: index,
- page: 1
- })
- },
- skipNext() {
- wx.navigateTo({
- url: '/pages/statistics/statistics',
- })
- },
- //选择区域事件
- change(event) {
- var that = this;
- this.setData({
- page: 1
- })
- var options = this.data.option1;
- var areaId = options[event.detail].areaID
- var url = '';
- this.setData({
- areaID: areaId
- })
- if (this.data.active == 0) {
- that.tongji()
- } else if (this.data.active == 1) {
- url = 'user/userStatistics?put_area_id=' + areaId
- } else if (this.data.active == 2) {
- url = 'bike/statistics?put_area_id=' + areaId
- } else if (this.data.active == 3) {
- url = 'order/orderStatistics?put_area_id=' + areaId
- } else if (this.data.active == 4) {
- url = {
- put_area_id: areaId
- }
- app.request('work_order/workOrderStatistics', url, 'POST').then(res => {
- //工单统计
- console.log(res)
- that.setData({
- work_order: res.data
- })
- })
- }
- that.screen()
- if (that.data.active == 1 || that.data.active == 2 || that.data.active == 3) {
- app.request(url, '', 'GET').then(res => {
- //用户统计
- console.log(res)
- if (this.data.active == 1) {
- that.setData({
- user: res.data
- })
- } else if (this.data.active == 2) {
- that.setData({
- bike: res.data
- })
- } else if (this.data.active == 3) {
- that.setData({
- order: res.data
- })
- }
- })
- }
- },
- screen: function() {
- //点击筛选 点击区域 上拉刷新的公共方法
- var that = this;
- var active = that.data.active;
- if (active == 0) {
- //当前是全部管理不需要加载
- return;
- }
- wx.showLoading({
- title: '加载中...',
- })
- var url = '';
- var data = '';
- var name = '';
- if (that.data.name != '') {
- name = '&' + that.data.name
- }
- if (active == 1) {
- //用户管理
- if (that.data.areaID != '') {
- data = '&put_area_id=' + that.data.areaID
- }
- url = 'user/list?page=1' + that.data.userUrl;
- } else if (active == 2) {
- //车辆管理
- if (that.data.areaID != '') {
- data = '&put_area_id=' + that.data.areaID
- }
- url = 'bike/list?page=1';
- } else if (active == 3) {
- //订单管理
- if (that.data.areaID != '') {
- data = '&put_area_id=' + that.data.areaID
- }
- if (that.data.curPage == 1) {
- url = 'order/list?page=';
- } else {
- url = 'orderRent/list?page=';
- }
- } else if (active == 4) {
- //工单管理
- if (that.data.areaID != '') {
- data = '&put_area_id=' + that.data.areaID
- }
- url = 'work_order/list?page=1';
- }
- app.request(url + data + name, '', 'GET').then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- wx.hideLoading()
- if (active == 1) {
- that.setData({
- userList: res.data.data
- })
- } else if (active == 2) {
- that.setData({
- bikeList: res.data.data
- })
- } else if (active == 3) {
- that.setData({
- orderList: res.data.data
- })
- } else if (active == 4) {
- that.setData({
- work_orderList: res.data.data
- })
- }
- }
- })
- },
- loadmore: function() {
- //上拉加载更多的公共方法
- var that = this;
- var active = that.data.active;
- if (active == 0) {
- //当前是全部管理不需要加载
- return;
- }
- wx.showLoading({
- title: '加载中...',
- })
- var url = '';
- var page = that.data.page + 1;
- var data = '';
- var name = '';
- if (that.data.name != '') {
- name = '&' + that.data.name
- }
- if (active == 1) {
- //用户管理
- if (that.data.areaID != '') {
- data = '&put_area_id=' + that.data.areaID
- }
- url = 'user/list?page=' + that.data.userUrl;
- } else if (active == 2) {
- //车辆管理
- if (that.data.areaID != '') {
- data = '&put_area_id=' + that.data.areaID
- }
- url = 'bike/list?page=';
- } else if (active == 3) {
- //订单管理
- if (that.data.areaID != '') {
- data = '&put_area_id=' + that.data.areaID
- }
- if (that.data.curPage == 1) {
- url = 'order/list?page=';
- } else {
- url = 'orderRent/list?page=';
- }
- } else if (active == 4) {
- //工单管理
- if (that.data.areaID != '') {
- data = '&put_area_id=' + that.data.areaID
- }
- url = 'work_order/list?page=';
- }
- app.request(url + page + data + name, '', 'GET').then(res => {
- console.log(res)
- if (res.statusCode == 200) {
- if (res.data.data.length > 0) {
- wx.hideLoading()
- that.setData({
- page
- })
- if (active == 1) {
- that.setData({
- userList: that.data.userList.concat(res.data.data)
- })
- } else if (active == 2) {
- that.setData({
- bikeList: that.data.bikeList.concat(res.data.data)
- })
- } else if (active == 3) {
- that.setData({
- orderList: that.data.orderList.concat(res.data.data)
- })
- } else if (active == 4) {
- that.setData({
- work_orderList: that.data.work_orderList.concat(res.data.data)
- })
- }
- } else {
- wx.showToast({
- title: '暂无更多数据',
- icon: 'none'
- })
- }
- }
- })
- },
- users: function(e) {
- var that = this;
- var url = e.currentTarget.dataset.url;
- var data = ''
- if (url != '') {
- data = '&' + url
- }
- app.request('user/list/?page=1' + data, '', 'GET').then(res => {
- console.log(res, '用户')
- that.setData({
- userList: res.data.data,
- userUrl: data
- })
- })
- },
- detail: function(e) {
- //用户详情
- wx.navigateTo({
- url: '/pages/userDetail/userDetail?id=' + e.currentTarget.dataset.id,
- })
- },
- bike_detail: function(e) {
- //车辆详情
- var event = e.currentTarget.dataset
- wx.navigateTo({
- url: '/pages/carDetails/carDetails?id=' + event.id + '&bike_no=' + event.bike_no,
- })
- },
- orderDetail: function(e) {
- //订单详情
- wx.navigateTo({
- url: '/pages/orderDetail/orderDetail?id=' + e.currentTarget.dataset.id + '&index=' + this.data.curPage,
- })
- },
- wordDetail: function(e) {
- //工单详情
- wx.navigateTo({
- url: '/pages/workDetail/workDetail?id=' + e.currentTarget.dataset.id,
- })
- },
- onReady: function() {
- },
- onShow: function() {
- token = wx.getStorageSync('token')
- },
- onHide: function() {
- },
- onUnload: function() {
- },
- onPullDownRefresh: function() {
- wx.showNavigationBarLoading();
- this.screen(), wx.hideNavigationBarLoading(), wx.stopPullDownRefresh();
- },
- onReachBottom: function() {
- this.loadmore()
- },
- onShareAppMessage: function() {
- }
- })
|