Authored by yyq

promotion list

{
"extends": "yoho",
"parserOptions": {
"sourceType": "module"
"sourceType": "module",
"ecmaVersion": 6,
"ecmaFeatures": {
"experimentalObjectRestSpread": true
}
},
"rules": {
"camelcase": "off",
... ...
... ... @@ -13,5 +13,33 @@ export default {
method: 'app.search.shop.productList'
}, params)
});
},
/**
* 搜索promotion商品列表
* @param params
* @returns {*}
*/
promotionProductList(params) {
return api.get({
url: '',
data: Object.assign({
method: 'app.search.promotion.productList',
}, params)
});
},
/**
* 搜索coupon商品列表
* @param params
* @returns {*}
*/
couponProductList(params) {
return api.get({
url: '',
data: Object.assign({
method: 'app.search.coupon.productList',
}, params)
});
}
};
... ...
... ... @@ -24,7 +24,7 @@ function _queryFromServiceAsync(fn) {
} else {
return Promise.reject();
}
};
}
Page({
data: {
... ... @@ -54,7 +54,7 @@ Page({
onShow() {
this.getCartData();
},
onHide: function () {
onHide: function() {
if (this.data.isEditing) {
this.editCartStatus({clearEditing: true});
}
... ... @@ -128,7 +128,7 @@ Page({
} else {
return Promise.reject({});
}
}).catch((e) => {
}).catch(() => {
this.setData(this._oldOrdinaryCartData);
});
},
... ... @@ -164,27 +164,27 @@ Page({
this.setData({promotionMoreStatus});
},
navToPromotionPage(e) {
let pItem = e.currentTarget.dataset.promotionItem;
let pItem = e.currentTarget.dataset.promotion;
let promotion_type = pItem.promotion_type;
let gStatus = (+pItem.status === 10 || +pItem.status === 30);
if (promotion_type == 'Gift' && gStatus) {
if (promotion_type === 'Gift' && gStatus) {
router.go('cartGift', {
promotion_id: pItem.promotion_id,
is_gift: 1,
status: pItem.status
});
} else if (promotion_type == 'Needpaygift' && gStatus) {
} else if (promotion_type === 'Needpaygift' && gStatus) {
router.go('cartGift', {
promotion_id: pItem.promotion_id,
status: pItem.status
});
} else {
// console.log("跳转促销商品列表页面");
let spliceUrl = "?title=优惠活动商品" + "&promotionTitle=以下商品参加【" + pItem.promotion_title + "】促销活动&promotion_id=" + promotionItem.promotion_id;
wx.navigateTo({
url: '../goodsList/PromotionList' + spliceUrl,
router.go('productSearch', {
title: '优惠活动商品',
promotionTitle: pItem.promotion_title,
promotionId: pItem.promotion_id
});
}
},
... ... @@ -219,7 +219,7 @@ Page({
if (res && res.code === 200) {
this.editCart([goods], 'Y');
}
})
});
}
},
editBundleNum(e) {
... ... @@ -340,7 +340,7 @@ Page({
for (let i in this._removeGoodsList) {
if (this._removeGoodsList.hasOwnProperty(i) && this._removeGoodsList[i]) {
removeList.push(this._removeGoodsList[i]);
};
}
}
if (!removeList.length) {
... ... @@ -372,7 +372,7 @@ Page({
if (invalidGoods && invalidGoods.length) {
invalidGoods.map(list => {
invalidList.push.apply(invalidList, list);
})
});
}
return this.removeCartGoodsAsync(invalidList);
... ... @@ -398,7 +398,7 @@ Page({
});
},
paymentAction: function() {
//如果没有选中商品则不能进入结算页
// 如果没有选中商品则不能进入结算页
if (this.data.shoppingCartData.selected_goods_count <= 0) {
return this.showToast('您还没有选择宝贝哦');
}
... ... @@ -410,13 +410,13 @@ Page({
confirmColor: '#444444',
cancelColor: '#444444',
}).then(res => {
if (res.confirm) {
// TODO 去选择赠品
// that.navToChooseGiftPage();
} else if (res.cancel) {
//直接跳转 结算页面
router.go('cartEnsure');
}
if (res.confirm) {
// TODO 去选择赠品
// that.navToChooseGiftPage();
} else if (res.cancel) {
// 直接跳转 结算页面
router.go('cartEnsure');
}
});
}
router.go('cartEnsure');
... ... @@ -427,7 +427,7 @@ Page({
Picker.pickerHide(this);
}
},
confirmChoose(e) {
confirmChoose() {
let sku = this.data.selectedSKU;
if (!sku) {
... ... @@ -437,7 +437,7 @@ Page({
let buyNumber = this.data.pickerData.view.buyNumber;
let min_buy_number = this.data.pickerData.view.min_buy_number > 0 ? this.data.pickerData.view.min_buy_number : 1;
if (buyNumber > 0 && buyNumber < min_buy_number && min_buy_number != 1) {
if (buyNumber > 0 && buyNumber < min_buy_number && min_buy_number !== 1) {
return this.showToast('最低' + min_buy_number + '件起');
}
... ... @@ -467,6 +467,5 @@ Page({
}
});
},
// eslint-disable-next-line
...Picker.pickerAction
});
... ...
... ... @@ -45,7 +45,7 @@
<template is="cartInvalidList" data="{{invalidGoodsList}}"/>
<!-- 已参与活动 -->
<view class="used-promotion" wx:if="{{promotionInfo}}">
<view class="used-promotion" wx:if="{{promotionInfo.length}}">
<view class="promotion-title">已参与活动</view>
<block wx:for="{{promotionInfo}}" wx:key="unique">
<view class="promotion-item">• {{item.promotion_title}}</view>
... ...
... ... @@ -89,6 +89,7 @@ page {
border-bottom: 1rpx solid #f0f0f0;
font-size: 26rpx;
line-height: 1.4;
background-color: #fff;
}
.used-promotion .promotion-title {
... ...
... ... @@ -31,10 +31,7 @@ Page({
});
this.productList({
query: this.data.query,
order: this.data.order,
gender: this.data.gender,
page: this.data.currentPage + 1,
limit: 20
page: this.data.currentPage + 1
});
} else {
this.setData({
... ... @@ -42,9 +39,35 @@ Page({
});
}
},
onLoad: function() {
onLoad: function(options) {
this._baseParams = {
shop_id: app.getShopId(),
limit: 20
};
this._searchFn = searchModel.productList;
yas = new Yas();
yas.pageOpenReport();
if (options.title) {
wx.setNavigationBarTitle({
title: decodeURIComponent(options.title)
});
}
if (options.promotionId) {
let title = decodeURIComponent(options.promotionTitle || '');
title = title ? `【${title}】` : '';
this.setData({
placeholder: '搜索该促销活动适用的商品',
activityTitle: `以下商品参加${title}促销活动`
});
this._searchFn = searchModel.promotionProductList;
this._baseParams.promotion_id = options.promotionId;
this.productList();
}
},
onShow: function() {
this.getRecentKeys();
... ... @@ -82,27 +105,26 @@ Page({
});
}
this.setData({searched: true, query});
this.setData({query});
this.data.productList = [];
this.setRecentKeys(query);
this.productList({page: 1, limit: 20, query, order: this.data.order, gender: this.data.gender});
this.productList({query});
},
productList: function(params) {
if (!params.query) {
return wx.showToast({
title: '检索关键词不能为空',
icon: 'none',
duration: 1500
});
}
if (this.data.isLoading) {
return;
}
params = params || {};
params.page = params.page || 1;
this.data.isLoading = true;
wx.showLoading({title: '加载中'});
params.shop_id = app.getShopId();
searchModel.productList(params).then(res => {
this._searchFn(Object.assign(params, {
order: this.data.order,
gender: this.data.gender,
}, this._baseParams)).then(res => {
if (res.code === 200) {
const keyAdapter = {
skn: 'product_skn',
... ... @@ -123,12 +145,15 @@ Page({
});
this.data.isLoading = false;
list = this.data.productList.concat(list);
this.setData({
searched: true,
showLoading: false,
productList: this.data.productList.concat(list),
productList: list,
currentPage: params.page,
totalPage: res.data.page_total,
noResult: this.data.productList.concat(list).length === 0
noResult: list.length === 0
});
if (params.resetScroll) {
... ...
<view class="search-container" style="min-height:{{windowHeight}}px;">
<view class="top-search">
<view class="input-bg"></view>
<input class="search-input" value="{{query}}" confirm-type="search" placeholder="店内潮品搜一下"
<input class="search-input" value="{{query}}" confirm-type="search" placeholder="{{placeholder ? placeholder : '店内潮品搜一下'}}"
bindconfirm="confirmQuery" bindinput="bindQueryInput"
placeholder-class="placeholder" auto-focus/>
<image class="icon" src="../../../static/images/search@2x.png"></image>
... ... @@ -10,7 +10,7 @@
<view class="title">最近搜索
<image class="delete" src="../../../static/images/delete.png" bindtap="deleteRecent"></image></view>
<view class="keys">
<text wx:for="{{recentKeys}}" wx:key="{{item}}"
<text wx:for="{{recentKeys}}" wx:key="{{item}}"
class="key" bindtap="searchRecent" data-key="{{item}}">{{item}}</text>
</view>
</view>
... ... @@ -23,6 +23,9 @@
<view class="no-res-txt">未搜索到任何相关商品</view>
</view>
<view wx:if="{{productList.length > 0}}" class="product-list">
<view class="activity-title" wx:if="{{activityTitle}}">
<text>{{activityTitle}}</text>
</view>
<product-list list="{{productList}}"
show-loading="{{showLoading}}"
show-no-more="{{showNoMore}}">
... ...
... ... @@ -128,3 +128,10 @@
padding-top: 179rpx;
padding-bottom: 60rpx;
}
.activity-title {
padding: 20rpx 30rpx;
background-color: #f0f0f0;
font-size: 24rpx;
text-align: center;
}
... ...