Commit 705201a2b90edb28fa2e145cce31bdfd99be2a66

Authored by yvan.ni
1 parent 9f86a08b

促销多活动的优化

components/promate_pop/promate_pop.js
1 Component({ 1 Component({
2 /*** 页面的初始数据***/ 2 /*** 页面的初始数据***/
3 data: { 3 data: {
4 - type:0,// 0只显示再商品详情页面 1显示再有选择按钮 4 + type:0, //0只显示再商品详情页面 1显示再有选择按钮
  5 + pro_pop:0, //是否弹出
5 }, 6 },
6 methods: { 7 methods: {
7 -  
8 //-- 初始化弹出框 -- 8 //-- 初始化弹出框 --
9 - set_init(){ 9 + set_init(type){
  10 + if(!type) type=0;
10 11
  12 + this.setData({
  13 + type:type,pro_pop:1
  14 + })
11 }, 15 },
12 16
13 /*----pop的开关---*/ 17 /*----pop的开关---*/
components/promate_pop/promate_pop.wxml
@@ -9,6 +9,81 @@ @@ -9,6 +9,81 @@
9 <view class="xc-frame"> 9 <view class="xc-frame">
10 <view class="top-frame"> 10 <view class="top-frame">
11 <view class="xc-coupon-frame "> 11 <view class="xc-coupon-frame ">
  12 + <!-- 优惠促销 -->
  13 + <view class="item_pro flex ai-center">
  14 + <view class="tab_bx fs24">优惠</view>
  15 + <view class="item_pro_left flex jc-center ai-center">
  16 + <view class="fs34 left_f_box" >优惠促销</view>
  17 + </view>
  18 +
  19 + <view class="item_pro_right">
  20 + <view class="fs26">消费满100元享受优惠</view>
  21 + <view class="fs22" style="max-width: 430rpx; color: #b9b6b6">
  22 + <text class="tick pdr20" >减价10元</text>
  23 + <text class="tick pdr20" >减价10元</text>
  24 + <text class="tick pdr20" >减价10元</text>
  25 + <text class="tick pdr20" >减价10元</text>
  26 + <text class="tick pdr20" >减价10元</text>
  27 + <text class="tick pdr20" >减价10元</text>
  28 + <text class="tick pdr20" >减价10元</text>
  29 + </view>
  30 +
  31 +
  32 +
  33 + </view>
  34 + <view class="xq_btn fs30">详情</view>
  35 +
  36 + </view>
  37 + <!-- 搭配促销 -->
  38 + <view class="item_pro flex ai-center">
  39 + <view class="tab_bx fs24">搭配</view>
  40 + <view class="item_pro_left flex jc-center ai-center">
  41 + <view class="fs36 left_f_box">搭配促销</view>
  42 + </view>
  43 +
  44 + <view class="item_pro_right">
  45 + <view class="fs26">活动名称</view>
  46 + <view class="fs26">搭配价:<text class="c-red">¥101.00-210.00</text></view>
  47 + <view class="fs22" style="color: #b9b6b6">
  48 + 2022.12.19 00:00:00 至 2022.12.31 23:59:59
  49 + </view>
  50 + </view>
  51 + <view class="xq_btn fs30">详情</view>
  52 +
  53 + </view>
  54 + <!-- 组合购 -->
  55 + <view class="item_pro flex ai-center">
  56 + <view class="tab_bx fs24">组合</view>
  57 + <view class="item_pro_left flex jc-center ai-center">
  58 + <view class="fs36 left_f_box">组合购</view>
  59 + </view>
  60 +
  61 + <view class="item_pro_right">
  62 + <view class="fs26">活动名称</view>
  63 + <view class="fs22" style="color: #b9b6b6">
  64 + 2022.12.19 00:00:00 至 2022.12.31 23:59:59
  65 + </view>
  66 + </view>
  67 + <view class="xq_btn fs30">详情</view>
  68 +
  69 + </view>
  70 + <!-- 阶梯促销 -->
  71 + <view class="item_pro flex ai-center">
  72 + <view class="tab_bx fs24">阶梯</view>
  73 + <view class="item_pro_left flex jc-center ai-center">
  74 + <view class="fs36 left_f_box">阶梯促销</view>
  75 + </view>
  76 +
  77 + <view class="item_pro_right">
  78 + <view class="fs26">第1件8折,第2件7折,第3件6折</view>
  79 + <view class="fs22" style="color: #b9b6b6">
  80 + 2022.12.19 00:00:00 至 2022.12.31 23:59:59
  81 + </view>
  82 + </view>
  83 + <view class="xq_btn fs30">详情</view>
  84 +
  85 + </view>
  86 +
12 87
13 </view> 88 </view>
14 </view> 89 </view>
components/promate_pop/promate_pop.wxss
1 -@import '../../app.wxss';  
2 /* 自定义弹出窗口 */ 1 /* 自定义弹出窗口 */
3 .cx-popup { 2 .cx-popup {
4 width: 100%; 3 width: 100%;
@@ -9,6 +8,20 @@ @@ -9,6 +8,20 @@
9 position: fixed; 8 position: fixed;
10 bottom: 0; 9 bottom: 0;
11 } 10 }
  11 +
  12 +.cx-popup .top {
  13 + font-size: 32rpx;
  14 + padding: 20rpx 0;
  15 + border-bottom: 2rpx solid #ebedf0;
  16 +}
  17 +
  18 +.cx-popup .top-frame {
  19 + /* width: 100%;
  20 + display: flex;
  21 + justify-content: center;
  22 + overflow: hidden; */
  23 +}
  24 +
12 .xc-top-content { 25 .xc-top-content {
13 width: 88%; 26 width: 88%;
14 height: 85rpx; 27 height: 85rpx;
@@ -21,9 +34,7 @@ @@ -21,9 +34,7 @@
21 padding-top: 24rpx; 34 padding-top: 24rpx;
22 overflow: hidden; 35 overflow: hidden;
23 } 36 }
24 -.xc-frame {  
25 - padding: 20rpx;  
26 -} 37 +
27 .xc-frame .list-frame { 38 .xc-frame .list-frame {
28 width: 90%; 39 width: 90%;
29 height: 100%; 40 height: 100%;
@@ -103,6 +114,27 @@ @@ -103,6 +114,27 @@
103 margin-top: 50rpx; 114 margin-top: 50rpx;
104 } 115 }
105 116
  117 +.cx-confirm {
  118 + width: 100%;
  119 + padding: 20rpx;
  120 + box-sizing: border-box;
  121 + /* height: 160rpx; */
  122 +
  123 +}
  124 +
  125 +
  126 +
  127 +.cx-confirm .confirm {
  128 + /* width: 372rpx;
  129 + height: 60rpx; */
  130 + background-color: #f40026;
  131 + color: #fff;
  132 + border-radius: 10rpx;
  133 + line-height: 80rpx;
  134 + font-size: 28rpx;
  135 +
  136 +}
  137 +
106 .xc-not-Selection { 138 .xc-not-Selection {
107 width: 60rpx; 139 width: 60rpx;
108 height: 60rpx; 140 height: 60rpx;
@@ -136,3 +168,56 @@ @@ -136,3 +168,56 @@
136 transform: translateY(550rpx); 168 transform: translateY(550rpx);
137 } 169 }
138 } 170 }
  171 +
  172 +.item_pro{
  173 + background-color: #fceeee;height: 170rpx; position: relative;
  174 +}
  175 +
  176 +.item_pro~.item_pro{
  177 + margin-top: 20rpx;
  178 +}
  179 +
  180 +.item_pro .item_pro_left{
  181 + width:170rpx;flex-shrink: 0; position: relative;
  182 +}
  183 +
  184 +.item_pro .item_pro_right{
  185 + position: relative;
  186 +}
  187 +
  188 +
  189 +.tick {
  190 + position: relative;
  191 +}
  192 +
  193 +.tick:before {
  194 + content: '';
  195 + display: inline-block;
  196 + vertical-align: middle;
  197 + margin-top: -4rpx;
  198 + margin-right: 8rpx;
  199 + width: 22rpx;
  200 + height: 22rpx;
  201 + background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABYAAAAWCAMAAADzapwJAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAABCUExURUdwTPInDPInDPgoDfMnDPYqEvInDPInDPInDP87NPUoDv8vEvMoDPInDPIoDPMnDvInDPInDPInDPIoDPQoDfInDEON4KMAAAAVdFJOUwD45yawG4zz3gQ0DmLOfECQZpPlS54kMQ4AAAC0SURBVBjTbZFREoMgDERDS0xQQNHu/a/alEGtaIYfHrBhs0S1pujVifo40VkhC+BUHSDzQTlBhjHY8bjogXmDZ+orJKwXwMUeUoa/0PeGbH8Q4Y5CJopYOjosiOQxdpRGk1UXOkrBKdkimtN8UrKrJBVXdzsllSYSjR/0J9JaGn81WluWtonYKQ0op51P3M2L2bmZN9n8MKoVqTph/RsseyjfYxAkfgot/82CpuJVLOLSIv4Cd5AJ37BgpFwAAAAASUVORK5CYII=) no-repeat;
  202 + background-size: 22rpx auto;
  203 +}
  204 +.xq_btn{
  205 + position: absolute;
  206 + right: 18rpx;
  207 + top:52rpx;
  208 + width: 100rpx;
  209 + height: 60rpx;
  210 + background-color: #e03033;
  211 + color: #fff; text-align: center; line-height: 60rpx;
  212 + border-radius:10rpx ;
  213 +}
  214 +.left_f_box{
  215 + width:80rpx;font-weight: bolder; color:#d9001b; line-height: 44rpx;text-align: center;
  216 +}
  217 +.tab_bx{
  218 + position: absolute;top: 0; left: 0; width: 60rpx; height: 40rpx;
  219 + background-color: #f5bcc1;color: #d9001b; display: flex; justify-content: center;align-items: center;
  220 +}
  221 +
  222 +
  223 +@import '../../app.wxss';
packageE/pages/cart/cart2/cart2.js
@@ -1822,7 +1822,8 @@ Page({ @@ -1822,7 +1822,8 @@ Page({
1822 var ob = th.data.prom_goods_map[pickid]; 1822 var ob = th.data.prom_goods_map[pickid];
1823 for (var ii in ob) { 1823 for (var ii in ob) {
1824 var item_map = ob[ii]; 1824 var item_map = ob[ii];
1825 - if (item_map.bs == undefined || item_map.bs == null) { 1825 + //if (item_map.bs == undefined || item_map.bs == null) {
  1826 + if (item_map.hasOwnProperty('cy_cx')) {
1826 //等待,获取一下优惠活动的信息 1827 //等待,获取一下优惠活动的信息
1827 await getApp().request.promiseGet("/api/weshop/goods/getDiscount", { 1828 await getApp().request.promiseGet("/api/weshop/goods/getDiscount", {
1828 data: { 1829 data: {
@@ -1833,6 +1834,7 @@ Page({ @@ -1833,6 +1834,7 @@ Page({
1833 }).then(res => { 1834 }).then(res => {
1834 if (res.data.code == 0 && res.data.data.condition) { 1835 if (res.data.code == 0 && res.data.data.condition) {
1835 var get_data = res.data.data; 1836 var get_data = res.data.data;
  1837 + item_map.cy_cx=1;
1836 item_map.is_bz = get_data.is_bz; //是不是倍增 1838 item_map.is_bz = get_data.is_bz; //是不是倍增
1837 item_map.bs = get_data.bs; //是不是倍数 1839 item_map.bs = get_data.bs; //是不是倍数
1838 item_map.is_past = get_data.is_past; //是不是包邮 1840 item_map.is_past = get_data.is_past; //是不是包邮
@@ -1896,6 +1898,7 @@ Page({ @@ -1896,6 +1898,7 @@ Page({
1896 } 1898 }
1897 } 1899 }
1898 } 1900 }
  1901 + else item_map.cy_cx=0;
1899 }) 1902 })
1900 } 1903 }
1901 1904
@@ -1951,17 +1954,23 @@ Page({ @@ -1951,17 +1954,23 @@ Page({
1951 if (!item_map.is_xz_yh) q_conditin = o_price; 1954 if (!item_map.is_xz_yh) q_conditin = o_price;
1952 } 1955 }
1953 1956
1954 - //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表-----------  
1955 - for (var j = 0; j < ord_goods.length; j++) {  
1956 - if (ord_goods[j].is_gift) continue;  
1957 - if (ord_goods[j].whsle_id) continue;  
1958 - if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) {  
1959 - ord_goods[j].is_xz_yh = ord_goods[j].is_xz_yh ? ord_goods[j].is_xz_yh : item_map.is_xz_yh;  
1960 - ord_goods[j].is_past = item_map.is_past;  
1961 - ord_goods[j].account_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_fir;  
1962 - ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir;  
1963 - ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account;  
1964 - ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu; 1957 + //-- 如果有参与促销才来进行计算 --
  1958 + if(item_map.cy_cx) {
  1959 + //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表-----------
  1960 + for (var j = 0; j < ord_goods.length; j++) {
  1961 + if (ord_goods[j].is_gift) continue;
  1962 + if (ord_goods[j].whsle_id) continue;
  1963 + if (ord_goods[j].prom_type == 3 && ord_goods[j].prom_id == item_map.prom_id) {
  1964 + ord_goods[j].is_xz_yh = ord_goods[j].is_xz_yh ? ord_goods[j].is_xz_yh : item_map.is_xz_yh;
  1965 + ord_goods[j].is_past = item_map.is_past;
  1966 + ord_goods[j].is_order_yh = item_map.is_order_yh;
  1967 + ord_goods[j].is_post_temp = item_map.is_post_temp;
  1968 +
  1969 + ord_goods[j].account_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_fir;
  1970 + ord_goods[j].account_yu_fir = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu_fir;
  1971 + ord_goods[j].account = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account;
  1972 + ord_goods[j].account_yu = th.item_map_get_goods(ord_goods[j].goods_id, item_map).account_yu;
  1973 + }
1965 } 1974 }
1966 } 1975 }
1967 1976
@@ -2253,7 +2262,7 @@ Page({ @@ -2253,7 +2262,7 @@ Page({
2253 o_price += item[jc].goods_price * item[jc].goods_num; 2262 o_price += item[jc].goods_price * item[jc].goods_num;
2254 2263
2255 //--- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 --- 2264 //--- 秒杀, 团购的时候,判断有没有订单优惠和包邮模板的叠加 ---
2256 - if( [1,2,6].indexOf(item[jc].prom_type)>-1){ 2265 + if( [1,2,3,6].indexOf(item[jc].prom_type)>-1){
2257 if(!item[jc].is_order_yh && !item[jc].whsle_id){ 2266 if(!item[jc].is_order_yh && !item[jc].whsle_id){
2258 no_order_yh+=item[jc].goods_price * item[jc].goods_num; 2267 no_order_yh+=item[jc].goods_price * item[jc].goods_num;
2259 if(item[jc].quan_num) no_order_yh-=item[jc].quan_num; //券要把他补回去 2268 if(item[jc].quan_num) no_order_yh-=item[jc].quan_num; //券要把他补回去
@@ -5632,6 +5641,7 @@ Page({ @@ -5632,6 +5641,7 @@ Page({
5632 5641
5633 if (res.data.code == 0) { 5642 if (res.data.code == 0) {
5634 prom = res.data.data; 5643 prom = res.data.data;
  5644 +
5635 if(prom && prom.limit_num*1){ 5645 if(prom && prom.limit_num*1){
5636 let user_pre_buynum=await th.getUserBuyPromNum_pre(prom.id) 5646 let user_pre_buynum=await th.getUserBuyPromNum_pre(prom.id)
5637 if (user_pre_buynum>=prom.limit_num) { 5647 if (user_pre_buynum>=prom.limit_num) {
@@ -5719,6 +5729,11 @@ Page({ @@ -5719,6 +5729,11 @@ Page({
5719 }).then(res => { 5729 }).then(res => {
5720 if (res.data.code == 0) { 5730 if (res.data.code == 0) {
5721 var get_data = res.data.data; 5731 var get_data = res.data.data;
  5732 +
  5733 + //只有在活动已经开始参与优惠促销的时候
  5734 + th.data.bn_is_order_yh=prom.is_order_yh;
  5735 + th.data.bn_is_post_temp=prom.is_post_temp;
  5736 +
5722 arr.is_bz = prom.is_bz; //是不是倍增 5737 arr.is_bz = prom.is_bz; //是不是倍增
5723 arr.is_xz_yh = arr.is_xz_yh ? arr.is_xz_yh : prom.is_xz_yh; //是不是优惠 5738 arr.is_xz_yh = arr.is_xz_yh ? arr.is_xz_yh : prom.is_xz_yh; //是不是优惠
5724 arr.bs = get_data.bs; //是不是倍数 5739 arr.bs = get_data.bs; //是不是倍数
@@ -5895,6 +5910,9 @@ Page({ @@ -5895,6 +5910,9 @@ Page({
5895 ob.goods_num = item.goods_num; 5910 ob.goods_num = item.goods_num;
5896 ob.is_bz = prom.is_bz; 5911 ob.is_bz = prom.is_bz;
5897 ob.is_xz_yh = prom.is_xz_yh; 5912 ob.is_xz_yh = prom.is_xz_yh;
  5913 + ob.is_xz_yh = prom.is_xz_yh;
  5914 + ob.is_order_yh = prom.is_order_yh;
  5915 + ob.is_post_temp = prom.is_post_temp;
5898 ob.goods = new Array(); 5916 ob.goods = new Array();
5899 ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num }); 5917 ob.goods.push({ goods_id: item.goods_id, goods_price: item.goods_price, goods_num: item.goods_num });
5900 map[pickid][item.prom_id] = ob; 5918 map[pickid][item.prom_id] = ob;
pages/goods/goodsInfo/goodsInfo.js
@@ -1207,6 +1207,11 @@ Page({ @@ -1207,6 +1207,11 @@ Page({
1207 this.data.enterAddressPage && (this.data.enterAddressPage = !1); 1207 this.data.enterAddressPage && (this.data.enterAddressPage = !1);
1208 1208
1209 1209
  1210 + setTimeout(()=>{
  1211 + var pro_pop = this.selectComponent("#pro_pop"); //组件的id
  1212 + pro_pop.set_init();
  1213 + },1500)
  1214 +
1210 1215
1211 1216
1212 1217
pages/goods/goodsInfo/goodsInfo.wxml
  1 +<!-- 促销弹出框 -->
  2 +<pro_pop id="pro_pop"></pro_pop>
  3 +
1 <import src="../../../utils/wxParse/wxParse.wxml"></import> 4 <import src="../../../utils/wxParse/wxParse.wxml"></import>
2 <wxs module="filters" src="../../../utils/filter.wxs"></wxs> 5 <wxs module="filters" src="../../../utils/filter.wxs"></wxs>
3 <wxs module="g_filters" src="g_filter.wxs"></wxs> 6 <wxs module="g_filters" src="g_filter.wxs"></wxs>
@@ -1794,6 +1797,4 @@ @@ -1794,6 +1797,4 @@
1794 1797
1795 <include src="../../../components/com_servicer/com_servicer.wxml"></include> 1798 <include src="../../../components/com_servicer/com_servicer.wxml"></include>
1796 1799
1797 -<!-- 促销弹出框 -->  
1798 -<pro_pop id="pro_pop"></pro_pop>  
1799 1800