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.
70 lines
2.1 KiB
70 lines
2.1 KiB
// pages/index/index.js
|
|
import { getBalanceInfo } from "../../../api/payment"
|
|
const math = require('../../../utils/math')
|
|
const event = require('../../../utils/event')
|
|
const app = getApp()
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
/** 页面的初始数据 */
|
|
data: {
|
|
firstShow: false,
|
|
height: app.globalData.safeFragmentHeight - 100,
|
|
tabList: [
|
|
{ status: 50, badge: '', name: '待预约', icon: '/assets/agent/icon-dyy.png' },
|
|
{ status: 51, badge: '', name: '待送货', icon: '/assets/agent/icon-dsh.png' },
|
|
{ status: 53, badge: '', name: '结算中', icon: '/assets/agent/icon-sjz.png' },
|
|
{ status: 54, badge: '', name: '已完成', icon: '/assets/agent/icon-ywc.png' }
|
|
],
|
|
banlanceInfo: {accountMoney: 0, frozenMoney: 0}
|
|
},
|
|
lifetimes: {
|
|
attached: function () {
|
|
event.on('EventMessage', this, this.onEvent)
|
|
},
|
|
detached: function () {
|
|
event.remove('EventMessage', this)
|
|
}
|
|
},
|
|
methods: {
|
|
onRestart: function () {
|
|
if(!this.data.firstShow) {
|
|
this.setData({ height: app.globalData.safeFragmentHeight - 100 })
|
|
}
|
|
this.fetchStatisticsInfo()
|
|
this.data.firstShow = true
|
|
},
|
|
onEvent: function (message) {
|
|
if (message.what == 888) {
|
|
}
|
|
},
|
|
fetchStatisticsInfo: function(loading){
|
|
getBalanceInfo().then(result => {
|
|
if(result.data){
|
|
result.data.accountMoney = math.minus(result.data.accountMoney, result.data.frozenMoney)
|
|
this.setData({ banlanceInfo: result.data })
|
|
}
|
|
if(loading){
|
|
wx.hideLoading()
|
|
}
|
|
}).catch(err => {
|
|
if(loading){
|
|
wx.hideLoading()
|
|
}
|
|
})
|
|
},
|
|
agentList: function (e) {
|
|
if(e.currentTarget.dataset.status){
|
|
wx.navigateTo({ url: `/pages/agent/order-list/index?status=${e.currentTarget.dataset.status}` })
|
|
} else {
|
|
wx.navigateTo({ url: `/pages/agent/order-list/index` })
|
|
}
|
|
},
|
|
settlementInfo: function(){
|
|
wx.navigateTo({ url: `/pages/settlement/index/index` })
|
|
}
|
|
}
|
|
})
|