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

update

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