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.
147 lines
5.6 KiB
147 lines
5.6 KiB
// pages/index/index.js
|
|
import Dialog from '../../../components/dialog/dialog'
|
|
import { getStatisticsInfo } from "../../../api/saas"
|
|
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,
|
|
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' },
|
|
// { status: 5, badge: '', name: '已关闭', icon: '/assets/image/icon_close.png' }
|
|
],
|
|
tabList2: [
|
|
{ status: 1, badge: '', name: '出库', icon: '/assets/image/icon_checking.png' },
|
|
{ status: 2, badge: '', name: '出库查询', icon: '/assets/image/icon_checking.png' },
|
|
{ status: 3, badge: '', name: '出库总汇', icon: '/assets/image/icon_finish.png' },
|
|
// { status: 5, badge: '', name: '已关闭', icon: '/assets/image/icon_close.png' }
|
|
],
|
|
show: false,
|
|
totalInfo: {
|
|
totalMoney: 0,
|
|
totalWeight: 0,
|
|
availableCreditLine: 0,
|
|
usedCreditLine: 0
|
|
},
|
|
vdate: [],
|
|
vdateString: ''
|
|
},
|
|
lifetimes: {
|
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
|
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')
|
|
this.setData({userInfo: app.userInfo, height: app.globalData.safeFragmentHeight - 100, minDate, maxDate, vdate, vdateString })
|
|
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) {
|
|
wx.navigateTo({ url: '/pages/process/agent-list/index' })
|
|
},
|
|
checkList: function (e) {
|
|
// if(!app.userInfo.isSaasPerssion){
|
|
// Dialog.alert({ title: '温馨提示', message: '您还不是纸通宝SAAS的授权客户,无法使用,如有疑问请联系相关客服人员。' }).then(() => {
|
|
// })
|
|
// return
|
|
// }
|
|
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 })
|
|
}
|
|
},
|
|
outList: function(e){
|
|
|
|
},
|
|
fetchStatisticsInfo: function(vdate){
|
|
getStatisticsInfo({startTime: util.formatTime(new Date(vdate[0]), 'Y-M-D'), endTime: util.formatTime(new Date(vdate[1]), 'Y-M-D')}).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 })
|
|
}).catch(err => {
|
|
console.log(err)
|
|
})
|
|
},
|
|
showSheet: function(){
|
|
this.setData({ show: true })
|
|
event.emit('TabMessage', { what: 99, visiable: false })
|
|
},
|
|
onClose: function() {
|
|
this.setData({ show: false })
|
|
setTimeout(function(){
|
|
event.emit('TabMessage', { what: 99, visiable: true })
|
|
}, 100)
|
|
},
|
|
onSelect: function({detail}) {
|
|
const [start, end] = detail
|
|
this.onClose()
|
|
this.fetchStatisticsInfo([start.getTime(), end.getTime()])
|
|
},
|
|
toAuths: function(){
|
|
wx.navigateTo({ url: '/pages/htmls/auths/index' })
|
|
}
|
|
}
|
|
})
|