Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

500 rindas
12 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. const format = require('../../utils/format.js')
  6. Page({
  7. data: {
  8. data: {
  9. list: []
  10. }, //数据
  11. crollTop: 0,
  12. scrollHeight: 0,
  13. house_type: 0, //户型
  14. house_style: 0, //风格
  15. house_area: 0, //面积
  16. flagdate: null,
  17. list: [],
  18. tabTxt: [{
  19. title: '全部',
  20. idss: 0
  21. },
  22. {
  23. title: '日期',
  24. idss: 1
  25. },
  26. // {
  27. // title: '类型',
  28. // idss: 2
  29. // },
  30. {
  31. title: '状态',
  32. idss: 3
  33. },
  34. // {
  35. // title: '来源',
  36. // idss: 4
  37. // }
  38. ],
  39. showList: null,
  40. loading: "",
  41. tab: [true, true, true, true, true],
  42. disabled: false, //加载更多按钮状态
  43. page: 1, //当前页码
  44. hasMore: false, //加载更多按钮
  45. moreTxt: '点击加载更多',
  46. dataNull: true,
  47. status: '',
  48. type: '',
  49. source: '',
  50. date: "",
  51. date2: "",
  52. idss: 0,
  53. subsidy: '',
  54. pageNum: 1, //第几页
  55. height: null,
  56. statustypes: [
  57. {
  58. name: '审核中',
  59. status: 0,
  60. id: 0
  61. },
  62. {
  63. name: '审核通过',
  64. status: 1,
  65. id: 1
  66. },
  67. {
  68. name: '审核驳回',
  69. status: 2,
  70. id:2
  71. },
  72. {
  73. name: '已失效',
  74. status: 3,
  75. id:3
  76. }
  77. ],
  78. starttime: null,
  79. endtime: null,
  80. billTypeValue: null,
  81. paramData: null,
  82. topData: null,
  83. tabList:[
  84. {
  85. label:'订单录入',
  86. value:'1'
  87. },
  88. {
  89. label:'VIP卡绑定',
  90. value:'2'
  91. },
  92. {
  93. label:'绑卡记录',
  94. value:'3'
  95. }
  96. ],
  97. active: '1',
  98. formData:{
  99. "activityId": null, //活动id
  100. "phone": "",
  101. "name": "",
  102. "address": "",
  103. "vipNum": ""
  104. },
  105. rule: {
  106. "phone": [{
  107. required: true,
  108. message: "请填写客户电话"
  109. },
  110. {
  111. type: 'phone',
  112. message: "请输入正确的手机号码"
  113. }],
  114. "name": [{
  115. required: true,
  116. message: "请填写客户姓名"
  117. }
  118. ],
  119. "address": [{
  120. required: true,
  121. message: "请填写客户地址"
  122. }],
  123. "vipNum": [{
  124. required: true,
  125. message: "请填写会员卡号"
  126. }
  127. ]
  128. },
  129. searchActive: '1',
  130. searchVal:'',
  131. allCardList:[] //绑卡记录
  132. },
  133. /**
  134. * 生命周期函数--监听页面加载
  135. */
  136. onLoad: function (options) {
  137. this.setData({
  138. paramData:options
  139. });
  140. },
  141. tabChange: function(e){
  142. this.setData({
  143. active: e.target.dataset.index,
  144. searchVal:'',
  145. pageNum: 1
  146. })
  147. if(e.target.dataset.index!=='2') this.getList(1)
  148. },
  149. searchTabChange:function(e){
  150. this.setData({
  151. searchActive: e.target.dataset.index,
  152. searchVal:''
  153. })
  154. this.getList(1)
  155. },
  156. inputChange(e) {
  157. this.setData({
  158. formData: Object.assign(this.data.formData, {
  159. [e.target.dataset.key]: e.detail.value
  160. })
  161. })
  162. },
  163. searchTnputChange(e) {
  164. this.setData({
  165. searchVal: e.detail.value
  166. })
  167. },
  168. searchVipData(){
  169. this.getList(1)
  170. },
  171. /**
  172. * 绑定会员
  173. */
  174. submitForm() {
  175. if (!format.validateForm(this.data.formData, this.data.rule)) {
  176. return
  177. }
  178. Http.post({
  179. url: config.api.legionUserSaveOrUpdate,
  180. data: {
  181. ...this.data.formData,
  182. activityId: this.data.paramData.id
  183. }
  184. }).then(res => {
  185. wx.showToast({
  186. title: '绑定成功!',
  187. icon: "none"
  188. })
  189. }).catch(err => {
  190. wx.showToast({
  191. title: err.message ? err.message : err.data,
  192. icon: "none"
  193. })
  194. })
  195. },
  196. // 选项卡
  197. filterTab: function (e) {
  198. let that = this;
  199. console.log(e);
  200. that.setData({
  201. loading: ""
  202. })
  203. that.setData({
  204. idss: e.target.dataset.idss || e.currentTarget.dataset.idss,
  205. pageNum: 1
  206. })
  207. if (e.currentTarget.dataset.idss === 0) {
  208. this.setData({
  209. source: '',
  210. type: '',
  211. status: '',
  212. date: '',
  213. date2: ''
  214. })
  215. this.getList(1)
  216. this.getTotleData()
  217. }
  218. var data = [true, true, true, true, true],
  219. index = e.currentTarget.dataset.index;
  220. data[index] = !that.data.tab[index];
  221. that.setData({
  222. tab: data
  223. })
  224. },
  225. bindDateChange1: function (e) {
  226. if (new Date(e.detail.value).getTime() > new Date(this.data.date2).getTime()) {
  227. wx.showToast({
  228. title: '抱歉,开始日期不能大于结束日期',
  229. icon: 'none',
  230. duration: 2000,
  231. mask: false
  232. });
  233. return;
  234. }
  235. this.setData({
  236. date: e.detail.value,
  237. })
  238. },
  239. bindDateChange2: function (e) {
  240. if (new Date(e.detail.value).getTime() < new Date(this.data.date).getTime()) {
  241. wx.showToast({
  242. title: '抱歉,结束日期不能小于开始日期',
  243. icon: 'none',
  244. duration: 2000,
  245. mask: false
  246. });
  247. return;
  248. }
  249. this.setData({
  250. date2: e.detail.value
  251. })
  252. },
  253. search(e) {
  254. console.log(e.currentTarget.dataset.ids)
  255. let type = e.currentTarget.dataset.ids;
  256. if (type == 0) {
  257. this.setData({
  258. source: '',
  259. type: '',
  260. status: '',
  261. date: '',
  262. date2: ''
  263. })
  264. } else if (type == 1) {
  265. if (!this.data.date) {
  266. wx.showToast({
  267. title: '抱歉请选择开始日期',
  268. icon: 'none',
  269. duration: 2000,
  270. mask: false
  271. });
  272. return;
  273. } else if (!this.data.date2) {
  274. wx.showToast({
  275. title: '抱歉请选择结束日期',
  276. icon: 'none',
  277. duration: 2000,
  278. mask: false
  279. });
  280. return;
  281. }
  282. } else if (type == 2) {
  283. this.setData({
  284. type: e.currentTarget.dataset.id
  285. })
  286. } else if (type == 3) {
  287. console.log(e.currentTarget.dataset.id)
  288. this.setData({
  289. status: e.currentTarget.dataset.id
  290. })
  291. } else if (type == 4) {
  292. this.setData({
  293. source: e.currentTarget.dataset.id
  294. })
  295. }
  296. var data = [true, true, true, true, true];
  297. this.setData({
  298. tab: data
  299. })
  300. this.getList(1)
  301. this.getTotleData()
  302. },
  303. onShow() {
  304. this.getList(1)
  305. this.getTotleData()
  306. },
  307. formatData(data) {
  308. let arr = [];
  309. data.map((item, index) => {
  310. let a = {};
  311. a.value = [item];
  312. a.dateR = item.createDate01;
  313. let indexSt = 0;
  314. let haveIf = false;
  315. console.log(item, this.data.auditWayOptions, 1111)
  316. console.log(item.sourceStr, item.typeStr, item.statusStr, 222)
  317. arr.map((item01, index01) => {
  318. if (item.id == item01.id) {
  319. indexSt = index01;
  320. haveIf = true;
  321. }
  322. })
  323. 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()) {
  324. arr[indexSt].value.push(item)
  325. } 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()) {
  326. arr.push(a)
  327. }
  328. })
  329. this.setData({
  330. allBillList: arr
  331. })
  332. console.log(arr, 888888888888)
  333. },
  334. getTotleData() {
  335. let _this = this;
  336. Http.get({
  337. url: config.api.legionOrderStatistics,
  338. data: {
  339. createDateBegin: this.data.date ? this.data.date + " 00:00:00" : '',
  340. createDateEnd: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
  341. auditStatus: this.data.status,
  342. activityId: this.data.paramData.id
  343. }
  344. })
  345. .then(res => {
  346. _this.setData({
  347. topData: res.data
  348. })
  349. wx.stopPullDownRefresh();
  350. })
  351. .catch(err => {
  352. wx.stopPullDownRefresh();
  353. wx.showToast({
  354. title: err.message,
  355. icon: 'none',
  356. duration: 2000,
  357. mask: false
  358. });
  359. });
  360. },
  361. getList: function(page){
  362. if(this.data.active === '1'){
  363. this.getLegionOrderList(page)
  364. }else{
  365. this.getLegionUserList(page)
  366. }
  367. },
  368. getLegionOrderList: function (page) {
  369. let _this = this;
  370. Http.get({
  371. url: config.api.legionOrderList,
  372. data: {
  373. pageNum: page,
  374. pageSize: 10,
  375. createDateBegin: this.data.date ? this.data.date + " 00:00:00" : '',
  376. createDateEnd: this.data.date2 ? this.data.date2 + " 23:59:59" : '',
  377. auditStatus: this.data.status,
  378. activityId: this.data.paramData.id
  379. }
  380. })
  381. .then(res => {
  382. wx.stopPullDownRefresh();
  383. let data = res.data.list;
  384. let allBillList = [];
  385. if (page == 1) {
  386. allBillList = res.data.list;
  387. } else {
  388. allBillList = _this.data.allBillList;
  389. }
  390. allBillList.map((item, index) => {
  391. let haveIf = false;
  392. item.startDate = util.formatTime(item.createDate, 'yyyy-MM-dddd hh:mm:ss')
  393. item.statusStr = this.data.statustypes.find(e => e.status === item.auditStatus)?.name
  394. })
  395. if (res.data.pages <= page) {
  396. _this.setData({
  397. allBillList,
  398. pageNum: res.data.pages - 1,
  399. content: '已经加载全部数据!'
  400. })
  401. } else {
  402. _this.setData({
  403. allBillList,
  404. loading: false,
  405. content: '小主,我在玩命加载中...'
  406. })
  407. }
  408. })
  409. .catch(err => {
  410. wx.stopPullDownRefresh();
  411. wx.showToast({
  412. title: err.message,
  413. icon: 'none',
  414. duration: 2000,
  415. mask: false
  416. });
  417. });
  418. },
  419. getLegionUserList: function (page) {
  420. let _this = this;
  421. Http.get({
  422. url: config.api.legionUserList,
  423. data: {
  424. pageNum: page,
  425. pageSize: 10,
  426. phone: this.data.searchActive === '1'?this.data.searchVal:'',
  427. vipNum: this.data.searchActive === '2'?this.data.searchVal:'',
  428. activityId: this.data.paramData.id
  429. }
  430. })
  431. .then(res => {
  432. wx.stopPullDownRefresh();
  433. let data = res.data.list;
  434. let allCardList = [];
  435. if (page == 1) {
  436. allCardList = res.data.list;
  437. } else {
  438. allCardList = _this.data.allCardList;
  439. }
  440. allCardList.map((item, index) => {
  441. let haveIf = false;
  442. item.startDate = util.formatTime(item.createDate, 'yyyy-MM-dddd hh:mm:ss')
  443. item.statusStr = this.data.statustypes.find(e => e.status === item.auditStatus)?.name
  444. })
  445. if (res.data.pages <= page) {
  446. _this.setData({
  447. allCardList,
  448. pageNum: res.data.pages - 1,
  449. content: '已经加载全部数据!'
  450. })
  451. } else {
  452. _this.setData({
  453. allCardList,
  454. loading: false,
  455. content: '小主,我在玩命加载中...'
  456. })
  457. }
  458. })
  459. .catch(err => {
  460. wx.stopPullDownRefresh();
  461. wx.showToast({
  462. title: err.message,
  463. icon: 'none',
  464. duration: 2000,
  465. mask: false
  466. });
  467. });
  468. },
  469. onPullDownRefresh: function (e) {
  470. let that = this;
  471. that.setData({
  472. pageNum: 1,
  473. list: []
  474. });
  475. that.getList(1);
  476. this.getTotleData()
  477. },
  478. onReachBottom() {
  479. var that = this;
  480. that.data.pageNum++;
  481. that.setData({
  482. pageNum: that.data.pageNum,
  483. loading: true
  484. });
  485. that.getList(that.data.pageNum);
  486. this.getTotleData()
  487. },
  488. viewDetail(e) {
  489. let id = e.currentTarget.dataset.id
  490. let flag = e.currentTarget.dataset.flag
  491. wx.navigateTo({
  492. url: `/pages/legionOrderDetail/index?id=${id}&auditStatus=${flag}`,
  493. })
  494. },
  495. submit() {
  496. wx.navigateTo({
  497. url: `/pages/legionOrderDetail/index?tag=add&activityId=${this.data.paramData.id}`,
  498. })
  499. }
  500. });