|
- const util = require("../../../utils/util.js");
- const config = require("../../../config/config.js");
- const Http = require("../../../utils/HttpBasics");
- Page({
- data: {
- tabs: [
- {
- key: 0,
- name: "未使用"
- },
- {
- key: 1,
- name: "已使用"
- },
- {
- key: 2,
- name: "已过期"
- },
- {
- key: 3,
- name: "已退款"
- }
- ],
- list: [],
- current: "0",
- current_scroll: "0",
- page: 1,
- allow_load: true
- },
- onLoad() {
- this.getList(0, 0);
- },
-
- //点击跳转到券详情页面
- gotouse: function(e) {
- console.log(e.currentTarget.dataset.quancode);
- console.log("点击跳转到券详情");
- wx.navigateTo({
- url: `/pages/couponorder/detail/index?quancode=${
- e.currentTarget.dataset.quancode
- }`,
- success: function(res) {
- // success
- console.log("点击跳转到券详情页面");
- },
- fail: function() {
- // fail
- },
- complete: function() {
- // complete
- }
- });
- },
- getList(key, pageNum) {
- var that = this;
- console.log(key);
- console.log(pageNum);
- if (that.data.allow_load) {
- wx.showLoading({
- title: "加载中"
- });
- Http.get({
- url: config.api.couponOrderList,
- data: {
- pageNum: pageNum,
- pageSize: 8,
- couponOrderStatus: key
- }
- }).then(res => {
- console.log(res);
- res.data.list.map(file => {
- file.expiredTime = util.fmtDate(file.expiredTime);
- });
- console.log("姐姐的订单列表");
- setTimeout(function() {
- wx.hideLoading();
- }, 1200);
- if (pageNum >= res.data.pages) {
- that.setData({
- allow_load: false
- });
- }
- /**
- * 先赋值后渲染页面
- * concat 不会改变原数组值
- * push 会改变原数组值,但不会一条一条插入,而是整个数组插入
- */
- that.data.list = that.data.list.concat(res.data.list);
- that.setData({
- list: that.data.list
- });
- });
- } else {
- console.log("加载完成allow_load设置成false");
- }
- },
- handleChange({ detail }) {
- console.log(detail);
- this.setData({
- current: detail.key
- });
- },
- handleChangeScroll({ detail }) {
- this.setData({
- list: [],
- allow_load: true,
- current_scroll: detail.key
- });
- this.getList(detail.key, 1);
- this.setData({
- current_scroll: detail.key
- });
- },
- onReachBottom: function() {
- var that = this;
- console.log(that.data.page);
- that.data.page++;
- console.log(that.data.page);
- that.setData({
- page: that.data.page
- });
- console.info("after++ " + that.data.page);
- that.getList(that.data.current_scroll, that.data.page);
- }
- });
|