// customer/pages/effectiveapproval/effectiveapproval.js const App = getApp(); const utils = require("../../../utils/http"); var page = 1; Page({ /** * 页面的初始数据 */ data: { showSearch: true, showInput: true, datashow: false, listArr: [], keyword: '', check_state: '', showText: '全部', showType: 1 }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { page = 1; if (options.type == 2) { this.setData({ showInput: false, showType: options.type }) wx.setNavigationBarTitle({ title: '有效客户申请', }) } else { this.setData({ showType: 1 }) } this.getApprovallist(); }, getInputValue(e) { this.setData({ keyword: e.detail.value }) }, handleSearch() { this.setData({ showSearch: !this.data.showSearch }) }, handleInput() { this.setData({ showInput: !this.data.showInput }) }, onSearch(e) { let val = e.currentTarget.dataset.val; let text = e.currentTarget.dataset.text; this.setData({ check_state: val || '', showSearch: true, showText: text }) page = 1; this.getApprovallist(); }, toCustomer(e) { let id = e.currentTarget.dataset.id; wx.navigateTo({ url: '/mycustomer/pages/customermsg/customermsg?cid=' + id, }) }, handleAppvalClick(e) { let type = e.currentTarget.dataset.type; let id = e.currentTarget.dataset.id; var that = this; wx.showLoading(); utils.$post({ url: App.globalData.webUrl + 'api/valid_check/check', header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { customer_id: id, state: type, }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { wx.showToast({ title: '审核成功', }) page = 1; this.getApprovallist(); } } }) }, getApprovallist() { var that = this; wx.showLoading({ title: '加载中...', }) let apiStr = this.data.showType == 1 ? 'api/valid_check/list' : 'api/valid_check/apply_list'; utils.$post({ url: App.globalData.webUrl + apiStr, header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { page: page, limit: 20, keyword: that.data.keyword, state: that.data.check_state }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { that.setData({ listArr: res.data.data, datashow: true }) } } }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { page = 1; this.getApprovallist(); let timer = setTimeout(() => { wx.stopPullDownRefresh(); clearTimeout(timer); }, 600) }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { page = page + 1; var that = this; wx.showLoading({ title: '加载中...', }) let apiStr = this.data.showType == 1 ? 'api/valid_check/list' : 'api/valid_check/apply_list'; utils.$post({ url: App.globalData.webUrl + apiStr, header: { 'Authorization': 'bearer ' + App.globalData.token }, data: { page: page, limit: 20, keyword: that.data.keyword, state: that.data.check_state }, success: function (res) { wx.hideLoading(); if (res.data.code == '0') { let dataArr = that.data.listArr.concat(res.data.data); that.setData({ listArr: dataArr, datashow: true }) } } }) }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })