✨ feat(37需求): 打开webview的页面
This commit is contained in:
@@ -46,6 +46,7 @@ import { getPlayerMiniGameDataShow } from './miniGameService';
|
||||
import { getWeeklyFundDataShow } from './weeklyFundService';
|
||||
import { getMonthlyFundData } from './monthlyFundService';
|
||||
import { getPlayerRebateDataShow } from './rebateService';
|
||||
import { getWebviewDataShow } from './webviewService';
|
||||
|
||||
/**
|
||||
* 获取活动数据
|
||||
@@ -262,6 +263,11 @@ export async function getActivity(serverId: number, roleId: string, uid: number,
|
||||
activityData = await getPlayerRebateDataShow(activityId, serverId, roleId, uid);
|
||||
break
|
||||
}
|
||||
case ACTIVITY_TYPE.WEBVIEW:
|
||||
{
|
||||
activityData = await getWebviewDataShow(activityId, serverId, roleId);
|
||||
break
|
||||
}
|
||||
default: {
|
||||
console.log('未知活动类型.........', activityType)
|
||||
break;
|
||||
|
||||
29
game-server/app/services/activity/webviewService.ts
Normal file
29
game-server/app/services/activity/webviewService.ts
Normal file
@@ -0,0 +1,29 @@
|
||||
import { WebViewData } from "../../domain/activityField/webviewField";
|
||||
import { getRoleCreateTime, getServerCreateTime } from "../redisService";
|
||||
import { getActivityById } from "./activityService";
|
||||
|
||||
/**
|
||||
* 玩家活动数据
|
||||
*
|
||||
* @param {number} serverId 区Id
|
||||
* @param {number} activityId 活动Id
|
||||
* @param {string} roleId 角色Id
|
||||
*
|
||||
*/
|
||||
export async function getWebviewData(activityId: number, serverId: number, roleId: string) {
|
||||
|
||||
let activityData = await getActivityById(activityId);
|
||||
let createTime = await getRoleCreateTime(roleId);
|
||||
let serverTime = await getServerCreateTime(serverId);
|
||||
|
||||
let playerData = new WebViewData(activityData, createTime, serverTime);
|
||||
return playerData;
|
||||
}
|
||||
|
||||
export async function getWebviewDataShow(activityId: number, serverId: number, roleId: string) {
|
||||
let playerData = await getWebviewData(activityId, serverId, roleId);
|
||||
if(playerData && playerData.canShow && playerData.canShow()) {
|
||||
return playerData.getShowResult();
|
||||
}
|
||||
return null
|
||||
}
|
||||
@@ -268,8 +268,8 @@ export default class GameController extends Controller {
|
||||
|
||||
public async updateOtherLink() {
|
||||
const { ctx } = this;
|
||||
const { wxPublicAccountQrCode, bbsLink, customerLink } = ctx.request.body;
|
||||
ctx.body = await ctx.service.game.updateOtherLink(wxPublicAccountQrCode, bbsLink, customerLink);
|
||||
const { wxPublicAccountQrCode, bbsLink, bbsAndroidLink, customerLink } = ctx.request.body;
|
||||
ctx.body = await ctx.service.game.updateOtherLink(wxPublicAccountQrCode, bbsLink, bbsAndroidLink, customerLink);
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -437,11 +437,11 @@ export default class Game extends Service {
|
||||
return ctx.service.utils.resResult(STATUS.SUCCESS);
|
||||
}
|
||||
|
||||
public async updateOtherLink(wxPublicAccountQrCode: string, bbsLink: string, customerLink: string ) {
|
||||
public async updateOtherLink(wxPublicAccountQrCode: string, bbsLink: string, bbsAndroidLink: string, customerLink: string ) {
|
||||
const { ctx } = this;
|
||||
let updateArr: { type: number, link?: string, qrCodeLink?: string }[] = [];
|
||||
let updateArr: { type: number, link?: string, qrCodeLink?: string, androidLink?: string }[] = [];
|
||||
if(wxPublicAccountQrCode) updateArr.push({ type: SNS_LINK_TYPE.WX_PUBLIC_ACCOUNT, qrCodeLink: wxPublicAccountQrCode });
|
||||
if(bbsLink) updateArr.push({ type: SNS_LINK_TYPE.BBS, link: bbsLink });
|
||||
if(bbsLink) updateArr.push({ type: SNS_LINK_TYPE.BBS, link: bbsLink, androidLink: bbsAndroidLink });
|
||||
if(customerLink) updateArr.push({ type: SNS_LINK_TYPE.CUSTOMER, link: customerLink });
|
||||
await LinkModel.updateLinks(updateArr, ctx.user?.uid);
|
||||
|
||||
|
||||
@@ -65,7 +65,8 @@ export enum ACTIVITY_TYPE {
|
||||
BIND_PHONE = 50, // 绑定手机号
|
||||
WEEKLY_FUND = 51, // 周基金
|
||||
MONTHLY_FUND = 52, // 月基金
|
||||
REBATE = 53, // 返利
|
||||
REBATE = 53, // 返利
|
||||
WEBVIEW = 54, // 平台活动页面
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,6 +13,8 @@ export default class Link extends BaseModel {
|
||||
@prop({ required: true, default: '' })
|
||||
link: string; // 外链
|
||||
@prop({ required: true, default: '' })
|
||||
androidLink: string; // 安卓外链
|
||||
@prop({ required: true, default: '' })
|
||||
qrCodeLink: string; // 微信群二维码
|
||||
|
||||
public static async findByServerId(serverId: number) {
|
||||
@@ -35,9 +37,9 @@ export default class Link extends BaseModel {
|
||||
return result;
|
||||
}
|
||||
|
||||
public static async updateLinks(updateArr: { type: number, link?: string, qrCodeLink?: string }[], uid: number) {
|
||||
await LinkModel.bulkWrite(updateArr.map(({type, link, qrCodeLink}) => {
|
||||
return { updateOne: { filter: { type, serverId: 0 }, update: { $set: { link, qrCodeLink, updatedBy: uid }, $setOnInsert: { createdBy: uid } }, upsert: true} }
|
||||
public static async updateLinks(updateArr: { type: number, link?: string, qrCodeLink?: string, androidLink?: string }[], uid: number) {
|
||||
await LinkModel.bulkWrite(updateArr.map(({type, link, qrCodeLink, androidLink }) => {
|
||||
return { updateOne: { filter: { type, serverId: 0 }, update: { $set: { link, qrCodeLink, androidLink, updatedBy: uid }, $setOnInsert: { createdBy: uid } }, upsert: true} }
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,10 +86,12 @@ class WXPublicAccountPage extends PageData {
|
||||
}
|
||||
|
||||
class BBSPage extends PageData {
|
||||
link: string; // 论坛外链
|
||||
iosLink: string; // 论坛外链
|
||||
androidLink: string; // 安卓外链
|
||||
|
||||
public setLink(link: LinkType) {
|
||||
this.link = link.link;
|
||||
this.iosLink = link.link;
|
||||
this.androidLink = link.androidLink;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
34
shared/domain/activityField/webviewField.ts
Normal file
34
shared/domain/activityField/webviewField.ts
Normal file
@@ -0,0 +1,34 @@
|
||||
import { ActivityModelType } from "../../db/Activity";
|
||||
import { ActivityBase } from "./activityField";
|
||||
|
||||
interface WebViewDataInDb {
|
||||
iosUrl: string;
|
||||
androidUrl: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* 打脸公告
|
||||
*/
|
||||
export class WebViewData extends ActivityBase {
|
||||
iosUrl: string;
|
||||
androidUrl: string;
|
||||
|
||||
constructor(activityData: ActivityModelType, createTime: number, serverTime: number) {
|
||||
super(activityData, createTime, serverTime)
|
||||
this.initData(activityData.data)
|
||||
}
|
||||
|
||||
public initData(data: string) {
|
||||
let dataObj: WebViewDataInDb = JSON.parse(data);
|
||||
this.iosUrl = dataObj.iosUrl;
|
||||
this.androidUrl = dataObj.androidUrl;
|
||||
}
|
||||
|
||||
public getShowResult() {
|
||||
return {
|
||||
...this.getBaseKeys(),
|
||||
iosUrl: this.iosUrl,
|
||||
androidUrl: this.androidUrl,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -292,5 +292,11 @@
|
||||
"activityType": 53,
|
||||
"name": "REBATE",
|
||||
"string": "返利"
|
||||
},
|
||||
{
|
||||
"id": 54,
|
||||
"activityType": 54,
|
||||
"name": "WEBVIEW",
|
||||
"string": "平台活动网页"
|
||||
}
|
||||
]
|
||||
Reference in New Issue
Block a user