微信小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

326 行
7.8 KiB

  1. import * as UTIL from '../../utils/util.js';
  2. import * as API from '../../utils/API.js';
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. isIPX: app.globalData.isIPX,
  10. show:false,
  11. accountList:[],
  12. approvalItemsOptions:[],
  13. bookName:'',
  14. accountListXJ:[],
  15. showDialog:false,
  16. projectId:'',
  17. beforeClose(action) {
  18. return new Promise((resolve) => {
  19. setTimeout(() => {
  20. if (action === 'confirm') {
  21. // 拦截确认操作
  22. resolve(false);
  23. } else {
  24. resolve(true);
  25. }
  26. }, 0);
  27. });
  28. }
  29. },
  30. /**
  31. * 生命周期函数--监听页面加载
  32. */
  33. onLoad: function (options) {
  34. },
  35. //跳转支出申请
  36. swichPaymentApply:function(e){
  37. console.log(e.currentTarget.dataset.current);
  38. // let cur = e.currentTarget.dataset.current;
  39. // if (this.data.currentTaB == cur) {
  40. // return false;
  41. // }else{
  42. // wx.navigateTo({
  43. // url: '../inCome/index?id=' + id,
  44. // })
  45. // }
  46. wx.navigateTo({
  47. url: '/pages/apply/paymentTemplate/add/add',
  48. })
  49. },
  50. openBox:function(){
  51. var that = this ;
  52. that.setData({
  53. show: true,
  54. })
  55. },
  56. closeBox:function(){
  57. var that = this ;
  58. that.setData({
  59. show: false,
  60. })
  61. },
  62. goTemplate:function(e){
  63. wx.navigateTo({
  64. url: 'paymentTemplate/add/add?id='+e.currentTarget.dataset.id+'&type=template'
  65. })
  66. },
  67. updateMoney:function(e){
  68. UTIL.showLoadingHaveMask('正在查询');
  69. UTIL.httpRequest(API.URL_GET_GETBALANCEENQUIRY+e.currentTarget.dataset.id, {method:'GET'}, {
  70. success: (res) => {
  71. if (res.code == API.SUCCESS_CODE) {
  72. this.setData({
  73. ["accountList["+e.currentTarget.dataset.index+"].balance"]:res.msg
  74. })
  75. UTIL.hideLoadingHaveMask();
  76. wx.showToast({
  77. title: '查询成功',
  78. icon: 'success',
  79. duration: 2000,
  80. })
  81. }else{
  82. UTIL.hideLoadingHaveMask();
  83. wx.showToast({
  84. title: '查询失败',
  85. icon: 'error',
  86. duration: 2000,
  87. })
  88. }
  89. }
  90. })
  91. },
  92. back:function(){
  93. wx.navigateBack({
  94. delta: 1
  95. })
  96. },
  97. /**
  98. * 生命周期函数--监听页面初次渲染完成
  99. */
  100. onReady: function () {
  101. },
  102. /**
  103. * 生命周期函数--监听页面显示
  104. */
  105. onShow: function () {
  106. var that = this;
  107. wx.showLoading({
  108. title: '正在加载账户',
  109. mask:true
  110. })
  111. var sendData = {
  112. pageNum:'1',
  113. pageSize:'100',
  114. accountName:'',
  115. bankAccountNumber:'',
  116. status:'N',
  117. method:'GET',
  118. accountType:102
  119. }
  120. var sendData2 = {
  121. pageNum:'1',
  122. pageSize:'100',
  123. accountName:'',
  124. bankAccountNumber:'',
  125. status:'N',
  126. method:'GET',
  127. accountType:101
  128. }
  129. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
  130. success: (res) => {
  131. this.setData({
  132. bankTypeOptions:res.data
  133. });
  134. }
  135. })
  136. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  137. success: (res) => {
  138. if (res.code == API.SUCCESS_CODE) {
  139. this.setData({bookName:res.user.bookName})
  140. }
  141. }
  142. })
  143. UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, {
  144. success: (res) => {
  145. if (res.code == API.SUCCESS_CODE) {
  146. that.setData({
  147. approvalItemsOptions : res.rows
  148. })
  149. }
  150. }
  151. })
  152. setTimeout(function(){
  153. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData,{
  154. success: (res) => {
  155. for (let i = 0; i < res.rows.length; i++) {
  156. if(res.rows[i].bankAccountNumber==null){continue;}
  157. res.rows[i].bankAccountNumber = res.rows[i].bankAccountNumber.replace(/(\d{4})(?=\d)/g, "$1 ");
  158. res.rows[i].balance = parseFloat(res.rows[i].balance).toFixed(2);
  159. res.rows[i].bankTypeText = UTIL.getTransform(res.rows[i].bankType,that.data.bankTypeOptions);
  160. }
  161. console.log(res.rows)
  162. that.setData({
  163. accountList:res.rows
  164. })
  165. wx.hideLoading();
  166. }
  167. })
  168. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData2,{
  169. success: (res) => {
  170. for (let i = 0; i < res.rows.length; i++) {
  171. if(res.rows[i].bankAccountNumber==null){continue;}
  172. res.rows[i].bankAccountNumber = res.rows[i].bankAccountNumber.replace(/(\d{4})(?=\d)/g, "$1 ")
  173. }
  174. console.log(res.rows)
  175. that.setData({
  176. accountListXJ:res.rows
  177. })
  178. }
  179. })
  180. },1000)
  181. },
  182. delete(e){
  183. console.log(e);
  184. var that = this;
  185. UTIL.httpRequest(API.URL_GET_REMOVEAPPROVAL + e.currentTarget.dataset.id, {method:'GET'},{
  186. success: (res) => {
  187. if (res.code == API.SUCCESS_CODE) {
  188. that.data.approvalItemsOptions.splice(e.currentTarget.dataset.index, 1);
  189. wx.showToast({
  190. title: '删除成功!',
  191. icon: 'success',
  192. duration: 2000
  193. })
  194. that.setData({
  195. approvalItemsOptions : that.data.approvalItemsOptions
  196. })
  197. }
  198. }
  199. })
  200. },
  201. getMr(e){
  202. var that = this;
  203. UTIL.httpRequest(API.URL_GET_GETSETDEFAULTVALUES + e.currentTarget.dataset.id, {method:'GET'},{
  204. success: (res) => {
  205. if (res.code == API.SUCCESS_CODE) {
  206. UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, {
  207. success: (res) => {
  208. if (res.code == API.SUCCESS_CODE) {
  209. wx.showToast({
  210. title: '设置成功!',
  211. icon: 'success',
  212. duration: 2000
  213. })
  214. that.setData({
  215. approvalItemsOptions : res.rows
  216. })
  217. }
  218. }
  219. })
  220. }
  221. }
  222. })
  223. },
  224. showDialog(e){
  225. var that = this ;
  226. that.setData({showDialog:true,projectId:e.currentTarget.dataset.id})
  227. },
  228. //支付口令修改
  229. edit(e){
  230. var that = this ;
  231. var zz = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\da-zA-Z~!@#$%^&*]{6,}$/;
  232. if(!(zz.test(that.data.password))){
  233. wx.showToast({
  234. title: '请根据提示修改',
  235. icon: 'error',
  236. duration: 2000,
  237. })
  238. return;
  239. }
  240. let data = {
  241. id: that.data.projectId ,
  242. accountPassword: that.data.password,
  243. method:'POST'
  244. }
  245. UTIL.httpRequest(API.URL_GET_PASSWORDEDIT, data,{
  246. success: (res) => {
  247. if (res.code == API.SUCCESS_CODE) {
  248. wx.showToast({
  249. title: '设置成功!',
  250. icon: 'success',
  251. duration: 2000
  252. })
  253. that.setData({
  254. showDialog : false,
  255. id: '' ,
  256. accountPassword: '',
  257. })
  258. }else if(res.code == "403"){
  259. wx.showToast({
  260. title: "无修改权限",
  261. icon: 'error',
  262. duration: 2000
  263. })
  264. }else{
  265. wx.showToast({
  266. title: "系统错误",
  267. icon: 'error',
  268. duration: 2000
  269. })
  270. }
  271. }
  272. })
  273. },
  274. bindNameInput(e){
  275. var that = this ;
  276. console.log(e);
  277. that.setData({password:e.detail.value});
  278. },
  279. /**
  280. * 生命周期函数--监听页面隐藏
  281. */
  282. onHide: function () {
  283. },
  284. /**
  285. * 生命周期函数--监听页面卸载
  286. */
  287. onUnload: function () {
  288. },
  289. /**
  290. * 页面相关事件处理函数--监听用户下拉动作
  291. */
  292. onPullDownRefresh: function () {
  293. },
  294. /**
  295. * 页面上拉触底事件的处理函数
  296. */
  297. onReachBottom: function () {
  298. },
  299. navigate(even){
  300. wx.navigateTo({
  301. url: even.currentTarget.dataset.url,
  302. })
  303. },
  304. /**
  305. * 用户点击右上角分享
  306. */
  307. onShareAppMessage: function () {
  308. }
  309. })