import * as UTIL from '../../utils/util.js'; import * as API from '../../utils/API.js'; const app = getApp(); Page({ /** * 页面的初始数据 */ data: { isIPX: app.globalData.isIPX, show:false, accountList:[], approvalItemsOptions:[], bookName:'', accountListXJ:[], showDialog:false, projectId:'', bankName:'', beforeClose(action) { return new Promise((resolve) => { setTimeout(() => { if (action === 'confirm') { // 拦截确认操作 resolve(false); } else { resolve(true); } }, 0); }); } }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { }, //跳转支出申请 swichPaymentApply:function(e){ console.log(e.currentTarget.dataset.current); // let cur = e.currentTarget.dataset.current; // if (this.data.currentTaB == cur) { // return false; // }else{ // wx.navigateTo({ // url: '../inCome/index?id=' + id, // }) // } wx.navigateTo({ url: '/pages/apply/paymentTemplate/add/add', }) }, openBox:function(){ var that = this ; that.setData({ show: true, }) }, closeBox:function(){ var that = this ; that.setData({ show: false, }) }, goTemplate:function(e){ wx.navigateTo({ url: 'paymentTemplate/add/add?id='+e.currentTarget.dataset.id+'&type=template' }) }, updateMoney:function(e){ UTIL.showLoadingHaveMask('正在查询'); UTIL.httpRequest(API.URL_GET_GETBALANCEENQUIRY+e.currentTarget.dataset.id, {method:'GET'}, { success: (res) => { if (res.code == API.SUCCESS_CODE) { this.setData({ ["accountList["+e.currentTarget.dataset.index+"].balance"]:res.msg }) UTIL.hideLoadingHaveMask(); wx.showToast({ title: '查询成功', icon: 'success', duration: 2000, }) }else{ UTIL.hideLoadingHaveMask(); wx.showToast({ title: '查询失败', icon: 'error', duration: 2000, }) } } }) }, back:function(){ wx.navigateBack({ delta: 1 }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { var that = this; wx.showLoading({ title: '正在加载账户', mask:true }) var sendData = { pageNum:'1', pageSize:'100', accountName:'', bankAccountNumber:'', status:'N', method:'GET', accountType:102 } var sendData2 = { pageNum:'1', pageSize:'100', accountName:'', bankAccountNumber:'', status:'N', method:'GET', accountType:101 } UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, { success: (res) => { this.setData({ bankTypeOptions:res.data }); } }) UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, { success: (res) => { if (res.code == API.SUCCESS_CODE) { this.setData({bookName:res.user.bookName}) } } }) UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, { success: (res) => { if (res.code == API.SUCCESS_CODE) { that.setData({ approvalItemsOptions : res.rows }) } } }) setTimeout(function(){ UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData,{ success: (res) => { for (let i = 0; i < res.rows.length; i++) { if(res.rows[i].bankAccountNumber==null){continue;} res.rows[i].bankAccountNumber = res.rows[i].bankAccountNumber.replace(/(\d{4})(?=\d)/g, "$1 "); res.rows[i].balance = Number(res.rows[i].balance).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => { return $1 + ","; }).replace(/\.$/, ""); res.rows[i].bankTypeText = UTIL.getTransform(res.rows[i].bankType,that.data.bankTypeOptions); } console.log(res.rows) that.setData({ accountList:res.rows }) wx.hideLoading(); } }) UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData2,{ success: (res) => { for (let i = 0; i < res.rows.length; i++) { res.rows[i].balance = Number(res.rows[i].balance).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => { return $1 + ","; }).replace(/\.$/, ""); } console.log(res.rows) that.setData({ accountListXJ:res.rows }) } }) },1000) }, delete(e){ console.log(e); var that = this; UTIL.httpRequest(API.URL_GET_REMOVEAPPROVAL + e.currentTarget.dataset.id, {method:'GET'},{ success: (res) => { if (res.code == API.SUCCESS_CODE) { that.data.approvalItemsOptions.splice(e.currentTarget.dataset.index, 1); wx.showToast({ title: '删除成功!', icon: 'success', duration: 2000 }) that.setData({ approvalItemsOptions : that.data.approvalItemsOptions }) } } }) }, getMr(e){ var that = this; UTIL.httpRequest(API.URL_GET_GETSETDEFAULTVALUES + e.currentTarget.dataset.id, {method:'GET'},{ success: (res) => { if (res.code == API.SUCCESS_CODE) { UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, { success: (res) => { if (res.code == API.SUCCESS_CODE) { wx.showToast({ title: '设置成功!', icon: 'success', duration: 2000 }) that.setData({ approvalItemsOptions : res.rows }) } } }) } } }) }, showDialog(e){ var that = this ; that.setData({ showDialog:true, projectId:e.currentTarget.dataset.id, bankName:e.currentTarget.dataset.name, id: '' , password: '',}) }, //支付口令修改 edit(e){ var that = this ; var zz = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\da-zA-Z~!@#$%^&*]{6,}$/; if(!(zz.test(that.data.password))){ wx.showToast({ title: '请根据提示修改', icon: 'error', duration: 2000, }) return; } let data = { id: that.data.projectId , accountPassword: that.data.password, method:'POST' } UTIL.httpRequest(API.URL_GET_PASSWORDEDIT, data,{ success: (res) => { if (res.code == API.SUCCESS_CODE) { wx.showToast({ title: '设置成功!', icon: 'success', duration: 2000 }) that.setData({ showDialog : false, }) }else if(res.code == "403"){ wx.showToast({ title: "无修改权限", icon: 'error', duration: 2000 }) that.setData({ showDialog : false, }) }else{ wx.showToast({ title: "系统错误", icon: 'error', duration: 2000 }) } } }) }, bindNameInput(e){ var that = this ; console.log(e); that.setData({password:e.detail.value}); }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, navigate(even){ wx.navigateTo({ url: even.currentTarget.dataset.url, }) }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { } })