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.

334 lines
8.3 KiB

  1. var app = getApp();
  2. const config = require('../../config/config.js')
  3. const util = require('../../utils/util.js')
  4. const Http = require('../../utils/HttpBasics.js')
  5. Page({
  6. data: {
  7. data: {
  8. list: []
  9. }, //数据
  10. crollTop: 0,
  11. scrollHeight: 0,
  12. house_type: 0, //户型
  13. house_style: 0, //风格
  14. house_area: 0, //面积
  15. flagdate: null,
  16. list: [],
  17. tabTxt: [{
  18. title: '全部',
  19. idss: 0
  20. },
  21. {
  22. title: '日期',
  23. idss: 1
  24. },
  25. // {
  26. // title: '类型',
  27. // idss: 2
  28. // },
  29. {
  30. title: '状态',
  31. idss: 3
  32. },
  33. // {
  34. // title: '来源',
  35. // idss: 4
  36. // }
  37. ],
  38. showList: null,
  39. loading: "",
  40. tab: [true, true, true, true, true],
  41. disabled: false, //加载更多按钮状态
  42. page: 1, //当前页码
  43. hasMore: false, //加载更多按钮
  44. moreTxt: '点击加载更多',
  45. dataNull: true,
  46. status: '',
  47. type: '',
  48. source: '',
  49. date: "",
  50. date2: "",
  51. idss: 0,
  52. subsidy: '',
  53. pageNum: 1, //第几页
  54. height: null,
  55. statustypes: [
  56. {
  57. name: '进行中',
  58. status: 1,
  59. id: 1
  60. },
  61. {
  62. name: '已过期',
  63. status: 3,
  64. id: 3
  65. },
  66. {
  67. name: '未开始',
  68. status: 4,
  69. id: 4
  70. }
  71. ],
  72. starttime: null,
  73. endtime: null,
  74. billTypeValue: null
  75. },
  76. // 选项卡
  77. filterTab: function (e) {
  78. let that = this;
  79. console.log(e);
  80. that.setData({
  81. loading: ""
  82. })
  83. that.setData({
  84. idss: e.target.dataset.idss || e.currentTarget.dataset.idss,
  85. pageNum: 1
  86. })
  87. if (e.currentTarget.dataset.idss === 0) {
  88. this.setData({
  89. source: '',
  90. type: '',
  91. status: '',
  92. date: '',
  93. date2: ''
  94. })
  95. this.getList(1)
  96. this.getTotleData()
  97. }
  98. var data = [true, true, true, true, true],
  99. index = e.currentTarget.dataset.index;
  100. data[index] = !that.data.tab[index];
  101. that.setData({
  102. tab: data
  103. })
  104. },
  105. bindDateChange1: function (e) {
  106. if (new Date(e.detail.value).getTime() > new Date(this.data.date2).getTime()) {
  107. wx.showToast({
  108. title: '抱歉,开始日期不能大于结束日期',
  109. icon: 'none',
  110. duration: 2000,
  111. mask: false
  112. });
  113. return;
  114. }
  115. this.setData({
  116. date: e.detail.value,
  117. })
  118. },
  119. bindDateChange2: function (e) {
  120. if (new Date(e.detail.value).getTime() < new Date(this.data.date).getTime()) {
  121. wx.showToast({
  122. title: '抱歉,结束日期不能小于开始日期',
  123. icon: 'none',
  124. duration: 2000,
  125. mask: false
  126. });
  127. return;
  128. }
  129. this.setData({
  130. date2: e.detail.value
  131. })
  132. },
  133. search(e) {
  134. console.log(e.currentTarget.dataset.ids)
  135. let type = e.currentTarget.dataset.ids;
  136. if (type == 0) {
  137. this.setData({
  138. source: '',
  139. type: '',
  140. status: '',
  141. date: '',
  142. date2: ''
  143. })
  144. } else if (type == 1) {
  145. if (!this.data.date) {
  146. wx.showToast({
  147. title: '抱歉请选择开始日期',
  148. icon: 'none',
  149. duration: 2000,
  150. mask: false
  151. });
  152. return;
  153. } else if (!this.data.date2) {
  154. wx.showToast({
  155. title: '抱歉请选择结束日期',
  156. icon: 'none',
  157. duration: 2000,
  158. mask: false
  159. });
  160. return;
  161. }
  162. } else if (type == 2) {
  163. this.setData({
  164. type: e.currentTarget.dataset.id
  165. })
  166. } else if (type == 3) {
  167. console.log(e.currentTarget.dataset.id)
  168. this.setData({
  169. status: e.currentTarget.dataset.id
  170. })
  171. } else if (type == 4) {
  172. this.setData({
  173. source: e.currentTarget.dataset.id
  174. })
  175. }
  176. var data = [true, true, true, true, true];
  177. this.setData({
  178. tab: data
  179. })
  180. this.getList(1)
  181. this.getTotleData()
  182. },
  183. onShow() {
  184. this.getList(1)
  185. this.getTotleData()
  186. },
  187. formatData(data) {
  188. let arr = [];
  189. data.map((item, index) => {
  190. let a = {};
  191. a.value = [item];
  192. a.dateR = item.createDate01;
  193. let indexSt = 0;
  194. let haveIf = false;
  195. console.log(item, this.data.auditWayOptions, 1111)
  196. console.log(item.sourceStr, item.typeStr, item.statusStr, 222)
  197. arr.map((item01, index01) => {
  198. if (item.id == item01.id) {
  199. indexSt = index01;
  200. haveIf = true;
  201. }
  202. })
  203. if (haveIf && (new Date(item.createDate)).valueOf() >= (new Date(this.data.date + ' 00:00:00')).valueOf() && (new Date(item.createDate)).valueOf() <= (new Date(this.data.date2 + ' 23:59:59')).valueOf()) {
  204. arr[indexSt].value.push(item)
  205. } else if ((new Date(item.createDate)).valueOf() >= (new Date(this.data.date + ' 00:00:00')).valueOf() && (new Date(item.createDate)).valueOf() <= (new Date(this.data.date2 + ' 23:59:59')).valueOf()) {
  206. arr.push(a)
  207. }
  208. })
  209. this.setData({
  210. allBillList: arr
  211. })
  212. console.log(arr, 888888888888)
  213. },
  214. getTotleData() {
  215. let _this = this;
  216. Http.get({
  217. url: config.api.getSubsidySummary,
  218. data: {
  219. startdate: this.data.date ? this.data.date + " 00:00:00" : '',
  220. enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
  221. source: this.data.source,
  222. type: this.data.type,
  223. status: this.data.status
  224. }
  225. })
  226. .then(res => {
  227. _this.setData({
  228. subsidy: Number(Number(res.data.subsidy) / 100).toFixed(2)
  229. })
  230. wx.stopPullDownRefresh();
  231. })
  232. .catch(err => {
  233. wx.stopPullDownRefresh();
  234. wx.showToast({
  235. title: err.message,
  236. icon: 'none',
  237. duration: 2000,
  238. mask: false
  239. });
  240. });
  241. },
  242. getList: function (page) {
  243. let _this = this;
  244. Http.get({
  245. url: config.api.cashbackList,
  246. data: {
  247. pageNum: page,
  248. pageSize: 10,
  249. begin: this.data.date ? this.data.date + " 00:00:00" : '',
  250. enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
  251. status: this.data.status
  252. }
  253. })
  254. .then(res => {
  255. wx.stopPullDownRefresh();
  256. let data = res.data.list;
  257. let allBillList = [];
  258. if (page == 1) {
  259. allBillList = res.data.list;
  260. } else {
  261. allBillList = _this.data.allBillList;
  262. }
  263. allBillList.map((item, index) => {
  264. let haveIf = false;
  265. item.startDate = util.formatTime(item.startTime, 'yyyy-MM-dddd')
  266. item.endDate = util.formatTime(item.endTime, 'yyyy-MM-dddd') // hh:mm:ss
  267. item.statusStr = this.data.statustypes.find(e => e.status === item.status)?.name
  268. item.isStart = item.startTime > new Date().getTime()
  269. if (item.startTime > new Date().getTime()) {
  270. item.startBtn = '活动未开始'
  271. item.startFlag = 0
  272. } else if (item.endTime < new Date().getTime()) {
  273. // item.startBtn = '活动已结束'
  274. // item.startFlag = 1
  275. item.startBtn = '参加活动'
  276. item.startFlag = 2
  277. } else {
  278. item.startBtn = '参加活动'
  279. item.startFlag = 2
  280. }
  281. })
  282. if (res.data.pages <= page) {
  283. _this.setData({
  284. allBillList,
  285. pageNum: res.data.pages - 1,
  286. content: '已经加载全部数据!'
  287. })
  288. } else {
  289. _this.setData({
  290. allBillList,
  291. loading: false,
  292. content: '小主,我在玩命加载中...'
  293. })
  294. }
  295. })
  296. .catch(err => {
  297. wx.stopPullDownRefresh();
  298. wx.showToast({
  299. title: err.message,
  300. icon: 'none',
  301. duration: 2000,
  302. mask: false
  303. });
  304. });
  305. },
  306. onPullDownRefresh: function (e) {
  307. let that = this;
  308. that.setData({
  309. pageNum: 1,
  310. list: []
  311. });
  312. that.getList(1);
  313. this.getTotleData()
  314. },
  315. onReachBottom() {
  316. var that = this;
  317. that.data.pageNum++;
  318. that.setData({
  319. pageNum: that.data.pageNum,
  320. loading: true
  321. });
  322. that.getList(that.data.pageNum);
  323. this.getTotleData()
  324. },
  325. viewDetail(e) {
  326. let id = e.currentTarget.dataset.id
  327. let flag = e.currentTarget.dataset.flag
  328. if (flag === 2) {
  329. wx.navigateTo({
  330. url: `/pages/cashContent/cashContent?id=${id}`,
  331. })
  332. }
  333. }
  334. });