effectiveapproval.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. // customer/pages/effectiveapproval/effectiveapproval.js
  2. const App = getApp();
  3. const utils = require("../../../utils/http");
  4. var page = 1;
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. showSearch: true,
  11. showInput: true,
  12. datashow: false,
  13. listArr: [],
  14. keyword: '',
  15. check_state: '',
  16. showText: '全部',
  17. showType: 1
  18. },
  19. /**
  20. * 生命周期函数--监听页面加载
  21. */
  22. onLoad(options) {
  23. page = 1;
  24. if (options.type == 2) {
  25. this.setData({
  26. showInput: false,
  27. showType: options.type
  28. })
  29. wx.setNavigationBarTitle({
  30. title: '有效客户申请',
  31. })
  32. } else {
  33. this.setData({
  34. showType: 1
  35. })
  36. }
  37. this.getApprovallist();
  38. },
  39. getInputValue(e) {
  40. this.setData({
  41. keyword: e.detail.value
  42. })
  43. },
  44. handleSearch() {
  45. this.setData({
  46. showSearch: !this.data.showSearch
  47. })
  48. },
  49. handleInput() {
  50. this.setData({
  51. showInput: !this.data.showInput
  52. })
  53. },
  54. onSearch(e) {
  55. let val = e.currentTarget.dataset.val;
  56. let text = e.currentTarget.dataset.text;
  57. this.setData({
  58. check_state: val || '',
  59. showSearch: true,
  60. showText: text
  61. })
  62. page = 1;
  63. this.getApprovallist();
  64. },
  65. toCustomer(e) {
  66. let id = e.currentTarget.dataset.id;
  67. wx.navigateTo({
  68. url: '/mycustomer/pages/customermsg/customermsg?cid=' + id,
  69. })
  70. },
  71. handleAppvalClick(e) {
  72. let type = e.currentTarget.dataset.type;
  73. let id = e.currentTarget.dataset.id;
  74. var that = this;
  75. wx.showLoading();
  76. utils.$post({
  77. url: App.globalData.webUrl + 'api/valid_check/check',
  78. header: {
  79. 'Authorization': 'bearer ' + App.globalData.token
  80. },
  81. data: {
  82. customer_id: id,
  83. state: type,
  84. },
  85. success: function (res) {
  86. wx.hideLoading();
  87. if (res.data.code == '0') {
  88. wx.showToast({
  89. title: '审核成功',
  90. })
  91. page = 1;
  92. this.getApprovallist();
  93. }
  94. }
  95. })
  96. },
  97. getApprovallist() {
  98. var that = this;
  99. wx.showLoading({
  100. title: '加载中...',
  101. })
  102. let apiStr = this.data.showType == 1 ? 'api/valid_check/list' : 'api/valid_check/apply_list';
  103. utils.$post({
  104. url: App.globalData.webUrl + apiStr,
  105. header: {
  106. 'Authorization': 'bearer ' + App.globalData.token
  107. },
  108. data: {
  109. page: page,
  110. limit: 20,
  111. keyword: that.data.keyword,
  112. state: that.data.check_state
  113. },
  114. success: function (res) {
  115. wx.hideLoading();
  116. if (res.data.code == '0') {
  117. that.setData({
  118. listArr: res.data.data,
  119. datashow: true
  120. })
  121. }
  122. }
  123. })
  124. },
  125. /**
  126. * 生命周期函数--监听页面初次渲染完成
  127. */
  128. onReady() {
  129. },
  130. /**
  131. * 生命周期函数--监听页面显示
  132. */
  133. onShow() {
  134. },
  135. /**
  136. * 生命周期函数--监听页面隐藏
  137. */
  138. onHide() {
  139. },
  140. /**
  141. * 生命周期函数--监听页面卸载
  142. */
  143. onUnload() {
  144. },
  145. /**
  146. * 页面相关事件处理函数--监听用户下拉动作
  147. */
  148. onPullDownRefresh() {
  149. page = 1;
  150. this.getApprovallist();
  151. let timer = setTimeout(() => {
  152. wx.stopPullDownRefresh();
  153. clearTimeout(timer);
  154. }, 600)
  155. },
  156. /**
  157. * 页面上拉触底事件的处理函数
  158. */
  159. onReachBottom() {
  160. page = page + 1;
  161. var that = this;
  162. wx.showLoading({
  163. title: '加载中...',
  164. })
  165. let apiStr = this.data.showType == 1 ? 'api/valid_check/list' : 'api/valid_check/apply_list';
  166. utils.$post({
  167. url: App.globalData.webUrl + apiStr,
  168. header: {
  169. 'Authorization': 'bearer ' + App.globalData.token
  170. },
  171. data: {
  172. page: page,
  173. limit: 20,
  174. keyword: that.data.keyword,
  175. state: that.data.check_state
  176. },
  177. success: function (res) {
  178. wx.hideLoading();
  179. if (res.data.code == '0') {
  180. let dataArr = that.data.listArr.concat(res.data.data);
  181. that.setData({
  182. listArr: dataArr,
  183. datashow: true
  184. })
  185. }
  186. }
  187. })
  188. },
  189. /**
  190. * 用户点击右上角分享
  191. */
  192. onShareAppMessage() {
  193. }
  194. })