微信小程序
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

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