|
- const format = require("../../../utils/util.js");
- const config = require("../../../config/config.js");
- const app = getApp();
- const Http = require("../../../utils/HttpBasics");
- const imgurl = require("../../../utils/imgurl");
- Page({
- data: {
- couponUrl:imgurl.coupon.url,
- gouUrl:imgurl.gou.url,
- linessUrl:imgurl.liness.url,
- loadingUrl:imgurl.loading.url,
- list: [],
- current: "0",
- current_scroll: "0",
- page: 1,
- allow_load: true
- },
- onLoad(options) {
- this.getList(0, 0);
- if (options.quanid){
- this.setData({
- quanid: options.quanid
- })
- }
- },
-
- /**
- * 选择使用的优惠券
- */
- choicecoupon: function(e) {
- wx.navigateBack();
- var pages = getCurrentPages();
- var prevPage = pages[pages.length - 2] //上一个页面
- var that = this;
- var quantitle = e.currentTarget.dataset.title;
- var quanid = e.currentTarget.dataset.id;
- prevPage.setData({
- quantitle: quantitle,
- quanid: quanid,
- });
- wx.setStorage({
- key: 'chosed',
- data: 'chosed',
- })
- },
- getList(key, pageNum) {
- var that = this;
- if (that.data.allow_load) {
- Http.get({
- url: config.api.couponOrderCarList,
- data: {
- pageNum: pageNum,
- pageSize: 20,
- couponOrderStatus: key
- }
- }).then(res => {
- res.data.list.map(file => {
- file.expiredTime = format.formatTime(
- file.expiredTime,
- "yyyy-MM-dd hh:mm:ss"
- );
- });
- if (pageNum >= res.data.pages) {
- that.setData({
- allow_load: false
- });
- }
- that.data.list = that.data.list.concat(res.data.list);
- that.setData({
- list: that.data.list
- });
- })
- .catch(err => {
- wx.showToast({
- title: err.errMsg,
- icon: 'none',
- duration: 2000,
- mask: false
- });
- })
- }
- },
- });
|