微信小程序
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

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