纸通宝SAAS仓库
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.
 

107 lines
2.9 KiB

// pages/home/customer/index.js
import { getCustomerList } from "../../../api/saas"
const util = require('../../../utils/util')
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
height: app.globalData.fragmentHeight - 100,
loading: true,
requesting: false,
finished: false,
top: 0,
orderList: [],
form: {
name: '',
pageNum: 1,
pageSize: 10
},
base64: null,
showEmbedded: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({ height: app.globalData.fragmentHeight - 100 })
this.fetchCustomerList()
},
onRefreshList: function () {
this.setData({
orderList: [],
['form.pageNum']: 1,
loading: true,
finished: false
})
this.fetchCustomerList()
},
//1:待定价,2:待过皮重,3:待过磅审核,4:待付款,5:已完成
fetchCustomerList: function () {
if (this.data.requesting || this.data.finished) {
return
}
if (this.data.loading) {
this.data.requesting = true
} else {
this.setData({ requesting: true })
}
getCustomerList(this.data.form).then(result => {
if (result.data && result.data.records.length) {
var respList = result.data.records
let nowList = `orderList[${this.data.orderList.length}]`
var num = this.data.form.pageNum
var finished = ((num - 1) * this.data.form.pageSize + respList.length) >= result.data.total
if(this.data.form.pageNum == 1){
this.setData({
[nowList]: respList,
['form.pageNum']: (num + 1),
top: 0,
finished,
requesting: false,
loading: false
})
} else {
this.setData({
[nowList]: respList,
['form.pageNum']: (num + 1),
finished,
requesting: false,
loading: false
})
}
} else {
this.setData({ finished: true, requesting: false, loading: false })
}
}).catch(err => {
this.setData({ requesting: false, loading: false })
util.showToast(err)
})
},
onChange({detail}) {
this.data.form.name = detail
},
onSearch:function(){
this.onRefreshList()
},
customerInfo: function(e){
wx.navigateTo({ url: '/pages/process/customer-info/index?id=' + e.currentTarget.dataset.id })
},
onClickHideEmbedded: function(){
this.setData({ showEmbedded: false })
},
addEmployee: function(event){
wx.showLoading({ title: '加载中', mask: true })
const form = { id: 5 }
form.metaData = { factoryId: app.userInfo.factoryId, factoryName: app.userInfo.factoryName }
generateCode(form).then(result => {
this.setData({ showEmbedded: true, base64: result.data })
wx.hideLoading()
}).catch(err => {
wx.hideLoading()
util.showToast(err)
})
}
})