Authored by yyq

promotion list

1 { 1 {
2 "extends": "yoho", 2 "extends": "yoho",
3 "parserOptions": { 3 "parserOptions": {
4 - "sourceType": "module" 4 + "sourceType": "module",
  5 + "ecmaVersion": 6,
  6 + "ecmaFeatures": {
  7 + "experimentalObjectRestSpread": true
  8 + }
5 }, 9 },
6 "rules": { 10 "rules": {
7 "camelcase": "off", 11 "camelcase": "off",
@@ -13,5 +13,33 @@ export default { @@ -13,5 +13,33 @@ export default {
13 method: 'app.search.shop.productList' 13 method: 'app.search.shop.productList'
14 }, params) 14 }, params)
15 }); 15 });
  16 + },
  17 +
  18 + /**
  19 + * 搜索promotion商品列表
  20 + * @param params
  21 + * @returns {*}
  22 + */
  23 + promotionProductList(params) {
  24 + return api.get({
  25 + url: '',
  26 + data: Object.assign({
  27 + method: 'app.search.promotion.productList',
  28 + }, params)
  29 + });
  30 + },
  31 +
  32 + /**
  33 + * 搜索coupon商品列表
  34 + * @param params
  35 + * @returns {*}
  36 + */
  37 + couponProductList(params) {
  38 + return api.get({
  39 + url: '',
  40 + data: Object.assign({
  41 + method: 'app.search.coupon.productList',
  42 + }, params)
  43 + });
16 } 44 }
17 }; 45 };
@@ -24,7 +24,7 @@ function _queryFromServiceAsync(fn) { @@ -24,7 +24,7 @@ function _queryFromServiceAsync(fn) {
24 } else { 24 } else {
25 return Promise.reject(); 25 return Promise.reject();
26 } 26 }
27 -}; 27 +}
28 28
29 Page({ 29 Page({
30 data: { 30 data: {
@@ -54,7 +54,7 @@ Page({ @@ -54,7 +54,7 @@ Page({
54 onShow() { 54 onShow() {
55 this.getCartData(); 55 this.getCartData();
56 }, 56 },
57 - onHide: function () { 57 + onHide: function() {
58 if (this.data.isEditing) { 58 if (this.data.isEditing) {
59 this.editCartStatus({clearEditing: true}); 59 this.editCartStatus({clearEditing: true});
60 } 60 }
@@ -128,7 +128,7 @@ Page({ @@ -128,7 +128,7 @@ Page({
128 } else { 128 } else {
129 return Promise.reject({}); 129 return Promise.reject({});
130 } 130 }
131 - }).catch((e) => { 131 + }).catch(() => {
132 this.setData(this._oldOrdinaryCartData); 132 this.setData(this._oldOrdinaryCartData);
133 }); 133 });
134 }, 134 },
@@ -164,27 +164,27 @@ Page({ @@ -164,27 +164,27 @@ Page({
164 this.setData({promotionMoreStatus}); 164 this.setData({promotionMoreStatus});
165 }, 165 },
166 navToPromotionPage(e) { 166 navToPromotionPage(e) {
167 - let pItem = e.currentTarget.dataset.promotionItem; 167 + let pItem = e.currentTarget.dataset.promotion;
168 let promotion_type = pItem.promotion_type; 168 let promotion_type = pItem.promotion_type;
169 169
170 let gStatus = (+pItem.status === 10 || +pItem.status === 30); 170 let gStatus = (+pItem.status === 10 || +pItem.status === 30);
171 171
172 - if (promotion_type == 'Gift' && gStatus) { 172 + if (promotion_type === 'Gift' && gStatus) {
173 router.go('cartGift', { 173 router.go('cartGift', {
174 promotion_id: pItem.promotion_id, 174 promotion_id: pItem.promotion_id,
175 is_gift: 1, 175 is_gift: 1,
176 status: pItem.status 176 status: pItem.status
177 }); 177 });
178 - } else if (promotion_type == 'Needpaygift' && gStatus) { 178 + } else if (promotion_type === 'Needpaygift' && gStatus) {
179 router.go('cartGift', { 179 router.go('cartGift', {
180 promotion_id: pItem.promotion_id, 180 promotion_id: pItem.promotion_id,
181 status: pItem.status 181 status: pItem.status
182 }); 182 });
183 } else { 183 } else {
184 - // console.log("跳转促销商品列表页面");  
185 - let spliceUrl = "?title=优惠活动商品" + "&promotionTitle=以下商品参加【" + pItem.promotion_title + "】促销活动&promotion_id=" + promotionItem.promotion_id;  
186 - wx.navigateTo({  
187 - url: '../goodsList/PromotionList' + spliceUrl, 184 + router.go('productSearch', {
  185 + title: '优惠活动商品',
  186 + promotionTitle: pItem.promotion_title,
  187 + promotionId: pItem.promotion_id
188 }); 188 });
189 } 189 }
190 }, 190 },
@@ -219,7 +219,7 @@ Page({ @@ -219,7 +219,7 @@ Page({
219 if (res && res.code === 200) { 219 if (res && res.code === 200) {
220 this.editCart([goods], 'Y'); 220 this.editCart([goods], 'Y');
221 } 221 }
222 - }) 222 + });
223 } 223 }
224 }, 224 },
225 editBundleNum(e) { 225 editBundleNum(e) {
@@ -340,7 +340,7 @@ Page({ @@ -340,7 +340,7 @@ Page({
340 for (let i in this._removeGoodsList) { 340 for (let i in this._removeGoodsList) {
341 if (this._removeGoodsList.hasOwnProperty(i) && this._removeGoodsList[i]) { 341 if (this._removeGoodsList.hasOwnProperty(i) && this._removeGoodsList[i]) {
342 removeList.push(this._removeGoodsList[i]); 342 removeList.push(this._removeGoodsList[i]);
343 - }; 343 + }
344 } 344 }
345 345
346 if (!removeList.length) { 346 if (!removeList.length) {
@@ -372,7 +372,7 @@ Page({ @@ -372,7 +372,7 @@ Page({
372 if (invalidGoods && invalidGoods.length) { 372 if (invalidGoods && invalidGoods.length) {
373 invalidGoods.map(list => { 373 invalidGoods.map(list => {
374 invalidList.push.apply(invalidList, list); 374 invalidList.push.apply(invalidList, list);
375 - }) 375 + });
376 } 376 }
377 377
378 return this.removeCartGoodsAsync(invalidList); 378 return this.removeCartGoodsAsync(invalidList);
@@ -398,7 +398,7 @@ Page({ @@ -398,7 +398,7 @@ Page({
398 }); 398 });
399 }, 399 },
400 paymentAction: function() { 400 paymentAction: function() {
401 - //如果没有选中商品则不能进入结算页 401 + // 如果没有选中商品则不能进入结算页
402 if (this.data.shoppingCartData.selected_goods_count <= 0) { 402 if (this.data.shoppingCartData.selected_goods_count <= 0) {
403 return this.showToast('您还没有选择宝贝哦'); 403 return this.showToast('您还没有选择宝贝哦');
404 } 404 }
@@ -410,13 +410,13 @@ Page({ @@ -410,13 +410,13 @@ Page({
410 confirmColor: '#444444', 410 confirmColor: '#444444',
411 cancelColor: '#444444', 411 cancelColor: '#444444',
412 }).then(res => { 412 }).then(res => {
413 - if (res.confirm) {  
414 - // TODO 去选择赠品  
415 - // that.navToChooseGiftPage();  
416 - } else if (res.cancel) {  
417 - //直接跳转 结算页面  
418 - router.go('cartEnsure');  
419 - } 413 + if (res.confirm) {
  414 + // TODO 去选择赠品
  415 + // that.navToChooseGiftPage();
  416 + } else if (res.cancel) {
  417 + // 直接跳转 结算页面
  418 + router.go('cartEnsure');
  419 + }
420 }); 420 });
421 } 421 }
422 router.go('cartEnsure'); 422 router.go('cartEnsure');
@@ -427,7 +427,7 @@ Page({ @@ -427,7 +427,7 @@ Page({
427 Picker.pickerHide(this); 427 Picker.pickerHide(this);
428 } 428 }
429 }, 429 },
430 - confirmChoose(e) { 430 + confirmChoose() {
431 let sku = this.data.selectedSKU; 431 let sku = this.data.selectedSKU;
432 432
433 if (!sku) { 433 if (!sku) {
@@ -437,7 +437,7 @@ Page({ @@ -437,7 +437,7 @@ Page({
437 let buyNumber = this.data.pickerData.view.buyNumber; 437 let buyNumber = this.data.pickerData.view.buyNumber;
438 let min_buy_number = this.data.pickerData.view.min_buy_number > 0 ? this.data.pickerData.view.min_buy_number : 1; 438 let min_buy_number = this.data.pickerData.view.min_buy_number > 0 ? this.data.pickerData.view.min_buy_number : 1;
439 439
440 - if (buyNumber > 0 && buyNumber < min_buy_number && min_buy_number != 1) { 440 + if (buyNumber > 0 && buyNumber < min_buy_number && min_buy_number !== 1) {
441 return this.showToast('最低' + min_buy_number + '件起'); 441 return this.showToast('最低' + min_buy_number + '件起');
442 } 442 }
443 443
@@ -467,6 +467,5 @@ Page({ @@ -467,6 +467,5 @@ Page({
467 } 467 }
468 }); 468 });
469 }, 469 },
470 - // eslint-disable-next-line  
471 ...Picker.pickerAction 470 ...Picker.pickerAction
472 }); 471 });
@@ -45,7 +45,7 @@ @@ -45,7 +45,7 @@
45 <template is="cartInvalidList" data="{{invalidGoodsList}}"/> 45 <template is="cartInvalidList" data="{{invalidGoodsList}}"/>
46 46
47 <!-- 已参与活动 --> 47 <!-- 已参与活动 -->
48 - <view class="used-promotion" wx:if="{{promotionInfo}}"> 48 + <view class="used-promotion" wx:if="{{promotionInfo.length}}">
49 <view class="promotion-title">已参与活动</view> 49 <view class="promotion-title">已参与活动</view>
50 <block wx:for="{{promotionInfo}}" wx:key="unique"> 50 <block wx:for="{{promotionInfo}}" wx:key="unique">
51 <view class="promotion-item">• {{item.promotion_title}}</view> 51 <view class="promotion-item">• {{item.promotion_title}}</view>
@@ -89,6 +89,7 @@ page { @@ -89,6 +89,7 @@ page {
89 border-bottom: 1rpx solid #f0f0f0; 89 border-bottom: 1rpx solid #f0f0f0;
90 font-size: 26rpx; 90 font-size: 26rpx;
91 line-height: 1.4; 91 line-height: 1.4;
  92 + background-color: #fff;
92 } 93 }
93 94
94 .used-promotion .promotion-title { 95 .used-promotion .promotion-title {
@@ -31,10 +31,7 @@ Page({ @@ -31,10 +31,7 @@ Page({
31 }); 31 });
32 this.productList({ 32 this.productList({
33 query: this.data.query, 33 query: this.data.query,
34 - order: this.data.order,  
35 - gender: this.data.gender,  
36 - page: this.data.currentPage + 1,  
37 - limit: 20 34 + page: this.data.currentPage + 1
38 }); 35 });
39 } else { 36 } else {
40 this.setData({ 37 this.setData({
@@ -42,9 +39,35 @@ Page({ @@ -42,9 +39,35 @@ Page({
42 }); 39 });
43 } 40 }
44 }, 41 },
45 - onLoad: function() { 42 + onLoad: function(options) {
  43 + this._baseParams = {
  44 + shop_id: app.getShopId(),
  45 + limit: 20
  46 + };
  47 +
  48 + this._searchFn = searchModel.productList;
  49 +
46 yas = new Yas(); 50 yas = new Yas();
47 yas.pageOpenReport(); 51 yas.pageOpenReport();
  52 +
  53 + if (options.title) {
  54 + wx.setNavigationBarTitle({
  55 + title: decodeURIComponent(options.title)
  56 + });
  57 + }
  58 +
  59 + if (options.promotionId) {
  60 + let title = decodeURIComponent(options.promotionTitle || '');
  61 +
  62 + title = title ? `【${title}】` : '';
  63 + this.setData({
  64 + placeholder: '搜索该促销活动适用的商品',
  65 + activityTitle: `以下商品参加${title}促销活动`
  66 + });
  67 + this._searchFn = searchModel.promotionProductList;
  68 + this._baseParams.promotion_id = options.promotionId;
  69 + this.productList();
  70 + }
48 }, 71 },
49 onShow: function() { 72 onShow: function() {
50 this.getRecentKeys(); 73 this.getRecentKeys();
@@ -82,27 +105,26 @@ Page({ @@ -82,27 +105,26 @@ Page({
82 }); 105 });
83 } 106 }
84 107
85 - this.setData({searched: true, query}); 108 + this.setData({query});
86 this.data.productList = []; 109 this.data.productList = [];
87 this.setRecentKeys(query); 110 this.setRecentKeys(query);
88 - this.productList({page: 1, limit: 20, query, order: this.data.order, gender: this.data.gender}); 111 + this.productList({query});
89 }, 112 },
90 productList: function(params) { 113 productList: function(params) {
91 - if (!params.query) {  
92 - return wx.showToast({  
93 - title: '检索关键词不能为空',  
94 - icon: 'none',  
95 - duration: 1500  
96 - });  
97 - }  
98 if (this.data.isLoading) { 114 if (this.data.isLoading) {
99 return; 115 return;
100 } 116 }
101 117
  118 + params = params || {};
  119 + params.page = params.page || 1;
  120 +
102 this.data.isLoading = true; 121 this.data.isLoading = true;
103 wx.showLoading({title: '加载中'}); 122 wx.showLoading({title: '加载中'});
104 - params.shop_id = app.getShopId();  
105 - searchModel.productList(params).then(res => { 123 +
  124 + this._searchFn(Object.assign(params, {
  125 + order: this.data.order,
  126 + gender: this.data.gender,
  127 + }, this._baseParams)).then(res => {
106 if (res.code === 200) { 128 if (res.code === 200) {
107 const keyAdapter = { 129 const keyAdapter = {
108 skn: 'product_skn', 130 skn: 'product_skn',
@@ -123,12 +145,15 @@ Page({ @@ -123,12 +145,15 @@ Page({
123 }); 145 });
124 146
125 this.data.isLoading = false; 147 this.data.isLoading = false;
  148 +
  149 + list = this.data.productList.concat(list);
126 this.setData({ 150 this.setData({
  151 + searched: true,
127 showLoading: false, 152 showLoading: false,
128 - productList: this.data.productList.concat(list), 153 + productList: list,
129 currentPage: params.page, 154 currentPage: params.page,
130 totalPage: res.data.page_total, 155 totalPage: res.data.page_total,
131 - noResult: this.data.productList.concat(list).length === 0 156 + noResult: list.length === 0
132 }); 157 });
133 158
134 if (params.resetScroll) { 159 if (params.resetScroll) {
1 <view class="search-container" style="min-height:{{windowHeight}}px;"> 1 <view class="search-container" style="min-height:{{windowHeight}}px;">
2 <view class="top-search"> 2 <view class="top-search">
3 <view class="input-bg"></view> 3 <view class="input-bg"></view>
4 - <input class="search-input" value="{{query}}" confirm-type="search" placeholder="店内潮品搜一下" 4 + <input class="search-input" value="{{query}}" confirm-type="search" placeholder="{{placeholder ? placeholder : '店内潮品搜一下'}}"
5 bindconfirm="confirmQuery" bindinput="bindQueryInput" 5 bindconfirm="confirmQuery" bindinput="bindQueryInput"
6 placeholder-class="placeholder" auto-focus/> 6 placeholder-class="placeholder" auto-focus/>
7 <image class="icon" src="../../../static/images/search@2x.png"></image> 7 <image class="icon" src="../../../static/images/search@2x.png"></image>
@@ -10,7 +10,7 @@ @@ -10,7 +10,7 @@
10 <view class="title">最近搜索 10 <view class="title">最近搜索
11 <image class="delete" src="../../../static/images/delete.png" bindtap="deleteRecent"></image></view> 11 <image class="delete" src="../../../static/images/delete.png" bindtap="deleteRecent"></image></view>
12 <view class="keys"> 12 <view class="keys">
13 - <text wx:for="{{recentKeys}}" wx:key="{{item}}" 13 + <text wx:for="{{recentKeys}}" wx:key="{{item}}"
14 class="key" bindtap="searchRecent" data-key="{{item}}">{{item}}</text> 14 class="key" bindtap="searchRecent" data-key="{{item}}">{{item}}</text>
15 </view> 15 </view>
16 </view> 16 </view>
@@ -23,6 +23,9 @@ @@ -23,6 +23,9 @@
23 <view class="no-res-txt">未搜索到任何相关商品</view> 23 <view class="no-res-txt">未搜索到任何相关商品</view>
24 </view> 24 </view>
25 <view wx:if="{{productList.length > 0}}" class="product-list"> 25 <view wx:if="{{productList.length > 0}}" class="product-list">
  26 + <view class="activity-title" wx:if="{{activityTitle}}">
  27 + <text>{{activityTitle}}</text>
  28 + </view>
26 <product-list list="{{productList}}" 29 <product-list list="{{productList}}"
27 show-loading="{{showLoading}}" 30 show-loading="{{showLoading}}"
28 show-no-more="{{showNoMore}}"> 31 show-no-more="{{showNoMore}}">
@@ -128,3 +128,10 @@ @@ -128,3 +128,10 @@
128 padding-top: 179rpx; 128 padding-top: 179rpx;
129 padding-bottom: 60rpx; 129 padding-bottom: 60rpx;
130 } 130 }
  131 +
  132 +.activity-title {
  133 + padding: 20rpx 30rpx;
  134 + background-color: #f0f0f0;
  135 + font-size: 24rpx;
  136 + text-align: center;
  137 +}