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

116 lines
3.3 KiB

// pages/home/customer/index.js
import { generateCode } from "../../../api/user"
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,
customerName: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({ height: app.globalData.fragmentHeight - 100 })
this.fetchCustomerList()
},
onRefreshList: function () {
if (this.data.requesting) {
return
}
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/home/customer-info/index?id=' + e.currentTarget.dataset.id })
},
onClickHideEmbedded: function(){
this.setData({ showEmbedded: false })
},
bindCustomer: function(e){
var item = this.data.orderList[e.currentTarget.dataset.page][e.currentTarget.dataset.index]
wx.navigateTo({ url: `/pages/client/registe/index?id=${item.id}` })
// wx.showLoading({ title: '加载中', mask: true })
// const form = { id: 6 }
// form.metaData = {
// factoryId: app.userInfo.factoryId,
// factoryName: app.userInfo.factoryName,
// factoryCustomerId: item.id,
// factoryCustomerName: item.name,
// factoryCustomerMobile: item.mobile
// }
// generateCode(form).then(result => {
// this.setData({ showEmbedded: true, base64: result.data, customerName: item.name })
// wx.hideLoading()
// }).catch(err => {
// wx.hideLoading()
// util.showToast(err)
// })
}
})