Authored by 陈峰

Merge branch 'feature/group-tab-and-limit' into 'release/6.9.0'

普通团可以增加购买数量,并且如果有最小数量限制的时候,不能小于最小数量



See merge request !1731
... ... @@ -237,7 +237,7 @@ class GroupService extends global.yoho.BaseModel {
page: 1,
limit: 20,
joinLimit: 1,
order: 's_t_desc'
order: 'h_v_desc'
};
let newParams = {
...initParams,
... ...
... ... @@ -174,9 +174,8 @@
<span class="bottom-title">单人购买</span>
{{/if}}
</button>
<button class="buynow join-group-btn" {{#ifcond activityIdDetail.peopleNum "==" '0'}} style="background-color: #b0b0b0;" {{/ifcond}}
id="buynow">
id="buynow" data-joinLimit="{{activityIdDetail.joinLimit}}" data-saleNum="{{activityIdDetail.saleNum}}">
<span class="bottom-title">{{activityIdDetail.formatCollagePrice}}</span>
{{#if groupNo}}
<span class="bottom-title">确认参团{{#if isShowPop}},仅限新人{{/if}}</span>
... ...
... ... @@ -42,7 +42,6 @@
{{> group/progress-countdown}}
<div class="status-btn positive invite-join">邀请小伙伴拼团{{#ifcond joinLimit '==' 1}}(仅限新人){{/ifcond}}</div>
{{/ifcond}}
{{#ifcond pageGo '===' 2}}
<div class="status-tip">还差<span class="red">{{lackNum}}</span>拼团成功,剩余时间</div>
{{> group/progress-countdown}}
... ...
... ... @@ -5,14 +5,15 @@
<span class="iconfont drop">&#xe613;</span>
</a>
</li> --}}
<li class="new active" data-type="new" data-order="s_t_desc">
<li class="popularity active" data-type="popularity" data-order="h_v_desc">
<a href="javascript:void(0);">
<span class="span-test">最新</span>
<span class="span-test">人气</span>
</a>
</li>
<li class="popularity" data-type="popularity" data-order="h_v_desc">
<li class="new" data-type="new" data-order="s_t_desc">
<a href="javascript:void(0);">
<span class="span-test">人气</span>
<span class="span-test">最新</span>
</a>
</li>
<li class="price" data-type="price">
... ... @@ -30,4 +31,4 @@
<span class="iconfont cur">&#xe613;</span>
</a>
</li>
</ul>
\ No newline at end of file
</ul>
... ...
... ... @@ -194,6 +194,7 @@ class BuyNowController {
product_sku: product_sku,
group_no,
activity_id: activity_id,
buy_number: buy_number
})
]);
... ... @@ -430,7 +431,7 @@ class BuyNowController {
udid: udid,
group_no: req.body.group_no,
sku_type: req.body.sku_type,
buy_number: 1,
buy_number: req.body.buy_number || 1,
gift_card_code: req.body.gift_card_code,
address_id: req.body.address_id,
delivery_time: 2,
... ... @@ -501,13 +502,14 @@ class BuyNowController {
let productSku = req.body.productSku;
let activityId = req.body.activityId;
let groupNo = req.body.groupNo || '';
let buyNum = req.body.buyNum || 1;
let params = {
uid: uid,
product_sku: productSku,
group_no: groupNo,
activity_id: activityId,
buy_number: 10
buy_number: buyNum
};
co(function * () {
... ...
... ... @@ -80,7 +80,7 @@ class BuyNowModel extends global.yoho.BaseModel {
uid: params.uid,
product_sku: params.product_sku,
group_no: params.group_no || '',
buy_number: 1,
buy_number: params.buy_number || 1,
yoho_coin_mode: 0, // 是否使用有货币
yoho_bill_term: 0, // H5 不支持分期
is_support_apple_pay: 'N', // H5 不支持 APPLE PAY
... ...
... ... @@ -49,9 +49,12 @@
<span class="operator iconfont disabled">&#xe625;</span>
</a>
<input id="good-num" class="good-num disabled" type="text" value="{{@root.buyNumber}}" disabled="true">
<a class="btn btn-plus" href="javascript:void(0);">
<span class="operator iconfont disabled">&#xe624;</span>
</a>
<a class="btn btn-plus" href="javascript:void(0);">
<span class="operator iconfont disabled">&#xe624;</span>
</a>
{{#ifcond @root.joinLimit '==' 2}}
<span style="height: 2.35rem;line-height: 2.35rem; padding: 0.1rem 0.4rem;color: red; font-size: 0.6rem; margin-left: 0.5rem; border-radius: 0.2rem; border: 1px solid red;">{{@root.saleNum}}件起售</span>
{{/ifcond}}
</div>
<!--<span class="left-num-discount">即将售罄</span>-->
<!--<span class="left-num-discount">限购{{buy_limit_number}}件</span>-->
... ...
... ... @@ -336,13 +336,15 @@ class Detail extends Page {
if (!this.pickData.goodsList) {
return;
}
this.pickData.activityId = document.getElementById('activityId').value;
this.pickData.groupNo = document.getElementById('groupNo').value;
this.pickData.joinLimit = document.getElementById('buynow').dataset.joinlimit || '1';
this.pickData.saleNum = document.getElementById('buynow').dataset.salenum || '1';
chosePanel.show({
data: this.pickData
}).then(result => {
if (result && result.sku) {
console.log(result);
if (result.buyNow) { // 立即购买
let nextUrl = location.origin + '/cart/index/buynow/orderensure?product_sku=' +
result.sku.skuId + '&buy_number=' + result.buyNum + '&is_group=1&activity_id=' + this.pickData.activityId;
... ...
... ... @@ -230,7 +230,7 @@ class GroupProgress extends Page {
}).then(result => {
if (result && result.sku) {
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 query = `is_group=1&product_sku=${result.sku.skuId}&buy_number=${result.buyNum}&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()) {
... ... @@ -271,6 +271,7 @@ class GroupProgress extends Page {
if (!data || data.code !== 200) {
return;
}
let groupProductDetail = data.data.collageProductSingleBo || {};
let color_length = 0;
... ... @@ -306,6 +307,8 @@ class GroupProgress extends Page {
this.pickData.buy_limit_number = 1;
this.pickData.goodsList = data.data.goods_list;
this.pickData.isSoldOutSoon = isSoldOutSoon;
this.pickData.joinLimit = groupProductDetail.joinLimit.toString() || '1';
this.pickData.saleNum = groupProductDetail.saleNum || 1;
// 默认显示第一种颜色的尺码
this.pickData.defaultImage = data.data.goods_list[0].color_image;
... ...
... ... @@ -57,12 +57,12 @@ class Group extends Page {
newGroup: {
$pre: this.selector.filterTab.find('.active'), // 记录新团筛选tab的激活项
joinLimit: 1,
order: 's_t_desc'
order: 'h_v_desc'
},
normalGroup: {
$pre: this.selector.filterTab.find('.active'), // 记录普通团筛选tab的激活项
joinLimit: 2,
order: 's_t_desc'
order: 'h_v_desc'
}
};
... ...
... ... @@ -78,6 +78,11 @@ class ChosePanel {
this._setSelector();
this._initBlockStatus();
if (this.data.joinLimit === '2') { // 如果是普通团,则让增加数量的按钮可用
$goodNum.val(parseInt(this.data.saleNum, 10));
this.data.buyNumber = parseInt(this.data.saleNum, 10);
$('.btn-plus').find('.operator').removeClass('disabled');
}
innerScroll.disableScroll($choseArea);
}
... ... @@ -141,6 +146,13 @@ class ChosePanel {
$yohoPage.on('touchstart', '#chose-btn-buynow', (e) => {
return this._choseBtnSureClick(e, true);
});
$yohoPage.on('touchend', '.btn-plus, .btn-minus', (e) => {
let button = e.currentTarget;
if (!$(button).find('.operator').hasClass('disabled')) {
return this._numClick(e);
}
});
}
/**
... ... @@ -178,14 +190,26 @@ class ChosePanel {
let buyNum;
buyNum = $(e.currentTarget).hasClass('btn-minus') ? this.data.buyNumber - 1 : this.data.buyNumber + 1;
if (buyNum < 1) {
$btnMinus.find('.operator').addClass('disabled');
return;
} else if (buyNum === 1) {
$btnMinus.find('.operator').addClass('disabled');
if (this.data.joinLimit === '2') {
if (buyNum < parseInt(this.data.saleNum, 10)) {
$btnMinus.find('.operator').addClass('disabled');
return;
} else if (buyNum === parseInt(this.data.saleNum, 10)) {
$btnMinus.find('.operator').addClass('disabled');
} else {
$btnMinus.find('.operator').removeClass('disabled');
}
} else {
$btnMinus.find('.operator').removeClass('disabled');
if (buyNum < 1) {
$btnMinus.find('.operator').addClass('disabled');
return;
} else if (buyNum === 1) {
$btnMinus.find('.operator').addClass('disabled');
} else {
$btnMinus.find('.operator').removeClass('disabled');
}
}
if (this._checkSku(buyNum)) {
this.data.buyNumber = buyNum;
$goodNum.val(buyNum);
... ... @@ -209,6 +233,11 @@ class ChosePanel {
_choseBtnSureClick() {
let self = this;
let skuId = this._checkSku();
let buyNum = 1;
if (self.data.joinLimit === '2') {
buyNum = self.data.buyNumber;
}
if (skuId) {
$.ajax({
... ... @@ -218,12 +247,13 @@ class ChosePanel {
productSku: skuId,
activityId: self.data.activityId,
groupNo: self.data.groupNo,
buyNum: buyNum
}
}).then(data => {
if (data && data.code === 200) {
this._resolve && this._resolve({
sku: {skuId},
buyNum: 1, // 拼团只支持一件
buyNum: buyNum, // 拼团只支持一件
buyNow: true
});
} else {
... ... @@ -286,6 +316,10 @@ class ChosePanel {
$goodNum.val(1);
this.data.buyNumber = 1;
if (this.data.joinLimit === '2') {
$goodNum.val(parseInt(this.data.saleNum, 10));
this.data.buyNumber = parseInt(this.data.saleNum, 10);
}
$choseBtnSure.css('background-color', '#d0021b').text('确定');
}
... ... @@ -296,6 +330,10 @@ class ChosePanel {
} else {
$goodNum.val(1);
this.data.buyNumber = 1;
if (this.data.joinLimit === '2') {
$goodNum.val(parseInt(this.data.saleNum, 10));
this.data.buyNumber = parseInt(this.data.saleNum, 10);
}
$choseBtnSure.css('background-color', '#d0021b').text('确定');
}
}
... ...
... ... @@ -164,6 +164,8 @@ function submitGroupOrder(verifyCode) {
loading.showLoadingMask();
isSubmiting = true;
console.log(qs);
let postData = {
product_sku: qs.product_sku,
buy_number: qs.buy_number,
... ...