Commit 86ef6c33 by 穆启卓

首页改成整个卡片点击 + 首页代码整理

parent 2d127bd3
......@@ -7,7 +7,7 @@
<!-- 信息广播 -->
<NoticeBonus class="notice-broadcast"></NoticeBonus>
<!-- 挑战赛卡片 -->
<div class="challenge-card" v-for="item in gameList">
<div class="challenge-card" v-for="item in gameList" @click="clickCard(item)">
<img class="corner-marker" src="../images/SignUp/home_tag_bsz.png" v-if="item.status===0">
<img class="corner-marker" src="../images/SignUp/home_tag_zmz.png" v-if="item.status===1">
<img class="corner-marker" src="../images/SignUp/home_tag_yjs.png" v-if="item.status===2">
......@@ -50,38 +50,20 @@
<script>
import NoticeBonus from "@/components/NoticeBonus.vue";
import Free from "@/components/Free.vue";
import Modal from "@/components/Modal.vue";
import PayFailModal from "@/components/PayFailModal.vue";
import Reborn from "@/components/Reborn.vue";
import {
dakaPay,
track,
userCards,
daka_index,
select_follow
} from "@/components/axios/api";
import { constants } from "crypto";
export default {
name: "SignUp",
components: {
NoticeBonus,
Modal,
Free,
Reborn,
PayFailModal
Reborn
},
data() {
return {
contract_data: {},
showFreeModal: false,
modalTitle: "",
modalDesc: "",
modalShown: false,
current_date: {},
isShowPayFail: false,
isFollow: false,
gameList: [],
followInfo: {},
needFollow: false
......@@ -92,12 +74,19 @@ export default {
this.getFollowInfo();
},
methods: {
// 点击卡片整块的跳转
clickCard(item) {
if (item.status===1 && item.already_join===0) {
this.goOtherPage('PartakeChallenge');
} else {
this.goWhereDetail(item);
}
},
goOtherPage(pageName) {
if (!this.followInfo.follow) {
this.needFollow = true;
return;
}
console.log("pageName", pageName);
this.$router.push({ name: pageName });
},
goWhereDetail(item) {
......@@ -120,22 +109,31 @@ export default {
}
});
} else {
console.log("item", item);
// 未报名
if (sessionStorage.getItem('userHaveJoinGame') === 'true') {
item.daka_signup = true;
} else {
item.daka_signup = false;
item.newGameWeek = this.gameList[0].week.slice(4,8);
}
sessionStorage.setItem("ChallengeDetailData", JSON.stringify(item));
this.$router.push({ name: "ChallengeDetail" });
}
}
},
// 关注公众号
getFollowInfo() {
select_follow().then(res => {
console.log(res);
if (res.code == 0) {
this.followInfo = res.data;
sessionStorage.setItem("followInfo", JSON.stringify(res.data));
}
});
},
// 关注公众号弹框
closePopup() {
this.needFollow = false;
},
getPageData() {
daka_index().then(res => {
if (res.code === 0) {
......@@ -143,127 +141,8 @@ export default {
item.action = item.week.substring(item.week.length - 4);
});
this.gameList = res.data;
console.log("gameList", this.gameList);
}
});
},
togglePayFail() {
this.isShowPayFail = !this.isShowPayFail;
},
showSuccess() {
this.showModal("温馨提示", "报名成功", {
scb: () => {
if (this.isFollow == 1) {
this.$router.push({ name: "Read" });
} else {
this.$router.push({ name: "Success" });
}
}
});
},
confirmModal(scb) {
scb && scb();
this.modalShown = false;
},
showFree(e) {
e.stopPropagation();
track("free_contract_show");
if (localStorage.getItem("first_show_free") == 1) {
localStorage.setItem("first_show_free", 2);
this.canShowFree = false;
} else {
this.canCheckShowFree = false;
this.canShowFree = false;
}
userCards().then(res => {
console.log("获取免契约金数据", res);
let data = {
card: res.data.contract_card,
cnt: res.data.contract_cnt
};
this.current_date = new Date(res.date);
// if (
// // 如果明天没报名,而且还有免契约金卡,则可以使用
// !this.date_status[1].user_status.daka_signup &&
// res.data.contract_card > 0
// ) {
// data.can_get = true;
// // 其他情况,显示报名下期比赛
// } else {
// data.can_get = false;
// }
this.contract_data = JSON.parse(JSON.stringify(data));
this.showFreeModal = true;
});
},
closeFree() {
this.showFreeModal = false;
},
showModal(title, desc, option) {
this.modalTitle = title || "";
this.modalDesc = desc || "";
this.modalOption = option || {};
this.modalShown = true;
},
closeModal() {
this.modalShown = false;
},
payToSign() {
dakaPay().then(response => {
this.current_date = new Date(response.date);
if (response.code == 1) {
this.showModal("温馨提示", response.msg);
return;
}
let result = response.data;
console.log("请求打卡支付数据", result);
if (result) {
WeixinJSBridge.invoke(
"getBrandWCPayRequest",
{
appId: result.appId, //公众号名称,由商户传入
timeStamp: `${result.timeStamp}`, //时间戳,自1970年以来的秒数
nonceStr: result.nonceStr, //随机串
package: result.package,
signType: result.signType, //微信签名方式:
paySign: result.paySign //微信签名
},
// result,
res => {
console.log("支付调用结果", res);
if (res.err_msg == "get_brand_wcpay_request:ok") {
// 使用以上方式判断前端返回,微信团队郑重提示:
//res.err_msg将在用户支付成功后返回ok,但并不保证它绝对可靠。
// 支付成功后的回调函数
console.log("支付成功");
this.showModal("温馨提示", "报名成功", {
scb: () => {
if (this.isFollow == 1) {
this.$router.push({ name: "Read" });
} else {
this.$router.push({ name: "Success" });
}
}
});
// this.dateSelect(2);
// localStorage.setItem("is_every", 0)
// location.replace("#/Success");
}
if (res.err_msg == "get_brand_wcpay_request:fail") {
// this.showModal("温馨提示", "支付服务繁忙,请稍后重试");
this.togglePayFail();
}
if (res.err_msg == "get_brand_wcpay_request:cancel") {
// console.log("支付取消");
this.togglePayFail();
}
}
);
}
});
},
closePopup() {
this.needFollow = false;
}
}
};
......
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