抖音b端
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.

372 satır
8.9 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. billtypes: [{
  56. name: '自主结算',
  57. billTypeValue: 1,
  58. id: 1
  59. },
  60. {
  61. name: '微信分账',
  62. billTypeValue: 2,
  63. id: 2
  64. }
  65. ],
  66. statustypes: [{
  67. name: '未结算',
  68. status: 0,
  69. id: 0
  70. },
  71. {
  72. name: '已结算',
  73. status: 1,
  74. id: 1
  75. }
  76. ],
  77. //结算来源
  78. auditWayOptions: [
  79. /* {
  80. name: "全部",
  81. value: ''
  82. }, */
  83. {
  84. name: "补贴",
  85. value: 0,
  86. id: 0
  87. },
  88. {
  89. name: "卡消费",
  90. value: 1,
  91. id: 1
  92. },
  93. {
  94. name: "券核销",
  95. value: 2,
  96. id: 2
  97. },
  98. {
  99. name: "砍价核销",
  100. value: 3,
  101. id: 3
  102. },
  103. {
  104. name: "拼团核销",
  105. value: 4,
  106. id: 4
  107. },
  108. {
  109. name: "收银分账",
  110. value: 5,
  111. id: 5
  112. },
  113. {
  114. name: "可配送商品",
  115. value: 6,
  116. id: 6
  117. },
  118. ],
  119. starttime: null,
  120. endtime: null,
  121. billTypeValue: null
  122. },
  123. // 选项卡
  124. filterTab: function (e) {
  125. let that = this;
  126. console.log(e);
  127. that.setData({
  128. loading: ""
  129. })
  130. that.setData({
  131. idss: e.target.dataset.idss || e.currentTarget.dataset.idss,
  132. pageNum: 1
  133. })
  134. if (e.currentTarget.dataset.idss === 0) {
  135. this.setData({
  136. source: '',
  137. type: '',
  138. status: '',
  139. date: '',
  140. date2: ''
  141. })
  142. this.getList(1)
  143. this.getTotleData()
  144. }
  145. var data = [true, true, true, true, true],
  146. index = e.currentTarget.dataset.index;
  147. data[index] = !that.data.tab[index];
  148. that.setData({
  149. tab: data
  150. })
  151. },
  152. bindDateChange1: function (e) {
  153. if (new Date(e.detail.value).getTime() > new Date(this.data.date2).getTime()) {
  154. tt.showToast({
  155. title: '抱歉,开始日期不能大于结束日期',
  156. icon: 'none',
  157. duration: 2000,
  158. mask: false
  159. });
  160. return;
  161. }
  162. this.setData({
  163. date: e.detail.value,
  164. })
  165. },
  166. bindDateChange2: function (e) {
  167. if (new Date(e.detail.value).getTime() < new Date(this.data.date).getTime()) {
  168. tt.showToast({
  169. title: '抱歉,结束日期不能小于开始日期',
  170. icon: 'none',
  171. duration: 2000,
  172. mask: false
  173. });
  174. return;
  175. }
  176. this.setData({
  177. date2: e.detail.value
  178. })
  179. },
  180. search(e) {
  181. console.log(e.currentTarget.dataset.ids)
  182. let type = e.currentTarget.dataset.ids;
  183. if (type == 0) {
  184. this.setData({
  185. source: '',
  186. type: '',
  187. status: '',
  188. date: '',
  189. date2: ''
  190. })
  191. } else if (type == 1) {
  192. if (!this.data.date) {
  193. tt.showToast({
  194. title: '抱歉请选择开始日期',
  195. icon: 'none',
  196. duration: 2000,
  197. mask: false
  198. });
  199. return;
  200. } else if (!this.data.date2) {
  201. tt.showToast({
  202. title: '抱歉请选择结束日期',
  203. icon: 'none',
  204. duration: 2000,
  205. mask: false
  206. });
  207. return;
  208. }
  209. } else if (type == 2) {
  210. this.setData({
  211. type: e.currentTarget.dataset.id
  212. })
  213. } else if (type == 3) {
  214. console.log(e.currentTarget.dataset.id)
  215. this.setData({
  216. status: e.currentTarget.dataset.id
  217. })
  218. } else if (type == 4) {
  219. this.setData({
  220. source: e.currentTarget.dataset.id
  221. })
  222. }
  223. var data = [true, true, true, true, true];
  224. this.setData({
  225. tab: data
  226. })
  227. this.getList(1)
  228. this.getTotleData()
  229. },
  230. onShow() {
  231. this.getList(1)
  232. this.getTotleData()
  233. },
  234. formatData(data) {
  235. let arr = [];
  236. data.map((item, index) => {
  237. let a = {};
  238. a.value = [item];
  239. a.dateR = item.createDate01;
  240. let indexSt = 0;
  241. let haveIf = false;
  242. console.log(item, this.data.auditWayOptions, 1111)
  243. console.log(item.sourceStr, item.typeStr, item.statusStr, 222)
  244. arr.map((item01, index01) => {
  245. if (item.id == item01.id) {
  246. indexSt = index01;
  247. haveIf = true;
  248. }
  249. })
  250. 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()) {
  251. arr[indexSt].value.push(item)
  252. } 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()) {
  253. arr.push(a)
  254. }
  255. })
  256. this.setData({
  257. allBillList: arr
  258. })
  259. console.log(arr, 888888888888)
  260. },
  261. getTotleData() {
  262. let _this = this;
  263. Http.get({
  264. url: config.api.getSubsidySummary,
  265. data: {
  266. startdate: this.data.date ? this.data.date + " 00:00:00" : '',
  267. enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
  268. source: this.data.source,
  269. type: this.data.type,
  270. status: this.data.status
  271. }
  272. })
  273. .then(res => {
  274. console.log(res, 777)
  275. _this.setData({
  276. subsidy: Number(Number(res.data.subsidy) / 100).toFixed(2)
  277. })
  278. tt.stopPullDownRefresh();
  279. })
  280. .catch(err => {
  281. tt.stopPullDownRefresh();
  282. tt.showToast({
  283. title: err.message,
  284. icon: 'none',
  285. duration: 2000,
  286. mask: false
  287. });
  288. });
  289. },
  290. getList: function (page) {
  291. let _this = this;
  292. Http.get({
  293. url: config.api.getSubsidyList,
  294. data: {
  295. pageNum: page,
  296. pageSize: 10,
  297. startdate: this.data.date ? this.data.date + " 00:00:00" : '',
  298. enddate: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
  299. source: this.data.source,
  300. type: this.data.type,
  301. status: this.data.status
  302. }
  303. })
  304. .then(res => {
  305. tt.stopPullDownRefresh();
  306. let data = res.data.list;
  307. let allBillList = [];
  308. if (page == 1) {
  309. allBillList = res.data.list;
  310. } else {
  311. allBillList = _this.data.allBillList;
  312. }
  313. data.map((item, index) => {
  314. let haveIf = false;
  315. item.createDate01 = util.formatTime(item.createDate, 'yyyy-MM-dddd hh:mm:ss')
  316. item.sourceStr = this.data.auditWayOptions.filter(e => e.value == item.source).length > 0 ? this.data.auditWayOptions.filter(e => e.value == item.source)[0].name : '';
  317. item.typeStr = this.data.billtypes.filter(e => e.id == item.type).length > 0 ? this.data.billtypes.filter(e => e.id == item.type)[0].name : '';
  318. item.statusStr = item.status === 0 ? '未结算' : "已结算";
  319. allBillList.map((item02, index02) => {
  320. if (item02.id == item.id) {
  321. haveIf = true;
  322. }
  323. })
  324. if (!haveIf) {
  325. allBillList.push(item)
  326. }
  327. })
  328. console.log(allBillList, 444)
  329. if (res.data.pages <= page) {
  330. _this.setData({
  331. allBillList,
  332. pageNum: res.data.pages - 1,
  333. content: '已经加载全部数据!'
  334. })
  335. } else {
  336. _this.setData({
  337. allBillList,
  338. loading: false,
  339. content: '小主,我在玩命加载中...'
  340. })
  341. }
  342. })
  343. .catch(err => {
  344. tt.stopPullDownRefresh();
  345. tt.showToast({
  346. title: err.message,
  347. icon: 'none',
  348. duration: 2000,
  349. mask: false
  350. });
  351. });
  352. },
  353. onPullDownRefresh: function (e) {
  354. let that = this;
  355. that.setData({
  356. pageNum: 1,
  357. list: []
  358. });
  359. that.getList(1);
  360. this.getTotleData()
  361. },
  362. onReachBottom() {
  363. var that = this;
  364. that.data.pageNum++;
  365. that.setData({
  366. pageNum: that.data.pageNum,
  367. loading: true
  368. });
  369. that.getList(that.data.pageNum);
  370. this.getTotleData()
  371. }
  372. });