Index.vue
2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
<template>
<div class="wrap">
<!-- KV模块 -->
<div class="module-kv">
<div class="top-btn-box">
<a class="top-btn rule-btn" @click="ruleModalOpen" />
</div>
<div class="date">兑换时间:2023年7月13日-9月9日</div>
</div>
<!-- 弹窗 -->
<RuleModal :visible="ruleModalVisible" />
</div>
</template>
<script>
import { reactive } from 'vue'
import RuleModal from '@/components/RuleModal.vue'
import { reqPublic, Tracker } from '@/scripts/requests/index.js'
import { getUrlSearchJson } from '@/scripts/util.js'
import { isIOS, isMobile } from 'detect-mobile-device'
import dayjs from 'dayjs'
export default {
name: 'IndexPage',
components: {
RuleModal
},
setup() {
// 公共上报字段
const publicReportParams = reactive({
game_appkey: 'nwDNza2ltADBAcETlnPO',
game_id: '600025',
plat_id: !isMobile() ? '4' : isIOS() ? '0' : '1', //上报平台代表的ID,ios 0/android 1/h5 3/pc 4
client_time: dayjs().format('YYYY-MM-DD HH:mm:ss')
})
return {
publicReportParams
}
},
data() {
return {
ruleModalVisible: false //规则弹窗
}
},
computed: {
/**
* Url携带参数,游戏中跳转带出
*/
urlSearch() {
return getUrlSearchJson()
}
},
provide() {
return {
closeModal: this.closeModal
}
},
created() {},
methods: {
/**
* 登录
* @param {Object} userOps 用户参数
*/
login(userOps) {
const { timestamp, gameId, signature, openId, roleId, serverId } = userOps
reqPublic
.login({ gameId, timestamp, signature }, { openId, roleId, serverId })
.then(res => {
if (process.env.VUE_APP_MODE === 'development') {
//本地开发处理
window.location.href =
'http://localhost:8080/?' + window.location.href.split('?')[1]
return
}
window.location.href = res.request.responseURL
})
.catch(err => {
console.log('fail', err)
})
},
/**
* 关闭弹窗
* @param {*} object 控制开关的变量名称
*/
closeModal(object) {
this[object] = false
},
/**
* 打开规则弹窗
*/
ruleModalOpen() {
this.ruleModalVisible = true
},
/**
* 页面加载上报(登录成功后)
*/
onloadReport() {
let params = [
{
...this.publicReportParams,
log_type: 'CustomEvent',
event_id: 'enter_h5'
}
]
Tracker.report(params)
}
}
}
</script>
<style scoped lang="scss">
@import './index.scss';
</style>