Commit 9cc2138a by 前端

fixed

1 parent 46f0e2d6
...@@ -150,11 +150,11 @@ export default { ...@@ -150,11 +150,11 @@ export default {
methods: { methods: {
async taskRewards() { async taskRewards() {
const { allow, rewardId } = this.$parent.$parent; const { allow, rewardId } = this.$parent.$parent;
const { id, merchantId, merchantName } = this.$route.query; const { id, merchantId, merchantName, phone, accountId, nickName } =
const { phone, accountId, nickName, openid } = util.getUserInfo(); this.$route.query;
const params = { const params = {
taskId: id, taskId: id,
phone: openid, phone,
merchantId, merchantId,
merchantName, merchantName,
nickName, nickName,
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* @Author: yangming yangming@didihu.com.cn * @Author: yangming yangming@didihu.com.cn
* @Date: 2023-01-31 15:41:18 * @Date: 2023-01-31 15:41:18
* @LastEditors: 前端 qianduan01@didihu.com.cn * @LastEditors: 前端 qianduan01@didihu.com.cn
* @LastEditTime: 2023-02-17 10:33:24 * @LastEditTime: 2023-02-19 21:08:35
* @FilePath: \h5Demo\src\store\index.js * @FilePath: \h5Demo\src\store\index.js
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
*/ */
...@@ -178,12 +178,12 @@ export default new Vuex.Store({ ...@@ -178,12 +178,12 @@ export default new Vuex.Store({
let params = util.getPageQuery(); //从链接获取 let params = util.getPageQuery(); //从链接获取
if (Object.keys(params).length && params.id) if (Object.keys(params).length && params.id)
util.setLocalStorage("wx_scrm_link_params", params); util.setLocalStorage("wx_scrm_link_params", params);
dispatch("registerHttp"); dispatch("registerHttp", params.sessionId);
const storage_sessionId = util.getSessionId(); // const storage_sessionId = util.getSessionId();
if (storage_sessionId) { // if (storage_sessionId) {
dispatch("registerHttp", storage_sessionId); // dispatch("registerHttp", storage_sessionId);
return; // return;
} else dispatch("login"); // } else dispatch("login");
}, },
registerHttp({ dispatch }, sessionId = "") { registerHttp({ dispatch }, sessionId = "") {
window.$HTTP = new Http({ window.$HTTP = new Http({
...@@ -194,17 +194,22 @@ export default new Vuex.Store({ ...@@ -194,17 +194,22 @@ export default new Vuex.Store({
}, },
taskInsert({ dispatch }, event) { taskInsert({ dispatch }, event) {
//click 1浏览 play 1参与 //click 1浏览 play 1参与
const { logo, nickName, openid, phone } = util.getUserInfo(); const {
const { id, merchantId, merchantName } = util.getLocalStorage( id,
"wx_scrm_link_params" merchantId,
); merchantName,
headImgUrl,
nickName,
openid,
phone,
} = util.getLocalStorage("wx_scrm_link_params");
const params = { const params = {
taskId: id, taskId: id,
merchantId, merchantId,
openId: phone, openId: openid,
phone: openid, phone: phone,
nickName, nickName,
headImgUrl: logo, headImgUrl,
merchantName, merchantName,
...event, ...event,
}; };
......
...@@ -200,15 +200,22 @@ export default { ...@@ -200,15 +200,22 @@ export default {
//行为上报 //行为上报
taskInsert(click, play) { taskInsert(click, play) {
//click 1浏览 play 1参与 //click 1浏览 play 1参与
const { logo, nickName, openid, phone } = this.getUserInfo(); const {
const { id, merchantId, merchantName } = this.$route.query; headImgUrl,
nickName,
openid,
phone,
id,
merchantId,
merchantName,
} = this.getUserInfo();
const params = { const params = {
taskId: id, taskId: id,
merchantId, merchantId,
openId: phone, openId: openid,
phone: openid, phone: phone,
nickName, nickName,
headImgUrl: logo, headImgUrl,
merchantName, merchantName,
click, click,
play, play,
...@@ -218,7 +225,7 @@ export default { ...@@ -218,7 +225,7 @@ export default {
}); });
}, },
getUserInfo() { getUserInfo() {
const userInfo = util.getUserInfo() || {}; const userInfo = util.getLocalStorage("wx_scrm_link_params") || {};
return userInfo; return userInfo;
}, },
//任务详情 //任务详情
...@@ -241,21 +248,60 @@ export default { ...@@ -241,21 +248,60 @@ export default {
}); });
}); });
}, },
getHiddle() {
// 设置隐藏属性和改变可见属性的事件的名称
var hidden, visibilityChange;
if (typeof document.hidden !== "undefined") {
// Opera 12.10 and Firefox 18 and later support
hidden = "hidden";
visibilityChange = "visibilitychange";
} else if (typeof document.msHidden !== "undefined") {
hidden = "msHidden";
visibilityChange = "msvisibilitychange";
} else if (typeof document.webkitHidden !== "undefined") {
hidden = "webkitHidden";
visibilityChange = "webkitvisibilitychange";
}
const _this = this;
function handleVisibilityChange() {
if (document[hidden]) {
_this.handleEnd();
} else {
_this.hanldStart();
}
}
// 如果浏览器不支持addEventListener 或 Page Visibility API 给出警告
if (
typeof document.addEventListener === "undefined" ||
typeof document[hidden] === "undefined"
) {
console.log(
"This demo requires a browser, such as Google Chrome or Firefox, that supports the Page Visibility API."
);
} else {
// 处理页面可见属性的改变
document.addEventListener(
visibilityChange,
handleVisibilityChange,
false
);
}
},
}, },
async mounted() { async mounted() {
// this.getHiddle();
window.addEventListener("beforeunload", (e) => this.handleEnd()); //监听页面刷新触发事件 window.addEventListener("beforeunload", (e) => this.handleEnd()); //监听页面刷新触发事件
const { phone, openid } = this.getUserInfo(); const { phone, openid, id, merchantId } = this.getUserInfo();
const { id, merchantId } = this.$route.query; const taskCheck = await GAME.taskCheck({ id, merchantId, phone });
const taskCheck = await GAME.taskCheck({ id, merchantId, phone: openid });
await this.getTaskDetail(); await this.getTaskDetail();
this.allow = taskCheck.data.allow; this.allow = !taskCheck.data.allow;
if (!this.allow) { if (!this.allow) {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.gameRef.isFinish = true; this.$refs.gameRef.isFinish = true;
}); });
return; return;
} }
const gameToken = await GAME.gameToken({ phone: openid }); const gameToken = await GAME.gameToken({ phone });
this.accountSecToken = gameToken.data.accountSecToken; this.accountSecToken = gameToken.data.accountSecToken;
this.joinGame(); this.joinGame();
setTimeout(() => { setTimeout(() => {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!