Commit fc90ffebb1f8e91d6f7b03253f29147ebb8f4e3e

Authored by yvan.ni
1 parent 22911483

预售的指定门店的优化

packageA/pages/goodsInfo/goodsInfo.wxss
@@ -2425,7 +2425,7 @@ margin: auto; */ @@ -2425,7 +2425,7 @@ margin: auto; */
2425 } 2425 }
2426 .shop_name{ 2426 .shop_name{
2427 margin-right: 10rpx; 2427 margin-right: 10rpx;
2428 - max-width: 375rpx; 2428 + max-width: 370rpx;
2429 } 2429 }
2430 .address{ 2430 .address{
2431 /* width: 100%; 2431 /* width: 100%;
packageC/pages/presell/cart/cart.js
@@ -2763,6 +2763,14 @@ Page({ @@ -2763,6 +2763,14 @@ Page({
2763 } 2763 }
2764 }) 2764 })
2765 2765
  2766 + if(!presellList || !presellList.length){
  2767 + var content = good.goods_name + '未找到预售活动,请取消订单';
  2768 + th.toast(content);
  2769 + th.setData({ paying: 0 });
  2770 + return false;
  2771 + }
  2772 +
  2773 +
2766 if (presellList) { 2774 if (presellList) {
2767 2775
2768 if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) { 2776 if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) {
@@ -2777,6 +2785,29 @@ Page({ @@ -2777,6 +2785,29 @@ Page({
2777 return false; 2785 return false;
2778 } 2786 }
2779 2787
  2788 + var fres=await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell_id, {});
  2789 + //接口调用成功的时候
  2790 + if(fres && fres.data.code==0 && fres.data.data){
  2791 + //如果有指定门店的时候
  2792 + if(fres.data.data.pick_up_lists){
  2793 + var idx0=fres.data.data.pick_up_lists.findIndex(function (e){
  2794 + return e.pickup_id==order.pickup_id;
  2795 + })
  2796 + if(idx0<0){
  2797 + getApp().confirmBox(good.goods_name+"预售活动的门店不可售");
  2798 + th.setData({ paying: 0 });
  2799 + return false;
  2800 + }
  2801 + }
  2802 +
  2803 + }else{
  2804 + var content = good.goods_name + '未找到预售活动,请取消订单';
  2805 + th.toast(content);
  2806 + th.setData({ paying: 0 });
  2807 + return false;
  2808 + }
  2809 +
  2810 +
2780 } 2811 }
2781 } 2812 }
2782 2813
packageC/pages/presell/goodsInfo/goodsInfo.js
@@ -878,6 +878,7 @@ Page({ @@ -878,6 +878,7 @@ Page({
878 sele_g: t.data.data, 878 sele_g: t.data.data,
879 userInfo: getApp().globalData.userInfo, 879 userInfo: getApp().globalData.userInfo,
880 }); 880 });
  881 +
881 ee.init(gid); 882 ee.init(gid);
882 //获取门店 883 //获取门店
883 ee.get_sto(); 884 ee.get_sto();
@@ -1912,6 +1913,7 @@ Page({ @@ -1912,6 +1913,7 @@ Page({
1912 //---------拿出门店分类和门店------------ 1913 //---------拿出门店分类和门店------------
1913 get_sto(e) { 1914 get_sto(e) {
1914 var th = this, is_normal = e; 1915 var th = this, is_normal = e;
  1916 + var that=th;
1915 1917
1916 if (e == 1) { 1918 if (e == 1) {
1917 th.setData({ is_normal: 1 }) 1919 th.setData({ is_normal: 1 })
@@ -1921,6 +1923,8 @@ Page({ @@ -1921,6 +1923,8 @@ Page({
1921 1923
1922 var timer_get = setInterval(function () { 1924 var timer_get = setInterval(function () {
1923 if (th.data.is_get_local_ok == 0) return false; 1925 if (th.data.is_get_local_ok == 0) return false;
  1926 + if (!th.data.fir_def_store) return false;
  1927 +
1924 var dd = null, i = getApp().request; 1928 var dd = null, i = getApp().request;
1925 if (!th.data.sele_g) return false; 1929 if (!th.data.sele_g) return false;
1926 1930
@@ -1968,44 +1972,107 @@ Page({ @@ -1968,44 +1972,107 @@ Page({
1968 }).then(res => { 1972 }).then(res => {
1969 var e = res; 1973 var e = res;
1970 1974
  1975 + //确保门店的数量要>0时,才进行计算
1971 if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) { 1976 if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) {
1972 1977
1973 - //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店  
1974 - if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) {  
1975 - th.setData({  
1976 - def_pick_store: e.data.data.pageData[0],  
1977 - sto_sele_name: e.data.data.pageData[0].pickup_name,  
1978 - sto_sele_id: e.data.data.pageData[0].pickup_id,  
1979 - sto_sele_distr: e.data.data.pageData[0].distr_type  
1980 - });  
1981 - th.data.fir_def_store = e.data.data.pageData[0];  
1982 - }  
1983 1978
1984 - //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 --  
1985 - if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') {  
1986 - for (var k = 0; k < e.data.data.pageData.length; k++) {  
1987 - if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) {  
1988 - e.data.data.pageData.splice(k, 1); //删除  
1989 - break; 1979 +
  1980 + //指定门店判断, 不是普通购买的时候,秒杀的时候,秒杀有指定门店
  1981 + var pickup_ids=th.data.presellForm.pick_up_lists
  1982 + //-- 如果有指定门店的时候 --
  1983 + if(pickup_ids){
  1984 +
  1985 + var ok_arr=[];
  1986 + for (let i in e.data.data.pageData) {
  1987 + let ite = e.data.data.pageData[i];
  1988 + //-- 查找一下门店有没有在 --
  1989 + var idx=pickup_ids.findIndex(function (e){
  1990 + return e.pickup_id==ite.pickup_id;
  1991 + })
  1992 + if(idx>-1){
  1993 + ok_arr.push(ite)
  1994 + }
  1995 + }
  1996 +
  1997 + //判断会员的默认的门店是不是匹配指定的门店
  1998 + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){
  1999 + //-- 查找一下门店有没有在 --
  2000 + var idx1=pickup_ids.findIndex(function (e){
  2001 + return e.pickup_id==th.data.def_pick_store.pickup_id;
  2002 + })
  2003 +
  2004 + if(idx1<0){
  2005 + //如果是秒杀的指定门店,就要设置秒杀的
  2006 + th.data.def_pick_store.is_no_dis_act=1;
  2007 + }else{
  2008 + th.data.def_pick_store.is_no_dis_act=0;
1990 } 2009 }
  2010 +
  2011 + that.setData({
  2012 + def_pick_store: th.data.def_pick_store
  2013 + })
  2014 +
  2015 + }
  2016 + e.data.data.pageData=ok_arr; //数组重新赋值
  2017 + e.data.data.total=ok_arr.length; //数组的长度
  2018 + }
  2019 + else{
  2020 + //-- 多规格指定门店优化 --
  2021 + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}'){
  2022 + th.data.def_pick_store.is_no_dis_act=0;
  2023 + that.setData({
  2024 + def_pick_store: th.data.def_pick_store
  2025 + })
1991 } 2026 }
1992 - e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加  
1993 } 2027 }
1994 2028
  2029 + //确保门店的数量要>0时,才进行计算
  2030 + if(e.data.data.pageData.length > 0) {
1995 2031
1996 - th.setData({ all_pick_list: e.data.data.pageData });  
1997 2032
1998 - //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购 预售--  
1999 - if(!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id  
2000 - && th.data.sales_rules >= 2 && !th.data.is_newsales_rules && ([1,2,4,6,8,9].indexOf(th.data.prom_type)==-1 || is_normal == 1)) {  
2001 - setTimeout(function () {  
2002 - th.deal_pickup_dline(e);  
2003 - }, 800)  
2004 - } else {  
2005 - setTimeout(function () {  
2006 - th.deal_pickup(e); //--普通门店排版--  
2007 - }, 800) 2033 + //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店
  2034 + if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) {
  2035 + th.setData({
  2036 + def_pick_store: e.data.data.pageData[0],
  2037 + sto_sele_name: e.data.data.pageData[0].pickup_name,
  2038 + sto_sele_id: e.data.data.pageData[0].pickup_id,
  2039 + sto_sele_distr: e.data.data.pageData[0].distr_type
  2040 + });
  2041 + th.data.fir_def_store = e.data.data.pageData[0];
  2042 + }
  2043 +
  2044 + //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 --
  2045 + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') {
  2046 + for (var k = 0; k < e.data.data.pageData.length; k++) {
  2047 + if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) {
  2048 + e.data.data.pageData.splice(k, 1); //删除
  2049 + break;
  2050 + }
  2051 + }
  2052 + e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加
  2053 + }
  2054 +
  2055 +
  2056 + th.setData({all_pick_list: e.data.data.pageData});
  2057 +
  2058 + //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购 预售--
  2059 + if (!getApp().is_virtual(th.data.sele_g) && !th.data.sele_g.whsle_id
  2060 + && th.data.sales_rules >= 2 && !th.data.is_newsales_rules && ([1, 2, 4, 6, 8, 9].indexOf(th.data.prom_type) == -1 || is_normal == 1)) {
  2061 + setTimeout(function () {
  2062 + th.deal_pickup_dline(e);
  2063 + }, 800)
  2064 + } else {
  2065 + setTimeout(function () {
  2066 + th.deal_pickup(e); //--普通门店排版--
  2067 + }, 800)
  2068 + }
2008 } 2069 }
  2070 + else{
  2071 + wx.hideLoading();
  2072 + }
  2073 + }
  2074 + else{
  2075 + wx.hideLoading();
2009 } 2076 }
2010 }) 2077 })
2011 }, 200) 2078 }, 200)
packageC/pages/presell/goodsInfo/goodsInfo.wxml
@@ -192,7 +192,10 @@ @@ -192,7 +192,10 @@
192 </view> 192 </view>
193 <block wx:else> 193 <block wx:else>
194 <view class="no_store" wx:if="{{def_pick_store && def_pick_store.is_no_dis}}"> 194 <view class="no_store" wx:if="{{def_pick_store && def_pick_store.is_no_dis}}">
195 - (配送不匹配2) 195 + (配送不匹配)
  196 + </view>
  197 + <view class="no_store" wx:elif="{{def_pick_store && def_pick_store.is_no_dis_act}}">
  198 + (该店不可售)
196 </view> 199 </view>
197 <view class="no_store" wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules>=2 && prom_type==0}}"> 200 <view class="no_store" wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && sales_rules>=2 && prom_type==0}}">
198 (库存不足) 201 (库存不足)
@@ -629,7 +632,8 @@ @@ -629,7 +632,8 @@
629 <block wx:else> 632 <block wx:else>
630 <view wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">(库存不足)</view> 633 <view wx:if="{{def_pickpu_list && !def_pickpu_list.length}}">(库存不足)</view>
631 <block wx:else> 634 <block wx:else>
632 - <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配1)</view> 635 + <view class="no_store" wx:if="{{def_pick_store.is_no_dis}}">(配送不匹配)</view>
  636 + <view class="no_store" wx:elif="{{def_pick_store.is_no_dis_act}}">(该店不可售)</view>
633 <view wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && !filters.is_virtual_gd(sele_g.is_virtual) && sales_rules>=2 && prom_type==0}}"> 637 <view wx:elif="{{def_pick_store && !def_pick_store.CanOutQty && !filters.is_virtual_gd(sele_g.is_virtual) && sales_rules>=2 && prom_type==0}}">
634 (库存不足) 638 (库存不足)
635 </view> 639 </view>
@@ -671,9 +675,13 @@ @@ -671,9 +675,13 @@
671 </view> 675 </view>
672 </view> 676 </view>
673 <view class="spec-cart-btns"> 677 <view class="spec-cart-btns">
674 - <view wx:if="{{def_pick_store && def_pick_store.is_no_dis}}" class="spec-cart-btn fs32" data-action="add" > 678 + <view wx:if="{{def_pick_store && def_pick_store.is_no_dis}}" class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">
675 门店的不匹配 679 门店的不匹配
676 </view> 680 </view>
  681 + <view wx:elif="{{def_pick_store && def_pick_store.is_no_dis_act}}" class="spec-cart-btn fs32" data-action="add" style="background-color: #dcdcdc;color: #999;">
  682 + 该门店不可售
  683 + </view>
  684 +
677 <block wx:else> 685 <block wx:else>
678 <!-- 根本就找不到门店 --> 686 <!-- 根本就找不到门店 -->
679 <block wx:if="{{!only_pk && !def_pickpu_list}}"> 687 <block wx:if="{{!only_pk && !def_pickpu_list}}">
@@ -855,7 +863,10 @@ @@ -855,7 +863,10 @@
855 <view class="address-frame xc-ash"> 863 <view class="address-frame xc-ash">
856 <view class="flex-vertical-between butttem5"> 864 <view class="flex-vertical-between butttem5">
857 <view class="flex xc-ash"> 865 <view class="flex xc-ash">
858 - <view class="fs30 xc-black3 address_name">{{item.pickup_name}}</view> 866 + <view class="fs30 xc-black3 address_name">{{item.pickup_name}}
  867 + <text class="c-red22" wx:if="{{item.is_no_dis}}">(配送不匹配)</text>
  868 + <text class="c-red22" wx:elif="{{item.is_no_dis_act}}">(该点不可售)</text>
  869 + </view>
859 </view> 870 </view>
860 <view> 871 <view>
861 <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}"> 872 <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}">
@@ -881,7 +892,10 @@ @@ -881,7 +892,10 @@
881 <view class="address-frame xc-ash"> 892 <view class="address-frame xc-ash">
882 <view class="flex-vertical-between "> 893 <view class="flex-vertical-between ">
883 <view class="flex xc-ash"> 894 <view class="flex xc-ash">
884 - <view class="fs30 xc-black3 address_name">{{item.pickup_name}}</view> 895 + <view class="fs30 xc-black3 address_name">{{item.pickup_name}}
  896 + <text class="c-red22" wx:if="{{item.is_no_dis}}">(配送不匹配)</text>
  897 + <text class="c-red22" wx:elif="{{item.is_no_dis_act}}">(该点不可售)</text>
  898 + </view>
885 </view> 899 </view>
886 <view> 900 <view>
887 <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}"> 901 <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}">
@@ -909,7 +923,10 @@ @@ -909,7 +923,10 @@
909 <view class="address-frame xc-ash"> 923 <view class="address-frame xc-ash">
910 <view class="flex-vertical-between "> 924 <view class="flex-vertical-between ">
911 <view class="flex xc-ash"> 925 <view class="flex xc-ash">
912 - <view class="fs28 xc-black3 address_name">{{item.pickup_name}}</view> 926 + <view class="fs28 xc-black3 address_name">{{item.pickup_name}}
  927 + <text class="c-red22" wx:if="{{item.is_no_dis}}">(配送不匹配)</text>
  928 + <text class="c-red22" wx:elif="{{item.is_no_dis_act}}">(该点不可售)</text>
  929 + </view>
913 </view> 930 </view>
914 <view> 931 <view>
915 <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}"> 932 <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}">
packageC/pages/presell/goodsInfo/goodsInfo.wxss
@@ -3016,4 +3016,6 @@ button.custom-service::after{ @@ -3016,4 +3016,6 @@ button.custom-service::after{
3016 border: 2rpx solid rgb(238, 238, 238); 3016 border: 2rpx solid rgb(238, 238, 238);
3017 padding-left: 30rpx; 3017 padding-left: 30rpx;
3018 } 3018 }
3019 - 3019 +.c-red22{
  3020 + color: #d60021
  3021 +}
pages/user/order_detail/order_detail.js
@@ -592,6 +592,13 @@ Page({ @@ -592,6 +592,13 @@ Page({
592 } 592 }
593 }) 593 })
594 594
  595 + if(!presellList || !presellList.length){
  596 + var content = good.goods_name + '未找到预售活动,请取消订单';
  597 + th.toast(content);
  598 + th.setData({ paying: 0 });
  599 + return false;
  600 + }
  601 +
595 if (presellList) { 602 if (presellList) {
596 if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) { 603 if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) {
597 var content = good.goods_name + '购买数量超出商品库存,请取消订单'; 604 var content = good.goods_name + '购买数量超出商品库存,请取消订单';
@@ -607,6 +614,28 @@ Page({ @@ -607,6 +614,28 @@ Page({
607 return false; 614 return false;
608 } 615 }
609 616
  617 + var fres=await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell_id, {});
  618 + //接口调用成功的时候
  619 + if(fres && fres.data.code==0 && fres.data.data){
  620 + //如果有指定门店的时候
  621 + if(fres.data.data.pick_up_lists){
  622 + var idx0=fres.data.data.pick_up_lists.findIndex(function (e){
  623 + return e.pickup_id==order.pickup_id;
  624 + })
  625 + if(idx0<0){
  626 + getApp().confirmBox(good.goods_name+"预售活动的门店不可售");
  627 + th.setData({ paying: 0 });
  628 + return false;
  629 + }
  630 + }
  631 +
  632 + }else{
  633 + var content = good.goods_name + '未找到预售活动,请取消订单';
  634 + th.toast(content);
  635 + th.setData({ paying: 0 });
  636 + return false;
  637 + }
  638 +
610 } 639 }
611 } 640 }
612 641
pages/user/order_list/order_list.js
@@ -906,10 +906,15 @@ Page({ @@ -906,10 +906,15 @@ Page({
906 } 906 }
907 }) 907 })
908 908
909 -  
910 - if (presellList) { 909 + if(!presellList || !presellList.length){
  910 + var content = good.goods_name + '未找到预售活动,请取消订单';
  911 + th.toast(content);
  912 + th.setData({ paying: 0 });
  913 + return false;
  914 + }
911 915
912 916
  917 + if (presellList) {
913 if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) { 918 if (good.goods_num > presellList.presell_sumqty - presellList.buy_goodnum) {
914 var content = good.goods_name + '购买数量超出商品库存,请取消订单'; 919 var content = good.goods_name + '购买数量超出商品库存,请取消订单';
915 th.toast(content); 920 th.toast(content);
@@ -924,6 +929,28 @@ Page({ @@ -924,6 +929,28 @@ Page({
924 return false; 929 return false;
925 } 930 }
926 931
  932 + var fres=await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellForm/get/"+os.stoid+"/"+presell_id, {});
  933 + //接口调用成功的时候
  934 + if(fres && fres.data.code==0 && fres.data.data){
  935 +
  936 + //如果有指定门店的时候
  937 + if(fres.data.data.pick_up_lists){
  938 + var idx0=fres.data.data.pick_up_lists.findIndex(function (e){
  939 + return e.pickup_id==order.pickup_id;
  940 + })
  941 + if(idx0<0){
  942 + getApp().confirmBox(good.goods_name+"预售活动的门店不可售");
  943 + th.setData({ paying: 0 });
  944 + return false;
  945 + }
  946 + }
  947 +
  948 + }else{
  949 + var content = good.goods_name + '未找到预售活动,请取消订单';
  950 + th.toast(content);
  951 + th.setData({ paying: 0 });
  952 + return false;
  953 + }
927 } 954 }
928 } 955 }
929 956