approval.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. // pages/Hisorders/Hisorders.js
  2. var BASEURL = require('../../utils/wxconstant.js')
  3. var baseUrl = BASEURL.BaseUrl()
  4. var baseutils = require('../../utils/baseUtils.js')
  5. var netUtil = require('../../utils/network.js')
  6. var pageSize = 1
  7. var isregistered
  8. Page({
  9. /**
  10. * 页面的初始数据
  11. */
  12. data: {
  13. // tab切换
  14. currentTab: 0,
  15. clientHeight: '',
  16. /**
  17. * 页面配置
  18. */
  19. winWidth: 0,
  20. winHeight: 0,
  21. already:[],
  22. wait:[],
  23. fill:[],
  24. fromType:'1'
  25. },
  26. /**
  27. * 生命周期函数--监听页面加载
  28. */
  29. onLoad: function (options) {
  30. var that = this
  31. isregistered = wx.getStorageSync('isregistered')
  32. /**
  33. * 获取系统信息
  34. */
  35. wx.getSystemInfo({
  36. success: function (res) {
  37. that.setData({
  38. winWidth: res.windowWidth,
  39. winHeight: res.windowHeight,
  40. clientHeight: res.windowHeight
  41. });
  42. }
  43. })
  44. },
  45. getAllApproval:function(){
  46. var that = this
  47. var data = {
  48. openid: wx.getStorageSync('openid'),
  49. pageCount: 20,
  50. pageSize: pageSize
  51. }
  52. var url = baseUrl + BASEURL.getUrl.getAllApproval
  53. netUtil.requestLoading(url, data, '正在加载数据...', 'GET', function (res) {
  54. if(res.data.success && res.data.data){
  55. if(pageSize == 1){
  56. that.setData({
  57. already: res.data.data.already,
  58. wait: res.data.data.wait,
  59. fill: res.data.data.fill
  60. })
  61. }else{
  62. that.setData({
  63. already: [...that.data.already, ...res.data.data.already],
  64. wait: [...that.data.wait, ...res.data.data.wait],
  65. fill: [...that.data.fill, ...res.data.data.fill]
  66. })
  67. }
  68. }
  69. }, function (res) {
  70. wx.showToast({
  71. title: '加载数据失败',
  72. icon: 'none',
  73. duration: 2000
  74. })
  75. })
  76. },
  77. ApprovaledClick:function(event){
  78. var itemdata = event.currentTarget.dataset.item
  79. var fromtype = event.currentTarget.dataset.fromtype
  80. console.log('event', event)
  81. wx.navigateTo({
  82. url: '../applyjoinapprovel/applyjoinapprovel' + '?getItemdata=' + JSON.stringify(itemdata) + '&getfromType=' + fromtype,
  83. })
  84. },
  85. /**
  86. * 点击tab切换
  87. */
  88. swichNav: function (e) {
  89. var that = this;
  90. // console.log('swichNav=', e)
  91. if (this.data.currentTab == e.target.dataset.current) {
  92. return false;
  93. } else {
  94. that.setData({
  95. currentTab: e.target.dataset.current
  96. })
  97. }
  98. },
  99. /**
  100. * 滑动切换tab
  101. */
  102. bindChange: function (e) {
  103. var that = this;
  104. if (e.detail.source == 'touch') {
  105. that.setData({ currentTab: e.detail.current });
  106. }
  107. },
  108. /**
  109. * 生命周期函数--监听页面初次渲染完成
  110. */
  111. onReady: function () {
  112. },
  113. /**
  114. * 生命周期函数--监听页面显示
  115. */
  116. onShow: function () {
  117. isregistered = wx.getStorageSync('isregistered')
  118. if (isregistered) {
  119. this.getAllApproval()
  120. } else {
  121. // wx.showModal({
  122. // title: '提示',
  123. // content: '您当前尚未进行微信授权登录,是否立即前往?',
  124. // success: function (res) {
  125. // if (res.confirm) {
  126. // wx.switchTab({
  127. // url: '../mine/mine',
  128. // })
  129. // } else if (res.cancel) {
  130. // return
  131. // }
  132. // }
  133. // })
  134. }
  135. },
  136. /**
  137. * 生命周期函数--监听页面隐藏
  138. */
  139. onHide: function () {
  140. },
  141. /**
  142. * 生命周期函数--监听页面卸载
  143. */
  144. onUnload: function () {
  145. },
  146. /**
  147. * 页面相关事件处理函数--监听用户下拉动作
  148. */
  149. onPullDownRefresh: function () {
  150. var that = this
  151. wx.showNavigationBarLoading() //在标题栏中显示加载
  152. pageSize = 1
  153. that.getAllApproval()
  154. //模拟加载
  155. setTimeout(function () {
  156. // complete
  157. wx.hideNavigationBarLoading() //完成停止加载
  158. wx.stopPullDownRefresh() //停止下拉刷新
  159. }, 500);
  160. },
  161. /**
  162. * 页面上拉触底事件的处理函数
  163. */
  164. onReachBottom: function () {
  165. pageSize++;
  166. this.getAllApproval()
  167. wx.showNavigationBarLoading();
  168. var that = this;
  169. setTimeout(function () { wx.hideNavigationBarLoading() }, 2000);
  170. },
  171. /**
  172. * 用户点击右上角分享
  173. */
  174. onShareAppMessage: function () {
  175. }
  176. })