// packageD/ActivityDetail/ActivityDetail.js
var app = getApp();
var WxParse = require("../../wxParse/wxParse.js");
Page({
/**
* 页面的初始数据
*/
data: {
language: "",
store_id: "", // 门店拓客
//领取人数大于4
lingquBox: true,
// 购买人数大于4
newGmBox: true,
// 活动介绍内容是否全部展示
boxShow: true,
// 背景图片
bosPto: true,
audio_link: "",
songStop: true,
infoList: {},
poster_open:0,
poster_show:false,
poster_url:'',
show:false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
console.log(options);
this.setData({
kind: options.id,
store_id: options.store_id,
});
if (options.scene) {
let scene = decodeURIComponent(options.scene);
if (scene) {
var info_arr = [];
info_arr = scene.split("&");
for (let i = 0; i < info_arr.length; i++) {
let chil_arr = [];
chil_arr = info_arr[i].split("=");
console.log("59", chil_arr);
if (chil_arr[0] == "id") {
this.setData({
kind: chil_arr[1],
});
} else if (chil_arr[0] == "mid") {
app._setMid(chil_arr[1]);
}
}
}
}
this.getData();
},
tapLoadWatch(e){
let img = e.currentTarget.dataset.img
wx.previewImage({
current: img, // 当前显示图片的http链接
urls: [img] // 需要预览的图片http链接列表
})
},
setPosterShow(){
this.setData({poster_show:!this.data.poster_show});
},
getPosterImage(){
if(this.data.poster_url!='') {
this.setData({poster_show:true});
return;
}
let urlStr = app.getNetAddresss(
"plugin.share-activity.frontend.activity.get-poster"
);
app._getNetWork({
data: {
activity_id: this.data.kind,
},
url: urlStr,
success: (resdata) => {
var res = resdata.data;
if (res.result == 1) {
this.setData({
poster_show:true,
poster_url:res.data.poster
});
}
}
});
},
toGoods() {
var diyfrom = this.data.infoList.diyform_id;
console.log(diyfrom);
let url = "";
if (diyfrom) {
url =
"/packageC/diyform/diyform?scene=" +
diyfrom +
"&goodsId=" +
this.data.infoList.goods_id +
"&&optionsId=" +
this.data.infoList.option_id +
"&&total=" +
this.data.infoList.total;
if (this.data.store_id) {
url = url + "&store_id=" + this.data.store_id;
}
wx.navigateTo({
url: url,
});
} else {
// tag=-2&goodsId=7615&optionsId=&total=1
url =
"/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&goodsId=" +
this.data.infoList.goods_id +
"&&optionsId=" +
this.data.infoList.option_id +
"&&total=" +
this.data.infoList.total;
if (this.data.store_id) {
url = url + "&store_id=" + this.data.store_id;
}
wx.navigateTo({
url: url,
});
}
},
countdown() {
let that = this;
let now = new Date();
let nowseon = String(Date.parse(now)).substr(0, 10);
let end = that.data.infoList.end_time;
if (end - nowseon <= 0) {
console.log(end, nowseon);
that.setData({
stop: false,
});
return;
}
var msec = end - nowseon;
let day = parseInt(msec / 60 / 60 / 24),
hr = parseInt((msec / 60 / 60) % 24),
min = parseInt((msec / 60) % 60),
sec = parseInt(msec % 60);
hr = hr > 9 ? hr : "0" + hr;
min = min > 9 ? min : "0" + min;
sec = sec > 9 ? sec : "0" + sec;
that.setData({
Day: day,
Hour: hr,
Min: min,
Sec: sec,
});
// 一秒后递归
setTimeout(() => {
this.countdown();
}, 1000);
},
handleContact(e) {
console.log(e.detail.path);
console.log(e.detail.query);
},
linkTomember() {
wx.reLaunch({
url: "/packageG/member_v2/member_v2",
});
},
linkToorder() {
wx.navigateTo({
url: "/packageA/member/myOrder_v2/myOrder_v2?status=0",
});
},
setDataByTabIndex() {
this.setData({
first_content: this.data.infoList.agreement,
});
let article = this.data.first_content;
if (article.indexOf("") <= -1) {
WxParse.wxParse("article", "html", article, this);
}
console.log("1111111111111111");
},
replaceDetail(details) {
var texts = ""; //待拼接的内容
while (details.indexOf("
")
) {
texts +=
details.substring(0, details.indexOf('style="') + 7) +
"max-width:100%;height:auto;margin:0 auto;"; //从 ![]()