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

update

parent f1f9af32
......@@ -43,7 +43,7 @@
</form-item>
<form-item label="任务奖励">
<input onChange="onChange" data-name="value" defaultValue="{{value}}" name="value" addonTextAfter="{{unit}}"/>
<input onChange="onChange" data-name="value" defaultValue="{{value}}" name="value" addonTextAfter="{{unit}}" placeholder="1-999" maxLength="{{3}}"/>
</form-item>
</form>
<view class="task-content-btn">
......
......@@ -72,8 +72,9 @@ Component({
const [startTime, endTime] = e.detail.value;
const innerTimeRange = [ startTime || '', endTime || '' ];
if(!startTime && !endTime) {
this.confrimChangeTime(['', ''])
this.confrimChangeTime(['', ''], '请输入活动时间')
}
this.setData({
innerTimeRange
})
......@@ -92,9 +93,9 @@ Component({
}
let timeHasSame = new Date(endTime).getTime() === new Date(startTime).getTime()
let timeIsCantChoose = new Date().getTime() > new Date(startTime).getTime()
let timeBeginError = new Date().getTime(startTime) > new Date(endTime).getTime();
if (timeHasSame || timeIsCantChoose) {
if (timeHasSame || timeIsCantChoose || timeBeginError) {
let errTips = '';
if (timeIsCantChoose && !disableStartTime) {
errTips = `活动开始时间不能小于当前时间`
......@@ -104,6 +105,10 @@ Component({
errTips = `开始时间不能等于结束时间`
console.log('error', '开始时间不能等于结束时间')
}
if(timeBeginError) {
errTips = `开始时间不能大于结束时间`;
console.log('error', '开始时间不能大于结束时间');
}
this.confrimChangeTime([startTime, endTime], errTips)
} else {
this.setData({
......
......@@ -8,140 +8,45 @@ const ResultsModel = require("../utils/results.model");
let resultsModel = new ResultsModel();
//保存授权信息
//保存授权信息//保存授权信息
module.exports = async (context) => {
loginfo(context, "sellerInfo");
let {
openId,
accessToken,
appKey,
userNick,
appOwnerOpenId,
consumeMiniAppId,
} = context;
let { openId, accessToken, appKey, userNick, appOwnerOpenId } = context;
let ActivitySeller = new ActivitySellerService(context);
let ActivityTop = new ActivityTopService(context);
let ActivityInstance = new ActivityInstanceService(context);
try {
let primaryAccountNick = userNick;
let isPrimaryAccount = true;
if (~userNick.indexOf(":")) {
let userNickArr = userNick.split(":");
isPrimaryAccount = false;
primaryAccountNick = userNickArr[0];
if (!isPrimaryAccount) {
let sellerInfo = await ActivitySeller.getSellerInfoByUserNick(
primaryAccountNick
);
if (sellerInfo) {
accessToken = sellerInfo.accessToken;
} else {
return resultsModel.error(
CODE_TYPES.SYSTEM_ERROR,
"请用主账号进入后台进行授权"
);
}
let userNickArr = userNick.split(":");
let isPrimaryAccount = userNickArr.length === 1;
console.log(userNick, isPrimaryAccount, "userNick------");
if (!isPrimaryAccount) {
let sellerInfo = await ActivitySeller.getSellerInfoByUserNick(
userNickArr[0]
);
console.log(sellerInfo, "seller----info------");
if (sellerInfo) {
accessToken = sellerInfo.accessToken;
}
}
let hasResult = await ActivitySeller.findSellerInfo(openId);
let subInfo = await ActivityTop.getSubRelationship(primaryAccountNick);
if (hasResult && hasResult[0] && isPrimaryAccount) {
await ActivitySeller.updateSellerInfo(openId, {
let hasResult = await ActivitySeller.findSellerInfo(context.openId);
if (hasResult && hasResult[0]) {
await ActivitySeller.updateSellerInfo(context.openId, {
accessToken,
});
await ActivityInstance.updateInstanceInfo(openId, {
accessToken,
});
// return resultsModel.success({ deadline: subInfo.deadline || "" });
return resultsModel.success(true);
} else {
let shopInfoResult = await ActivityTop.getShopId();
if (!shopInfoResult.success) {
return resultsModel.error(
CODE_TYPES.SYSTEM_ERROR,
"获取淘宝店铺信息失败"
);
}
try {
await ActivitySeller.saveSellerInfo({
let result = await ActivitySeller.saveSellerInfo({
accessToken,
openId,
appKey,
shopId: shopInfoResult.data.sid,
userNick,
appOwnerOpenId,
});
// return resultsModel.success({ deadline: subInfo.deadline || "" });
return resultsModel.success(result);
} catch (e) {
console.log(e, "保存授权信息失败");
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "保存授权信息失败");
}
}
let instanceOldInfo = await ActivityInstance.getMiniAppInstanceInfoByNick(
primaryAccountNick
);
if (!instanceOldInfo) {
if (!isPrimaryAccount) {
return resultsModel.error(
CODE_TYPES.SYSTEM_ERROR,
"请用主账号进入后台进行授权"
);
}
let instanceInfo = await ActivityTop.getTemplateInstantiate();
const { app_id, app_version } = instanceInfo;
if (instanceInfo) {
let onlineInstance = await ActivityTop.pushOnlineInstance({
app_id,
app_version,
});
await ActivityInstance.saveInstanceInfo({
...instanceInfo,
clients: onlineInstance.online_results.miniapp_instance_app_online_dto.reduce(
(s, v) => {
return (s += v.client + ",");
},
""
),
...onlineInstance.app_info,
accessToken,
template_version: TEMPLATE_INFO.template_version,
template_id: TEMPLATE_INFO.template_id,
openId,
appKey,
consumeMiniAppId,
userNick,
appOwnerOpenId,
});
} else {
console.log("实例化信息获取失败");
}
} else {
if (TEMPLATE_INFO.template_version !== instanceOldInfo.template_version) {
const { clients, app_id, template_id } = instanceOldInfo;
let updateInfo = {
clients,
app_id,
template_id,
ext_json: {
name: "online",
},
template_version: TEMPLATE_INFO.template_version,
};
let updateInstanceInfo = await ActivityTop.updateMiniInstance(
updateInfo
);
let onlineInstance = await ActivityTop.pushOnlineInstance({
app_id: updateInstanceInfo.app_id,
app_version: updateInstanceInfo.app_version,
});
await ActivityInstance.updateInstanceInfo({
template_version: TEMPLATE_INFO.template_version,
...onlineInstance.app_info,
app_version: updateInstanceInfo.app_version,
pre_view_url: updateInstanceInfo.pre_view_url,
});
}
}
return resultsModel.success({ deadline: subInfo.deadline || "" });
} catch (e) {
console.log(e, "获取授权信息失败");
return resultsModel.error(CODE_TYPES.SYSTEM_ERROR, "获取授权信息失败");
......
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