Authored by huangyCode

Merge branch 'feature/group-buy' of http://git.yoho.cn/fe/yohobuywap-node into feature/group-buy

# Conflicts:
#	apps/activity/controllers/group.js
... ... @@ -25,21 +25,24 @@ function index(req, res, next) {
function groupListIndex(req, res, next) {
let params = Object.assign({}, req.query);
let showType = params.showType || 1; // 1、只展示已开始的 2、只展示即将开始的 3、展示全部
let uid = 0;
Promise.all([req.ctx(GroupService).groupList(params),
showType === '2' && req.ctx(GroupService).readyListResource()
]).then(result => {
if (typeof req.user.uid !== 'undefined') {
uid = req.user.uid;
}
req.ctx(GroupService).groupListIndex(params, uid).then(result => {
return res.render('group/group-list', {
title: '拼团列表',
title: params.title || '拼团列表',
page: 'group-list',
localCss: true,
nodownload: true,
width750: true,
wechatShare: true,
activityData: result[0],
resource: result[1],
showType
activityData: result.groupList,
resource: result.readyListResource,
shareInfo: result.shareInfo,
showType: result.showType
});
}).catch(next);
}
... ... @@ -125,6 +128,20 @@ const productData = (req, res, next) => {
}).catch(next);
};
const groupResultRec = (req, res, next) => {
let limit = req.query.limit || 20;
let page = req.query.page || 1;
let activityId = req.query.activityId;
req.ctx(GroupService).groupResultRec({
activityId,
limit,
page
}).then(result => {
res.json(result);
}).catch(next);
};
function goodsDetail(req, res, next) {
let headerData = headerModel.setNav({
navTitle: '商品详情'
... ... @@ -178,7 +195,10 @@ function delOrder(req, res, next) {
let orderCode = req.query.id;
let uid = req.user.uid;
req.ctx(GroupService).delOrder({orderCode, uid}).then((result) => {
req.ctx(GroupService).delOrder({
orderCode,
uid
}).then((result) => {
res.json(result);
}).catch(next);
}
... ... @@ -187,7 +207,10 @@ function cancelOrder(req, res, next) {
let orderCode = req.query.id;
let uid = req.user.uid;
req.ctx(GroupService).cancelOrder({orderCode, uid}).then((result) => {
req.ctx(GroupService).cancelOrder({
orderCode,
uid
}).then((result) => {
res.json(result);
}).catch(next);
}
... ... @@ -203,15 +226,17 @@ function changeOrderStatus(orderItem) {
case 'buyNow':
orderBtn.push({
buyNow: true,
link: helpers.urlFormat('/home/orders/paynew', {order_code: orderItem.order_code}),
link: helpers.urlFormat('/home/orders/paynew', {
order_code: orderItem.order_code
}),
});
break;
case 'closeOrder':// 取消订单
case 'closeOrder': // 取消订单
orderBtn.push({
closeOrder: true
});
break;
case 'delOrder':// 删除订单
case 'delOrder': // 删除订单
orderBtn.push({
delOrder: true,
});
... ... @@ -286,6 +311,7 @@ module.exports = {
groupList,
progress,
productData,
groupResultRec,
goodsDetail,
order,
filter,
... ...
... ... @@ -44,6 +44,40 @@ class GroupApi extends global.yoho.BaseModel {
return activityData;
}));
}
_getShareId(params) {
return this.get({
url: '',
data: {
method: 'app.union.shareOrder.queryUnionTypeByUid',
uid: params.uid
},
param: {
code: 200
}
}).then((result) => {
result = result.data;
return result;
}).catch(error => {
console.log(error);
return error;
});
}
_getShareInfo(params) {
return this.get({
url: '/operations/api/v5/webshare/getShare',
data: {
...params
},
param: {
code: 200
}
}).then((result) => {
result = result.data;
return result;
});
}
_getPromoteCount() {
let option = {
data: {
... ... @@ -242,8 +276,10 @@ class GroupApi extends global.yoho.BaseModel {
shop_id: data.shop_id,
};
return this.get({data: param})
.then(res =>{
return this.get({
data: param
})
.then(res => {
let shopList = res.data;
if (shopList && shopList.length) {
... ... @@ -266,7 +302,9 @@ class GroupApi extends global.yoho.BaseModel {
activityId: obj.activityId,
};
return this.get({data: param})
return this.get({
data: param
})
.then(data => {
return data.data;
})
... ... @@ -283,7 +321,9 @@ class GroupApi extends global.yoho.BaseModel {
productSkn: obj.productSkn
};
return this.get({data: param})
return this.get({
data: param
})
.then(function(data) {
return data.data;
}).catch(function(error) {
... ... @@ -298,7 +338,9 @@ class GroupApi extends global.yoho.BaseModel {
coupon_limit_status: 0
};
return this.get({data: param})
return this.get({
data: param
})
.then(function(data) {
let free = [{
flag: 1,
... ...
... ... @@ -29,7 +29,7 @@ class GroupService extends global.yoho.BaseModel {
return result;
} catch (e) {
throw new Error('Group index fail to load resources.');
throw new Error('fail to load ready list resources.');
}
}
... ... @@ -112,7 +112,7 @@ class GroupService extends global.yoho.BaseModel {
});
return {
recommend
...recommend
};
} catch (e) {
... ... @@ -130,6 +130,40 @@ class GroupService extends global.yoho.BaseModel {
return result;
}
async groupListIndex(params, uid) {
let result = {};
// 兼容小程序的type配置 type为4则显示即将开始列表
if (!params.showType) {
params.showType = params.type === '4' ? '2' : '1';
}
result.showType = params.showType; // 1、只展示已开始的 2、只展示即将开始的 3、展示全部
result.groupList = await this.groupList(params);
result.readyListResource = result.showType === '2' && await this.readyListResource();
// 登录后获取分享信息
if (uid !== 0) {
let share_id = await this.getShareId(uid);
result.shareInfo = await this.getShareInfo({
share_id
});
} else {
result.shareInfo = '';
}
return result;
}
async getShareId(uid) {
try {
const result = await this.api._getShareId({
uid
});
return result.shareId;
} catch (e) {
throw new Error('can not get shareId.');
}
}
async tabData() {
const result = await this.api._getPromoteCount();
let tabsData = {};
... ... @@ -221,14 +255,23 @@ class GroupService extends global.yoho.BaseModel {
throw new Error('Group list fail to load resources.');
}
}
async getShareInfo(params) {
try {
return await this.api._getShareInfo(params);
} catch (e) {
throw new Error('get shareInfo failed.');
}
}
async goodsDetail(params) {
let result = await this.api.getProductData(params);
if (result.shop_id) {
result.storeUrl = `/shop/${_.get(result, 'brand_info.brand_domain')}-${_.get(result, 'shop_id')}.html`;
}
result.shopInfo = await this.api.getShopInfo({brand_id: result.brand_id, shop_id: result.shop_id});
result.shopInfo = await this.api.getShopInfo({
brand_id: result.brand_id,
shop_id: result.shop_id
});
result.activityIdDetail = await this.api.getCollageProductInfo(params);
result.activityGroupDetailList = await this.api.fetchActivityGroups(params);
result.support = await this.api.getSupport(params);
... ...
... ... @@ -372,6 +372,7 @@ router.get('/group/goods-list', group.groupList); // 拼团列表
router.get('/group/filter', group.filter); // 首页筛选结果页
router.get('/group/search', group.searchList); // 首页筛选列表
router.get('/group/progress', auth, group.progress); // 拼团状态详情页
router.get('/group/groupResultRec', group.groupResultRec); // 拼团状态详情页
router.get('/group/productData', group.productData); // 商品信息
router.get('/group/detail', group.goodsDetail);
router.get('/group/order', auth, group.order); // 我的拼团
... ...
<div class="container">
<div class="container" data-share-img="{{shareInfo.bigImage}}" data-share-title="{{shareInfo.title}}" data-share-content="{{shareInfo.content}}">
{{#if activityData.banner}}
<a href="{{activityData.banner.imageUrl}}" class="img-wrapper">
... ... @@ -15,7 +15,7 @@
{{/each}}
{{/if}}
{{/ifcond}}
<div id="goodsContainer">
<div class="goods-list">
{{#each activityData.activityList}}
... ... @@ -26,4 +26,7 @@
</div>
<a class="my-group my-group-handler" href="/activity/group/order">我的拼团</a>
<div class='my-share'></div>
\ No newline at end of file
{{#if shareInfo}}
<div class='my-share'></div>
{{/if}}
<div class="h5-share-clipboard"></div>
\ No newline at end of file
... ...
... ... @@ -13,7 +13,8 @@
data-activity-id="{{activityId}}" data-group-no="{{groupNo}}" data-page-go="{{pageGo}}">
<img src="{{image2 yourJoinItem.productIcon w=200 h=282}}" alt="" class="card-pre-img">
<div class="info">
<div class="name">{{yourJoinItem.productName}}</div>
<div class="name">{{#ifcond joinLimit '==' 1}}<span class="tag"></span>{{/ifcond}}{{yourJoinItem
.productName}}</div>
<div class="group-price">{{yourJoinItem.productGroupPrice}}</div>
<div class="single-buy-price">单人购买:<span class="line-through">{{yourJoinItem
.productSalePrice}}</span></div>
... ... @@ -87,7 +88,8 @@
<div class="product-item" data-product-skn="{{productSkn}}" data-activity-id="{{activityId}}">
<img data-original="{{image2 defaultImages w=200 h=282}}" alt="商品图片" class="prd-item-img lazy">
<div class="prd-info">
<div class="prd-name">{{productName}}</div>
<div class="prd-name">{{#ifcond @root.data.joinLimit '==' 1}}<span class="tag"></span>{{/ifcond
}}{{productName}}</div>
<div class="price">
<span class="cprice">¥{{collagePrice}}</span>
<span class="mprice">¥{{marketPrice}}</span>
... ...
... ... @@ -43,6 +43,14 @@ class BuyNowController {
let product_sku = req.query.product_sku;
let buy_number = req.query.buy_number;
let isGroup = req.query.is_group || '0';
if (isGroup === '1') {
isGroup = false;
} else {
isGroup = true;
}
if (!product_sku || !buy_number) {
return next();
}
... ... @@ -72,103 +80,208 @@ class BuyNowController {
});
}
co(function * () {
let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] =
yield Promise.all([
req.ctx(userModel).queryProfile(uid),
req.ctx(addressModel).addressData(uid),
req.ctx(BuyNowModel).payment({
uid: uid,
product_sku: product_sku,
sku_type: req.query.sku_type,
buy_number: buy_number,
yoho_coin_mode: parseInt(orderInfo.use_yoho_coin, 10) > 0 ? 1 : 0
}),
computerPromise,
req.ctx(BuyNowModel).countUsableCoupon({
uid: uid,
product_sku: req.query.product_sku,
sku_type: req.query.sku_type,
buy_number: buy_number,
delivery_way: orderInfo.delivery_way
}),
req.ctx(shoppingModel).countUsableGiftCard(uid) // 可用礼品卡数量
]);
// 获取用户完整手机号
let mobile = _.get(userProfile, 'data.mobile', '');
let orderAddress = _.get(result, 'address', []);
let addressList = _.get(address, 'data', []);
let autoSelectCouponCodeStr = _.get(result, 'data.coupon_pay.coupon_code', '');
let orderEnsure = {};
if (result.code !== 200 && result.message) {
orderEnsure = {message: result.message};
} else {
orderAddress.length && _.forEach(addressList, address => { //eslint-disable-line
if (address.address_id === orderAddress.address_id) {
mobile = address.mobile;
return false;
if (isGroup) {
co(function * () {
let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] =
yield Promise.all([
req.ctx(userModel).queryProfile(uid),
req.ctx(addressModel).addressData(uid),
req.ctx(BuyNowModel).payment({
uid: uid,
product_sku: product_sku,
sku_type: req.query.sku_type,
buy_number: buy_number,
yoho_coin_mode: parseInt(orderInfo.use_yoho_coin, 10) > 0 ? 1 : 0
}),
computerPromise,
req.ctx(BuyNowModel).countUsableCoupon({
uid: uid,
product_sku: req.query.product_sku,
sku_type: req.query.sku_type,
buy_number: buy_number,
delivery_way: orderInfo.delivery_way
}),
req.ctx(shoppingModel).countUsableGiftCard(uid) // 可用礼品卡数量
]);
// 获取用户完整手机号
let mobile = _.get(userProfile, 'data.mobile', '');
let orderAddress = _.get(result, 'address', []);
let addressList = _.get(address, 'data', []);
let autoSelectCouponCodeStr = _.get(result, 'data.coupon_pay.coupon_code', '');
let orderEnsure = {};
if (result.code !== 200 && result.message) {
orderEnsure = {message: result.message};
} else {
orderAddress.length && _.forEach(addressList, address => { //eslint-disable-line
if (address.address_id === orderAddress.address_id) {
mobile = address.mobile;
return false;
}
});
if (orderInfo.user_check_coupon !== 'Y' && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('buynow_info', JSON.stringify(orderInfo), actCkOpthn);
}
});
if (orderInfo.user_check_coupon !== 'Y' && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('buynow_info', JSON.stringify(orderInfo), actCkOpthn);
// 兼容原有的数据格式
orderInfo.deliveryId = orderInfo.delivery_way;
orderInfo.deliveryTimeId = orderInfo.delivery_time;
orderInfo.couponCode = orderInfo.coupon_code;
orderInfo.yohoCoin = orderInfo.use_yoho_coin;
orderInfo.paymentType = orderInfo.payment_type;
orderEnsure = _.assign(
paymentProcess.tranformPayment(
_.get(result, 'data', {}), orderInfo, null, null,
_.get(computeData, 'data', {})),
{
coupon: paymentProcess.handleCoupons({
paymentApiCouponData: _.get(result, 'data.coupon_pay', {}),
validCouponCount: _.get(validCouponCount, 'data.count', 0),
orderComputeCouponPay: _.get(computeData, 'data.coupon_pay'),
userCheckCoupon: orderInfo.user_check_coupon
}),
selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
product_sku: product_sku,
buy_number: buy_number
}),
selectCouponUrl: helpers.urlFormat('/cart/index/buynow/selectCoupon', {
product_sku: product_sku,
buy_number: buy_number
}),
isOrdinaryCart: true,
isGroupCart: true,
choseGiftCard: helpers.urlFormat('/cart/index/buynow/selectGiftcard'),
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: _.get(validGiftCardCount, 'data.count', 0),
orderCompute: _.get(computeData, 'data', {})
})
}
);
}
// 兼容原有的数据格式
orderInfo.deliveryId = orderInfo.delivery_way;
orderInfo.deliveryTimeId = orderInfo.delivery_time;
orderInfo.couponCode = orderInfo.coupon_code;
orderInfo.yohoCoin = orderInfo.use_yoho_coin;
orderInfo.paymentType = orderInfo.payment_type;
orderEnsure = _.assign(
paymentProcess.tranformPayment(
_.get(result, 'data', {}), orderInfo, null, null,
_.get(computeData, 'data', {})),
{
coupon: paymentProcess.handleCoupons({
paymentApiCouponData: _.get(result, 'data.coupon_pay', {}),
validCouponCount: _.get(validCouponCount, 'data.count', 0),
orderComputeCouponPay: _.get(computeData, 'data.coupon_pay'),
userCheckCoupon: orderInfo.user_check_coupon
}),
selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
return res.render('buynow/order-ensure', {
pageHeader: headerModel.setNav({
navTitle: '确认订单',
navBtn: false
}),
module: 'cart',
page: 'buynow-order-ensure',
title: '确认订单',
width750: true,
localCss: true,
product_sku: product_sku,
orderEnsure: orderEnsure,
userMobile: mobile
});
})().catch(next);
} else {
let activity_id = req.query.activity_id;
let group_no = req.query.group_no;
co(function * () {
let [userProfile, address, result, computeData, validCouponCount, validGiftCardCount] =
yield Promise.all([
req.ctx(userModel).queryProfile(uid),
req.ctx(addressModel).addressData(uid),
req.ctx(BuyNowModel).groupBuyPayment({
uid: uid,
product_sku: product_sku,
buy_number: buy_number
group_no,
activity_id: activity_id,
}),
selectCouponUrl: helpers.urlFormat('/cart/index/buynow/selectCoupon', {
product_sku: product_sku,
buy_number: buy_number
computerPromise,
req.ctx(BuyNowModel).countUsableCoupon({
uid: uid,
product_sku: req.query.product_sku,
sku_type: req.query.sku_type,
buy_number: buy_number,
delivery_way: orderInfo.delivery_way
}),
isOrdinaryCart: true,
choseGiftCard: helpers.urlFormat('/cart/index/buynow/selectGiftcard'),
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: _.get(validGiftCardCount, 'data.count', 0),
orderCompute: _.get(computeData, 'data', {})
})
req.ctx(shoppingModel).countUsableGiftCard(uid) // 可用礼品卡数量
]);
// 获取用户完整手机号
let mobile = _.get(userProfile, 'data.mobile', '');
let orderAddress = _.get(result, 'address', []);
let addressList = _.get(address, 'data', []);
let autoSelectCouponCodeStr = _.get(result, 'data.coupon_pay.coupon_code', '');
let orderEnsure = {};
if (result.code !== 200 && result.message) {
orderEnsure = {message: result.message};
} else {
orderAddress.length && _.forEach(addressList, address => { //eslint-disable-line
if (address.address_id === orderAddress.address_id) {
mobile = address.mobile;
return false;
}
});
if (orderInfo.user_check_coupon !== 'Y' && autoSelectCouponCodeStr) {
orderInfo.coupon_code = autoSelectCouponCodeStr;
res.cookie('buynow_info', JSON.stringify(orderInfo), actCkOpthn);
}
);
}
return res.render('buynow/order-ensure', {
pageHeader: headerModel.setNav({
navTitle: '确认订单',
navBtn: false
}),
module: 'cart',
page: 'buynow-order-ensure',
title: '确认订单',
width750: true,
localCss: true,
product_sku: product_sku,
orderEnsure: orderEnsure,
userMobile: mobile
});
// 兼容原有的数据格式
orderInfo.deliveryId = orderInfo.delivery_way;
orderInfo.deliveryTimeId = orderInfo.delivery_time;
orderInfo.couponCode = orderInfo.coupon_code;
orderInfo.yohoCoin = orderInfo.use_yoho_coin;
orderInfo.paymentType = orderInfo.payment_type;
orderEnsure = _.assign(
paymentProcess.tranformPayment(
_.get(result, 'data', {}), orderInfo, null, null,
_.get(computeData, 'data', {})),
{
coupon: paymentProcess.handleCoupons({
paymentApiCouponData: _.get(result, 'data.coupon_pay', {}),
validCouponCount: _.get(validCouponCount, 'data.count', 0),
orderComputeCouponPay: _.get(computeData, 'data.coupon_pay'),
userCheckCoupon: orderInfo.user_check_coupon
}),
selectAddressUrl: helpers.urlFormat('/cart/index/buynow/selectAddress', {
product_sku: product_sku,
buy_number: buy_number
}),
selectCouponUrl: helpers.urlFormat('/cart/index/buynow/selectCoupon', {
product_sku: product_sku,
buy_number: buy_number
}),
isOrdinaryCart: false,
isGroupCart: false,
choseGiftCard: helpers.urlFormat('/cart/index/buynow/selectGiftcard'),
giftCards: paymentProcess.handleGiftCards({
validGiftCardCount: _.get(validGiftCardCount, 'data.count', 0),
orderCompute: _.get(computeData, 'data', {})
})
}
);
}
return res.render('buynow/order-ensure', {
pageHeader: headerModel.setNav({
navTitle: '确认订单',
navBtn: false
}),
module: 'cart',
page: 'buynow-order-ensure',
title: '确认订单',
width750: true,
localCss: true,
product_sku: product_sku,
orderEnsure: orderEnsure,
userMobile: mobile
});
})().catch(next);
}
})().catch(next);
}
/**
... ...
... ... @@ -73,6 +73,32 @@ class BuyNowModel extends global.yoho.BaseModel {
return this.post(finalParams);
}
groupBuyPayment(params) {
let finalParams = {
data: {
method: 'app.GroupBuy.payment',
uid: params.uid,
product_sku: params.product_sku,
group_no: params.group_no || '',
buy_number: 1,
yoho_coin_mode: 0, // 是否使用有货币
yoho_bill_term: 0, // H5 不支持分期
is_support_apple_pay: 'N', // H5 不支持 APPLE PAY
activity_id: params.activity_id || 0,
enable_red_envelopes: 0 // H5 不支持使用红包
},
param: {
cache: false
}
};
if (params && params.group_no) {
finalParams.data.group_no = params.group_no;
}
return this.post(finalParams);
}
/**
* 数据改变,重新计算结算数据
* @param {*} params
... ...
... ... @@ -61,6 +61,7 @@
{{/each}}
</ul>
</div>
{{#if isGroupCart}}
<div class="sub-block dispatch-time">
<h3>
<p>送货时间</p>
... ... @@ -80,6 +81,7 @@
{{/each}}
</ul>
</div>
{{/if}}
</section>
{{#if isJit}}
... ... @@ -94,6 +96,7 @@
<section class="block">
<ul class="sale-invoice">
{{#if isGroupCart}}
{{!-- 优惠券 --}}
{{#if isOrdinaryCart}}
<li class="coupon">
... ... @@ -133,6 +136,7 @@
</a>
</li>
{{/if}}
{{/if}}
{{!-- 发票 --}}
{{#if invoice}}
... ...
... ... @@ -52,7 +52,7 @@
</a>
</div>
<!--<span class="left-num-discount">即将售罄</span>-->
<span class="left-num-discount">限购{{buy_limit_number}}</span>
<!--<span class="left-num-discount">限购{{buy_limit_number}}件</span>-->
</div>
</div>
</div>
... ...
<div class="product-item" data-product-skn="{{productSkn}}" data-activity-id="{{activityId}}">
<img src="{{image2 defaultImages w=200 h=282 q=80}}" alt="商品图片" class="prd-item-img">
<div class="prd-info">
<div class="prd-name">{{#ifcond @root.data.joinLimit '==' 1}}<span class="tag"></span>{{/ifcond
}}{{productName}}</div>
<div class="price">
<span class="cprice">¥{{collagePrice}}</span>
<span class="mprice">¥{{marketPrice}}</span>
</div>
{{#ifcond joinPeopleNum '>' 0}}
<span class="joined">{{joinPeopleNum}} 人已參加</span>
{{/ifcond}}
<div class="buy-btn">
<span class="num">{{peopleNum}}人成团</span>
<span class="immediate">立即购买</span>
</div>
</div>
</div>
... ...
... ... @@ -4,13 +4,25 @@ import $ from 'yoho-jquery';
import Page from 'js/yoho-page';
import qs from 'yoho-qs';
import ProductListLoader from './group/group-list';
import Clipboard from 'clipboard';
import tip from 'js/plugin/tip';
import dialog from 'js/plugin/dialog';
import sharePlugin from 'js/common/share';
import yoSdk from 'yoho-activity-sdk';
const querystring = require('querystring');
class ProductList extends Page {
constructor() {
super();
this.selector = {
$goodsContainer: $('.goods-list')
$pageContainer: $('.container'),
$goodsContainer: $('.goods-list'),
$share: $('.my-share')
};
this.shareData = {
shareImgUrl: this.selector.$pageContainer.data('share-img'),
shareTitle: this.selector.$pageContainer.data('share-title')
};
this.firstScreen = this.selector.$goodsContainer.children().size() > 0;
if (!this.firstScreen) {
... ... @@ -26,13 +38,16 @@ class ProductList extends Page {
new ProductListLoader(initParams, '/activity/group/goods-list', {
scrollActived: this.firstScreen
});
this.shareInfo();
this.bindEvents();
this.swiperTop();
}
bindEvents() {
this.selector.$goodsContainer.on('click', '.groupListCellTapped',
this.checkDetail.bind(this));
this.selector.$share.on('click', this.share.bind(this));
}
checkDetail(e) {
let $this = $(e.currentTarget);
... ... @@ -42,6 +57,42 @@ class ProductList extends Page {
console.log(productSkn, activityId);
window.location.href = `/activity/group/detail?activityId=${activityId}&productSkn=${productSkn}`;
}
shareInfo() {
let shareData = this.shareData;
let [link, paramsStr] = location.href.split('?');
let params = querystring.parse(paramsStr);
delete params['openby:yohobuy'];
paramsStr = querystring.stringify(params);
link = link + (paramsStr ? '?' + paramsStr : '');
sharePlugin({
title: shareData.shareTitle,
imgUrl: shareData.shareImgUrl,
link: link
});
let clipboardShare = new Clipboard('.h5-share-clipboard', {
text: () => {
return `${shareData.shareTitle}>>${link}`;
}
});
clipboardShare.on('success', (e) => {
tip.show('复制成功,发送给好友', 3500);
e.clearSelection();
});
}
share() {
if (/QQ/i.test(navigator.userAgent) ||
/MicroMessenger/i.test(navigator.userAgent)) {
dialog.showDialog({
hasClass: 'group-guide-mask'
});
} else if (yoSdk.env === 'h5') {
$('.h5-share-clipboard').trigger('click');
}
}
// 顶部swiper
swiperTop() {
... ...
... ... @@ -8,6 +8,7 @@ import dialog from 'js/plugin/dialog';
import lazyLoad from 'yoho-jquery-lazyload';
import yoSdk from 'yoho-activity-sdk';
let yoho = require('js/yoho-app');
let recItem = require('hbs/activity/group/progress-rec-item.hbs');
class GroupProgress extends Page {
constructor() {
... ... @@ -30,9 +31,13 @@ class GroupProgress extends Page {
groupPrice: '',
shareImgUrl: ''
};
this.page = 2;
this.loading = false;
this.loadedAll = false;
// 去参团弹出商品选择数据
this.pickData = {};
this.beforeScroll = document.body.scrollTop; // 滚动前位置记录
this.init();
}
... ... @@ -42,6 +47,20 @@ class GroupProgress extends Page {
this.bindEvents();
this.shareInfo();
this.countdown();
let timeout = '';
let self = this;
window.onscroll = function() {
if (timeout !== null) {
clearTimeout(timeout);
}
timeout = setTimeout(function() {
if ($(document).height() - $(window).scrollTop() - $(window).height() < 500) {
this.loadMoreData();
}
}.bind(self), 50);
};
}
initData() {
... ... @@ -64,7 +83,7 @@ class GroupProgress extends Page {
}
bindEvents() {
this.selector.$productItem.on('click', this.goDetail.bind(this));
$(document).on('click', '.product-item', this.goDetail.bind(this));
this.selector.$goJoin.on('click', this.goJoin.bind(this));
this.selector.$joinGroup.on('click', this.joinGroup.bind(this));
this.selector.$inviteJoin.on('click', this.inviteJoin.bind(this));
... ... @@ -206,9 +225,9 @@ class GroupProgress extends Page {
data: this.pickData
}).then(result => {
if (result && result.sku) {
if (result.buyNow) { // 立即购买
let nextUrl = location.origin + '/cart/index/buynow/orderensure?product_sku=' +
result.sku.skuId + '&buy_number=' + result.buyNum;
if (result.buyNow) {
let query = `is_group=1&product_sku=${result.sku.skuId}&buy_number=1&activity_id=${this.data.activityId}&group_no=${this.data.groupNo}`; // eslint-disable-line
let nextUrl = location.origin + `/cart/index/buynow/orderensure?${query}`;
if (!yoho.isLogin()) {
yoho.goLogin(nextUrl);
... ... @@ -306,6 +325,45 @@ class GroupProgress extends Page {
this.pickData.minusButtonEnable = minusButtonEnable;
});
}
loadMoreData() {
if (this.loading || this.loadedAll) {
return;
}
this.loading = true;
this.ajax({
url: '/activity/group/groupResultRec',
data: {
page: this.page,
limit: 4
}
}).then(result => {
if (!result.collageProductVoList) {
this.loading = false;
this.loadedAll = true;
return;
}
this.page = this.page + 1;
this.renderMoreData(result.collageProductVoList);
this.loading = false;
}).catch(() => {
this.loading = false;
});
}
renderMoreData(list) {
console.log('render data');
let appendHtml = '';
list.forEach(item => {
appendHtml += recItem(item);
});
$('.recommend').append(appendHtml);
}
}
$(() => {
... ...
... ... @@ -27,7 +27,6 @@ let $yohoPage = $('.yoho-page'),
$choseArea,
$goodNum,
$btnMinus,
$btnPlus,
$thumbImg,
$choseBtnSure;
... ... @@ -108,7 +107,6 @@ class ChosePanel {
$choseArea = $('.chose-panel .main .chose-items');
$goodNum = $('#good-num');
$btnMinus = $('.btn-minus');
$btnPlus = $('.btn-plus');
$thumbImg = $('.thumb-img');
$choseBtnSure = $('.btn-sure-buynow');
}
... ... @@ -120,9 +118,6 @@ class ChosePanel {
$yohoPage.on('touchstart', '.block', (e) => {
this._blockClick(e);
});
$yohoPage.on('touchstart', '.btn-plus,.btn-minus', (e) => {
this._numClick(e);
});
$yohoPage.on('touchstart', '.thumb-img .thumb', (e) => {
this._thumbClick(e);
});
... ... @@ -203,7 +198,7 @@ class ChosePanel {
if (skuId) {
this._resolve && this._resolve({
sku: {skuId},
buyNum: this.data.buyNumber || 1,
buyNum: 1, // 拼团只支持一件
buyNow: true
});
}
... ... @@ -270,8 +265,6 @@ class ChosePanel {
} else {
$goodNum.val(1);
this.data.buyNumber = 1;
$btnMinus.find('.operator').addClass('disabled');
$btnPlus.find('.operator').removeClass('disabled');
$choseBtnSure.css('background-color', '#d0021b').text('确定');
}
}
... ...
@import "~scss/layout/swiper";
@import "floor/banner-top";
body {
background-color: #fff;
}
.container {
margin-bottom: 90px;
}
... ... @@ -36,6 +40,11 @@
height: 246px;
border: 1px solid yellowgreen;
overflow: hidden;
.img {
width: 100%;
height: 100%;
}
}
.my-share {
... ... @@ -268,3 +277,23 @@
.button-hover {
opacity: 1;
}
.dialog-wrapper {
z-index: 9999;
}
.dialog-wrapper .dialog-box.group-guide-mask {
width: 284px;
height: 278px;
background: url("img/activity/group/share-tip.png");
background-size: 100% 100%;
margin: 0 !important;
border: 0;
right: 92px;
top: 28px !important;
left: auto;
> * {
display: none !important;
}
}
... ...
... ... @@ -72,15 +72,35 @@
padding: 34px 20px 0 230px;
box-sizing: border-box;
.name {
font-size: 24px;
color: #444;
letter-spacing: -0.8px;
line-height: 40px;
}
.name .tag {
display: inline-block;
width: 80px;
height: 28px;
margin-right: 16px;
vertical-align: middle;
background-image: url("img/activity/group/invite-new.png");
background-size: 80px 28px;
}
.group-price {
font-size: 40px;
color: #d0021b;
font-weight: bold;
line-height: 1;
margin-top: 40px;
}
.single-buy-price {
font-size: 20px;
color: #b0b0b0;
margin-top: 6px;
}
.single-buy-price .line-through {
... ... @@ -207,6 +227,16 @@
}
}
.prd-name .tag {
display: inline-block;
width: 80px;
height: 28px;
margin-right: 16px;
vertical-align: middle;
background-image: url("img/activity/group/invite-new.png");
background-size: 80px 28px;
}
.prd-info .price {
font-size: 0;
margin-top: 30px;
... ...
... ... @@ -10,6 +10,7 @@
.group {
.resources {
background-color: #fff;
margin-bottom: 90px;
}
... ...
... ... @@ -81,7 +81,7 @@ exports.processFilter = (list, options) => {
dataId: 'id',
subsName: 'name',
firstSub: 0,
dataType: 'ageLevel',
dataType: 'age_level',
sortNum: '2'
}
};
... ...