Commit 73bfcd95 by xuzhenghua

强制拼团

parent f4ccf1de
......@@ -106,15 +106,24 @@ class Group extends Component {
formatTimeByMillisecond = (millisecond) => {
let date = millisecond * 1000,
day = 0,
hours = 0,
minutes = 0,
seconds = 0;
date -= 1000;
if (millisecond > 86400) {
day = `${parseInt(date / (3600000 * 24))}`.padStart(2, 0)
hours = `${parseInt((date - day * 3600000 * 24) / 3600000)}`.padStart(2, 0)
minutes = `${parseInt((date - day * 3600000 * 24 - hours * 3600000) / 60000)}`.padStart(2, 0)
return `${day}:${hours}:${minutes}`;
} else {
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);
return `${hours}:${minutes}:${seconds}`;
}
}
render() {
const { courseInfo } = this.props;
......
import React, { Component } from 'react'
import React, {Component} from 'react'
import './togroup.scss'
import { HeaderBar, VList } from '../../../common'
import { getParam, http, browser, wxShare } from "@/utils";
import { connect } from "react-redux"
import { Link } from "react-router-dom"
import { WingBlank, WhiteSpace, Flex, Toast, Modal } from 'antd-mobile'
import {HeaderBar, VList} from '../../../common'
import {getParam, http, browser, wxShare} from "@/utils"
import {connect} from "react-redux"
import {Link} from "react-router-dom"
import {WingBlank, WhiteSpace, Flex, Toast, Modal} from 'antd-mobile'
@connect(state => ({user: state.user}))
......@@ -21,34 +21,34 @@ class ToGroup extends Component {
number: 0, // 差几人成团
isBuy: false,
modal: false,
pddOrderId:''
pddOrderId: ''
}
}
invitedFriends = () => {
const {pdd_price, number, data} = this.state;
const {pdd_price, number, data} = this.state
if (browser.isWeixin) {
let share = this.state.share;
let share = this.state.share
this.setState({
share: !share,
});
})
wxShare({
title: `【仅剩${number}个名额】我${pdd_price}元拼了《${data.course_title}》`,
desc: data.course_title,
link: location.href+'&is_originator=1',
link: location.href + '&is_originator=1',
imgUrl: data.image_name,
});
})
} else {
Toast.info('请在微信中使用分享功能!', 2);
Toast.info('请在微信中使用分享功能!', 2)
}
}
componentDidMount() {
http.get(`${API['base-api']}/pdd/info/${getParam('id')}`).then(res => {
if (res.data.errno !== 0) {
Toast.info(res.data.msg, 2);
return;
Toast.info(res.data.msg, 2)
return
}
this.setState({
data: res.data.data.course_info,
......@@ -61,41 +61,51 @@ class ToGroup extends Component {
pddOrderId: res.data.data.pdd_order_id,
countdown: '',
isBuy: res.data.data.is_buy
});
})
if (res.data.data.is_success === 0) {
let date = res.data.data.end_time * 1000,
day = 0,
hours = 0,
minutes = 0,
seconds = 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);
if (res.data.data.end_time > 86400) {
day = `${parseInt(date / (3600000 * 24))}`.padStart(2, 0)
hours = `${parseInt((date - day * 3600000 * 24) / 3600000)}`.padStart(2, 0)
minutes = `${parseInt((date - day * 3600000 * 24 - hours * 3600000) / 60000)}`.padStart(2, 0)
this.setState({
countdown: `${day}:${hours}:${minutes}`
})
} else {
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)
}
});
})
}
toCourseDetail = (id) => {
const {history} = this.props;
history.push(`/detail?id=${id}`, {href: '/classify'});
return false;
const {history} = this.props
history.push(`/detail?id=${id}`, {href: '/classify'})
return false
}
handleToGroup = () => {
const {isBuy = false, data = {}} = this.state;
const {user, history, location} = this.props;
const {isBuy = false, data = {}} = this.state
const {user, history, location} = this.props
if (user.hasError) {
if (browser.isWeixin) {
let redirectURI = window.location.href
if (redirectURI.includes('code=') && redirectURI.includes('state=STATE')) {
let index = redirectURI.lastIndexOf('code=');
redirectURI = redirectURI.substr(0, index - 1);
let index = redirectURI.lastIndexOf('code=')
redirectURI = redirectURI.substr(0, index - 1)
}
window.location.assign(`https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx23dac6775ac82877&redirect_uri=${encodeURIComponent(redirectURI)}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`)
} else {
......@@ -110,7 +120,7 @@ class ToGroup extends Component {
`/order?id=${data.course_id}`,
{
group: 1,
pdd_order_id:this.state.pddOrderId
pdd_order_id: this.state.pddOrderId
}
)
} else {
......@@ -121,7 +131,7 @@ class ToGroup extends Component {
}
render() {
const {data: {course_id, course_title, simpledescription, price0, price1}, pdd_price, is_success, person_num, groupon_member, course_list} = this.state;
const {data: {course_id, course_title, simpledescription, price0, price1}, pdd_price, is_success, person_num, groupon_member, course_list} = this.state
const Info = (
<div className="info">
<p className='title' onClick={() => this.toCourseDetail(course_id)}>
......@@ -151,8 +161,8 @@ class ToGroup extends Component {
onPress: () => {
this.setState({
modal: false
});
this.props.history.push('/');
})
this.props.history.push('/')
}
}
]}
......@@ -203,7 +213,7 @@ class ToGroup extends Component {
return (
<VList
img={item.image_name}
key={item.uid}
key={item.course_id}
id={item.course_id}
info={weekInfo}
toDetail={this.toCourseDetail}
......@@ -219,13 +229,14 @@ class ToGroup extends Component {
}
function GorupContent(props) {
let tip, btn, dec, groupTip, shareTip, groupSuccessMbc;
const {pdd_price, data, groupon_member, is_success, person_num, share, number, countdown} = props.data;
let tip, btn, dec, groupTip, shareTip, groupSuccessMbc
const {pdd_price, data, groupon_member, is_success, person_num, share, number, countdown} = props.data
const {userInfo} = props
let ary = [], num = number;
let ary = [], num = number
while (num != 0) {
ary.push(num);
num--;
ary.push(num)
num--
}
groupTip = (<div className='group-user-list'>
<Flex justify='center' className='imgList'>
......@@ -241,7 +252,7 @@ function GorupContent(props) {
</div>
) : null
}
</div>);
</div>)
})
}
{
......@@ -254,14 +265,14 @@ function GorupContent(props) {
})
}
</Flex>
</div>);
</div>)
if (groupon_member && groupon_member.length > 0) {
let flag = false;
let flag = false
!userInfo.hasError && groupon_member.map(item => {
if (item.uid == userInfo.data.uid) {
flag = true
return;
return
}
})
if (flag) {
......@@ -269,7 +280,7 @@ function GorupContent(props) {
btn = <span className='group-btn' onClick={props.invitedFriends}>邀请好友参团 {countdown} 后结束</span>
dec = <p className='dec'>分享到3个群后,成团率高达98%</p>
} else {
if(getParam('is_originator') == 1){
if (getParam('is_originator') == 1) {
tip = <p className='tip'>{`拼团省¥${data.price1 - pdd_price}元`}</p>
btn = <a href="javascript:;" className='group-btn' onClick={props.handleToGroup}>一键参团</a>
} else {
......
......@@ -419,11 +419,12 @@ class Detail extends Component {
seconds = 0
setInterval(() => {
date -= 1000
console.log(endTime)
if (endTime > 86400) {
day = `${parseInt(date / (3600000 * 24))}`.padStart(2, 0)
hours = `${parseInt((date - day * 3600000 * 24) / 3600000)}`.padStart(2, 0)
minutes = `${parseInt((date - day * 3600000 * 24 - hours * 3600000) / 60000)}`.padStart(2, 0)
// seconds = `${parseInt((date - day * 3600000 * 24 - hours * 3600000 - minutes * 60000) / 1000)}`.padStart(2, 0);
this.setState({
countdown: `${day}:${hours}:${minutes}`
})
......
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