diff --git a/model/cart.js b/model/cart.js
index d0ad6c5..c0c43cc 100644
--- a/model/cart.js
+++ b/model/cart.js
@@ -110,7 +110,7 @@ export function genCartGroupData() {
'https://cdn-we-retail.ym.tencent.com/tsr/goods/muy-3a.png',
quantity: 13,
stockStatus: true,
- stockQuantity: 9,
+ stockQuantity: 1,
price: '29900',
originPrice: '0',
tagPrice: null,
diff --git a/pages/coupon/components/coupon-card/index.js b/pages/coupon/components/coupon-card/index.js
index 07785fe..f7eaec0 100644
--- a/pages/coupon/components/coupon-card/index.js
+++ b/pages/coupon/components/coupon-card/index.js
@@ -1,7 +1,7 @@
const statusMap = {
- default: { text: '去使用', theme: 'primary' },
- useless: { text: '已使用', theme: 'default' },
- disabled: { text: '已过期', theme: 'default' },
+ 1: { text: '去使用', theme: 'primary' },
+ 2: { text: '已使用', theme: 'default' },
+ 3: { text: '已过期', theme: 'default' },
};
Component({
options: {
@@ -29,7 +29,6 @@ Component({
return;
}
const statusInfo = statusMap[couponDTO.status];
-
this.setData({
btnText: statusInfo.text,
btnTheme: statusInfo.theme,
diff --git a/pages/coupon/components/coupon-card/index.wxss b/pages/coupon/components/coupon-card/index.wxss
index 905dc40..0d3ad6f 100644
--- a/pages/coupon/components/coupon-card/index.wxss
+++ b/pages/coupon/components/coupon-card/index.wxss
@@ -1,5 +1,5 @@
.coupon-btn-default {
- display: none;
+ /* display: none; */
}
.coupon-btn-primary {
diff --git a/pages/coupon/components/ui-coupon-card/index.js b/pages/coupon/components/ui-coupon-card/index.js
index 9101be8..77b757e 100644
--- a/pages/coupon/components/ui-coupon-card/index.js
+++ b/pages/coupon/components/ui-coupon-card/index.js
@@ -71,7 +71,7 @@ Component({
status: function (value) {
let theme = 'primary';
// 已过期或已使用的券 颜色置灰
- if (value === 'useless' || value === 'disabled') {
+ if (value == 2 || value == 3) {
theme = 'weak';
}
diff --git a/pages/coupon/components/ui-coupon-card/index.wxml b/pages/coupon/components/ui-coupon-card/index.wxml
index baf53d9..5cc9ab3 100644
--- a/pages/coupon/components/ui-coupon-card/index.wxml
+++ b/pages/coupon/components/ui-coupon-card/index.wxml
@@ -23,7 +23,7 @@
{{tools.getBigValues(value)[0]}}
.{{tools.getBigValues(value)[1]}}
- {{value / 100}}
+ {{value}}
元
{{desc}}
diff --git a/pages/coupon/coupon-list/index.js b/pages/coupon/coupon-list/index.js
index f3b8675..c49009c 100644
--- a/pages/coupon/coupon-list/index.js
+++ b/pages/coupon/coupon-list/index.js
@@ -1,21 +1,22 @@
-import { fetchCouponList } from '../../../services/coupon/index';
+import {
+ fetchCouponList
+} from '../../../services/coupon/index';
Page({
data: {
- status: 0,
- list: [
- {
+ status: 1,
+ list: [{
text: '可使用',
- key: 0,
- },
- {
- text: '已使用',
key: 1,
},
{
- text: '已失效',
+ text: '已使用',
key: 2,
},
+ {
+ text: '已失效',
+ key: 3,
+ },
],
couponList: [],
@@ -32,15 +33,15 @@ Page({
fetchList(status = this.data.status) {
let statusInFetch = '';
switch (Number(status)) {
- case 0: {
+ case 1: {
statusInFetch = 'default';
break;
}
- case 1: {
+ case 2: {
statusInFetch = 'useless';
break;
}
- case 2: {
+ case 3: {
statusInFetch = 'disabled';
break;
}
@@ -48,25 +49,36 @@ Page({
throw new Error(`unknown fetchStatus: ${statusInFetch}`);
}
}
- fetchCouponList(statusInFetch).then((couponList) => {
- this.setData({ couponList });
+ // 优惠券接口
+ fetchCouponList({
+ status: this.data.status
+ }).then((couponList) => {
+ this.setData({
+ couponList
+ });
});
},
tabChange(e) {
- const { value } = e.detail;
+ const {
+ value
+ } = e.detail;
- this.setData({ status: value });
+ this.setData({
+ status: value
+ });
this.fetchList(value);
},
goCouponCenterHandle() {
- wx.showToast({ title: '去领券中心', icon: 'none' });
+ wx.showToast({
+ title: '去领券中心',
+ icon: 'none'
+ });
},
onPullDownRefresh_() {
- this.setData(
- {
+ this.setData({
couponList: [],
},
() => {
@@ -74,4 +86,4 @@ Page({
},
);
},
-});
+});
\ No newline at end of file
diff --git a/pages/coupon/coupon-list/index.json b/pages/coupon/coupon-list/index.json
index 64b7e4b..db5581f 100644
--- a/pages/coupon/coupon-list/index.json
+++ b/pages/coupon/coupon-list/index.json
@@ -5,6 +5,7 @@
"t-tabs": "tdesign-miniprogram/tabs/tabs",
"t-tab-panel": "tdesign-miniprogram/tab-panel/tab-panel",
"t-icon": "tdesign-miniprogram/icon/icon",
- "coupon-card": "../components/coupon-card/index"
+ "coupon-card": "../components/coupon-card/index",
+ "t-empty": "tdesign-miniprogram/empty/empty"
}
}
\ No newline at end of file
diff --git a/pages/coupon/coupon-list/index.wxml b/pages/coupon/coupon-list/index.wxml
index 391fe7b..654c308 100644
--- a/pages/coupon/coupon-list/index.wxml
+++ b/pages/coupon/coupon-list/index.wxml
@@ -26,6 +26,7 @@
+
diff --git a/pages/coupon/coupon-list/index.wxss b/pages/coupon/coupon-list/index.wxss
index 4e28302..b731613 100644
--- a/pages/coupon/coupon-list/index.wxss
+++ b/pages/coupon/coupon-list/index.wxss
@@ -76,3 +76,7 @@ page {
.t-class-indicator {
color: #b9b9b9 !important;
}
+.t-empty__image {
+ width: 240rpx !important;
+ height: 240rpx !important;
+}
\ No newline at end of file
diff --git a/services/coupon/index.js b/services/coupon/index.js
index a0010e0..53c5ebe 100644
--- a/services/coupon/index.js
+++ b/services/coupon/index.js
@@ -1,65 +1,22 @@
-import { config } from '../../config/index';
+import {
+ request
+} from '../_utils/request';
-/** 获取优惠券列表 */
-function mockFetchCoupon(status) {
- const { delay } = require('../_utils/delay');
- const { getCouponList } = require('../../model/coupon');
- return delay().then(() => getCouponList(status));
-}
-
-/** 获取优惠券列表 */
-export function fetchCouponList(status = 'default') {
- if (config.useMock) {
- return mockFetchCoupon(status);
- }
- return new Promise((resolve) => {
- resolve('real api');
- });
-}
-
-/** 获取优惠券 详情 */
-function mockFetchCouponDetail(id, status) {
- const { delay } = require('../_utils/delay');
- const { getCoupon } = require('../../model/coupon');
- const { genAddressList } = require('../../model/address');
-
- return delay().then(() => {
- const result = {
- detail: getCoupon(id, status),
- storeInfoList: genAddressList(),
- };
-
- result.detail.useNotes = `1个订单限用1张,除运费券外,不能与其它类型的优惠券叠加使用(运费券除外)\n2.仅适用于各区域正常售卖商品,不支持团购、抢购、预售类商品`;
- result.detail.storeAdapt = `商城通用`;
-
- if (result.detail.type === 'price') {
- result.detail.desc = `减免 ${result.detail.value / 100} 元`;
-
- if (result.detail.base) {
- result.detail.desc += `,满${result.detail.base / 100}元可用`;
+/** 优惠券列表 */
+export function fetchCouponList(parm) {
+ return new Promise((resolve, reject) => {
+ request({
+ url: `CustomerCouponApi/getCustomerCouponList`,
+ data: parm,
+ method: 'GET',
+ success: function (res) {
+ let data = res.data;
+
+ resolve(data);
+ },
+ fail: function (error) {
+ reject(error);
}
-
- result.detail.desc += '。';
- } else if (result.detail.type === 'discount') {
- result.detail.desc = `${result.detail.value}折`;
-
- if (result.detail.base) {
- result.detail.desc += `,满${result.detail.base / 100}元可用`;
- }
-
- result.detail.desc += '。';
- }
-
- return result;
+ });
});
-}
-
-/** 获取优惠券 详情 */
-export function fetchCouponDetail(id, status = 'default') {
- if (config.useMock) {
- return mockFetchCouponDetail(id, status);
- }
- return new Promise((resolve) => {
- resolve('real api');
- });
-}
+}
\ No newline at end of file