Commit fbd674d0 authored by 秦海涛's avatar 秦海涛

update

parent 3dcd2320
...@@ -47,7 +47,7 @@ Component({ ...@@ -47,7 +47,7 @@ Component({
const { browseItemIds } = this.props; const { browseItemIds } = this.props;
this.setData({ this.setData({
chooseId: chooseId chooseId: chooseId
? chooseId ? [...chooseId]
: browseItemIds : browseItemIds
? browseItemIds.split(",").map((i) => +i) ? browseItemIds.split(",").map((i) => +i)
: [], : [],
...@@ -111,6 +111,7 @@ Component({ ...@@ -111,6 +111,7 @@ Component({
}, },
changeCheckStatus(e) { changeCheckStatus(e) {
const { chooseId } = this.data; const { chooseId } = this.data;
if (chooseId.length >= 20) { if (chooseId.length >= 20) {
my.showToast({ my.showToast({
type: "fail", type: "fail",
...@@ -118,20 +119,20 @@ Component({ ...@@ -118,20 +119,20 @@ Component({
}); });
} }
const { item } = e.target.dataset; const { item } = e.target.dataset;
console.log(item, "item");
if (chooseId.includes(item.itemId)) { if (chooseId.includes(item.itemId)) {
this.setData({ this.setData({
chooseId: chooseId, chooseId: chooseId.filter(v => v !== item.itemId),
}); });
} else { } else {
this.setData({ this.setData({
chooseId: [item.itemId], chooseId: [...chooseId, item.itemId],
}); });
} }
}, },
sureBabyDialog() { sureBabyDialog() {
const { chooseId } = this.data; const { chooseId } = this.data;
console.log(chooseId, "chooseId"); // console.log(chooseId, "chooseId");
this.props.onUpdateBabyChoose(chooseId.join()); this.props.onUpdateBabyChoose(chooseId.join());
this.closeBaby(); this.closeBaby();
}, },
......
...@@ -10,13 +10,14 @@ Component({ ...@@ -10,13 +10,14 @@ Component({
onSuccess: () => {}, onSuccess: () => {},
onError: () => {}, onError: () => {},
url: '', url: '',
dataName: ''
}, },
didMount() {}, didMount() {},
didUpdate() {}, didUpdate() {},
didUnmount() {}, didUnmount() {},
methods: { methods: {
async uploadImage() { async uploadImage() {
const { onSuccess, onError } = this.props; const { onSuccess, onError, dataName } = this.props;
try { try {
const res = await chooseImage(); const res = await chooseImage();
...@@ -38,7 +39,7 @@ Component({ ...@@ -38,7 +39,7 @@ Component({
}); });
onSuccess && onSuccess(url) onSuccess && onSuccess(url, dataName)
} catch (error) { } catch (error) {
onError({}, error) onError({}, error)
} }
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<view class="tb-rule-title">用于展示在活动页的规则说明</view> <view class="tb-rule-title">用于展示在活动页的规则说明</view>
<textarea <textarea
style="width:400px;margin: 10px 0 0 0" style="width:400px;margin: 10px 0 0 0"
value="{{rule}}" value="{{value}}"
onChange="onChange" onChange="onChange"
maxLength="2000" maxLength="2000"
hasLimitHint="{{true}}" hasLimitHint="{{true}}"
......
Component({ Component({
data: {}, data: {},
props: { props: {
onChange: () => {} onChange: () => {},
value: '',
}, },
didMount() {}, didMount() {},
didUpdate() {}, didUpdate() {},
methods: { methods: {
onChange(e) { onChange(e) {
this.props.onChange && this.props.onChange(e); this.props.onChange && this.props.onChange(e.detail.value);
}, },
}, },
}); });
<view class="items-config"> <view class="items-config">
<text style="font-size: 12px">{{itemIds ? `已选择${(itemIds + '').split(',')}个商品` : ''}} </text> <text style="font-size: 12px">{{itemIds ? `已选择${(itemIds + '').split(',').length}个商品` : ''}} </text>
<button type="primary" text size="small" onTap="onOpenDialog">{{itemIds ? '更换商品' : '选择商品'}}</button> <button type="primary" text size="small" onTap="onOpenDialog">{{itemIds ? '更换商品' : '选择商品'}}</button>
<items-dialog <items-dialog
onUpdateBabyChoose="onUpdateBabyChoose" onUpdateBabyChoose="onUpdateBabyChoose"
......
export default { export default {
// ams:ams接口,cloud: 云函数 // ams:ams接口,cloud: 云函数
requestType: "ams", requestType: "cloud",
// app环境 // app环境
env: "test", // online 线上 test 测试 env: "test", // online 线上 test 测试
......
...@@ -70,22 +70,6 @@ ...@@ -70,22 +70,6 @@
<tb-label title="任务配置"/> <tb-label title="任务配置"/>
<!-- <form-item
class="edit-content-form-item"
label="关注店铺"
validateState="{{formState['taskMap.attentionStore'].status}}"
help="{{formState['taskMap.attentionStore'].message}}"
asterisk="{{false}}">
<tb-config-input
textBefore="获得"
textAfter="体力值"
validateRange="{{[1, 99]}}"
value="{{taskMap.attentionStore.value}}"
dataName="taskMap.attentionStore.value"
onChange="onTaskInputChange",
placeholder="1-99"
/>
</form-item> -->
<form-item <form-item
class="edit-content-form-item" class="edit-content-form-item"
...@@ -104,51 +88,6 @@ ...@@ -104,51 +88,6 @@
/> />
</form-item> </form-item>
<form-item
class="edit-content-form-item"
label="签到"
validateState="{{formState['taskMap.sign'].status}}"
help="{{formState['taskMap.sign'].message}}"
asterisk="{{false}}">
<tb-config-input
textBefore="每日签到获得"
textAfter="体力值"
validateRange="{{[1, 99]}}"
value="{{taskMap.sign.value}}"
dataName="taskMap.sign.value"
onChange="onTaskInputChange",
placeholder="1-99"
/>
</form-item>
<form-item
class="edit-content-form-item"
label="兑换参与次数"
validateState="{{formState['taskMap.exchangeCredits'].status}}"
help="{{formState['taskMap.exchangeCredits'].message}}"
asterisk="{{false}}">
<tb-config-input
textBefore="可消耗"
textAfter="积分兑换参与次数"
validateRange="{{[1, 99]}}"
value="{{taskMap.exchangeCredits.value}}"
dataName="taskMap.exchangeCredits.value"
onChange="onTaskInputChange",
placeholder="1-99"
/>
<view style="margin: 10px 0 0 0">
<tb-config-input
textBefore="每天最多可兑换"
textAfter="次"
validateRange="{{[1, 10]}}"
value="{{taskMap.exchangeCredits.times}}"
dataName="taskMap.exchangeCredits.times"
onChange="onTaskInputChange",
placeholder="1-10"
/>
</view>
</form-item>
<form-item <form-item
class="edit-content-form-item" class="edit-content-form-item"
label="邀请好友" label="邀请好友"
...@@ -160,7 +99,7 @@ ...@@ -160,7 +99,7 @@
type="inviteFriends" type="inviteFriends"
taskData="{{taskMap.inviteFriends}}" taskData="{{taskMap.inviteFriends}}"
dataName="taskMap.inviteFriends" dataName="taskMap.inviteFriends"
onUpdate="onTaskDialogChange" onUpdate="onTaskChange"
/> />
</form-item> </form-item>
...@@ -176,25 +115,7 @@ ...@@ -176,25 +115,7 @@
hasLink hasLink
taskData="{{taskMap.jumpLink}}" taskData="{{taskMap.jumpLink}}"
dataName="taskMap.jumpLink" dataName="taskMap.jumpLink"
onUpdate="onTaskDialogChange" onUpdate="onTaskChange"
/>
</form-item>
<form-item
class="edit-content-form-item"
label="收藏商品"
validateState="{{formState['taskMap.collectGoods'].status}}"
help="{{formState['taskMap.collectGoods'].message}}"
asterisk="{{false}}">
<task-config
unit="体力值"
type="collectGoods"
hasLink
hasItems
taskData="{{taskMap.collectGoods}}"
dataName="taskMap.collectGoods"
onUpdate="onTaskDialogChange"
/> />
</form-item> </form-item>
...@@ -204,16 +125,16 @@ ...@@ -204,16 +125,16 @@
validateState="{{formState['taskMap.browseGoods'].status}}" validateState="{{formState['taskMap.browseGoods'].status}}"
help="{{formState['taskMap.browseGoods'].message}}" help="{{formState['taskMap.browseGoods'].message}}"
asterisk="{{false}}"> asterisk="{{false}}">
<items-config itemIds="{{taskMap.browseGoods.itemIds}}" dataName="taskMap.browseGoods" onUpdate="onTaskChange"/> <items-config itemIds="{{taskMap.browseGoods.itemIds}}" dataName="taskMap.browseGoods.itemIds" onUpdate="onTaskChange"/>
</form-item> </form-item>
<form-item <form-item
validateState="{{formState.image.status}}" validateState="{{formState.logoImage.status}}"
help="{{formState.image.message}}" help="{{formState.logoImage.message}}"
class="edit-content-form-item" class="edit-content-form-item"
label="logo图片" label="logo图片"
asterisk="{{false}}"> asterisk="{{false}}">
<tb-image-upload url="{{image}}" onSuccess="onImageChange"/> <tb-image-upload url="{{logoImage}}" dataName="logoImage" onSuccess="onChangeByDataName"/>
</form-item> </form-item>
...@@ -256,7 +177,17 @@ ...@@ -256,7 +177,17 @@
class="edit-content-form-item" class="edit-content-form-item"
label="淘口令图片" label="淘口令图片"
asterisk="{{false}}"> asterisk="{{false}}">
<tb-image-upload url="{{commandImg}}" onSuccess="onImageChange"/> <tb-image-upload url="{{commandImg}}" dataName="commandImg" onSuccess="onChangeByDataName"/>
</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"/>
</form-item> </form-item>
<view class="submit-btn"> <view class="submit-btn">
......
...@@ -87,19 +87,19 @@ Component({ ...@@ -87,19 +87,19 @@ Component({
], ],
taskMap: { taskMap: {
attentionStore: { // attentionStore: {
value: '', // value: '',
}, // },
beMembership: { beMembership: {
value:'' value:''
}, },
sign: { // sign: {
value: '' // value: ''
}, // },
exchangeCredits: { // exchangeCredits: {
value: '', // value: '',
times: '', // times: '',
}, // },
inviteFriends: { inviteFriends: {
title: '', // 任务标题 title: '', // 任务标题
taskRateType: 1, // 任务频率类型 taskRateType: 1, // 任务频率类型
...@@ -107,19 +107,20 @@ Component({ ...@@ -107,19 +107,20 @@ Component({
value: '', // 任务奖励 value: '', // 任务奖励
}, },
browseGoods: { browseGoods: {
title: "", title: "寻宝屋商品",
taskRateType: 1, taskRateType: 1,
times: 3, times: 3,
value: '', value: '',
link: '' link: '',
}, itemIds: ''
collectGoods: { },
title: "", // collectGoods: {
taskRateType: 1, // title: "",
times: 3, // taskRateType: 1,
value: '90', // times: 3,
itemIds: "", // value: '90',
}, // itemIds: "",
// },
jumpLink: { jumpLink: {
title: "", title: "",
taskRateType: 3, taskRateType: 3,
...@@ -176,6 +177,11 @@ Component({ ...@@ -176,6 +177,11 @@ Component({
[name]: value [name]: value
}) })
}, },
onRuleChange(rule) {
this.setData({
rule
})
},
setDataByKey(name, val) { setDataByKey(name, val) {
const keys = name.split('.'); const keys = name.split('.');
if(keys.length === 1) { if(keys.length === 1) {
...@@ -289,6 +295,9 @@ Component({ ...@@ -289,6 +295,9 @@ Component({
const params = this.formatActivityParams(this.data) const params = this.formatActivityParams(this.data)
console.log(params)
saveActivityInfo(params) saveActivityInfo(params)
.then(res => { .then(res => {
if (res.success) { if (res.success) {
...@@ -309,11 +318,14 @@ Component({ ...@@ -309,11 +318,14 @@ Component({
// 格式化参数 // 格式化参数
formatActivityParams(params) { formatActivityParams(params) {
const { const {
id, id = '',
activityId, activityId = '',
startTime, startTime,
endTime, endTime,
rule, rule,
title,
subtitle,
logoImg,
prizeInfoList, prizeInfoList,
taskList, taskList,
taskMap, taskMap,
...@@ -324,7 +336,11 @@ Component({ ...@@ -324,7 +336,11 @@ Component({
return { return {
id,
activityId, activityId,
title,
subtitle,
logoImg,
startTime: new Date(startTime).getTime(), startTime: new Date(startTime).getTime(),
endTime: new Date(endTime).getTime(), endTime: new Date(endTime).getTime(),
rule, rule,
...@@ -348,10 +364,10 @@ Component({ ...@@ -348,10 +364,10 @@ Component({
return list; return list;
}, },
// taskList转化taskMap // taskList转化taskMap
formatTaskListToMap(taskList) { formatTaskListToMap(taskList = []) {
let taskMap = {}; let taskMap = {};
taskList.forEach(task => { taskList.forEach(task => {
taskMap[task[type]] = task; taskMap[task['type']] = task;
}); });
return taskMap return taskMap
}, },
...@@ -360,6 +376,8 @@ Component({ ...@@ -360,6 +376,8 @@ Component({
let totalPercent = prizeInfoList.reduce((total, next) => { let totalPercent = prizeInfoList.reduce((total, next) => {
return total = addFloat(total, +next.probablity) return total = addFloat(total, +next.probablity)
}, 0) }, 0)
// 排名类型不含谢谢参与
if(prizeInfoList[0].rank) return prizeInfoList;
let prizeInfoListCopy = prizeInfoList.concat().map((v, index) => ({ ...v, level: index })); let prizeInfoListCopy = prizeInfoList.concat().map((v, index) => ({ ...v, level: index }));
if (totalPercent < 100) { if (totalPercent < 100) {
...@@ -382,6 +400,9 @@ Component({ ...@@ -382,6 +400,9 @@ Component({
let { name } = dataset let { name } = dataset
this.setData({ [name]: value }) this.setData({ [name]: value })
}, },
onChangeByDataName(val, dataName) {
this.setDataByKey(dataName, val)
},
// 选择奖品弹窗 // 选择奖品弹窗
handlerShowPrize(evt) { handlerShowPrize(evt) {
const { const {
......
...@@ -22,28 +22,34 @@ export const descriptor = { ...@@ -22,28 +22,34 @@ export const descriptor = {
timeRange: { timeRange: {
required: true required: true
}, },
image: { logoImage: {
required: true, required: true,
message: "请上传正确的图片" message: '请配置图片'
},
commandTitle: {
required: true,
message: '请输入淘口令名称'
},
beenInvitedText: {
required: true,
message: '请输入被邀请者文案'
},
commandImg: {
required: true,
message: '请输入淘口令图片'
},
rule: {
required: true,
message: '请输入活动规则'
}, },
taskMap: { taskMap: {
type: 'object', type: 'object',
required: true, required: true,
fields: { fields: {
attentionStore: {
validator: (rule, val) => {
return !!val.value
},
message: '请输入关注店铺任务的奖励'
},
beMembership: { beMembership: {
validator: (rule, val) => !!val.value, validator: (rule, val) => !!val.value,
message: '请输入成为会员任务的奖励' message: '请输入成为会员任务的奖励'
}, },
sign: {
validator: (rule, val) => !!val.value,
message: '请输入签到任务的奖励'
},
inviteFriends: { inviteFriends: {
validator: (rule, val) => !!(val.title && val.value), validator: (rule, val) => !!(val.title && val.value),
message: '请输入邀请任务' message: '请输入邀请任务'
...@@ -56,15 +62,9 @@ export const descriptor = { ...@@ -56,15 +62,9 @@ export const descriptor = {
}, },
browseGoods: { browseGoods: {
validator: (rule, val) => { validator: (rule, val) => {
return !!(val.title && val.value && val.link); return !!(val.itemIds);
}, },
message: '请输入寻宝屋商品任务' message: '请输入寻宝屋商品任务'
},
exchangeCredits: {
validator: (rule, val) => {
return !!(val.value && val.times);
},
message: '请输入兑换次数任务'
} }
} }
} }
......
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