抖音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.

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