Commit 2d1623a3 authored by liwei's avatar liwei

liwei

parents 5bbc20ff 014b3311
......@@ -64,7 +64,10 @@
import {
getwechatParam,
getInviteResultApi,
getInviteListApi
getInviteListApi,
getGoodsDetailApi,
getGroupDetailApi,
getStatusWechatApi
} from "../../service/api";
export default {
......@@ -74,10 +77,59 @@ export default {
return {
earnings: 0,
userNum: 0,
records: [
{
nickname: "test",
pay_at: "2019.7.5"
},
{
nickname: "test1111111",
pay_at: "2019.7.5"
},
{
nickname: "test222222222222",
pay_at: "2019.7.5"
}
],
showLoad: false,
join: false,
popType: false,
popFill: false,
popupVisible: false,
refVisible: false,
tabType: true,
popcontentW: `您已经购买过课程,无需重复<br>购买,您可以添加微信公众号了解更多`,
popcontentT: `为了更好地为您进行课程服务,<br>请扫码添加老师二维码`,
swiperOption: {
pagination: {
el: ".swiper-pagination"
}
},
QRCodeB: false,
dataURL: null,
user_id: null,
avatar: "",
invite_code_f: true,
invite_code: "",
shopId: "",
groupId: null,
groupDetail: false,
groupData: null,
show: false,
// comments: [
// '英语这样启蒙效果太棒啦,唱唱这个90天启蒙课程做真不错,推荐给你们!坚持打卡全额返学费,报课即送价值498元教具礼盒。数量有限,抢完即止!',
// '发现一款对宝宝英语启蒙特别有用的产品,每天10分钟宝宝已经爱上英语、爱唱英语。现在他们这个90天课程在做活动,坚持打卡全额返学费。我体验过了,真的很好!快带着宝宝一起唱玩英语吧~',
// '第一次接触线上启蒙英语,发现唱唱课程实在太棒啦,既省事宝宝学起来还方便,每天快乐中学习。现在他们这个90天课程在做活动,限时免费学,不花1分钱,学习90天,还送实物教具,机不可失,速来领取~'
// ],
comments: [
"英语这样启蒙效果太棒啦,唱唱这个启蒙课程做得真不错,推荐给你们!现在限时优惠,全勤完课还返66元现金,报名立送实物教具礼盒,包邮送到家。数量有限,先到先得!",
// '这家英语启蒙做的很不错\n再也不用花高价去外教班跟培训机构\n在家里就可以直接进行英语启蒙\n21天帮助宝宝树立英语学习兴趣,让宝宝爱上英语\n原价2980元,现在只需要99元\n全勤打卡18天赠送价值100元天猫同款3大精品礼盒\n限量200份,仅售3天!',
"发现一款对宝宝英语启蒙特别有用的产品,每天10分钟宝宝已经爱上英语、爱唱英语。现在他们这个21天课程在做活动,我体验过了,真的很好!现限时限量优惠,速来报名~",
"第一次接触线上启蒙英语,发现唱唱课程实在太棒啦,既省事宝宝学起来还方便,每天在快乐中学习。现在他们这个21天课程在做活动,全勤学习还返66元现金,报名立送教具礼盒,快来和我一起参与吧!"
],
commentIndex: 0,
shareTitle: "钜惠来袭!唱唱21天英语训练营,全勤学习返66元现金",
shareDesc: "21天让宝宝爱上说英语,报课即送教具礼盒,包邮送到家!",
records: []
shareDesc: "21天让宝宝爱上说英语,报课即送教具礼盒,包邮送到家!"
};
},
mounted() {
......@@ -86,15 +138,181 @@ export default {
this.getInviteResult();
this.getInviteList();
this.enableShare();
this.getDetail();
},
methods: {
refshow() {
Toast.loading({
mask: "true"
});
if (document.body.scrollTop < 10) {
document.body.scrollTop = 20;
document.documentElement.scrollTop = 20;
}
if (
localStorage.getItem("cc_token") &&
localStorage.getItem("cc_token") !== ""
) {
if (!this.invite_code) {
this.invite_code = "CC-USER";
}
this.user_id = JSON.parse(localStorage.getItem("userDesc")).user_id;
let _that = this;
let invite_code = this.invite_code.split("-");
if (
invite_code.length > 2 &&
(invite_code[1] === "TEACHER" || invite_code[1] === "XXMM")
) {
invite_code[1] = "USER";
}
let code = `${invite_code[0]}-${invite_code[1]}`;
let URL = `${process.env.BUY_URL}shopId=${this.shopId}&invite_code=${code}-${this.user_id}`;
if (this.groupId && this.groupId !== "null") {
URL += `&groupId=${this.groupId}`;
}
this.onNewShare(URL);
this.toDataURLBase64(
JSON.parse(localStorage.getItem("userDesc")).avatar.replace(
"http://",
"https://"
),
function(avatar) {
_that.avatar = avatar;
}
);
this.refVisible = true;
this.$nextTick(() => {
_that.qrcode(URL);
if (!this.dataURL) {
setTimeout(() => {
this.showLoad = true;
this.$nextTick(() => {
document.getElementById("showImg").onload = () => {
let { height, width, top } = document
.getElementById("capture")
.getClientRects()[0];
// document.getElementById('capture').style.width = width + 'px';
let o = this.getOffsetRect(this.$refs.imageWrapper);
console.log(
"document.getElementById",
document.getElementById("capture").getClientRects()[0]
);
document.getElementById("inviteBtn").style.top =
height + top + 20 + "px";
document.getElementById("inviteBtn").style.opacity = 1;
html2canvas(document.getElementById("capture"), {
async: true,
timeout: 500,
useCORS: true,
scrollX: 1,
scale: 2,
width: width,
height: height,
letterRendering: true
})
.then(canvas => {
let dataURL = canvas.toDataURL("image/png", 0.9);
this.dataURL = dataURL;
Toast.clear();
})
.catch(res => {
alert(res);
console.log();
});
};
});
}, 500);
} else {
}
});
} else {
let query = { retUrl: this.$route.fullPath, is_new_user_url: "1" };
this.$router.push({ name: "author", query: query });
}
},
getDetail() {
if (window.location.href.indexOf("invite_code") > -1) {
this.invite_code = this.$route.query.invite_code;
let l = this.invite_code.split("-").length;
if (l < 3) {
this.invite_code_f = false;
}
}
if (window.location.href.indexOf("shopId") > -1) {
this.shopId = this.$route.query.shopId;
getGoodsDetailApi(this.shopId).then(res => {
res.desc = JSON.parse(res.desc);
res.goods_desc = JSON.parse(res.goods_desc);
res.share_desc = JSON.parse(res.share_desc);
//商品下架跳转绑定商品
if (res.status === 2 && res.bind_goods_id) {
this.$router.push({
name: "buyDetail",
query: { shopId: res.bind_goods_id }
});
this.getDetail();
return;
}
this.groupDetail = res;
for (let i = 0; i < this.groupDetail.header_url.length; i++) {
this.groupDetail.header_url[i] = this.groupDetail.header_url[
i
].replace("http://", "https://");
}
this.groupDetail.desc.detail = this.groupDetail.desc.detail.replace(
/http:\/\//g,
"https://"
);
this.groupDetail.desc.qa = this.groupDetail.desc.qa.replace(
/http:\/\//g,
"https://"
);
if (
this.groupDetail.share_desc.refImg &&
this.groupDetail.share_desc.refImg.length === 1
) {
this.groupDetail.share_desc.refImg[0].url = this.groupDetail.share_desc.refImg[0].url.replace(
"http://",
"https://"
);
let _this = this;
this.toDataURLBase64(
this.groupDetail.share_desc.refImg[0].url,
function(avatarUrl) {
_this.groupDetail.share_desc.refImg[0].url = avatarUrl;
}
);
}
if (this.groupDetail.goods_type === 2) {
if (localStorage.getItem("cc_token")) {
getStatusWechatApi({ goods_id: this.shopId }).then(res => {
if (res.out_trade_no) {
this.$router.push({
name: "success",
query: { out_trade_no: res.out_trade_no }
});
} else {
this.refshow();
}
});
} else {
this.refshow();
}
} else {
this.refshow();
}
});
}
},
// 分享
enableShare: function() {
enableShare: function(option) {
let that = this;
getwechatParam({
api_list: "onMenuShareAppMessage,onMenuShareTimeline",
url: window.location.href.split("#")[0]
}).then(wechatRes => {
console.log("enableShare", wechatRes);
wx.config({
debug: false,
appId: wechatRes.appId,
......@@ -107,8 +325,9 @@ export default {
wx.onMenuShareTimeline({
title: that.shareTitle, // 分享标题
desc: that.shareDesc, // 分享描述
link: window.location.href, // 分享链接
link: option.shareUrl, // 分享链接
imgUrl:
option.shareIcon ||
"https://cdn.singsingenglish.com/singsing/recommend/logo-refer.png", // 分享图标
success: function() {
console.log("分享成功");
......@@ -116,7 +335,8 @@ export default {
"_trackEvent",
"分享",
"商品页好友分享",
`id${that.shopId}`
`id${that.shopId}`,
that.invite_code
]); //百度统计
},
cancel: function() {
......@@ -127,15 +347,17 @@ export default {
wx.onMenuShareAppMessage({
title: that.shareTitle, // 分享标题
desc: that.shareDesc, // 分享描述
link: window.location.href, // 分享链接
link: option.shareUrl, // 分享链接
imgUrl:
option.shareIcon ||
"https://cdn.singsingenglish.com/singsing/recommend/logo-refer.png", // 分享图标
success: function() {
window._hmt.push([
"_trackEvent",
"分享",
"商品页朋友圈分享",
`id${that.shopId}`
`id${that.shopId}`,
that.invite_code
]); //百度统计
},
cancel: function() {}
......@@ -143,6 +365,19 @@ export default {
});
});
},
onShare: function(type) {
let URL = `${process.env.BUY_URL}?shopId=${this.shopId}&groupId=${this.groupId}&invite_code=${this.invite_code}`;
let ownDetail = JSON.parse(localStorage.getItem("userDesc"));
if (type === 1) {
URL = `${process.env.BUY_URL}?shopId=${this.shopId}&invite_code=${this.invite_code}&nickname=${ownDetail.nickname}`;
}
this.enableShare({
product_title: this.groupDetail.share_desc.title,
desc: this.groupDetail.share_desc.content,
shareIcon: this.groupDetail.share_desc.img[0].url,
shareUrl: URL
});
},
lookMyInviteRecords() {
this.$refs.inviteRecord.scrollIntoView();
},
......
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