Commit 082a4f29 by wangshuo

BUG解决

parent d1f490a3
...@@ -19,6 +19,7 @@ class Group extends Component { ...@@ -19,6 +19,7 @@ class Group extends Component {
countdown: props.countdown, countdown: props.countdown,
now_groupon_list: [], now_groupon_list: [],
} }
console.log(props);
} }
// 查看更多 // 查看更多
...@@ -54,64 +55,23 @@ class Group extends Component { ...@@ -54,64 +55,23 @@ class Group extends Component {
alreadyIn: false, alreadyIn: false,
}); });
this.props.invitedFriends(); this.props.invitedFriends();
return; }
const { pdd_price, number, data } = this.state;
if (browser.isWeixin) {
let share = this.state.share;
this.setState({
share: !share,
});
let shareData = {
title: `【仅剩${number}个名额】我${pdd_price}元拼了《${data.course_title}》`,
desc: data.course_title, // 分享描述
link: location.origin + `/detail??id=${data.course_id}`, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: data.image_name, // 分享图标
};
http.post(`${API['base-api']}/m/sale/signature`).then(res => { componentWillReceiveProps(nextProps) {
const {nonce_str, signature, timestamp} = res.data; if (nextProps.courseInfo && nextProps.courseInfo.courseInfo && nextProps.courseInfo.courseInfo.course_info && nextProps.courseInfo.courseInfo.course_info.pdd_group_info) {
wx.config({ let now_groupon_list = nextProps.courseInfo.courseInfo.course_info.pdd_group_info.now_groupon_list;
"debug": false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 if (now_groupon_list && now_groupon_list.length > 0) {
"appId": 'wx23dac6775ac82877', // 必填,公众号的唯一标识 now_groupon_list.map(item => {
"timestamp": timestamp, // 必填,生成签名的时间戳 item.end_time -= 1;
"nonceStr": nonce_str, // 必填,生成签名的随机串 return item;
"signature": signature, // 必填,签名
jsApiList: [
'hideMenuItems',
'showMenuItems',
'updateAppMessageShareData',
'updateTimelineShareData',
'onMenuShareWeibo',
'onMenuShareAppMessage',
], // 必填,需要使用的JS接口列表
});
});
wx.ready(function () { //需在用户可能点击分享按钮前就先调用
wx.hideAllNonBaseMenuItem();
wx.showMenuItems({
menuList: ['menuItem:share:appMessage', 'menuItem:share:timeline'] // 要显示的菜单项,所有menu项见附录3
}); });
wx.updateAppMessageShareData({ this.setState({
...shareData, now_groupon_list,
success: function () {
// 设置成功
}
}) })
wx.updateTimelineShareData({ }
...shareData,
success: function () {
// 设置成功
}
})
});
} else {
Toast.info('请在微信中使用分享功能!', 2);
} }
}
componentWillReceiveProps(nextProps) {
this.setState({ this.setState({
countdown: nextProps.countdown, countdown: nextProps.countdown
}) })
} }
...@@ -119,7 +79,7 @@ class Group extends Component { ...@@ -119,7 +79,7 @@ class Group extends Component {
if (this.props.courseInfo && this.props.courseInfo.courseInfo && this.props.courseInfo.courseInfo.course_info && this.props.courseInfo.courseInfo.course_info.pdd_group_info) { if (this.props.courseInfo && this.props.courseInfo.courseInfo && this.props.courseInfo.courseInfo.course_info && this.props.courseInfo.courseInfo.course_info.pdd_group_info) {
let now_groupon_list = this.props.courseInfo.courseInfo.course_info.pdd_group_info.now_groupon_list; let now_groupon_list = this.props.courseInfo.courseInfo.course_info.pdd_group_info.now_groupon_list;
if (now_groupon_list && now_groupon_list.length > 0) { if (now_groupon_list && now_groupon_list.length > 0) {
setInterval(() => { // setInterval(() => {
now_groupon_list.map(item => { now_groupon_list.map(item => {
item.end_time -= 1; item.end_time -= 1;
return item; return item;
...@@ -127,7 +87,7 @@ class Group extends Component { ...@@ -127,7 +87,7 @@ class Group extends Component {
this.setState({ this.setState({
now_groupon_list, now_groupon_list,
}) })
}, 1000); // }, 1000);
} }
} }
} }
......
...@@ -41,6 +41,25 @@ class Detail extends Component { ...@@ -41,6 +41,25 @@ class Detail extends Component {
if(courseInfo.course_info.is_bargain) { if(courseInfo.course_info.is_bargain) {
this.getBargainInfo(); this.getBargainInfo();
} }
if (courseInfo.course_info) {
let course_info = courseInfo.course_info;
if (course_info.group_status === 3 || course_info.group_status === 4) {
let endTime = course_info.pdd_group_info.groupon_member.end_time;
let date = endTime * 1000,
hours = 0,
minutes = 0,
seconds = 0;
setInterval(() => {
date -= 1000
hours = `${parseInt(date / (60 * 60 * 1000))}`.padStart(2, 0);
minutes = `${parseInt((date - hours * 3600000) / 60000)}`.padStart(2, 0);
seconds = `${parseInt((date - hours * 3600000 - minutes * 60000) / 1000)}`.padStart(2, 0);
this.setState({
countdown: `${hours}:${minutes}:${seconds}`
});
}, 1000)
}
}
} }
// 点击子组件试听按钮 // 点击子组件试听按钮
......
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