| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112 |
- const _Http = getApp().globalData.http;
- Page({
- data: {
- id: 2026052510105006,
- active: 0,
- content: {
- nocache: true,
- pageNumber: 1,
- pageSize: 20,
- where: {
- status: '',
- showShipping: false,
- begindate: '',
- enddate: '',
- auditbegindate: '',
- auditenddate: '',
- condition: ''
- }
- },
- list: [],
- totalCount: 0,
- totalPoints: 0,
- isback: false,
- },
- onShow() {
- if (this.data.isback) {
- this.getList(true);
- }
- },
- onSearch({ detail }) {
- this.setData({
- 'content.where.condition': detail
- });
- this.getList(true);
- },
- startSearch({ detail }) {
- const condition = detail.value !== undefined ? detail.value : detail;
- if (condition == this.data.content.where.condition) return;
- this.setData({
- 'content.where.condition': condition
- });
- this.getList(true);
- },
- onClear() {
- this.setData({
- 'content.where.condition': ''
- });
- this.getList(true);
- },
- onChangeTab({ detail }) {
- this.setData({
- 'content.where.status': detail.title === '全部' ? '' : detail.title
- });
- this.getList(true);
- },
- getList(init = false) {
- if (init) this.selectComponent('#ListBox').goTop();
- _Http.init(this.data.content, init).then(content => {
- _Http.basic({
- id: this.data.id,
- content
- }).then(res => {
- this.selectComponent('#ListBox').RefreshToComplete();
- if (res.code != '1') return wx.showToast({
- title: res.msg,
- icon: "none"
- });
- // 处理商品图片
- let list = res.data || [];
- list.forEach(order => {
- if (order.items && order.items.length) {
- order.items.forEach(item => {
- item.imgUrl = item.attinfos && item.attinfos.length ? _Http.getSpecifiedImage(item.attinfos[0]) : '';
- });
- }
- });
- const isFirstPage = res.pageNumber == 1;
- const newList = isFirstPage ? list : this.data.list.concat(list);
- const totalPoints = newList.reduce((sum, order) => sum + (order.totalpoints || 0), 0);
- this.setData({
- content: _Http.paging(content, res),
- list: newList,
- totalCount: res.total || 0,
- totalPoints
- });
- });
- });
- },
- onLoad(options) {
- getApp().globalData.Language.getLanguagePackage(this, '积分订单');
- // 处理从"我的"页面传入的状态参数
- const tabs = ['', '新建', '提交', '完成'];
- let active = 0;
- if (options.status) {
- const idx = tabs.indexOf(options.status);
- if (idx > -1) active = idx;
- this.setData({
- 'content.where.status': options.status,
- active
- });
- }
- this.getList();
- }
- });
|