No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

333 líneas
8.0 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: 0,
  59. id: 0
  60. },
  61. {
  62. name: '审核通过',
  63. status: 1,
  64. id: 1
  65. },
  66. {
  67. name: '审核驳回',
  68. status: 2,
  69. id:2
  70. }
  71. ],
  72. starttime: null,
  73. endtime: null,
  74. billTypeValue: null,
  75. paramData: null,
  76. topData: null
  77. },
  78. /**
  79. * 生命周期函数--监听页面加载
  80. */
  81. onLoad: function (options) {
  82. this.setData({
  83. paramData:options
  84. });
  85. },
  86. // 选项卡
  87. filterTab: function (e) {
  88. let that = this;
  89. console.log(e);
  90. that.setData({
  91. loading: ""
  92. })
  93. that.setData({
  94. idss: e.target.dataset.idss || e.currentTarget.dataset.idss,
  95. pageNum: 1
  96. })
  97. if (e.currentTarget.dataset.idss === 0) {
  98. this.setData({
  99. source: '',
  100. type: '',
  101. status: '',
  102. date: '',
  103. date2: ''
  104. })
  105. this.getList(1)
  106. this.getTotleData()
  107. }
  108. var data = [true, true, true, true, true],
  109. index = e.currentTarget.dataset.index;
  110. data[index] = !that.data.tab[index];
  111. that.setData({
  112. tab: data
  113. })
  114. },
  115. bindDateChange1: function (e) {
  116. if (new Date(e.detail.value).getTime() > new Date(this.data.date2).getTime()) {
  117. wx.showToast({
  118. title: '抱歉,开始日期不能大于结束日期',
  119. icon: 'none',
  120. duration: 2000,
  121. mask: false
  122. });
  123. return;
  124. }
  125. this.setData({
  126. date: e.detail.value,
  127. })
  128. },
  129. bindDateChange2: function (e) {
  130. if (new Date(e.detail.value).getTime() < new Date(this.data.date).getTime()) {
  131. wx.showToast({
  132. title: '抱歉,结束日期不能小于开始日期',
  133. icon: 'none',
  134. duration: 2000,
  135. mask: false
  136. });
  137. return;
  138. }
  139. this.setData({
  140. date2: e.detail.value
  141. })
  142. },
  143. search(e) {
  144. console.log(e.currentTarget.dataset.ids)
  145. let type = e.currentTarget.dataset.ids;
  146. if (type == 0) {
  147. this.setData({
  148. source: '',
  149. type: '',
  150. status: '',
  151. date: '',
  152. date2: ''
  153. })
  154. } else if (type == 1) {
  155. if (!this.data.date) {
  156. wx.showToast({
  157. title: '抱歉请选择开始日期',
  158. icon: 'none',
  159. duration: 2000,
  160. mask: false
  161. });
  162. return;
  163. } else if (!this.data.date2) {
  164. wx.showToast({
  165. title: '抱歉请选择结束日期',
  166. icon: 'none',
  167. duration: 2000,
  168. mask: false
  169. });
  170. return;
  171. }
  172. } else if (type == 2) {
  173. this.setData({
  174. type: e.currentTarget.dataset.id
  175. })
  176. } else if (type == 3) {
  177. console.log(e.currentTarget.dataset.id)
  178. this.setData({
  179. status: e.currentTarget.dataset.id
  180. })
  181. } else if (type == 4) {
  182. this.setData({
  183. source: e.currentTarget.dataset.id
  184. })
  185. }
  186. var data = [true, true, true, true, true];
  187. this.setData({
  188. tab: data
  189. })
  190. this.getList(1)
  191. this.getTotleData()
  192. },
  193. onShow() {
  194. this.getList(1)
  195. this.getTotleData()
  196. },
  197. formatData(data) {
  198. let arr = [];
  199. data.map((item, index) => {
  200. let a = {};
  201. a.value = [item];
  202. a.dateR = item.createDate01;
  203. let indexSt = 0;
  204. let haveIf = false;
  205. console.log(item, this.data.auditWayOptions, 1111)
  206. console.log(item.sourceStr, item.typeStr, item.statusStr, 222)
  207. arr.map((item01, index01) => {
  208. if (item.id == item01.id) {
  209. indexSt = index01;
  210. haveIf = true;
  211. }
  212. })
  213. 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()) {
  214. arr[indexSt].value.push(item)
  215. } 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()) {
  216. arr.push(a)
  217. }
  218. })
  219. this.setData({
  220. allBillList: arr
  221. })
  222. console.log(arr, 888888888888)
  223. },
  224. getTotleData() {
  225. let _this = this;
  226. Http.get({
  227. url: config.api.raffleRecordCount,
  228. data: {
  229. createDateBegin: this.data.date ? this.data.date + " 00:00:00" : '',
  230. createDateEnd: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
  231. auditStatus: this.data.status,
  232. activityId: this.data.paramData.id
  233. }
  234. })
  235. .then(res => {
  236. _this.setData({
  237. topData: res.data
  238. })
  239. wx.stopPullDownRefresh();
  240. })
  241. .catch(err => {
  242. wx.stopPullDownRefresh();
  243. wx.showToast({
  244. title: err.message,
  245. icon: 'none',
  246. duration: 2000,
  247. mask: false
  248. });
  249. });
  250. },
  251. getList: function (page) {
  252. let _this = this;
  253. Http.get({
  254. url: config.api.raffleRecordList,
  255. data: {
  256. pageNum: page,
  257. pageSize: 10,
  258. createDateBegin: this.data.date ? this.data.date + " 00:00:00" : '',
  259. createDateEnd: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
  260. auditStatus: this.data.status,
  261. activityId: this.data.paramData.id
  262. }
  263. })
  264. .then(res => {
  265. wx.stopPullDownRefresh();
  266. let data = res.data.list;
  267. let allBillList = [];
  268. if (page == 1) {
  269. allBillList = res.data.list;
  270. } else {
  271. allBillList = _this.data.allBillList;
  272. }
  273. allBillList.map((item, index) => {
  274. let haveIf = false;
  275. item.startDate = util.formatTime(item.createDate, 'yyyy-MM-dddd')
  276. item.statusStr = this.data.statustypes.find(e => e.status === item.auditStatus)?.name
  277. })
  278. if (res.data.pages <= page) {
  279. _this.setData({
  280. allBillList,
  281. pageNum: res.data.pages - 1,
  282. content: '已经加载全部数据!'
  283. })
  284. } else {
  285. _this.setData({
  286. allBillList,
  287. loading: false,
  288. content: '小主,我在玩命加载中...'
  289. })
  290. }
  291. })
  292. .catch(err => {
  293. wx.stopPullDownRefresh();
  294. wx.showToast({
  295. title: err.message,
  296. icon: 'none',
  297. duration: 2000,
  298. mask: false
  299. });
  300. });
  301. },
  302. onPullDownRefresh: function (e) {
  303. let that = this;
  304. that.setData({
  305. pageNum: 1,
  306. list: []
  307. });
  308. that.getList(1);
  309. this.getTotleData()
  310. },
  311. onReachBottom() {
  312. var that = this;
  313. that.data.pageNum++;
  314. that.setData({
  315. pageNum: that.data.pageNum,
  316. loading: true
  317. });
  318. that.getList(that.data.pageNum);
  319. this.getTotleData()
  320. },
  321. viewDetail(e) {
  322. let id = e.currentTarget.dataset.id
  323. let flag = e.currentTarget.dataset.flag
  324. wx.navigateTo({
  325. url: `/pages/raffleDetails/index?id=${id}&tag=${flag == 2 ? 'edit' : 'detail'}`,
  326. })
  327. },
  328. submit() {
  329. wx.navigateTo({
  330. url: `/pages/raffleDetails/index?tag=add&activityId=${this.data.paramData.id}`,
  331. })
  332. }
  333. });