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

update

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