communityMembers.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. var page = 1;
  2. var app = getApp();
  3. var timeFormat = require("../../utils/timeFormat");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. isCalling: false,
  10. queryData: {
  11. createTime: null,
  12. communityId: null,
  13. order: [],
  14. page: page,
  15. pageSize: 20
  16. },
  17. maxDate: (0, timeFormat.formatYMD)(new Date()),
  18. searchKey: "",
  19. date: "",
  20. containerHeight: 0,
  21. showLoadMore: false,
  22. no_order: 0,
  23. page: 1,
  24. hide_tip: true,
  25. order: [],
  26. tip: '正在加载',
  27. },
  28. /**
  29. * 生命周期函数--监听页面加载
  30. */
  31. onLoad: function(options) {
  32. var sysInfo = wx.getSystemInfoSync();
  33. this.setData({
  34. containerHeight: sysInfo.windowHeight - Math.round(sysInfo.windowWidth / 375 * 125)
  35. });
  36. page = 1;
  37. this.data.queryData.communityId = app.globalData.disUserInfo.communityId;
  38. this.data.queryData.createTime = null;
  39. this.getData();
  40. },
  41. /**
  42. * 生命周期函数--监听页面显示
  43. */
  44. onShow: function() {
  45. var is_show_on = this.data.is_show_on;
  46. if (is_show_on > 0) {
  47. this.setData({
  48. page: 1,
  49. order: []
  50. })
  51. this.getData();
  52. } else {
  53. this.setData({
  54. is_show_on: is_show_on + 1
  55. })
  56. }
  57. },
  58. /**
  59. * 获取数据
  60. */
  61. getData: function() {
  62. wx.showLoading({
  63. title: "加载中...",
  64. mask: true
  65. });
  66. this.setData({
  67. isHideLoadMore: true
  68. })
  69. this.data.no_order = 1
  70. let that = this;
  71. var token = wx.getStorageSync('token');
  72. //currentTab
  73. app.util.request({
  74. 'url': 'entry/wxapp/index',
  75. 'data': {
  76. controller: 'community.get_community_member_orderlist',
  77. date: that.data.date,
  78. searchKey: that.data.searchKey,
  79. token: token,
  80. page: that.data.page
  81. },
  82. dataType: 'json',
  83. success: function(res) {
  84. if (res.data.code == 0) {
  85. let close_community_delivery_orders = res.data.close_community_delivery_orders || 0;
  86. let rushList = that.data.order.concat(res.data.data);
  87. that.setData({
  88. order: rushList,
  89. hide_tip: true,
  90. no_order: 0,
  91. close_community_delivery_orders
  92. });
  93. wx.hideLoading();
  94. } else {
  95. that.setData({
  96. isHideLoadMore: true
  97. })
  98. wx.hideLoading();
  99. return false;
  100. }
  101. }
  102. })
  103. },
  104. /**
  105. * 获取时间
  106. */
  107. getTodayMs: function() {
  108. var t = new Date();
  109. return t.setHours(0), t.setMinutes(0), t.setSeconds(0), t.setMilliseconds(0), Date.parse(t);
  110. },
  111. /**
  112. * 监控输入框
  113. */
  114. bindSearchChange: function(e) {
  115. this.setData({
  116. searchKey: e.detail.value
  117. });
  118. },
  119. /**
  120. * 搜索
  121. */
  122. searchByKey: function() {
  123. page = 1;
  124. this.setData({
  125. order: [],
  126. no_order: 0,
  127. page: 1
  128. });
  129. this.data.queryData.memberNickName = this.data.searchKey;
  130. this.getData();
  131. },
  132. /**
  133. * 取消
  134. */
  135. cancel: function() {
  136. page = 1;
  137. this.setData({
  138. searchKey: "",
  139. order: []
  140. });
  141. this.data.queryData.memberNickName = null;
  142. this.getData();
  143. },
  144. /**
  145. * 监控日期
  146. */
  147. bindDateChange: function(e) {
  148. page = 1;
  149. this.setData({
  150. date: e.detail.value,
  151. order: [],
  152. no_order: 0,
  153. page: 1
  154. });
  155. this.data.queryData.createTime = new Date(e.detail.value).getTime() - 28800000;
  156. this.getData();
  157. },
  158. /**
  159. * 清除日期
  160. */
  161. clearDate: function() {
  162. page = 1;
  163. this.setData({
  164. date: "",
  165. order: [],
  166. no_order: 0,
  167. page: 1
  168. });
  169. this.data.queryData.createTime = null;
  170. this.getData();
  171. },
  172. /**
  173. * 拨打电话
  174. */
  175. callTelphone: function(e) {
  176. var that = this;
  177. var phoneNumber = e.currentTarget.dataset.phone;
  178. if (phoneNumber!="未下单"){
  179. this.data.isCalling || (this.data.isCalling = true, wx.makePhoneCall({
  180. phoneNumber: phoneNumber,
  181. complete: function() {
  182. that.data.isCalling = false;
  183. }
  184. }));
  185. }
  186. },
  187. /**
  188. * 获取更多
  189. */
  190. getMore: function() {
  191. if (this.data.no_order == 1) return false;
  192. this.data.page += 1;
  193. this.getData();
  194. this.setData({
  195. isHideLoadMore: false
  196. })
  197. },
  198. goLink: function (e) {
  199. let close_community_delivery_orders = this.data.close_community_delivery_orders;
  200. if (close_community_delivery_orders!=1) {
  201. var pages_all = getCurrentPages();
  202. var url = e.currentTarget.dataset.link;
  203. if (pages_all.length > 3) {
  204. wx.redirectTo({ url })
  205. } else {
  206. wx.navigateTo({ url })
  207. }
  208. }
  209. },
  210. })