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

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