diff --git a/package1/components/planet/planet-daily-loop.vue b/package1/components/planet/planet-daily-loop.vue new file mode 100644 index 0000000..fe160b6 --- /dev/null +++ b/package1/components/planet/planet-daily-loop.vue @@ -0,0 +1,108 @@ + + + + + diff --git a/package1/components/planet/planet-operate.vue b/package1/components/planet/planet-operate.vue new file mode 100644 index 0000000..4b397db --- /dev/null +++ b/package1/components/planet/planet-operate.vue @@ -0,0 +1,157 @@ + + + + + diff --git a/package1/planet/index.vue b/package1/planet/index.vue index a224020..32e8c4b 100644 --- a/package1/planet/index.vue +++ b/package1/planet/index.vue @@ -38,6 +38,14 @@ @draw="goDrawResult"> + + + + + + @@ -103,6 +123,8 @@ import huntModal from '@/package1/components/planet/hunt-modal.vue' import buffShop from '@/package1/components/planet/buff-shop.vue' import planetNews from '@/package1/components/planet/planet-news.vue' + import planetOperate from '@/package1/components/planet/planet-operate.vue' + import planetDailyLoop from '@/package1/components/planet/planet-daily-loop.vue' export default { components: { @@ -113,7 +135,9 @@ planetRank, huntModal, buffShop, - planetNews + planetNews, + planetOperate, + planetDailyLoop }, data() { return { @@ -134,7 +158,9 @@ rankList: [], buffShop: [], newsList: [], - myBuffs: [] + myBuffs: [], + operate: {}, + dailyLoop: {} }, boxOpening: false, boxResult: { @@ -313,6 +339,129 @@ }) }) }, + promptTickets(title, callback) { + uni.showModal({ + title, + editable: true, + placeholderText: '输入星球券数量', + success: (res) => { + if (!res.confirm) return + const tickets = parseInt(res.content || '0', 10) + if (!tickets || tickets <= 0) { + this.tui.toast('请输入正确数量') + return + } + callback(tickets) + } + }) + }, + operateRequest(url, data, successText) { + this.tui.request(url, 'POST', Object.assign({ + userId: this.userId, + regionId: this.regionId + }, data || {})).then((res) => { + this.tui.toast(res.code == 200 ? successText : res.message, 1500, res.code == 200) + if (res.code == 200) this.loadHome(true) + }) + }, + onPlantTree(config) { + this.promptTickets(`投入 ${config.cycleHours}h 券树`, (tickets) => { + this.operateRequest('/app/planet/tree/plant', { configId: config.id, tickets }, '种植成功') + }) + }, + onHarvestTree(order) { + if (order.status === 2) { + this.tui.toast('这棵券树已经收获') + return + } + this.operateRequest('/app/planet/tree/harvest', { orderId: order.id }, '收获成功') + }, + onStoreWarehouse() { + this.promptTickets('存入松鼠仓库', (tickets) => { + this.operateRequest('/app/planet/warehouse/store', { tickets }, '存入成功') + }) + }, + onTakeWarehouse() { + this.promptTickets('从仓库取出', (tickets) => { + this.operateRequest('/app/planet/warehouse/take', { tickets }, '取出成功') + }) + }, + onUpgradeWarehouse() { + this.tui.modal('升级仓库', '确认消耗星球券升级松鼠仓库?', true, (ok) => { + if (ok) this.operateRequest('/app/planet/warehouse/upgrade', {}, '升级成功') + }) + }, + onUpgradeTower() { + this.tui.modal('升级防御塔', '确认消耗星球券提升拦截能力?', true, (ok) => { + if (ok) this.operateRequest('/app/planet/tower/upgrade', {}, '升级成功') + }) + }, + onRandomSearch() { + this.startSearch('/app/planet/search/random', {}, { nickname: '随机同校区玩家' }) + }, + onDailyCollect() { + if (!this.home.dailyLoop || !this.home.dailyLoop.signedToday) { + this.onSign() + return + } + if (this.home.dailyLoop.boxAvailable) { + this.openBox() + return + } + this.tui.toast('今天的顺手券已经收完') + }, + onDailyRevenge() { + const loop = this.home.dailyLoop || {} + if (loop.hasRevengeTarget && loop.revengeTarget && loop.revengeTarget.fromUserId) { + this.startSearch('/app/planet/search/target', { toUserId: loop.revengeTarget.fromUserId }, loop.revengeTarget) + } else { + this.onRandomSearch() + } + }, + startSearch(url, data, target) { + this.huntModal.show = true + this.huntModal.phase = 'searching' + this.huntModal.result = null + this.huntModal.target = target || { nickname: '同校区玩家' } + setTimeout(() => { this.huntModal.phase = 'locking' }, 900) + setTimeout(() => { this.huntModal.phase = 'chasing' }, 1800) + this.tui.request(url, 'POST', Object.assign({ + userId: this.userId, + regionId: this.regionId + }, data || {}), false, false, true).then((res) => { + setTimeout(() => { + if (res.code == 200 && res.result) { + this.huntModal.result = { + result: res.result.intercepted ? 'shield' : 'success', + message: res.result.message, + gainTickets: res.result.gainTickets, + totalGain: res.result.gainTickets, + remainHunt: res.result.remainSearchCount + } + this.huntModal.phase = 'result' + this.loadHome(true) + } else { + this.huntModal.show = false + this.tui.toast(res.message) + } + }, 2200) + }).catch(() => { + this.huntModal.show = false + }) + }, + onJoinPool() { + const loop = this.home.dailyLoop || {} + const n = loop.suggestedAddTickets || 1 + this.tui.modal('投入现金奖池', `建议投入 ${n} 张星球券,预计概率提升到 ${loop.suggestedProbability || 0}%。投入后星球券会被回收,确认上车?`, true, (ok) => { + if (!ok) return + this.operateRequest('/app/planet/pool/join', { tickets: n }, '投入成功') + }, '#22B889', '立即上车') + }, + onBidLandmark(item) { + this.promptTickets(`争夺${item.name}`, (tickets) => { + this.operateRequest('/app/planet/landmark/bid', { landmarkId: item.id, tickets }, '投入成功') + }) + }, goDrawResult() { uni.navigateTo({ url: '/package1/planet/drawResult'