商店加入version,当版本不一致时刷新商店内容

This commit is contained in:
dy 2023-12-25 13:50:43 +08:00
parent c323a9e255
commit 88c39187a0
6 changed files with 15 additions and 9 deletions

View File

@ -11,7 +11,7 @@ export default async function (call: ApiCall<ReqBuy, ResBuy>) {
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
let shopData = await ShopFun.getShopData(uid, shopId);
let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv);
let shopItem = shopData.shopItems[index];

View File

@ -17,7 +17,7 @@ export default async function (call: ApiCall<ReqOpen, ResOpen>) {
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
let shopData = await ShopFun.getShopData(uid, shopId)
let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv)
call.succ(shopData);
}

View File

@ -9,7 +9,7 @@ export default async function (call: ApiCall<ReqRefresh, ResRefresh>) {
let uid = shopId != "2" ? call.uid : call.conn.gud.ghId
let shopData = await ShopFun.getShopData(uid, shopId);
let shopData = await ShopFun.getShopData(uid, shopId, call.conn.gud.lv);
if (!shopData) return call.error(globalThis.lng.shop_1);

View File

@ -1213,6 +1213,7 @@ type gc_shop = k_v<{
'npcImg': number
/** 商店看板娘说话 */
'npcText': string
'version': string | number
}>;
type gc_shopcom = k_v<{

View File

@ -4,4 +4,5 @@ import {ResOpen} from '../shared/protocols/shop/PtlOpen';
export type CollectionShop = ResOpen & {
uid: string; // 玩家uid
shopId: string; // 商店id
version: string | number;
};

View File

@ -94,7 +94,7 @@ export class ShopFun {
)).value
}
static async getShopData(uid: string, shopId: string) {
static async getShopData(uid: string, shopId: string, lv: number) {
let where = {
uid: uid,
shopId: shopId
@ -114,6 +114,10 @@ export class ShopFun {
await this.changeShopData(uid, shopId, {useFreeRefreshNum: 0, lastFreeRefreshTime: G.time});
}
if (shopConf.version && shopConf.version != shopData.version) {
await this.changeShopData(uid, shopId, {shopItems: this.getShopItems(shopId, lv)})
}
return shopData
}