Commit 75cdb723 authored by 袁玲利's avatar 袁玲利

游戏排行榜

parent 3b1498ac
...@@ -16,6 +16,10 @@ ...@@ -16,6 +16,10 @@
</template> </template>
<script> <script>
var gHost = "https://" + window.location.host;
if (window.location.protocol != "https:") {
gHost = "https://uat-pay.xiaopay.net";
}
export default { export default {
data() { data() {
return { return {
...@@ -99,22 +103,117 @@ export default { ...@@ -99,22 +103,117 @@ export default {
appId: "wxb5612f7e17786c46", appId: "wxb5612f7e17786c46",
}, },
], ],
params: {
userid: "",
behavior: "", // 打开页面viewPage 、用户点击click 、 用户停留duration 、用户离开页面closePage
data: "", // 行为数据:填页面名称、点击元素标识、停留时长(5s/10s/30s/60s/5min/10min/30min)
},
timer: null,
second: 0,
}; };
}, },
mounted() { mounted() {
this.games.sort(() => 0.5 - Math.random()); this.games.sort(() => 0.5 - Math.random());
this.params.userId = getQueryParams("userId");
this.params.behavior = "viewPage";
this.params.data = "gameOrder";
this.GameStatistics();
this.init();
}, },
methods: { methods: {
init() {
const self = this;
this.timer = setInterval(() => {
this.second += 1;
console.log(this.second, "xxxxxxxxx");
if (this.second == 5) {
self.params.behavior = "duration";
self.params.data = "5s";
self.GameStatistics();
} else if (this.second == 10) {
self.params.behavior = "duration";
self.params.data = "10s";
self.GameStatistics();
} else if (this.second == 30) {
self.params.behavior = "duration";
self.params.data = "30s";
self.GameStatistics();
} else if (this.second == 60) {
self.params.behavior = "duration";
self.params.data = "60s";
self.GameStatistics();
} else if (this.second == 300) {
self.params.behavior = "duration";
self.params.data = "5min";
self.GameStatistics();
} else if (this.second == 600) {
self.params.behavior = "duration";
self.params.data = "10min";
self.GameStatistics();
} else if (this.second == 18000) {
self.params.behavior = "duration";
self.params.data = "30min";
self.GameStatistics();
}
}, 1000);
},
//获取参数
getQueryParams(params) {
let href = window.location.href;
let query = href.substring(href.indexOf("?") + 1);
let vars = query.split("&");
for (var i = 0; i < vars.length; i++) {
let pair = vars[i].split("=");
if (pair[0] == params) {
return pair[1];
}
}
return false;
},
// 小程序游戏统计接口
async GameStatistics() {
try {
let url = gHost + "/wechat/svweapp/GameStatistics";
let data = await this.$http.post(
{
url: url,
},
this.params
);
if (data.code != 200) {
uni.showToast({
icon: "none",
mask: true,
title: data.msg,
});
return;
}
} catch (e) {
console.log(e);
}
},
launchGame(game) { launchGame(game) {
// uni.navigateToMiniProgram({ // uni.navigateToMiniProgram({
// appId: game.appId, // appId: game.appId,
// }); // });
this.params.behavior = "click";
this.params.data = game.appId;
this.GameStatistics();
jWeixin.miniProgram.navigateTo({ jWeixin.miniProgram.navigateTo({
url: "/pages_subpackB/pages/game/main?appId=" + game.appId, url: "/pages_subpackB/pages/game/main?appId=" + game.appId,
}); });
// 这里可以添加游戏启动逻辑,比如跳转到游戏页面,或打开游戏等 // 这里可以添加游戏启动逻辑,比如跳转到游戏页面,或打开游戏等
}, },
}, },
onUnload() {
this.params.behavior = "viewPage";
this.params.data = "closePage";
this.GameStatistics();
if (this.timer !== null) {
clearInterval(this.timer);
this.timer = null;
}
},
}; };
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment