Commit 2a21b58a authored by 秦海涛's avatar 秦海涛

update

parent 79a03b04
...@@ -2,223 +2,18 @@ ...@@ -2,223 +2,18 @@
<view class="edit-breadcrumb"> <view class="edit-breadcrumb">
<text class="edit-title edit-title_my" onTap="backList">我的活动</text> <text class="edit-title edit-title_my" onTap="backList">我的活动</text>
<text class="edit-title edit-title-separate">/</text> <text class="edit-title edit-title-separate">/</text>
<text class="edit-title">{{activityId ? '编辑' : '新建'}} 「 店铺漂流记 」 活动</text> <text class="edit-title">{{activityId ? '编辑' : '新建'}} 「 <%=appName%> 」 活动</text>
</view> </view>
<view class="edit-content"> <view class="edit-content">
<form class="edit-content-form" inline="true" labelTextAlign="right" labelCol="{{labelCol}}"> <form class="edit-content-form" inline="true" labelTextAlign="right" labelCol="{{labelCol}}">
<tb-label title="基础配置"/> <% for(var i = 0; i < configList.length; ++i) {%>
<form-item <%-configList[i].template%><% } %>
class="edit-content-form-item"
label="活动时间"
validateState="{{formState.timeRange.status}}"
help="{{formState.timeRange.message}}"
asterisk="{{false}}">
<tb-range-picker
timeRange="{{timeRange}}"
originalStartTime="{{originalStartTime}}"
onChange="onTimeChange"
disableStartTime="{{isStart}}"
/>
</form-item>
<form-item
validateState="{{formState.title.status}}"
help="{{formState.title.message}}"
class="edit-content-form-item"
label="活动名称"
asterisk="{{false}}">
<tb-input
placeholder="请输入活动名称"
maxLength="12"
value="{{title}}"
dataName="title"
hasLimitHint="{{true}}"
onChange="onChange"
tips="活动名称仅在配置后台展示,用于区分活动,不在C端展示"
/>
</form-item>
<form-item
validateState="{{formState.subtitle.status}}"
help="{{formState.subtitle.message}}"
class="edit-content-form-item"
label="活动副标题"
asterisk="{{false}}">
<tb-input
placeholder="漂流寻宝赢取100元现金红包"
maxLength="16"
value="{{subtitle}}"
dataName="subtitle"
hasLimitHint="{{true}}"
onChange="onChange"
tips="活动副标题用于C端游戏首页展示,需与活动奖品相关,用于吸引用户参与"
/>
</form-item>
<tb-label title="奖品配置"/>
<form-item
class="edit-content-form-item"
label="奖品配置"
validateState="{{formState.prizeInfoList.status}}"
help="{{formState.prizeInfoList.message}}"
asterisk="{{false}}">
<rank-table
list="{{prizeInfoList}}"
onChange="onPrizeListChange"
limit="{{11}}"
maxRankLimit="{{100}}"
fixedRank="{{['1', '2', '3']}}"
imageLimit="{{[200, 200]}}"
/>
</form-item>
<tb-label title="任务配置"/>
<form-item
class="edit-content-form-item"
label="成为会员"
validateState="{{formState['taskMap.beMembership'].status}}"
help="{{formState['taskMap.beMembership'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.beMembership.checked}}" data-name="taskMap.beMembership.checked" onChange="onCheckChange"></checkbox>
<tb-config-input
textBefore="获得"
textAfter="体力值"
validateRange="{{[1, 99]}}"
value="{{taskMap.beMembership.value}}"
dataName="taskMap.beMembership.value"
onChange="onTaskInputChange",
placeholder="1-99"
/>
</view>
</form-item>
<form-item
class="edit-content-form-item"
label="邀请好友"
validateState="{{formState['taskMap.inviteFriends'].status}}"
help="{{formState['taskMap.inviteFriends'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.inviteFriends.checked}}" data-name="taskMap.inviteFriends.checked" onChange="onCheckChange"></checkbox>
<task-config
unit="体力值"
type="inviteFriends"
taskData="{{taskMap.inviteFriends}}"
dataName="taskMap.inviteFriends"
onUpdate="onTaskChange"
/>
</view>
</form-item>
<form-item
class="edit-content-form-item"
label="浏览指定页面"
validateState="{{formState['taskMap.jumpLink'].status}}"
help="{{formState['taskMap.jumpLink'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.jumpLink.checked}}" data-name="taskMap.jumpLink.checked" onChange="onCheckChange"></checkbox>
<task-config
unit="体力值"
type="jumpLink"
hasLink
taskData="{{taskMap.jumpLink}}"
dataName="taskMap.jumpLink"
onUpdate="onTaskChange"
/>
</view>
</form-item>
<form-item
class="edit-content-form-item"
label="寻宝屋商品"
validateState="{{formState['taskMap.browseGoods'].status}}"
help="{{formState['taskMap.browseGoods'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.browseGoods.checked}}" disabled="{{true}}"></checkbox>
<items-config itemIds="{{taskMap.browseGoods.itemIds}}" dataName="taskMap.browseGoods.itemIds" onUpdate="onTaskChange"/>
</view>
</form-item>
<form-item
validateState="{{formState.logoImg.status}}"
help="{{formState.logoImg.message}}"
class="edit-content-form-item"
label="logo图片"
asterisk="{{false}}">
<view style="display:flex;">
<tb-image-upload url="{{logoImg}}" dataName="logoImg" onSuccess="onChangeByDataName" imageLimit="{{[200, 90]}}"/>
<question-tips>
<image style="width:200px;height:400px;border:1px solid #ccc;margin-right:10px" src="//yun.duiba.com.cn/20200410/image2020-6-7_18-16-3.png"></image>
</question-tips>
</view>
</form-item>
<tb-label title="邀请配置"/>
<form-item
validateState="{{formState.commandTitle.status}}"
help="{{formState.commandTitle.message}}"
class="edit-content-form-item"
label="邀请淘口令名称"
asterisk="{{false}}">
<tb-input
placeholder="请输入邀请者淘口令名称"
maxLength="20"
value="{{commandTitle}}"
dataName="commandTitle"
hasLimitHint="{{true}}"
onChange="onChange"
/>
</form-item>
<form-item
validateState="{{formState.beenInvitedText.status}}"
help="{{formState.beenInvitedText.message}}"
class="edit-content-form-item"
label="被邀请者文案"
asterisk="{{false}}">
<tb-input
placeholder="请输入被邀请者文案"
maxLength="30"
value="{{beenInvitedText}}"
dataName="beenInvitedText"
hasLimitHint="{{true}}"
onChange="onChange"
/>
</form-item>
<form-item
validateState="{{formState.commandImg.status}}"
help="{{formState.commandImg.message}}"
class="edit-content-form-item"
label="淘口令图片"
asterisk="{{false}}">
<tb-image-upload url="{{commandImg}}" dataName="commandImg" onSuccess="onChangeByDataName" imageLimit="{{[400, 300]}}"/>
</form-item>
<tb-label title="规则配置"/>
<form-item
validateState="{{formState.rule.status}}"
help="{{formState.rule.message}}"
class="edit-content-form-item"
label="活动规则"
asterisk="{{false}}">
<tb-rule value="{{rule}}" onChange="onRuleChange" generateRuleInfo="{{{title: subtitle, startTime, endTime, prizeInfoList}}}"/>
</form-item>
<view class="submit-btn"> <view class="submit-btn">
<button onTap="onSubmit" type="primary">确定</button> <button onTap="onSubmit" type="primary">确定</button>
<button onTap="cancelEdit">取消</button> <button>取消</button>
</view> </view>
</form> </form>
......
This diff is collapsed.
import { TASK_RATE_TYPE } from '../const'
import flatten from 'lodash/flatten'
import { rankTableValidator } from "../../../utils/validate"; import { rankTableValidator } from "../../../utils/validate";
// 使用 async-validator 校验 // 使用 async-validator 校验
// 文档地址: https://github.com/yiminghe/async-validator // 文档地址: https://github.com/yiminghe/async-validator
export const descriptor = {
title: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value && value.length <= 12
},
message: "请输入正确的活动名称"
},
subtitle: { export const descriptor = {
required: true, <% for(var i = 0; i < configList.length; ++i) {%>
validator: (rule, value) => { <%- !taskKeys.includes(configList[i].key) && configList[i].validator ? configList[i].validator + ',' : '' %><% } %>
value = value.trim();
return !!value && value.length <= 16
},
message: "请输入正确的活动副标题"
},
prizeInfoList: {
required: true,
validator: rankTableValidator
},
timeRange: {required: true
},
logoImg: {
required: true,
message: '请配置图片'
},
commandTitle: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value;
},
message: '请输入淘口令名称'
},
beenInvitedText: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value;
},
message: '请输入被邀请者文案'
},
commandImg: {
required: true,
message: '请输入淘口令图片'
},
rule: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value;
},
message: '请输入活动规则'
},
taskMap: { taskMap: {
type: 'object', type: 'object',
required: true, required: false,
fields: { fields: {
beMembership: { <% for(var i = 0; i < configList.length; ++i) {%>
validator: (rule, val, cb, source) => { <%- taskKeys.includes(configList[i].key) && configList[i].validator ? configList[i].validator + ',' : '' %><% } %>
if(!source.beMembership.checked) return true;
return !!val.value
},
message: '请输入成为会员任务的奖励'
},
inviteFriends: {
validator: (rule, val, cb, source) => {
if(!source.inviteFriends.checked) return true;
return !!(val.title && val.value)
},
message: '请输入邀请任务'
},
jumpLink: {
validator: (rule, val, cb, source) => {
if(!source.jumpLink.checked) return true;
return !!(val.title && val.value && val.link);
},
message: '请输入浏览指定页面任务'
},
browseGoods: {
validator: (rule, val) => {
return !!(val.itemIds);
},
message: '请输入寻宝屋商品任务'
}
} }
} }
}; }
......
<view class="edit-container">
<view class="edit-breadcrumb">
<text class="edit-title edit-title_my" onTap="backList">我的活动</text>
<text class="edit-title edit-title-separate">/</text>
<text class="edit-title">{{activityId ? '编辑' : '新建'}} 「 店铺漂流记 」 活动</text>
</view>
<view class="edit-content">
<form class="edit-content-form" inline="true" labelTextAlign="right" labelCol="{{labelCol}}">
<tb-label title="基础配置"/>
<form-item
class="edit-content-form-item"
label="活动时间"
validateState="{{formState.timeRange.status}}"
help="{{formState.timeRange.message}}"
asterisk="{{false}}">
<tb-range-picker
timeRange="{{timeRange}}"
originalStartTime="{{originalStartTime}}"
onChange="onTimeChange"
disableStartTime="{{isStart}}"
/>
</form-item>
<form-item
validateState="{{formState.title.status}}"
help="{{formState.title.message}}"
class="edit-content-form-item"
label="活动名称"
asterisk="{{false}}">
<tb-input
placeholder="请输入活动名称"
maxLength="12"
value="{{title}}"
dataName="title"
hasLimitHint="{{true}}"
onChange="onChange"
tips="活动名称仅在配置后台展示,用于区分活动,不在C端展示"
/>
</form-item>
<form-item
validateState="{{formState.subtitle.status}}"
help="{{formState.subtitle.message}}"
class="edit-content-form-item"
label="活动副标题"
asterisk="{{false}}">
<tb-input
placeholder="漂流寻宝赢取100元现金红包"
maxLength="16"
value="{{subtitle}}"
dataName="subtitle"
hasLimitHint="{{true}}"
onChange="onChange"
tips="活动副标题用于C端游戏首页展示,需与活动奖品相关,用于吸引用户参与"
/>
</form-item>
<tb-label title="奖品配置"/>
<form-item
class="edit-content-form-item"
label="奖品配置"
validateState="{{formState.prizeInfoList.status}}"
help="{{formState.prizeInfoList.message}}"
asterisk="{{false}}">
<rank-table
list="{{prizeInfoList}}"
onChange="onPrizeListChange"
limit="{{11}}"
maxRankLimit="{{100}}"
fixedRank="{{['1', '2', '3']}}"
imageLimit="{{[200, 200]}}"
/>
</form-item>
<tb-label title="任务配置"/>
<form-item
class="edit-content-form-item"
label="成为会员"
validateState="{{formState['taskMap.beMembership'].status}}"
help="{{formState['taskMap.beMembership'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.beMembership.checked}}" data-name="taskMap.beMembership.checked" onChange="onCheckChange"></checkbox>
<tb-config-input
textBefore="获得"
textAfter="体力值"
validateRange="{{[1, 99]}}"
value="{{taskMap.beMembership.value}}"
dataName="taskMap.beMembership.value"
onChange="onTaskInputChange",
placeholder="1-99"
/>
</view>
</form-item>
<form-item
class="edit-content-form-item"
label="邀请好友"
validateState="{{formState['taskMap.inviteFriends'].status}}"
help="{{formState['taskMap.inviteFriends'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.inviteFriends.checked}}" data-name="taskMap.inviteFriends.checked" onChange="onCheckChange"></checkbox>
<task-config
unit="体力值"
type="inviteFriends"
taskData="{{taskMap.inviteFriends}}"
dataName="taskMap.inviteFriends"
onUpdate="onTaskChange"
/>
</view>
</form-item>
<form-item
class="edit-content-form-item"
label="浏览指定页面"
validateState="{{formState['taskMap.jumpLink'].status}}"
help="{{formState['taskMap.jumpLink'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.jumpLink.checked}}" data-name="taskMap.jumpLink.checked" onChange="onCheckChange"></checkbox>
<task-config
unit="体力值"
type="jumpLink"
hasLink
taskData="{{taskMap.jumpLink}}"
dataName="taskMap.jumpLink"
onUpdate="onTaskChange"
/>
</view>
</form-item>
<form-item
class="edit-content-form-item"
label="寻宝屋商品"
validateState="{{formState['taskMap.browseGoods'].status}}"
help="{{formState['taskMap.browseGoods'].message}}"
asterisk="{{false}}">
<view class="form-flex">
<checkbox class="form-check" checked="{{taskMap.browseGoods.checked}}" disabled="{{true}}"></checkbox>
<items-config itemIds="{{taskMap.browseGoods.itemIds}}" dataName="taskMap.browseGoods.itemIds" onUpdate="onTaskChange"/>
</view>
</form-item>
<form-item
validateState="{{formState.logoImg.status}}"
help="{{formState.logoImg.message}}"
class="edit-content-form-item"
label="logo图片"
asterisk="{{false}}">
<view style="display:flex;">
<tb-image-upload url="{{logoImg}}" dataName="logoImg" onSuccess="onChangeByDataName" imageLimit="{{[200, 90]}}"/>
<question-tips>
<image style="width:200px;height:400px;border:1px solid #ccc;margin-right:10px" src="//yun.duiba.com.cn/20200410/image2020-6-7_18-16-3.png"></image>
</question-tips>
</view>
</form-item>
<tb-label title="邀请配置"/>
<form-item
validateState="{{formState.commandTitle.status}}"
help="{{formState.commandTitle.message}}"
class="edit-content-form-item"
label="邀请淘口令名称"
asterisk="{{false}}">
<tb-input
placeholder="请输入邀请者淘口令名称"
maxLength="20"
value="{{commandTitle}}"
dataName="commandTitle"
hasLimitHint="{{true}}"
onChange="onChange"
/>
</form-item>
<form-item
validateState="{{formState.beenInvitedText.status}}"
help="{{formState.beenInvitedText.message}}"
class="edit-content-form-item"
label="被邀请者文案"
asterisk="{{false}}">
<tb-input
placeholder="请输入被邀请者文案"
maxLength="30"
value="{{beenInvitedText}}"
dataName="beenInvitedText"
hasLimitHint="{{true}}"
onChange="onChange"
/>
</form-item>
<form-item
validateState="{{formState.commandImg.status}}"
help="{{formState.commandImg.message}}"
class="edit-content-form-item"
label="淘口令图片"
asterisk="{{false}}">
<tb-image-upload url="{{commandImg}}" dataName="commandImg" onSuccess="onChangeByDataName" imageLimit="{{[400, 300]}}"/>
</form-item>
<tb-label title="规则配置"/>
<form-item
validateState="{{formState.rule.status}}"
help="{{formState.rule.message}}"
class="edit-content-form-item"
label="活动规则"
asterisk="{{false}}">
<tb-rule value="{{rule}}" onChange="onRuleChange" generateRuleInfo="{{{title: subtitle, startTime, endTime, prizeInfoList}}}"/>
</form-item>
<view class="submit-btn">
<button onTap="onSubmit" type="primary">确定</button>
<button onTap="cancelEdit">取消</button>
</view>
</form>
</view>
\ No newline at end of file
import { TASK_RATE_TYPE } from '../const'
import flatten from 'lodash/flatten'
import { rankTableValidator } from "../../../utils/validate";
// 使用 async-validator 校验
// 文档地址: https://github.com/yiminghe/async-validator
export const descriptor = {
title: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value && value.length <= 12
},
message: "请输入正确的活动名称"
},
subtitle: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value && value.length <= 16
},
message: "请输入正确的活动副标题"
},
prizeInfoList: {
required: true,
validator: rankTableValidator
},
timeRange: {required: true
},
logoImg: {
required: true,
message: '请配置图片'
},
commandTitle: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value;
},
message: '请输入淘口令名称'
},
beenInvitedText: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value;
},
message: '请输入被邀请者文案'
},
commandImg: {
required: true,
message: '请输入淘口令图片'
},
rule: {
required: true,
validator: (rule, value) => {
value = value.trim();
return !!value;
},
message: '请输入活动规则'
},
taskMap: {
type: 'object',
required: true,
fields: {
beMembership: {
validator: (rule, val, cb, source) => {
if(!source.beMembership.checked) return true;
return !!val.value
},
message: '请输入成为会员任务的奖励'
},
inviteFriends: {
validator: (rule, val, cb, source) => {
if(!source.inviteFriends.checked) return true;
return !!(val.title && val.value)
},
message: '请输入邀请任务'
},
jumpLink: {
validator: (rule, val, cb, source) => {
if(!source.jumpLink.checked) return true;
return !!(val.title && val.value && val.link);
},
message: '请输入浏览指定页面任务'
},
browseGoods: {
validator: (rule, val) => {
return !!(val.itemIds);
},
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[`${key}.${fieldKey}`] = {
status: 'success',
message: ''
}
})
} else {
validators[key] = {
status: 'success',
message: ''
}
}
});
return validators
}
\ No newline at end of file
<view class="edit-container">
<view class="edit-breadcrumb">
<text class="edit-title edit-title_my" onTap="backList">我的活动</text>
<text class="edit-title edit-title-separate">/</text>
<text class="edit-title">{{activityId ? '编辑' : '新建'}} 「 <%=appName%> 」 活动</text>
</view>
<view class="edit-content">
<form class="edit-content-form" inline="true" labelTextAlign="right" labelCol="{{labelCol}}">
<% for(var i = 0; i < configList.length; ++i) {%>
<%-configList[i].template%><% } %>
<view class="submit-btn">
<button onTap="onSubmit" type="primary">确定</button>
<button>取消</button>
</view>
</form>
</view>
\ No newline at end of file
import { rankTableValidator } from "../../../utils/validate";
// 使用 async-validator 校验
// 文档地址: https://github.com/yiminghe/async-validator
export const descriptor = {
<% for(var i = 0; i < configList.length; ++i) {%>
<%- !taskKeys.includes(configList[i].key) && configList[i].validator ? configList[i].validator + ',' : '' %><% } %>
taskMap: {
type: 'object',
required: false,
fields: {
<% for(var i = 0; i < configList.length; ++i) {%>
<%- taskKeys.includes(configList[i].key) && configList[i].validator ? configList[i].validator + ',' : '' %><% } %>
}
}
}
export const formatValidator = (descriptor, validators) => {
validators = validators || {}
Object.keys(descriptor).forEach(key => {
if(descriptor[key].fields) {
Object.keys(descriptor[key].fields).forEach(fieldKey => {
validators[`${key}.${fieldKey}`] = {
status: 'success',
message: ''
}
})
} else {
validators[key] = {
status: 'success',
message: ''
}
}
});
return validators
}
\ No newline at end of file
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
<text class="db-title">活动管理</text> <text class="db-title">活动管理</text>
<button type="primary" onTap="tapname">创建活动</button> <button type="primary" onTap="tapname">创建活动</button>
</view> </view>
<list-table/> <%- listTable %>
...@@ -3,6 +3,9 @@ const { function: fc } = cloud; ...@@ -3,6 +3,9 @@ const { function: fc } = cloud;
Component({ Component({
props: {}, props: {},
data: {
buttons: <%= buttons %>
},
methods: { methods: {
// 创建活动 // 创建活动
tapname() { tapname() {
......
...@@ -2,4 +2,4 @@ ...@@ -2,4 +2,4 @@
<text class="db-title">活动管理</text> <text class="db-title">活动管理</text>
<button type="primary" onTap="tapname">创建活动</button> <button type="primary" onTap="tapname">创建活动</button>
</view> </view>
<%- listTable %> <list-table/>
...@@ -3,9 +3,6 @@ const { function: fc } = cloud; ...@@ -3,9 +3,6 @@ const { function: fc } = cloud;
Component({ Component({
props: {}, props: {},
data: {
buttons: <%= buttons %>
},
methods: { methods: {
// 创建活动 // 创建活动
tapname() { tapname() {
......
...@@ -12,11 +12,11 @@ export default { ...@@ -12,11 +12,11 @@ export default {
}, },
{ {
path: "/list", path: "/list",
component: "listTemp", component: "list",
}, },
{ {
path: "/add", path: "/add",
component: "addTemp", component: "add",
}, },
{ {
path: '/data/:id', path: '/data/:id',
...@@ -24,7 +24,7 @@ export default { ...@@ -24,7 +24,7 @@ export default {
}, },
{ {
path: "/edit/:id", path: "/edit/:id",
component: "addTemp", component: "add",
}, },
], ],
} }
......
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