diff --git a/src/api/game_data.ts b/src/api/game_data.ts index d6b3a97..c97101c 100644 --- a/src/api/game_data.ts +++ b/src/api/game_data.ts @@ -1,9 +1,12 @@ -const DATA_BASE = '' +const DATA_BASE = 'http://154.8.214.202:8030' export const searchGames = (params: any) => { + let data = {skip: 0, limit: 10} + Object.assign(data, params) return new Promise((resolve, reject) => { uni.request({ - url: `${DATA_BASE}/request/games`, + url: `${DATA_BASE}/getgamelist`, + data, success: (res) => { resolve && resolve(res.data); }, diff --git a/src/components/BigImgCell/index.vue b/src/components/BigImgCell/index.vue index 3c439fd..0e03550 100644 --- a/src/components/BigImgCell/index.vue +++ b/src/components/BigImgCell/index.vue @@ -4,28 +4,27 @@ - - 20%折扣 + + {{gData.cutOff}}%折扣 - {{gData.name}} ({{gData.ename}}) + {{gData.name}} ({{gData.subName}}) - + - - + - $200.0 - $200.0 - 美国 + ¥{{gData.price}} + ¥{{gData.originPrice}} + {{gData.priceCountry}} - - 折扣还剩7天 + + 折扣剩余{{gData.discountLeftTime}} @@ -128,6 +127,7 @@ uni-tag { padding-left: 15px; font-size: 26rpx; color: #fff; + text-shadow: black 0.1em 0.1em 0.2em; } .card-actions { diff --git a/src/components/GameSmallCell/index.vue b/src/components/GameSmallCell/index.vue index 0ff03c4..bbaa0ef 100644 --- a/src/components/GameSmallCell/index.vue +++ b/src/components/GameSmallCell/index.vue @@ -2,24 +2,24 @@ - 游戏名 + {{gData.name}} - 游戏英文名 + {{gData.subName}} - + - ¥100 - ¥150(日本) - + ¥{{gData.price}} + ¥{{gData.originPrice}}({{gData.priceCountry}}) + diff --git a/src/modules/gameinfo.ts b/src/modules/gameinfo.ts index be4c713..03800ef 100644 --- a/src/modules/gameinfo.ts +++ b/src/modules/gameinfo.ts @@ -1,9 +1,16 @@ +export interface ITagInfo{ + name: string + // default(灰色)、primary(蓝色)、success(绿色)、warning(黄色)、error(红色)、royal(紫色) + type: string + + fill: boolean +} export interface IGameInfo{ gameId: string name: string - ename: string + subName: string platform?: number - tags?: string[] + tags?: ITagInfo[] icon?: string banner?: string price?: number @@ -12,6 +19,6 @@ export interface IGameInfo{ discountLeftTime?: string, cutOff?: number - collect: boolean - zan: boolean + collect?: boolean + zan?: boolean } diff --git a/src/pages.json b/src/pages.json index 86dc99d..66aa2e8 100644 --- a/src/pages.json +++ b/src/pages.json @@ -11,7 +11,7 @@ "style": { "navigationBarTitleText": "index", "navigationStyle": "custom", - "enablePullDownRefresh": true, + "enablePullDownRefresh": false, "scrollIndicator": "none" } }, @@ -20,6 +20,7 @@ "style": { "navigationBarTitleText": "搜索", "scrollIndicator": "none", + "enablePullDownRefresh": false, "app-plus":{ "scrollIndicator":"none" } diff --git a/src/pages/index/index.vue b/src/pages/index/index.vue index 831ed9f..e5b3c68 100644 --- a/src/pages/index/index.vue +++ b/src/pages/index/index.vue @@ -13,6 +13,7 @@ > + @@ -21,6 +22,7 @@ import { Component, Vue } from 'vue-property-decorator' import BigImgCell from '@/components/BigImgCell/index.vue' import { IGameInfo } from '@/modules/gameinfo' import { getZanList, updateCollectInfo, updateZanInfo } from '@/api/game' +import { searchGames } from '@/api/game_data' @Component({ name: 'Index', @@ -32,18 +34,13 @@ import { getZanList, updateCollectInfo, updateZanInfo } from '@/api/game' export default class extends Vue{ private games: IGameInfo[] = [] + private more = 'more' + private moreCfg = {contentdown: "点击加载更多",contentrefresh: "正在加载...",contentnomore: "没有更多数据了"} $onLaunched: any async onLoad() { await this.$onLaunched; - for (let i = 0; i < 10; i++) { - this.games.push({ - gameId: i + '', - banner: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg', - name: '测试游戏' + i, - ename: 'test game ' + i - }) - } + await this.fetchGames() } onShareAppMessage(res: any) { if (res.from === 'button') {// 来自页面内分享按钮 @@ -97,7 +94,28 @@ export default class extends Vue{ private async fetchZanInfo() { await getZanList(['6500']) } - + private async loadMore(e: any) { + if (this.more === 'more') { + this.more = 'loading' + await this.fetchGames(this.games.length) + } + console.log(e) + } + private async fetchGames(start: number = 0) { + let res: any = await searchGames({cutoff: 1, skip: start}) + if (res.length === 0) { + this.more = 'noMore' + return + } + for (let data of res) { + data.gameId = data.oldGameId + '' + data.tags = [] + if (data.chinese) data.tags.push({name: data.chinese, type: 'error'}) + if (data.isLowest) data.tags.push({name: '史低', type: 'primary', fill: true}) + this.games.push(data) + } + this.more = 'more' + } } diff --git a/src/pages/list/index.vue b/src/pages/list/index.vue index e82ce47..cd21d36 100644 --- a/src/pages/list/index.vue +++ b/src/pages/list/index.vue @@ -5,6 +5,7 @@ + @@ -12,6 +13,7 @@ import { Component, Vue } from 'vue-property-decorator' import { IGameInfo } from '@/modules/gameinfo' import GameSmallCell from '@/components/GameSmallCell/index.vue' +import { searchGames } from '@/api/game_data' @Component({ name: 'Index', @@ -21,17 +23,11 @@ import GameSmallCell from '@/components/GameSmallCell/index.vue' }) export default class extends Vue{ private games: IGameInfo[] = [] + private more = 'more' + private moreCfg = {contentdown: "点击加载更多",contentrefresh: "正在加载...",contentnomore: "没有更多数据了"} - onLoad() { - for (let i = 0; i < 10; i++) { - this.games.push({ - gameId: i + '', - banner: 'https://vkceyugu.cdn.bspapp.com/VKCEYUGU-dc-site/094a9dc0-50c0-11eb-b680-7980c8a877b8.jpg', - name: '测试游戏' + i, - ename: 'test game ' + i - }) - } - + async onLoad() { + await this.fetchGames() } onClick(e: any) { @@ -41,6 +37,29 @@ export default class extends Vue{ animationDuration: 200}) } + private async loadMore(e: any) { + if (this.more === 'more') { + this.more = 'loading' + await this.fetchGames(this.games.length) + } + console.log(e) + } + private async fetchGames(start: number = 0) { + let res: any = await searchGames({cutoff: 1, skip: start}) + if (res.length === 0) { + this.more = 'noMore' + return + } + for (let data of res) { + data.gameId = data.oldGameId + '' + data.tags = [] + if (data.chinese) data.tags.push({name: data.chinese, type: 'error'}) + if (data.isLowest) data.tags.push({name: '史低', type: 'primary', fill: true}) + this.games.push(data) + } + this.more = 'more' + } + }