Commit 6444ac45 authored by qinhaitao's avatar qinhaitao

refactor: 💡 统一字段

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