crm_second_opening_mini/pagesA/bills/index.js

152 lines
3.0 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// pagesA/bills/index.js
require('../common/vendor.js');
const app = getApp(); //全局app
Page({
/**
* 页面的初始数据
*/
data: {
BASE_IMG_URL: app.globalData.BASE_IMG_URL,
BASE_URL:app.globalData.BASE_URL,
page: 1,
total: '',
list: [],
queryParams: {},
moneyInfo: {}
},
/**
* 生命周期函数--监听页面加载
*/
onLoad(options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow() {
this.data.page = 1;
this.getBillList();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom() {
let that = this;
let page = that.data.page;
that.setData({
page: page + 1
});
console.log(that.data.page)
that.getBillList();
},
getBillList() {
let that = this;
wx.request({
url: this.data.BASE_URL + '/addons/crmx/bill/getBillList',
data: {
page: that.data.page
},
header: {
'content-type': 'application/json', // 默认值
'token': wx.getStorageSync('token'),
},
success (res) {
if(res.data.code == 1) {
console.log(res.data)
let total = res.data.data.total;
if(that.data.page == 1) {
that.setData({
list:[]
})
}
if(res.data.data.list && total > that.data.list.length) {
let list = that.data.list;
list = list.concat(res.data.data.list);
that.setData({
list:list
})
}
}
}
})
},
addBills() {
wx.navigateTo({
url: '/pages/index/groupCompany/bills/addBills',
})
},
// 修改
revise(e) {
console.log(e);
let id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/index/groupCompany/bills/addBills?id=' + id,
})
},
//删除
delete(e) {
let that = this;
let id = e.currentTarget.dataset.id;
wx.request({
url: this.data.BASE_URL + '/addons/crmx/bill/delBill',
data: {
id: id
},
header: {
'content-type': 'application/json', // 默认值
'token': wx.getStorageSync('token'),
},
success (res) {
console.log(res.data,'删除成功')
wx.showToast({
title:"删除成功",
icon: 'success',//图标,支持"success"、"loading"
duration: 1200,//提示的延迟时间单位毫秒默认1500
mask: false,//是否显示透明蒙层防止触摸穿透默认false
})
setTimeout(function(){
that.setData({
page:1
})
that.getBillList();
},1400)
}
})
}
})