|
|
import Taro, {Component} from '@tarojs/taro';
|
|
|
import Taro, {Component, login} from '@tarojs/taro';
|
|
|
import {View, Swiper, SwiperItem, Image} from '@tarojs/components';
|
|
|
import {productDetail as productDetailModel} from '../../models';
|
|
|
import {getImgUrl} from '../../utils';
|
...
|
...
|
@@ -56,6 +56,7 @@ export default class ProductDetail extends Component { |
|
|
snapshootShareData: {},
|
|
|
skup: '',
|
|
|
storeId: -1,
|
|
|
isLogin: false,
|
|
|
productDec: {
|
|
|
color: {
|
|
|
text: '颜色',
|
...
|
...
|
@@ -84,7 +85,8 @@ export default class ProductDetail extends Component { |
|
|
config = {
|
|
|
usingComponents: {
|
|
|
'share-sheet' : '../../components/shareSheet/shareSheet',
|
|
|
'snapshoot-share' : '../../components/shareSheet/snapshootShare/snapshootShare'
|
|
|
'snapshoot-share' : '../../components/shareSheet/snapshootShare/snapshootShare',
|
|
|
'login-bg': '../../components/login/login-bg/login-bg'
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -109,29 +111,18 @@ export default class ProductDetail extends Component { |
|
|
const storeArr = p.split(',') || [];
|
|
|
const storeId = storeArr[1];
|
|
|
if (queryObj.skup) {
|
|
|
wx.hideShareMenu();
|
|
|
this.setState({
|
|
|
skup: queryObj.skup,
|
|
|
storeId
|
|
|
})
|
|
|
this.loadStoreProductInfo(queryObj.skup, storeId);
|
|
|
this.skupMustLogin(queryObj.skup, storeId);
|
|
|
} else {
|
|
|
this.loadElement({ id: queryObj.productId || queryObj.skn });
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
if (options && options.scene) {
|
|
|
console.log(options.scene);
|
|
|
let code = options.scene;
|
|
|
getQRCodeSource(code).then(json => {
|
|
|
if (json) {
|
|
|
if (json.skup) {
|
|
|
wx.hideShareMenu();
|
|
|
this.setState({
|
|
|
skup: json.skup,
|
|
|
storeId: json.storeId
|
|
|
});
|
|
|
this.loadStoreProductInfo(json.skup, json.storeId);
|
|
|
this.skupMustLogin(json.skup, json.storeId);
|
|
|
} else {
|
|
|
this.loadElement(json);
|
|
|
}
|
...
|
...
|
@@ -139,11 +130,47 @@ export default class ProductDetail extends Component { |
|
|
})
|
|
|
.catch(error => {
|
|
|
});
|
|
|
} else {
|
|
|
} else if(options.storeId && options.skup) {
|
|
|
this.skupMustLogin(options.skup, options.storeId);
|
|
|
}
|
|
|
else {
|
|
|
this.loadElement(options);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
skupMustLogin(skup, storeId) {
|
|
|
wx.hideShareMenu();
|
|
|
this.setState({
|
|
|
skup,
|
|
|
storeId
|
|
|
});
|
|
|
// event.emit('user-is-login', () => {
|
|
|
// this.loadStoreProductInfo(skup, storeId);
|
|
|
// }, () => {
|
|
|
// Taro.redirectTo({
|
|
|
// url: `/pages/productDetail/index?skup=${skup}&storeId=${storeId}`,
|
|
|
// });
|
|
|
// });
|
|
|
event.emit('judge-user-is-login', this.isLogined.bind(this), this.isLoginCallBack.bind(this, skup, storeId));
|
|
|
}
|
|
|
|
|
|
isLogined(isLogin) {
|
|
|
this.setState({
|
|
|
isLogin
|
|
|
})
|
|
|
}
|
|
|
|
|
|
isLoginCallBack(skup, storeId) {
|
|
|
this.loadStoreProductInfo(skup, storeId);
|
|
|
}
|
|
|
|
|
|
loginSuccess(isLogin) {
|
|
|
this.setState({
|
|
|
isLogin
|
|
|
})
|
|
|
let { skup, storeId } = this.state;
|
|
|
this.loadStoreProductInfo(skup, storeId);
|
|
|
}
|
|
|
|
|
|
async loadStoreProductInfo(skup, storeId) {
|
|
|
await getPrivateKey();
|
...
|
...
|
@@ -356,6 +383,13 @@ export default class ProductDetail extends Component { |
|
|
}
|
|
|
}
|
|
|
|
|
|
reportStoreId(storeId, e) {
|
|
|
debugger
|
|
|
console.log(storeId);
|
|
|
console.log(e);
|
|
|
productDetailModel.storeIdLoginReport(storeId, 'OfflineStore', e.detail).then(ret => {});
|
|
|
}
|
|
|
|
|
|
onShareAppMessage(res) {
|
|
|
console.log(res);
|
|
|
|
...
|
...
|
@@ -490,12 +524,14 @@ export default class ProductDetail extends Component { |
|
|
}
|
|
|
|
|
|
render() {
|
|
|
let {productInfo, recommendList, goodsList, productDec, id, skup} = this.state;
|
|
|
let {productInfo, recommendList, goodsList, productDec, id, skup, isLogin, storeId} = this.state;
|
|
|
let imageList = goodsList.image_list || [];
|
|
|
let status = productInfo.status;
|
|
|
|
|
|
let isShowLogin = !isLogin && storeId !== -1;
|
|
|
|
|
|
return (
|
|
|
<View className="product-page">
|
|
|
<View>
|
|
|
{ !isShowLogin && (<View className="product-page">
|
|
|
<View className="swiperNum">{this.swiperNum}</View>
|
|
|
<Swiper className='product-swiper' autoplay onChange={this.onChangeSwiper}>
|
|
|
{
|
...
|
...
|
@@ -609,7 +645,12 @@ export default class ProductDetail extends Component { |
|
|
{
|
|
|
skup ? <Image className="goYohoBuy" onClick={this.goOnLineProuduct.bind(this, id)} src={goOnLine} mode="aspectFill" /> : <Image className="goYohoBuy" onClick={this.goYohoBuyMinApp.bind(this)} src={goYohoBuy} mode="aspectFill" />
|
|
|
}
|
|
|
</View>
|
|
|
</View>)
|
|
|
}
|
|
|
{
|
|
|
isShowLogin && (<login-bg catchtouchmove='true' onReportStoreId={this.reportStoreId.bind(this, storeId)} onLoginSuccess={this.loginSuccess}></login-bg>)
|
|
|
}
|
|
|
</View>
|
|
|
)
|
|
|
}
|
|
|
} |
...
|
...
|
|