From 141233bb0f0c5c9d1614fb97f6394221a154cba7 Mon Sep 17 00:00:00 2001 From: "Stormeye.Wu" Date: Thu, 23 Aug 2018 21:54:37 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=9A=E6=80=81=E5=88=9D=E5=A7=8B=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/coupons/index/index.js | 70 +++++++++++++++++----------------- pages/coupons/index/index.wxml | 2 +- pages/index/coupons/index.js | 60 ++++++++++++++++------------- 3 files changed, 69 insertions(+), 63 deletions(-) diff --git a/pages/coupons/index/index.js b/pages/coupons/index/index.js index f46b55b..8d9d15f 100644 --- a/pages/coupons/index/index.js +++ b/pages/coupons/index/index.js @@ -5,51 +5,51 @@ const Http = require("../../../utils/HttpBasics") //1535126400000 Page({ data: { - tabs: [{ - key: 0, - name: "未使用" - }, - { - key: 1, - name: "已使用" - }, - { - key: 2, - name: "已过期" - }, - { - key: 3, - name: "已退款" - } - ], + tabs: [], list: [], current: '', current_scroll: '1' }, onLoad() { - this.getList(0) + this.getBusinessList(1) + this.getList(0, 1) }, - getList(key) { + getList(key, pageNum) { var that = this Http.get({ - url: config.api.couponOrderList, - data: { - pageNum: 1, - pageSize: 10, - orderStatus: key - } - }) - .then(function(res) { - console.log(res) - res.data.list.map(file => { - file.expiredTime = format.formatTime(file.expiredTime, 'yyyy-MM-dddd hh:mm:ss') + url: config.api.couponOrderList, + data: { + pageNum: pageNum, + pageSize: 10, + orderStatus: key + } }) - that.setData({ - list: res.data.list + .then(res => { + console.log(res) + res.data.list.map(file => { + file.expiredTime = format.formatTime(file.expiredTime, 'yyyy-MM-dddd hh:mm:ss') + }) + that.setData({ + list: res.data.list + }) }) - },function(error){ - - }) + }, + getBusinessList(pageNum) { + var that = this + Http.get({ + url: config.api.businessList, + data: { + pageNum: pageNum, + pageSize: 10, + type: 1 + } + }) + .then(function(res) { + console.log(res) + that.setData({ + list: res.data.list + }) + }, function(error) {}) }, handleChange({ detail diff --git a/pages/coupons/index/index.wxml b/pages/coupons/index/index.wxml index 6aa57d3..98bf28d 100644 --- a/pages/coupons/index/index.wxml +++ b/pages/coupons/index/index.wxml @@ -1,6 +1,6 @@ - + diff --git a/pages/index/coupons/index.js b/pages/index/coupons/index.js index 5059eb9..1b41688 100644 --- a/pages/index/coupons/index.js +++ b/pages/index/coupons/index.js @@ -14,32 +14,7 @@ Component({ * 组件的初始数据 */ data: { - tabs: [{ - key: 1, - name: "全部" - }, - { - key: 2, - name: "餐饮" - }, - { - key: 3, - name: "娱乐" - }, { - key: 4, - name: "服饰" - }, { - key: 5, - name: "超市" - }, - { - key: 6, - name: "亲子" - }, { - key: 7, - name: "其他" - }, - ], + tabs: [], list: [], current: '1', current_scroll: '1', @@ -66,8 +41,23 @@ Component({ }, }, ready() { - // TODO business获取 if (app.globalData.token && app.globalData.token != null) { + // business获取 + Http.get({ + url: config.api.businessList, + data: { + pageNum: 1, + pageSize: 10, + type: 1 + } + }) + .then(res => { + console.log(res) + that.setData({ + list: res.data.list + }) + }) + // 券list获取 Http.get({ url: config.api.couponList, data: { @@ -82,6 +72,22 @@ Component({ }) } else { app.couponListCallback = token => { + // business获取 + Http.get({ + url: config.api.businessList, + data: { + pageNum: pageNum, + pageSize: 10, + type: 1 + } + }) + .then(res => { + console.log(res) + that.setData({ + list: res.data.list + }) + }) + // 券list获取 Http.get({ url: config.api.couponList, data: {