Commit f01907b4 by zeven

Merge remote-tracking branch 'origin/master'

parents 764f4243 3319738f
...@@ -140,6 +140,9 @@ export default { ...@@ -140,6 +140,9 @@ export default {
const {data} = yield call(api.verifysms, action); const {data} = yield call(api.verifysms, action);
return data; return data;
}, },
*getAdvertising(action, {call}) {
return yield call(api.getAdvertising, action);
},
}, },
}; };
......
...@@ -53,9 +53,23 @@ const CounterMixins = ComposeComponent => { ...@@ -53,9 +53,23 @@ const CounterMixins = ComposeComponent => {
title: '', title: '',
dot: false, dot: false,
luckyVisible: false, luckyVisible: false,
autoplayTime: 10,
imgArr: [],
adType: 'image',
}; };
componentWillMount = async () => { componentWillMount = async () => {
const {data} = await this.props.dispatch({
type: 'store/getAdvertising',
service: 'counter',
});
if (data.code === 1 && data.data && Object.keys(data.data)) {
this.setState({
autoplayTime: Number(data.data.time),
imgArr: data.data.image,
adType: data.data.type,
});
}
const qrHost = await AsyncStorage.getItem('QRHOST'); const qrHost = await AsyncStorage.getItem('QRHOST');
await this.setState({qrHost}); await this.setState({qrHost});
}; };
...@@ -121,7 +135,18 @@ const CounterMixins = ComposeComponent => { ...@@ -121,7 +135,18 @@ const CounterMixins = ComposeComponent => {
if (window.socket.hasListeners('cmdOperate')) { if (window.socket.hasListeners('cmdOperate')) {
window.socket.removeAllListeners('cmdOperate'); window.socket.removeAllListeners('cmdOperate');
} }
if (window.socket.hasListeners('adsOperate')) {
window.socket.removeAllListeners('adsOperate');
}
window.socket.on('cmdOperate', this.command.bind(this)); window.socket.on('cmdOperate', this.command.bind(this));
window.socket.on('adsOperate', ({adsData}) => {
console.warn(adsData);
this.setState({
autoplayTime: Number(adsData.time),
imgArr: adsData[adsData.type],
adType: adsData.type,
});
});
window.socket.on( window.socket.on(
'counterOrder', 'counterOrder',
({type, msg, sid, token, payType, orderId}) => { ({type, msg, sid, token, payType, orderId}) => {
...@@ -728,7 +753,7 @@ const CounterMixins = ComposeComponent => { ...@@ -728,7 +753,7 @@ const CounterMixins = ComposeComponent => {
}; };
} }
return connect(({goods, admin}) => ({goods, admin}))(Mixins); return connect(({goods, admin, store}) => ({goods, admin, store}))(Mixins);
}; };
const CloseButton = ({onClose, style}) => { const CloseButton = ({onClose, style}) => {
......
...@@ -422,7 +422,16 @@ class VerticalPage extends Component { ...@@ -422,7 +422,16 @@ class VerticalPage extends Component {
); );
render() { render() {
let {admin, goods, goodsArr, qrHost, current} = this.props; let {
admin,
goods,
goodsArr,
qrHost,
current,
autoplayTime,
imgArr,
adType,
} = this.props;
let {contact} = this.state; let {contact} = this.state;
pageSize = pageSize =
goods && goods.bags.length > 0 goods && goods.bags.length > 0
...@@ -542,7 +551,7 @@ class VerticalPage extends Component { ...@@ -542,7 +551,7 @@ class VerticalPage extends Component {
marginRight: 50, marginRight: 50,
marginLeft: 50, marginLeft: 50,
}}> }}>
<Text style={styles.btnText}>无码商品</Text> <Text style={styles.btnText}>输入价格</Text>
</Touch> </Touch>
<Touch <Touch
onPress={this.props.clearList} onPress={this.props.clearList}
...@@ -693,11 +702,65 @@ class VerticalPage extends Component { ...@@ -693,11 +702,65 @@ class VerticalPage extends Component {
</View> </View>
{width > 801 ? ( {width > 801 ? (
<View style={styles.footer}> <View style={styles.footer}>
{adType === 'image' ? (
imgArr && imgArr.length > 0 ? (
imgArr.length === 1 ? (
imgArr.map((v, index) => (
<Image
key={index}
source={{uri: v}}
style={styles.swiperImg}
/>
))
) : (
<Swiper
style={styles.swiper} // 样式
loop // 如果设置为false,那么滑动到最后一张时,再次滑动将不会滑到第一张图片。
autoplay // 自动轮播
autoplayTimeout={autoplayTime || 10} // 每隔10秒切换
horizontal // 水平方向,为false可设置为竖直方向
showsButtons={false} // 为false时不显示控制按钮
showsPagination={false} // 为false不显示下方圆点
>
{imgArr.map((v, index) => (
<Image
key={index}
source={{uri: v}}
style={styles.swiperImg}
/>
))}
</Swiper>
)
) : (
<Swiper
style={styles.swiper} // 样式
loop // 如果设置为false,那么滑动到最后一张时,再次滑动将不会滑到第一张图片。
autoplay // 自动轮播
autoplayTimeout={autoplayTime || 10} // 每隔10秒切换
horizontal // 水平方向,为false可设置为竖直方向
showsButtons={false} // 为false时不显示控制按钮
showsPagination={false} // 为false不显示下方圆点
>
<Image
source={require('../assets/Vertical/first.jpg')}
style={styles.swiperImg}
/>
<Image
source={require('../assets/Vertical/second.jpg')}
style={styles.swiperImg}
/>
<Image
source={require('../assets/Vertical/third.jpg')}
style={styles.swiperImg}
/>
</Swiper>
)
) : (
<Swiper <Swiper
style={styles.swiper} // 样式 style={styles.swiper} // 样式
loop // 如果设置为false,那么滑动到最后一张时,再次滑动将不会滑到第一张图片。 loop // 如果设置为false,那么滑动到最后一张时,再次滑动将不会滑到第一张图片。
autoplay // 自动轮播 autoplay // 自动轮播
autoplayTimeout={10} // 每隔4秒切换 autoplayTimeout={autoplayTime || 10} // 每隔10秒切换
horizontal // 水平方向,为false可设置为竖直方向 horizontal // 水平方向,为false可设置为竖直方向
showsButtons={false} // 为false时不显示控制按钮 showsButtons={false} // 为false时不显示控制按钮
showsPagination={false} // 为false不显示下方圆点 showsPagination={false} // 为false不显示下方圆点
...@@ -715,6 +778,7 @@ class VerticalPage extends Component { ...@@ -715,6 +778,7 @@ class VerticalPage extends Component {
style={styles.swiperImg} style={styles.swiperImg}
/> />
</Swiper> </Swiper>
)}
</View> </View>
) : ( ) : (
<View /> <View />
......
...@@ -53,3 +53,7 @@ export function sendsms({phone}) { ...@@ -53,3 +53,7 @@ export function sendsms({phone}) {
export function verifysms({phone, code, userId}) { export function verifysms({phone, code, userId}) {
return axios.post('/store/verifysms', qs.stringify({phone, code, userId})); return axios.post('/store/verifysms', qs.stringify({phone, code, userId}));
} }
export function getAdvertising(action) {
return axios.get(`/store/advertising?${qs.stringify(action)}`);
}
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