Commit f01907b4 by zeven

Merge remote-tracking branch 'origin/master'

parents 764f4243 3319738f
......@@ -140,6 +140,9 @@ export default {
const {data} = yield call(api.verifysms, action);
return data;
},
*getAdvertising(action, {call}) {
return yield call(api.getAdvertising, action);
},
},
};
......
......@@ -53,9 +53,23 @@ const CounterMixins = ComposeComponent => {
title: '',
dot: false,
luckyVisible: false,
autoplayTime: 10,
imgArr: [],
adType: 'image',
};
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');
await this.setState({qrHost});
};
......@@ -121,7 +135,18 @@ const CounterMixins = ComposeComponent => {
if (window.socket.hasListeners('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('adsOperate', ({adsData}) => {
console.warn(adsData);
this.setState({
autoplayTime: Number(adsData.time),
imgArr: adsData[adsData.type],
adType: adsData.type,
});
});
window.socket.on(
'counterOrder',
({type, msg, sid, token, payType, orderId}) => {
......@@ -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}) => {
......
......@@ -422,7 +422,16 @@ class VerticalPage extends Component {
);
render() {
let {admin, goods, goodsArr, qrHost, current} = this.props;
let {
admin,
goods,
goodsArr,
qrHost,
current,
autoplayTime,
imgArr,
adType,
} = this.props;
let {contact} = this.state;
pageSize =
goods && goods.bags.length > 0
......@@ -542,7 +551,7 @@ class VerticalPage extends Component {
marginRight: 50,
marginLeft: 50,
}}>
<Text style={styles.btnText}>无码商品</Text>
<Text style={styles.btnText}>输入价格</Text>
</Touch>
<Touch
onPress={this.props.clearList}
......@@ -693,28 +702,83 @@ class VerticalPage extends Component {
</View>
{width > 801 ? (
<View style={styles.footer}>
<Swiper
style={styles.swiper} // 样式
loop // 如果设置为false,那么滑动到最后一张时,再次滑动将不会滑到第一张图片。
autoplay // 自动轮播
autoplayTimeout={10} // 每隔4秒切换
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>
{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
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>
)}
</View>
) : (
<View />
......
......@@ -53,3 +53,7 @@ export function sendsms({phone}) {
export function verifysms({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