Files
income_payments_applet/pages/personList/personList.js
T
2021-10-27 12:26:14 +08:00

225 lines
5.0 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// pages/personList/personList.js
import signUpApi from "../../assets/js/http/signUp"
Page({
/**
* 页面的初始数据
*/
data: {
// 列表查询条件
queryParam: {
companyId: '',
pageNo: 1,
pageSize: 10,
name: '',
column:'createTime',
order:'desc'
},
// 数据
dataSource: [],
// 选择参会人 还是 选择邮寄联系人 1 是参会人 2 是邮寄联系人
selectType:"",
// 是否是从国际研讨会跳过来的
page:'',
// 是否调用无权限接口
nolimitBool:false
},
// 输入查询条件
bindInputName(e) {
this.setData({
"queryParam.name": e.detail.value
})
},
// 查询
search() {
this.data.queryParam.pageNo = 1
this.loadData()
},
// 重置
reset() {
this.setData({
'queryParam.name': ''
})
this.search()
},
// 创建新的联系人
addPerson(e) {
console.log(e);
wx.navigateTo({
url: `../addPerson/addPerson?prepage=${e.currentTarget.dataset.prepage}`,
})
},
// 选中联系人
selectedItem(e) {
let pages = getCurrentPages()
let prevPage = pages[pages.length - 2];
const that = this
// 带过去的信息
let selectedPerson = e.currentTarget.dataset.person
wx.showModal({
title: '提示',
content: '是否选中该联系人',
success: function (res) {
if (res.confirm) {
//这里是点击了确定以后
if(that.data.selectType === '1'){
prevPage.setData({
'selectedPerson.name':selectedPerson.name,
'selectedPerson.id':selectedPerson.id
})
wx.navigateBack({
delta: 1,
})
}else if(that.data.selectType === '2' ){
prevPage.setData({
'selectedPostPerson.name':selectedPerson.name,
'selectedPostPerson.id':selectedPerson.id,
'selectedPostPerson.contactAddress':selectedPerson.contactAddress,
'selectedPostPerson.postalCode':selectedPerson.postalCode,
})
wx.navigateBack({
delta: 1,
})
}else{
// selectType不存在的情况
console.log('这里应该写什么么 ');
}
} else {
//这里是点击了取消以后
}
}
})
},
// 加载联系人列表
loadData() {
console.log('联系人列表',this.data.nolimitBool);
wx.showToast({
title: '加载中...',
icon: 'loading',
duration: 1000
})
if(this.data.nolimitBool){
signUpApi.personListNolimit(this.data.queryParam).then(res => {
if (res.success) {
// 搜索时,把原数据清空,重新筛选
if(this.data.queryParam.pageNo === 1) {
this.setData({
dataSource: []
})
}
if(res.result && res.result.length){
this.setData({
dataSource: [...this.data.dataSource, ...res.result]
})
}
}
}).catch(err => {
wx.showToast({
title: '加载失败',
icon: 'none',
duration: 1000
})
})
}else{
signUpApi.personList(this.data.queryParam).then(res => {
if (res.success) {
// 搜索时,把原数据清空,重新筛选
if(this.data.queryParam.pageNo === 1) {
this.setData({
dataSource: []
})
}
if(res.result && res.result.length){
this.setData({
dataSource: [...this.data.dataSource, ...res.result]
})
}
}
}).catch(err => {
wx.showToast({
title: '加载失败',
icon: 'none',
duration: 1000
})
})
}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options);
if(options.nolimit){
this.setData({
nolimitBool:true
})
}
this.setData({
'queryParam.companyId':options.companyId,
selectType:options.selectType,
page:options.page
})
this.loadData()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
const that = this
wx.getStorage({
key:'nolimit',
success(res){
that.setData({
nolimitBool:res.data
})
}
})
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.data.searchParams.pageNo++
this.loadData()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})