index.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. import {
  2. Home
  3. } from '../../utils/home.js';
  4. var home = new Home(); //实例化 首页 对象\
  5. var app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. keywords: '',
  12. message: [],
  13. page: 1,
  14. pageTrue: true,
  15. isDelivery: '未交付'
  16. },
  17. /**
  18. * 日期计算
  19. */
  20. countDate: function(date, date_) {
  21. var date = date.split("-");
  22. var nDate = new Date(date[1] + '-' + date[2] + '-' + date[0]); //转换为MM-DD-YYYY格式
  23. var date_ = date_.split("-");
  24. var nDate_ = new Date(date_[1] + '-' + date_[2] + '-' + date_[0]); //转换为MM-DD-YYYY格式
  25. if (Math.abs(nDate) >= Math.abs(nDate_) && (Math.abs(nDate) - Math.abs(nDate_)) > (31 * 24 * 60 * 60 * 1000)) {
  26. return false
  27. } else {
  28. return true
  29. }
  30. },
  31. nowTime: function() {
  32. let that = this
  33. var param = {
  34. }
  35. home.getTime(param, (res) => {
  36. var pickerTimeStart1 = res.data.qs_date
  37. var pickerTimeStart2 = res.data.js_date
  38. that.data.pickerTimeStart1 = pickerTimeStart1,
  39. that.data.pickerTimeStart2 = pickerTimeStart2,
  40. that.setData({
  41. pickerTimeStart1: pickerTimeStart1,
  42. pickerTimeStart2: pickerTimeStart2,
  43. currentTab: 0
  44. })
  45. that.filtrate()
  46. })
  47. },
  48. ysjilu: function() {
  49. let that = this
  50. that.data.isDelivery = '未交付'
  51. that.setData({
  52. currentTab: 0,
  53. isDelivery: '未交付'
  54. })
  55. that.filtrate()
  56. },
  57. xsjilu: function() {
  58. let that = this
  59. that.data.isDelivery = "已交付"
  60. that.setData({
  61. currentTab: 1,
  62. isDelivery: '已交付'
  63. })
  64. that.filtrate()
  65. },
  66. /**
  67. * 选择开始时间
  68. */
  69. changeTimeStart: function(e) {
  70. let that = this
  71. that.setData({
  72. pickerTimeStart1: e.detail.value
  73. })
  74. console.log(e.detail.value)
  75. // that.timeDispose()
  76. },
  77. /**
  78. * 查询条件
  79. */
  80. searchInput: function(e) {
  81. let that = this
  82. if (!e.detail.value) {
  83. that.setData({
  84. page: 1
  85. })
  86. }
  87. that.setData({
  88. keywords: e.detail.value
  89. })
  90. console.log(e.detail.value)
  91. },
  92. /**
  93. * 选择结束时间
  94. */
  95. changeTimeEnd: function(e) {
  96. let that = this
  97. that.setData({
  98. pickerTimeStart2: e.detail.value
  99. })
  100. console.log(e)
  101. // that.timeDispose()
  102. },
  103. /**
  104. * 数据查找
  105. */
  106. findData_: function(e) {
  107. let that = this
  108. var param = {
  109. //如果开始时间结束时间为空 就默认上月所有数据
  110. //页
  111. page: that.data.page,
  112. //条数
  113. pageSize: 13,
  114. //筛选
  115. keywords: that.data.keywords,
  116. //开始时间
  117. startTime: that.data.pickerTimeStart1,
  118. //结束时间
  119. endTime: that.data.pickerTimeStart2,
  120. //交付未交付
  121. isDelivery: that.data.isDelivery,
  122. //用户ID
  123. admin_id: wx.getStorageSync('user_id')
  124. }
  125. if (that.data.pageTrue) {
  126. wx.showLoading({
  127. title: '正在加载',
  128. mask: true,
  129. success: function(res) {},
  130. fail: function(res) {},
  131. complete: function(res) {},
  132. })
  133. home.findData_(param, (res) => {
  134. var total = res.data[2].arr_length
  135. var moneyTotal = res.data[1].is_pay_total_price
  136. if (total == 0) {
  137. that.setData({
  138. pageTrue: false
  139. })
  140. }
  141. if (that.data.pageSize > res.data.length) {
  142. that.setData({
  143. pageTrue: false
  144. })
  145. }
  146. res.data[0].forEach((val, index) => {
  147. var create_time = val.create_time.substring(0, 10);
  148. val.create_time = create_time.replace(/-/g, ".");
  149. });
  150. var message = that.data.message.concat(res.data[0])
  151. if (message.length > 12) {
  152. var findLen = 12
  153. } else {
  154. var findLen = message.length
  155. }
  156. that.setData({
  157. findLen: findLen,
  158. message: message,
  159. messageParam: JSON.stringify(message),
  160. moneyTotal: moneyTotal
  161. })
  162. wx.hideLoading()
  163. })
  164. } else if (e) {
  165. wx.showLoading({
  166. title: '正在加载',
  167. mask: true,
  168. success: function(res) {},
  169. fail: function(res) {},
  170. complete: function(res) {},
  171. })
  172. home.findData_(param, (res) => {
  173. var moneyTotal = res.data[1].total_prce
  174. var message = res.data[0]
  175. if (message.length > 12) {
  176. var findLen = 12
  177. } else {
  178. var findLen = message.length
  179. }
  180. that.setData({
  181. findLen: findLen,
  182. message: message,
  183. messageParam: JSON.stringify(message),
  184. moneyTotal: moneyTotal
  185. })
  186. wx.hideLoading()
  187. })
  188. }
  189. },
  190. findInput: function(e) {
  191. let that = this
  192. console.log(e.detail.value)
  193. that.setData({
  194. keywords: e.detail.value
  195. })
  196. },
  197. upper: function() {
  198. let that = this
  199. var page = that.data.page + 1
  200. that.setData({
  201. page: page
  202. })
  203. that.findData_()
  204. },
  205. filtrate: function() {
  206. let that = this
  207. that.setData({
  208. message: [],
  209. page: 1,
  210. pageTrue: true
  211. })
  212. that.findData_()
  213. },
  214. /**
  215. * 生命周期函数--监听页面加载
  216. */
  217. onLoad: function(options) {
  218. let that = this
  219. that.nowTime();
  220. },
  221. /**
  222. * 生命周期函数--监听页面初次渲染完成
  223. */
  224. onReady: function() {
  225. },
  226. /**
  227. * 生命周期函数--监听页面显示
  228. */
  229. onShow: function() {
  230. this.filtrate();
  231. },
  232. /**
  233. * 生命周期函数--监听页面隐藏
  234. */
  235. onHide: function() {
  236. },
  237. /**
  238. * 生命周期函数--监听页面卸载
  239. */
  240. onUnload: function() {},
  241. })