微信小程序
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

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