You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
208 lines
7.5 KiB
208 lines
7.5 KiB
// pages/index/index.js
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { getStatisticsInfo } from "../../../api/saas"
|
|
import { headerFactoryId } from "../../../api/user"
|
|
import util from '../../../utils/util'
|
|
const event = require('../../../utils/event')
|
|
const app = getApp()
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
/** 页面的初始数据 */
|
|
data: {
|
|
userInfo: app.userInfo,
|
|
height: app.globalData.safeFragmentHeight,
|
|
customBar: app.globalData.CustomBar || (app.globalData.isIos ? 64 : 60),
|
|
tabList: [
|
|
{ status: 1, badge: '', name: '定价', icon: '/assets/image/icon_pricing.png' },
|
|
{ status: 2, badge: '', name: '过磅审核', icon: '/assets/image/icon_checking.png' },
|
|
{ status: 3, badge: '', name: '待付款', icon: '/assets/image/icon_payment.png' },
|
|
{ status: 4, badge: '', name: '已完成', icon: '/assets/image/icon_finish.png' }
|
|
],
|
|
tabList1: [
|
|
{ status: 1, badge: '', name: '待收货', icon: '/assets/image/icon_pricing.png' },
|
|
{ status: 2, badge: '', name: '待定价', icon: '/assets/image/icon_checking.png' },
|
|
{ status: 3, badge: '', name: '待付款', icon: '/assets/image/icon_payment.png' },
|
|
{ status: 4, badge: '', name: '已完成', icon: '/assets/image/icon_finish.png' }
|
|
],
|
|
show: false,
|
|
totalInfo: {
|
|
totalMoney: 0,
|
|
totalWeight: 0,
|
|
availableCreditLine: 0,
|
|
usedCreditLine: 0
|
|
},
|
|
vdate: [],
|
|
vdateString: '',
|
|
factoryId: '12313K78978KK',
|
|
factoryList: [
|
|
{id: '12313000KK12K', name: '济州岛打包站'},
|
|
{id: '12313K78978KK', name: '福州道打包站'},
|
|
{id: '1231345500KKK', name: '钟落潭打包站'},
|
|
{id: '12345678978KK', name: '鹤山常服打包站'},
|
|
{id: '123sdfsdf00KKK', name: '合剂打包站'},
|
|
{id: '1231332K78978K', name: '永宁街打包站'},
|
|
{id: '123242K78978KK', name: '河西路打包站'},
|
|
{id: '12313378978KK5', name: '成林道打包站'}
|
|
],
|
|
visible: false,
|
|
actions: [
|
|
{ id: 1, name: '厂内收货' },
|
|
{ id: 2, name: '厂外收货' },
|
|
{ id: '', name: '全部' }
|
|
],
|
|
sheetStr: '全部',
|
|
sheet: false
|
|
},
|
|
lifetimes: {
|
|
attached: function () {
|
|
var min = new Date()
|
|
min.setFullYear(min.getFullYear() - 1, min.getMonth(), min.getDate())
|
|
min.setHours(0, 0, 0)
|
|
var minDate = min.getTime()
|
|
var max = new Date(new Date().getTime() + 24 * 60 * 60 * 1000)
|
|
max.setHours(0, 0, 0)
|
|
var maxDate = max.getTime()
|
|
var today = new Date()
|
|
today.setHours(0, 0, 0)
|
|
var vdate = [today.getTime(), maxDate]
|
|
var vdateString = util.formatDate(new Date(), 'Y-M-D') + '至' + util.formatDate(max, 'Y-M-D')
|
|
var height = app.globalData.safeFragmentHeight - 100
|
|
var customBar = app.globalData.CustomBar || (app.globalData.isIos ? 64 : 60)
|
|
if(app.userInfo.type && app.userInfo.type.indexOf('ADMIN') >= 0){
|
|
this.setData({userInfo: app.userInfo, height, minDate, maxDate, vdate, vdateString, customBar})
|
|
} else {
|
|
this.setData({userInfo: app.userInfo, height, minDate, maxDate, vdate, vdateString, customBar })
|
|
}
|
|
event.on('EventMessage', this, this.onEvent)
|
|
},
|
|
detached: function () {
|
|
event.remove('EventMessage', this)
|
|
}
|
|
},
|
|
methods: {
|
|
onRestart: function () {
|
|
this.fetchStatisticsInfo(this.data.vdate)
|
|
},
|
|
onEvent: function (message) {
|
|
if (message.what == 888) {
|
|
}
|
|
},
|
|
orderList: function (e) {
|
|
wx.navigateTo({ url: '/pages/process/order-list/index' })
|
|
},
|
|
agentList: function (e) {
|
|
// this.showFactoryList()
|
|
wx.navigateTo({ url: '/pages/process/agent-list/index' })
|
|
},
|
|
checkList: function (e) {
|
|
if(app.userInfo.applicationStatus == 0){
|
|
Dialog.alert({ title: '温馨提示', message: '您的申请还在审核中,如有疑问请联系管理员。' }).then(() => {
|
|
})
|
|
return
|
|
}
|
|
if(e.currentTarget.dataset.status == 3){
|
|
wx.navigateTo({ url: '/pages/process/payment-list/index?status=' + e.currentTarget.dataset.status })
|
|
} else if(e.currentTarget.dataset.status == 4){
|
|
wx.navigateTo({ url: '/pages/process/order-list/index?status=' + e.currentTarget.dataset.status })
|
|
} else {
|
|
wx.navigateTo({ url: '/pages/process/check-list/index?status=' + e.currentTarget.dataset.status })
|
|
}
|
|
},
|
|
outsideList: function(e){
|
|
if(e.currentTarget.dataset.status){
|
|
wx.navigateTo({ url: `/pages/process/outside-list/index?status=${e.currentTarget.dataset.status}` })
|
|
} else {
|
|
wx.navigateTo({ url: `/pages/process/outside-list/index` })
|
|
}
|
|
},
|
|
fetchStatisticsInfo: function(vdate, loading){
|
|
var param = {startTime: util.formatTime(new Date(vdate[0]), 'Y-M-D'), endTime: util.formatTime(new Date(vdate[1]), 'Y-M-D')}
|
|
getStatisticsInfo(param).then(result => {
|
|
if(Number(result.data.priceOrderNum) > 0){
|
|
this.data.tabList[0].badge = Number(result.data.priceOrderNum)
|
|
} else {
|
|
this.data.tabList[0].badge = ''
|
|
}
|
|
if(Number(result.data.waitAuditOrderNum) > 0){
|
|
this.data.tabList[1].badge = Number(result.data.waitAuditOrderNum)
|
|
} else {
|
|
this.data.tabList[1].badge = ''
|
|
}
|
|
if(Number(result.data.waitPayOrderNum) > 0){
|
|
this.data.tabList[2].badge = Number(result.data.waitPayOrderNum)
|
|
} else {
|
|
this.data.tabList[2].badge = ''
|
|
}
|
|
if(util.isEmpty(result.data.availableCreditLine)){
|
|
result.data.availableCreditLine = app.userInfo.availableCreditLine
|
|
}
|
|
if(util.isEmpty(result.data.usedCreditLine)){
|
|
result.data.usedCreditLine = app.userInfo.usedCreditLine
|
|
}
|
|
var vdateString = util.formatDate(new Date(vdate[0]), 'Y-M-D') + '至' + util.formatDate(new Date(vdate[1]), 'Y-M-D')
|
|
this.setData({ tabList: this.data.tabList, totalInfo: result.data, vdate, vdateString })
|
|
if(loading){
|
|
wx.hideLoading()
|
|
}
|
|
}).catch(err => {
|
|
if(loading){
|
|
wx.hideLoading()
|
|
}
|
|
})
|
|
},
|
|
showCalendar: function(){
|
|
this.setData({ show: true })
|
|
this.triggerEvent("zIndex", -1)
|
|
},
|
|
onClose: function() {
|
|
this.setData({ show: false })
|
|
this.trigEvent(9)
|
|
},
|
|
onSelect: function({detail}) {
|
|
const [start, end] = detail
|
|
this.onClose()
|
|
this.fetchStatisticsInfo([start.getTime(), end.getTime()])
|
|
},
|
|
toAuths: function(){
|
|
wx.navigateTo({ url: '/pages/htmls/auths/index' })
|
|
},
|
|
showFactoryList: function(){
|
|
this.setData({ visible: true })
|
|
this.triggerEvent("zIndex", -1)
|
|
},
|
|
onHide: function(){
|
|
this.setData({ visible: false })
|
|
this.trigEvent(9)
|
|
},
|
|
changeFactory: function(e){
|
|
var item = this.data.factoryList[e.currentTarget.dataset.index]
|
|
wx.showLoading({ title: '正在切换', mask: true })
|
|
headerFactoryId(item.id)
|
|
event.emit('EventMessage', { what: 999, desc: 'changeFactory' })
|
|
this.setData({ visible: false, factoryId: item.id })
|
|
this.trigEvent(9)
|
|
this.fetchStatisticsInfo(this.data.vdate, true)
|
|
},
|
|
trigEvent: function(zIndex){
|
|
setTimeout(() => {
|
|
this.triggerEvent('zIndex', zIndex)
|
|
}, 100);
|
|
},
|
|
showSheet: function(){
|
|
this.setData({ sheet: true })
|
|
this.triggerEvent("zIndex", -1)
|
|
},
|
|
onCancel: function(){
|
|
this.setData({ sheet: false })
|
|
this.trigEvent(9)
|
|
},
|
|
onAction: function({detail}){
|
|
this.setData({ sheetStr: detail.name })
|
|
|
|
}
|
|
}
|
|
})
|