Commit 8dcb724f62bf0f20f0dab59616399b83ac7b5382
1 parent
2fbd29c3
优化
Showing
1 changed file
with
107 additions
and
0 deletions
pages/goods/g_filter.wxs
0 → 100644
1 | +var g_filters = { | |
2 | + //-- 判断是不是有等级价 -- | |
3 | + is_has_rank: function (rank_switch, item) { | |
4 | + if (!rank_switch) return false; | |
5 | + if (item.cardprice1 || item.cardprice2 || item.cardprice3) { return true } | |
6 | + return false; | |
7 | + }, | |
8 | + | |
9 | + //-- 判断,不是等级会员时候,要显示的最低等级价和名称 -- | |
10 | + get_card_price: function (goods, all_card, type) { | |
11 | + var price1 = parseFloat(goods['cardprice1']); | |
12 | + var price2 = parseFloat(goods['cardprice2']); | |
13 | + var price3 = parseFloat(goods['cardprice3']); | |
14 | + if (!all_card) { | |
15 | + if (type == 0) return 0; | |
16 | + return ""; | |
17 | + } | |
18 | + | |
19 | + var arr = []; | |
20 | + var min_price = 0; | |
21 | + var min_name = ""; | |
22 | + | |
23 | + var min_price = null; | |
24 | + var min_name = null; | |
25 | + //---设置对应的价格名字---- | |
26 | + for (var i = 0; i < 3; i++) { | |
27 | + var vl = all_card[i]; | |
28 | + if (!vl) continue; | |
29 | + if (vl['CorrPrice'] == "Price1" && price1 > 0) { | |
30 | + if (min_price == null) { | |
31 | + min_price = price1; min_name = vl['CardName']; | |
32 | + } | |
33 | + else if (price1 < min_price) { | |
34 | + min_price = price1; min_name = vl['CardName']; | |
35 | + } | |
36 | + } | |
37 | + if (vl['CorrPrice'] == "Price2" && price2 > 0) { | |
38 | + if (min_price == null) { | |
39 | + min_price = price2; min_name = vl['CardName']; | |
40 | + } | |
41 | + else if (price2 < min_price) { | |
42 | + min_price = price2; min_name = vl['CardName']; | |
43 | + } | |
44 | + } | |
45 | + | |
46 | + if (vl['CorrPrice'] == "Price3" && price3 > 0) { | |
47 | + if (min_price == null) { | |
48 | + min_price = price3; min_name = vl['CardName']; | |
49 | + } | |
50 | + else if (price3 < min_price) { | |
51 | + min_price = price3; min_name = vl['CardName']; | |
52 | + } | |
53 | + } | |
54 | + | |
55 | + } | |
56 | + if (min_price == null) { | |
57 | + if (type == 0) return 0; | |
58 | + return ""; | |
59 | + } | |
60 | + | |
61 | + //if(type==0) return arr.length; | |
62 | + //--进行排序,升序--- | |
63 | + /*--- | |
64 | + arr.sort(function(a,b){ | |
65 | + if (a.price < b.price) { | |
66 | + return -1; | |
67 | + } else if (a.fee == b.fee) { | |
68 | + return 0; | |
69 | + } else { | |
70 | + return 1; | |
71 | + } | |
72 | + })--*/ | |
73 | + //-- 获取最下价钱,和相应的卡的名称 -- | |
74 | + //min_price=min.price; | |
75 | + //min_name=min.name; | |
76 | + if (type == 0) return min_price.toFixed(2); | |
77 | + if (min_name.length > 7) min_name = min_name.substring(0, 8); | |
78 | + return min_name; | |
79 | + }, | |
80 | + | |
81 | + | |
82 | + get_goods_url: function (item) { | |
83 | + | |
84 | + var url1 = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id + "&prom_id=" + item.prom_id + "&prom_type="+item.prom_type | |
85 | + // 预售活动 | |
86 | + if (item.prom_type == 8) { | |
87 | + url1 = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + item.goods_id + "&prom_id=" + item.prom_id | |
88 | + } | |
89 | + // 如果是幸运购活动商品 | |
90 | + if (item.prom_type == 9) { | |
91 | + url1 = "/packageC/pages/luckyGo/luckyGo_goodsInfo/luckyGo_goodsInfo?goods_id=" + item.goods_id + "&group_id=" + item.prom_id | |
92 | + } | |
93 | + | |
94 | + if ([1,2,6].indexOf(item.prom_type)>-1 && item.prom_id > 0) { | |
95 | + url1 = "/pages/goods/goodsInfo/goodsInfo?goods_id=" + item.goods_id + "&prom_id=" + item.prom_id + "&prom_type="+item.prom_type; | |
96 | + } | |
97 | + | |
98 | + | |
99 | + return url1; | |
100 | + } | |
101 | +} | |
102 | + | |
103 | +module.exports = { | |
104 | + is_has_rank: g_filters.is_has_rank, | |
105 | + get_card_price: g_filters.get_card_price, | |
106 | + get_goods_url: g_filters.get_goods_url | |
107 | +} | |
0 | 108 | \ No newline at end of file | ... | ... |