faet 添加优惠券列表对接
This commit is contained in:
parent
cd8590d259
commit
d6710e5a11
@ -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,
|
||||
|
@ -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,
|
||||
|
@ -1,5 +1,5 @@
|
||||
.coupon-btn-default {
|
||||
display: none;
|
||||
/* display: none; */
|
||||
}
|
||||
|
||||
.coupon-btn-primary {
|
||||
|
@ -71,7 +71,7 @@ Component({
|
||||
status: function (value) {
|
||||
let theme = 'primary';
|
||||
// 已过期或已使用的券 颜色置灰
|
||||
if (value === 'useless' || value === 'disabled') {
|
||||
if (value == 2 || value == 3) {
|
||||
theme = 'weak';
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
<text class="wr-coupon__left--value-int">{{tools.getBigValues(value)[0]}}</text>
|
||||
<text class="wr-coupon__left--value-decimal">.{{tools.getBigValues(value)[1]}}</text>
|
||||
</text>
|
||||
<text class="wr-coupon__left--value" wx:else>{{value / 100}}</text>
|
||||
<text class="wr-coupon__left--value" wx:else>{{value}}</text>
|
||||
<text class="wr-coupon__left--unit">元</text>
|
||||
<view class="wr-coupon__left--desc">{{desc}}</view>
|
||||
</view>
|
||||
|
@ -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({
|
||||
},
|
||||
);
|
||||
},
|
||||
});
|
||||
});
|
@ -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"
|
||||
}
|
||||
}
|
@ -26,6 +26,7 @@
|
||||
<view class="coupon-list-item" wx:for="{{couponList}}" wx:key="key">
|
||||
<coupon-card couponDTO="{{item}}" />
|
||||
</view>
|
||||
<t-empty wx:if="{{couponList.length == 0}}" t-class="empty-cls" t-class-image="t-empty__image" image="https://tdesign.gtimg.com/miniprogram/images/empty1.png" description="暂无数据" />
|
||||
</t-pull-down-refresh>
|
||||
<view class="center-entry">
|
||||
<view class="center-entry-btn" bind:tap="goCouponCenterHandle">
|
||||
|
@ -76,3 +76,7 @@ page {
|
||||
.t-class-indicator {
|
||||
color: #b9b9b9 !important;
|
||||
}
|
||||
.t-empty__image {
|
||||
width: 240rpx !important;
|
||||
height: 240rpx !important;
|
||||
}
|
@ -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');
|
||||
});
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user