Commit 6444ac45 authored by qinhaitao's avatar qinhaitao

refactor: 💡 统一字段

parent 43e53752
......@@ -28,11 +28,11 @@ Component({
<%- !taskKeys.includes(configList[i].key) && configList[i].key !== 'label' ? `${configList[i].key}: ${configList[i].defaultValue || "''"},` : '' %><% } %>
tasks: {
// 关注店铺
attentionStore: {
follow: {
value: '',
},
// 成为会员
beMembership: {
member: {
value: '',
},
// 签到
......@@ -45,7 +45,7 @@ Component({
times: '',
},
// 邀请好友
inviteFriends: {
invites: {
title: '', // 任务标题
taskRateType: 1, // 任务频率类型
times: 3, // 任务为每日限次次数值
......
......@@ -81,17 +81,17 @@
<form-item
class="edit-content-form-item"
label="成为会员"
validateState="{{formState['taskMap.beMembership'].status}}"
help="{{formState['taskMap.beMembership'].message}}"
validateState="{{formState['taskMap.member'].status}}"
help="{{formState['taskMap.member'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.beMembership.checked}}" data-name="taskMap.beMembership.checked" onChange="onCheckChange"></checkbox>
<checkbox class="form-check" checked="{{taskMap.member.checked}}" data-name="taskMap.member.checked" onChange="onCheckChange"></checkbox>
<tb-config-input
textBefore="获得"
textAfter="体力值"
validateRange="{{[1, 99]}}"
value="{{taskMap.beMembership.value}}"
dataName="taskMap.beMembership.value"
value="{{taskMap.member.value}}"
dataName="taskMap.member.value"
onChange="onTaskInputChange",
placeholder="1-99"
/>
......@@ -101,16 +101,16 @@
<form-item
class="edit-content-form-item"
label="邀请好友"
validateState="{{formState['taskMap.inviteFriends'].status}}"
help="{{formState['taskMap.inviteFriends'].message}}"
validateState="{{formState['taskMap.invites'].status}}"
help="{{formState['taskMap.invites'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.inviteFriends.checked}}" data-name="taskMap.inviteFriends.checked" onChange="onCheckChange"></checkbox>
<checkbox class="form-check" checked="{{taskMap.invites.checked}}" data-name="taskMap.invites.checked" onChange="onCheckChange"></checkbox>
<task-config
unit="体力值"
type="inviteFriends"
taskData="{{taskMap.inviteFriends}}"
dataName="taskMap.inviteFriends"
type="invites"
taskData="{{taskMap.invites}}"
dataName="taskMap.invites"
onUpdate="onTaskChange"
/>
</view>
......
This diff is collapsed.
import { TASK_RATE_TYPE } from '../const'
import flatten from 'lodash/flatten'
import { TASK_RATE_TYPE } from "../const";
import flatten from "lodash/flatten";
import { rankTableValidator } from "../../../utils/validate";
// 使用 async-validator 校验
......@@ -9,22 +9,22 @@ export const descriptor = {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value && value.length <= 12
return !!value && value.length <= 12;
},
message: "请输入正确的活动名称"
message: "请输入正确的活动名称",
},
subtitle: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value && value.length <= 16
return !!value && value.length <= 16;
},
message: "请输入正确的活动副标题"
message: "请输入正确的活动副标题",
},
prizeInfoList: {
required: true,
validator: rankTableValidator
validator: rankTableValidator,
},
//活动的开始时间和结束时间校验判断
timeRange: {
......@@ -45,7 +45,7 @@ export const descriptor = {
},
logoImg: {
required: true,
message: '请配置图片'
message: "请配置图片",
},
commandTitle: {
required: true,
......@@ -53,7 +53,7 @@ export const descriptor = {
value = value.trim();
return !!value;
},
message: '请输入淘口令名称'
message: "请输入淘口令名称",
},
beenInvitedText: {
required: true,
......@@ -61,11 +61,11 @@ export const descriptor = {
value = value.trim();
return !!value;
},
message: '请输入被邀请者文案'
message: "请输入被邀请者文案",
},
commandImg: {
required: true,
message: '请输入淘口令图片'
message: "请输入淘口令图片",
},
rule: {
required: true,
......@@ -73,62 +73,59 @@ export const descriptor = {
value = value.trim();
return !!value;
},
message: '请输入活动规则'
message: "请输入活动规则",
},
taskMap: {
type: 'object',
type: "object",
required: true,
fields: {
beMembership: {
member: {
validator: (rule, val, cb, source) => {
if(!source.beMembership.checked) return true;
return !!val.value
if (!source.member.checked) return true;
return !!val.value;
},
message: '请输入成为会员任务的奖励'
message: "请输入成为会员任务的奖励",
},
inviteFriends: {
invites: {
validator: (rule, val, cb, source) => {
if(!source.inviteFriends.checked) return true;
return !!(val.title && val.value)
if (!source.invites.checked) return true;
return !!(val.title && val.value);
},
message: '请输入邀请任务'
message: "请输入邀请任务",
},
jumpLink: {
validator: (rule, val, cb, source) => {
if(!source.jumpLink.checked) return true;
if (!source.jumpLink.checked) return true;
return !!(val.title && val.value && val.link);
},
message: '请输入浏览指定页面任务'
message: "请输入浏览指定页面任务",
},
browseGoods: {
validator: (rule, val) => {
return !!(val.itemIds);
return !!val.itemIds;
},
message: "请输入寻宝屋商品任务",
},
},
},
message: '请输入寻宝屋商品任务'
}
}
}
};
export const formatValidator = (descriptor, validators) => {
validators = validators || {}
Object.keys(descriptor).forEach(key => {
if(descriptor[key].fields) {
Object.keys(descriptor[key].fields).forEach(fieldKey => {
validators = validators || {};
Object.keys(descriptor).forEach((key) => {
if (descriptor[key].fields) {
Object.keys(descriptor[key].fields).forEach((fieldKey) => {
validators[`${key}.${fieldKey}`] = {
status: 'success',
message: ''
}
})
status: "success",
message: "",
};
});
} else {
validators[key] = {
status: 'success',
message: ''
status: "success",
message: "",
};
}
}
});
return validators
}
\ No newline at end of file
return validators;
};
......@@ -29,9 +29,8 @@ const DRAW_STATUS = {
//库存类型
const STOCK_TYPE = {
LIMIT_STOCK: 1,
NO_LIMIT_STOCK: 2
}
NO_LIMIT_STOCK: 2,
};
// 日志类型: error,info
const LOGGER_TYPE = {
......@@ -42,8 +41,8 @@ const LOGGER_TYPE = {
const SHIP_STATUS = {
NO_ADDRESS: 1,
NO_SHIP: 2,
HAS_SHIP: 3
}
HAS_SHIP: 3,
};
const PRIZE_TYPE = {
EQUITY: 1,
......@@ -55,8 +54,8 @@ const PRIZE_TYPE = {
const PRIZE_DATA_TYPR = {
RANK_PRIZE: 1,
PRO_PRIZE: 2,
BUILD_PRIZE: 3
}
BUILD_PRIZE: 3,
};
// code类型
const CODE_TYPES = {
PARAMS_ERROR: {
......@@ -95,11 +94,11 @@ const TEMPLATE_INFO = {
};
const TASK_TYPE_CHINA = {
beMembership: "成为会员",
attentionStore: "关注店铺",
member: "成为会员",
follow: "关注店铺",
sign: "签到",
exchangeCredits: "兑换积分",
inviteFriends: "邀请好友",
invites: "邀请好友",
orderGoods: "下单商品",
browseGoods: "浏览商品",
jumpLink: "跳转链接",
......@@ -108,11 +107,11 @@ const TASK_TYPE_CHINA = {
const TASK_CHECK_TYPE = {
value: {
list: [
"beMembership",
"attentionStore",
"member",
"follow",
"sign",
"exchangeCredits",
"inviteFriends",
"invites",
"orderGoods",
"jumpLink",
"collectGoods",
......@@ -123,7 +122,7 @@ const TASK_CHECK_TYPE = {
times: {
list: [
"exchangeCredits",
"inviteFriends",
"invites",
"orderGoods",
"browseGoods",
"jumpLink",
......@@ -131,19 +130,13 @@ const TASK_CHECK_TYPE = {
],
},
title: {
list: [
"inviteFriends",
"orderGoods",
"browseGoods",
"jumpLink",
"collectGoods",
],
list: ["invites", "orderGoods", "browseGoods", "jumpLink", "collectGoods"],
},
itemIds: {
list: ["orderGoods", "browseGoods", "collectGoods"],
},
taskRateType: {
list: ["inviteFriends", "orderGoods", "browseGoods", "collectGoods"],
list: ["invites", "orderGoods", "browseGoods", "collectGoods"],
},
link: { list: ["jumpLink"] },
};
......@@ -171,5 +164,5 @@ module.exports = {
PRIZE_TYPE,
SHIP_STATUS,
STOCK_TYPE,
PRIZE_DATA_TYPR
PRIZE_DATA_TYPR,
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment