Commit 39a7c8fa by wangshuo

跨域

parent d493c440
import React, {Component} from 'react'
import React, { Component } from 'react'
import './index.scss'
import {getParam} from "@/utils"
import {connect} from "react-redux"
import {Link} from "react-router-dom"
import {Flex} from 'antd-mobile'
import { getParam } from "@/utils"
import { connect } from "react-redux"
import { Link } from "react-router-dom"
import { Flex } from 'antd-mobile'
class Group extends Component {
......@@ -36,9 +36,9 @@ class Group extends Component {
toPay = (pdd_order_id) => {
const courseInfo = this.props.courseInfo.courseInfo.course_info;
if(courseInfo.group_status === 3) {
if (courseInfo.group_status === 3) {
this.props.history.push(`/order?id=${getParam('id')}&&groupon_code=${pdd_order_id}`);
}else{
} else {
this.setState({
isShowMore: false,
alreadyIn: true
......@@ -51,8 +51,8 @@ class Group extends Component {
isShowMore: false,
alreadyIn: false,
});
const {pdd_price, number, data} = this.state;
if(browser.isWeixin) {
const { pdd_price, number, data } = this.state;
if (browser.isWeixin) {
let share = this.state.share;
this.setState({
share: !share,
......@@ -64,7 +64,7 @@ class Group extends Component {
imgUrl: data.image_name, // 分享图标
};
http.post(`${api['pay-api']}/m/sale/signature`).then(res => {
const {nonce_str, signature, timestamp} = res.data;
const { nonce_str, signature, timestamp } = res.data;
wx.config({
"debug": false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
"appId": 'wx23dac6775ac82877', // 必填,公众号的唯一标识
......@@ -84,22 +84,22 @@ class Group extends Component {
wx.ready(function () { //需在用户可能点击分享按钮前就先调用
wx.hideAllNonBaseMenuItem();
wx.showMenuItems({
menuList: ['menuItem:share:appMessage' , 'menuItem:share:timeline'] // 要显示的菜单项,所有menu项见附录3
});
wx.updateAppMessageShareData({
menuList: ['menuItem:share:appMessage', 'menuItem:share:timeline'] // 要显示的菜单项,所有menu项见附录3
});
wx.updateAppMessageShareData({
...shareData,
success: function () {
// 设置成功
// 设置成功
}
})
wx.updateTimelineShareData({
...shareData,
success: function () {
// 设置成功
// 设置成功
}
})
});
}else{
} else {
Toast.info('请在微信中使用分享功能!', 2);
}
}
......@@ -113,9 +113,9 @@ class Group extends Component {
componentDidMount() {
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;
if(now_groupon_list && now_groupon_list.length > 0) {
if (now_groupon_list && now_groupon_list.length > 0) {
setInterval(() => {
now_groupon_list.map(item=>{
now_groupon_list.map(item => {
item.end_time -= 1;
return item;
});
......@@ -135,29 +135,29 @@ class Group extends Component {
formatTimeByMillisecond = (millisecond) => {
let date = millisecond * 1000,
hours = 0,
minutes = 0,
seconds = 0;
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);
return `${hours}:${minutes}:${seconds}`;
hours = 0,
minutes = 0,
seconds = 0;
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);
return `${hours}:${minutes}:${seconds}`;
}
render() {
const {alreadyIn, countdown, now_groupon_list} = this.state;
let groupInfo = '',groupon_member = '', group_status = -1, groupSuccessMbc = null;
const { alreadyIn, countdown, now_groupon_list } = this.state;
let groupInfo = '', groupon_member = '', group_status = -1, groupSuccessMbc = null;
if (this.props.courseInfo && this.props.courseInfo.courseInfo && this.props.courseInfo.courseInfo.course_info) {
groupInfo = this.props.courseInfo.courseInfo.course_info.pdd_group_info;
groupon_member = groupInfo.groupon_member;
group_status = this.props.courseInfo.courseInfo.course_info.group_status;
}
if(group_status === 4) {
if(groupon_member.member) {
const {number} = groupon_member;
let ary=[],num = number;
while(num != 0) {
if (group_status === 4) {
if (groupon_member.member) {
const { number } = groupon_member;
let ary = [], num = number;
while (num != 0) {
ary.push(num);
num--;
}
......@@ -190,17 +190,17 @@ class Group extends Component {
</Flex>
</div>);
groupSuccessMbc = <div className='groupSuccessMbc' onClick={this.hideMbc}>
<div className='content'>
<p>你已参团</p>
{groupTip}
<div className='group-btn' onClick={this.invitedFriends}>邀请好友参团 {countdown} 后结束</div>
<p className='dec'>分享到3个群后,成团率高达98%</p>
</div>
</div>;
<div className='content'>
<p>你已参团</p>
{groupTip}
<div className='group-btn' onClick={this.invitedFriends}>邀请好友参团 {countdown} 后结束</div>
<p className='dec'>分享到3个群后,成团率高达98%</p>
</div>
</div>;
}
}
return (
<div className='group-box'>
<div className="group-title">
......@@ -216,7 +216,7 @@ class Group extends Component {
groupInfo.now_groupon_list && groupInfo.now_groupon_list.length > 0 && groupInfo.now_groupon_list.map((item, index) => {
return (
<li key={index} className='group-item'>
<img className='avatar' src={item.avatar} alt=""/>
<img className='avatar' src={item.avatar} alt="" />
<div className='user-name text-overflow-one'>
{item.user_name}
</div>
......@@ -224,7 +224,7 @@ class Group extends Component {
<p>还差<span className='red'>{item.number}</span>拼成</p>
<p>剩余 {this.formatTimeByMillisecond(item.end_time)}</p>
</div>
<span onClick={()=>{this.toPay(item.pdd_order_id)}} className='topay'>去参团</span>
<span onClick={() => { this.toPay(item.pdd_order_id) }} className='topay'>去参团</span>
</li>
)
})
......@@ -243,7 +243,7 @@ class Group extends Component {
{groupSuccessMbc}
</>
)
}
{/*更多*/}
{
......@@ -258,13 +258,13 @@ class Group extends Component {
groupInfo.now_groupon_list && groupInfo.now_groupon_list.length > 0 && groupInfo.now_groupon_list.map((item, index) => {
return (
<li key={index} className='group-item'>
<img className='avatar' src={item.avatar} alt=""/>
<img className='avatar' src={item.avatar} alt="" />
<div className='user-name'>
<p className='name text-overflow-one'>{item.user_name}</p>
<p className='time'>剩余 {this.formatTimeByMillisecond(item.end_time)}</p>
</div>
<p className='group-status'>还差{item.number}</p>
<span onClick={()=>{this.toPay(item.pdd_order_id)}} className='topay'>去参团</span>
<span onClick={() => { this.toPay(item.pdd_order_id) }} className='topay'>去参团</span>
</li>
)
})
......@@ -275,7 +275,7 @@ class Group extends Component {
</div>
<i onClick={this.closeMore} className={'iconfont iconiconfront-2 close'}></i>
</div>
</div>
}
......@@ -285,6 +285,6 @@ class Group extends Component {
}
export default connect(
state => ({courseInfo: state}),
state => ({ courseInfo: state }),
null
)(Group)
......@@ -82,7 +82,14 @@ class ToGroup extends Component {
console.log(resultList);
let res = resultList[0],
userInfo = resultList[1];
if(res.data.errno !== 0) {
Toast.info(res.data.msg, 2);
return;
}
if(userInfo.data.code !== 200) {
Toast.info(res.data.msg, 2);
return;
}
this.setState({
data: res.data.data.course_info,
pdd_price: res.data.data.pdd_price,
......
import axios from "axios";
import qs from 'qs'
axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded';
const instance = axios.create({
transformRequest: [
(data) => qs.stringify(data)
],
headers: {
HTTP_PLAT_FORM: 5,
HTTP_PLAT: 5
HTTP_PLAT: 5,
}
})
......
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