微信小程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

194 line
4.9 KiB

  1. // pages/payee/index.js
  2. import * as UTIL from '../../utils/util.js';
  3. import * as API from '../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. list: {},
  12. result: "",
  13. bankTypeOptions:[]
  14. },
  15. /**
  16. * 生命周期函数--监听页面加载
  17. */
  18. onLoad(options) {
  19. console.log(options)
  20. // 可优化:数据请求放到 onload中 新增后在子页面修改父页面数据
  21. var that = this;
  22. that.setData({
  23. isPeers:options.isPeers,//是否同行
  24. bankType:options.bankType,//所属银行
  25. accountType:options.accountType,//账户类型
  26. payeeType:options.transferType,//申请转帐类型
  27. index:options.index
  28. })
  29. var that = this;
  30. // 获取收款账号列表
  31. let prames = {
  32. pageNum:1,
  33. pageSize:999,
  34. orderByColumn:'id',
  35. isAsc:'asc',
  36. isPeers:that.data.isPeers,//是否同行
  37. bankType:that.data.bankType,//所属银行
  38. accountType:that.data.accountType,//账户类型
  39. payeeType:that.data.payeeType,//申请转帐类型
  40. status:'0',
  41. method:'GET'
  42. }
  43. console.log(prames);
  44. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
  45. success: (res) => {
  46. that.setData({
  47. bankTypeOptions:res.data,
  48. })
  49. }
  50. })
  51. UTIL.httpRequest(API.URL_GET_SELECTLIST , prames, {
  52. success: (res) => {
  53. let array = res.rows ;
  54. for (let i = 0; i < array.length; i++) {
  55. array[i].payeeAccountText = array[i].payeeAccount.replace(/^(.{6})(?:\d+)(.{4})$/,"\$1****\$2");
  56. console.log(that.data.bankTypeOptions.filter(function (e) { return e.dictValue == array[i].bankType; }));
  57. array[i].bankTypeText = (that.data.bankTypeOptions.filter(function (e) { return e.dictValue == array[i].bankType; }))[0].dictLabel;
  58. }
  59. that.setData({
  60. list:array,
  61. })
  62. }
  63. })
  64. },
  65. goAdd(){
  66. wx.navigateTo({
  67. url: 'add/add',
  68. })
  69. },
  70. goSearch(e){
  71. var that = this;
  72. // 获取收款账号列表
  73. let prames = {
  74. pageNum:1,
  75. pageSize:999,
  76. orderByColumn:'id',
  77. isAsc:'asc',
  78. isPeers:that.data.isPeers,//是否同行
  79. bankType:that.data.bankType,//所属银行
  80. accountType:that.data.accountType,//账户类型
  81. payeeType:that.data.payeeType,//申请转帐类型
  82. status:'0',
  83. name:e.detail,
  84. method:'GET'
  85. }
  86. console.log(prames);
  87. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
  88. success: (res) => {
  89. that.setData({
  90. bankTypeOptions:res.data,
  91. })
  92. }
  93. })
  94. UTIL.httpRequest(API.URL_GET_PAYEESELECTLIST , prames, {
  95. success: (res) => {
  96. let array = res.rows ;
  97. for (let i = 0; i < array.length; i++) {
  98. array[i].payeeAccountText = array[i].payeeAccount.replace(/^(.{6})(?:\d+)(.{4})$/,"\$1****\$2");
  99. array[i].bankTypeText = (that.data.bankTypeOptions.filter(function (e) { return e.dictValue == array[i].bankType; }))[0].dictLabel;
  100. }
  101. that.setData({
  102. list:array,
  103. })
  104. }
  105. })
  106. },
  107. /**
  108. * 生命周期函数--监听页面初次渲染完成
  109. */
  110. onReady() {
  111. },
  112. /**
  113. * 生命周期函数--监听页面显示
  114. */
  115. onShow() {
  116. },
  117. onChange(event) {
  118. console.log(event);
  119. this.setData({
  120. result: event.detail,
  121. });
  122. },
  123. toggle(event) {
  124. const { index } = event.currentTarget.dataset;
  125. const checkbox = this.selectComponent(`.checkboxes-${index}`);
  126. checkbox.toggle();
  127. },
  128. back:function(){
  129. wx.navigateBack({
  130. delta: 1
  131. })
  132. },
  133. noop() {},
  134. goSubmit(){
  135. var that = this;
  136. if(that.data.result == ''){
  137. UTIL.showToastNoneIcon('请选择一个收款人!');
  138. return;
  139. }
  140. let array = that.data.list.filter(function (e) { return e.id == that.data.result; });
  141. console.log(array);
  142. let pages = getCurrentPages();
  143. let currentPage = null; //当前页面
  144. let prevPage = null; //上一个页面
  145. currentPage = pages[pages.length - 1]; //获取当前页面,将其赋值
  146. prevPage = pages[pages.length - 2]; //获取上一个页面,将其赋值
  147. if (prevPage) {
  148. prevPage.setData({
  149. ["form.transfers["+that.data.index+"].payeeList[0]"]: array[0]//将想要传的信息赋值给上一个页面data中的值
  150. })
  151. that.back()
  152. }
  153. },
  154. /**
  155. * 生命周期函数--监听页面隐藏
  156. */
  157. onHide() {
  158. },
  159. /**
  160. * 生命周期函数--监听页面卸载
  161. */
  162. onUnload() {
  163. },
  164. /**
  165. * 页面相关事件处理函数--监听用户下拉动作
  166. */
  167. onPullDownRefresh() {
  168. },
  169. /**
  170. * 页面上拉触底事件的处理函数
  171. */
  172. onReachBottom() {
  173. },
  174. /**
  175. * 用户点击右上角分享
  176. */
  177. onShareAppMessage() {
  178. }
  179. })