微信小程序
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.

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