diff --git a/sheep/api/promotion/coupon.js b/sheep/api/promotion/coupon.js
new file mode 100644
index 00000000..d4e62dd5
--- /dev/null
+++ b/sheep/api/promotion/coupon.js
@@ -0,0 +1,12 @@
+import request from '@/sheep/request';
+
+export default {
+ // 获得优惠劵模板列表
+ getCouponTemplateListByIds: (ids) => {
+ return request({
+ url: '/app-api/promotion/coupon-template/list-by-ids',
+ method: 'GET',
+ params: { ids }
+ });
+ }
+}
diff --git a/sheep/components/s-block-item/s-block-item.vue b/sheep/components/s-block-item/s-block-item.vue
index 7b6b0345..21fe32da 100644
--- a/sheep/components/s-block-item/s-block-item.vue
+++ b/sheep/components/s-block-item/s-block-item.vue
@@ -42,7 +42,7 @@
-
+
diff --git a/sheep/components/s-coupon-block/s-coupon-block.vue b/sheep/components/s-coupon-block/s-coupon-block.vue
index d8060bce..af29c097 100644
--- a/sheep/components/s-coupon-block/s-coupon-block.vue
+++ b/sheep/components/s-coupon-block/s-coupon-block.vue
@@ -1,126 +1,54 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- 立即领取
+
+
-
-
- {{ item.get_status_text }}
-
-
-
-
-
-
+ 立即领取
+
+
+
+
-
-
-
-
-
-
-
-
- {{ item.get_status_text }}
-
-
-
-
-
-
-
-
+
@@ -168,25 +131,21 @@
border-radius: 25rpx;
font-size: 24rpx;
line-height: 50rpx;
+ &.vertical {
+ width: 50rpx;
+ height: 140rpx;
+ margin: auto 20rpx auto 0;
+
+ .btn-text {
+ font-size: 24rpx;
+ text-align: center;
+ writing-mode: vertical-lr;
+ }
+ }
}
.coupon-item {
&:nth-of-type(1) {
margin-left: 0 !important;
}
}
- .md-coupon-wrap {
- .card-btn {
- width: 50rpx;
- height: 140rpx;
- margin: auto 0;
- margin-right: 20rpx;
-
- .btn-text {
- font-size: 24rpx;
- text-align: center;
- writing-mode: vertical-lr;
- writing-mode: tb-lr;
- }
- }
- }
diff --git a/sheep/components/s-tabbar/s-tabbar.vue b/sheep/components/s-tabbar/s-tabbar.vue
index 11c6cf34..369a8232 100644
--- a/sheep/components/s-tabbar/s-tabbar.vue
+++ b/sheep/components/s-tabbar/s-tabbar.vue
@@ -1,5 +1,5 @@
-
+
{{ props.title }}
- 仅剩:{{ props.surplus }}张
+ 仅剩:{{ props.surplus }}张
@@ -82,7 +82,7 @@
{{ state.stateMap[props.state] }}
- 仅剩:{{ props.surplus }}张
+ 仅剩:{{ props.surplus }}张
@@ -159,7 +159,7 @@
},
surplus: {
type: [Number, String],
- default: 1000,
+ default: 0,
},
type: {
type: String,
diff --git a/sheep/util/const.js b/sheep/util/const.js
new file mode 100644
index 00000000..9bf6ae22
--- /dev/null
+++ b/sheep/util/const.js
@@ -0,0 +1,47 @@
+// ========== MALL - 营销模块 ==========
+
+/**
+ * 优惠类型枚举
+ */
+export const PromotionDiscountTypeEnum = {
+ PRICE: {
+ type: 1,
+ name: '满减'
+ },
+ PERCENT: {
+ type: 2,
+ name: '折扣'
+ }
+}
+
+/**
+ * 优惠劵模板的有限期类型的枚举
+ */
+export const CouponTemplateValidityTypeEnum = {
+ DATE: {
+ type: 1,
+ name: '固定日期可用'
+ },
+ TERM: {
+ type: 2,
+ name: '领取之后可用'
+ }
+}
+
+/**
+ * 营销的商品范围枚举
+ */
+export const PromotionProductScopeEnum = {
+ ALL: {
+ scope: 1,
+ name: '通用劵'
+ },
+ SPU: {
+ scope: 2,
+ name: '商品劵'
+ },
+ CATEGORY: {
+ scope: 3,
+ name: '品类劵'
+ }
+}
diff --git a/sheep/util/index.js b/sheep/util/index.js
new file mode 100644
index 00000000..355d53af
--- /dev/null
+++ b/sheep/util/index.js
@@ -0,0 +1,79 @@
+import dayjs from "dayjs";
+
+/**
+ * 将一个整数转换为分数保留两位小数
+ * @param {number | string | undefined} num 整数
+ * @return {number} 分数
+ */
+export const formatToFraction = (num) => {
+ if (typeof num === 'undefined') return 0
+ const parsedNumber = typeof num === 'string' ? parseFloat(num) : num
+ return parseFloat((parsedNumber / 100).toFixed(2))
+}
+
+/**
+ * 将一个数转换为 1.00 这样
+ * 数据呈现的时候使用
+ *
+ * @param {number | string | undefined} num 整数
+ * @return {string} 分数
+ */
+export const floatToFixed2 = (num) => {
+ let str = '0.00'
+ if (typeof num === 'undefined') {
+ return str
+ }
+ const f = formatToFraction(num)
+ const decimalPart = f.toString().split('.')[1]
+ const len = decimalPart ? decimalPart.length : 0
+ switch (len) {
+ case 0:
+ str = f.toString() + '.00'
+ break
+ case 1:
+ str = f.toString() + '.0'
+ break
+ case 2:
+ str = f.toString()
+ break
+ }
+ return str
+}
+
+/**
+ * 将一个分数转换为整数
+ *
+ * @param {number | string | undefined} num 分数
+ * @return {number} 整数
+ */
+export const convertToInteger = (num) => {
+ if (typeof num === 'undefined') return 0
+ const parsedNumber = typeof num === 'string' ? parseFloat(num) : num
+ // TODO 分转元后还有小数则四舍五入
+ return Math.round(parsedNumber * 100)
+}
+
+
+
+/**
+ * 时间日期转换
+ * @param {dayjs.ConfigType} date 当前时间,new Date() 格式
+ * @param {string} format 需要转换的时间格式字符串
+ * @description format 字符串随意,如 `YYYY-mm、YYYY-mm-dd`
+ * @description format 季度:"YYYY-mm-dd HH:MM:SS QQQQ"
+ * @description format 星期:"YYYY-mm-dd HH:MM:SS WWW"
+ * @description format 几周:"YYYY-mm-dd HH:MM:SS ZZZ"
+ * @description format 季度 + 星期 + 几周:"YYYY-mm-dd HH:MM:SS WWW QQQQ ZZZ"
+ * @returns {string} 返回拼接后的时间字符串
+ */
+export function formatDate(date, format) {
+ // 日期不存在,则返回空
+ if (!date) {
+ return ''
+ }
+ // 日期存在,则进行格式化
+ if (format === undefined) {
+ format = 'YYYY-MM-DD HH:mm:ss'
+ }
+ return dayjs(date).format(format)
+}