Commit 66e81782ce07c2c74f5edfaa91f87915b9e9a7f6
1 parent
3f4f6cf4
同城配送 预售积分购的功能优化
Showing
5 changed files
with
344 additions
and
223 deletions
packageC/pages/presell/cart/cart.js
| ... | ... | @@ -648,7 +648,7 @@ Page({ |
| 648 | 648 | }, |
| 649 | 649 | |
| 650 | 650 | |
| 651 | - async calculatePrice2() { | |
| 651 | + async calculatePrice2() { | |
| 652 | 652 | var th = this; |
| 653 | 653 | if (!this.data.pre_arr) return false; |
| 654 | 654 | th.setData({ show_submit: 0,disabled_btn:0}) |
| ... | ... | @@ -1990,57 +1990,7 @@ Page({ |
| 1990 | 1990 | |
| 1991 | 1991 | //-----------当地址不为空,且是物流时,计算物流费用---------- |
| 1992 | 1992 | if (th.data.user_addr != null) { |
| 1993 | - //看是不是有调用过包邮券,如果活动可以使用优化券的情况下 | |
| 1994 | - | |
| 1995 | - | |
| 1996 | - //--------------开始计算物流------------------ | |
| 1997 | - var shipping_price =0; | |
| 1998 | - var lon=0;var lat=0; | |
| 1999 | - //-- 获取距离 -- | |
| 2000 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 2001 | - is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 2002 | - }).then(res=>{ | |
| 2003 | - if(res.data.code==0){ | |
| 2004 | - var data= JSON.parse(res.data.data); | |
| 2005 | - if(data.status==0){ | |
| 2006 | - lon=data.result.location.lng; | |
| 2007 | - lat=data.result.location.lat; | |
| 2008 | - } | |
| 2009 | - } | |
| 2010 | - }) | |
| 2011 | - | |
| 2012 | - | |
| 2013 | - var gd_w = good['weight'] * good['buynum']; | |
| 2014 | - //-- 获取距离 -- | |
| 2015 | - var req_data = { | |
| 2016 | - store_id: os.stoid, | |
| 2017 | - order_amount: allpice, | |
| 2018 | - lon: lon, lat: lat, | |
| 2019 | - pickup_id: bn_pick, | |
| 2020 | - goods_weight: gd_w | |
| 2021 | - } | |
| 2022 | - | |
| 2023 | - var is_next=1; | |
| 2024 | - //获取同城配送参数 | |
| 2025 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 2026 | - is_json: 1, | |
| 2027 | - data: req_data | |
| 2028 | - }).then(res => { | |
| 2029 | - if (res.data.code == 0) { | |
| 2030 | - shipping_price= res.data.data; | |
| 2031 | - }else{ | |
| 2032 | - is_next=0; | |
| 2033 | - wx.showToast({ | |
| 2034 | - title: res.data.msg, icon: 'none', duration: 2000 | |
| 2035 | - }) | |
| 2036 | - } | |
| 2037 | - }) | |
| 2038 | - if(!is_next){ | |
| 2039 | - th.setData({show_submit:1,disabled_btn:1}) | |
| 2040 | - return false | |
| 2041 | - } | |
| 2042 | - exp_price = parseFloat(shipping_price).toFixed(2); | |
| 2043 | - th.wuliu_next(allpice, quan_price, exp_price); | |
| 1993 | + th.wuliu_next(allpice, quan_price, 0); | |
| 2044 | 1994 | } else { |
| 2045 | 1995 | wx.showToast({ |
| 2046 | 1996 | title: '请先选择收货地址', icon: 'none', duration: 2000 |
| ... | ... | @@ -2060,7 +2010,7 @@ Page({ |
| 2060 | 2010 | if (o_condition < 0) o_condition = 0; |
| 2061 | 2011 | //如果同意参与订单优惠 |
| 2062 | 2012 | if (o_condition > 0 && this.data.pre_arr.is_useorderyh) { |
| 2063 | - th.check_is_order_prom(o_condition, function (ord_price) { | |
| 2013 | + th.check_is_order_prom(o_condition,async function (ord_price) { | |
| 2064 | 2014 | var bn_pick = th.data.pickup.pickup_id |
| 2065 | 2015 | var order_prom_amount = 0; |
| 2066 | 2016 | var order_prom_id = 0; |
| ... | ... | @@ -2095,9 +2045,59 @@ Page({ |
| 2095 | 2045 | th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) |
| 2096 | 2046 | } |
| 2097 | 2047 | |
| 2048 | + if(th.data.exp_type == 2) { | |
| 2049 | + var good = th.data.goods; | |
| 2050 | + //--------------开始计算物流------------------ | |
| 2051 | + var shipping_price = 0; | |
| 2052 | + var lon = 0; | |
| 2053 | + var lat = 0; | |
| 2054 | + //-- 获取距离 -- | |
| 2055 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 2056 | + is_json: 1, data: {address: th.data.user_addr.more_address + th.data.user_addr.address} | |
| 2057 | + }).then(res => { | |
| 2058 | + if (res.data.code == 0) { | |
| 2059 | + var data = JSON.parse(res.data.data); | |
| 2060 | + if (data.status == 0) { | |
| 2061 | + lon = data.result.location.lng; | |
| 2062 | + lat = data.result.location.lat; | |
| 2063 | + } | |
| 2064 | + } | |
| 2065 | + }) | |
| 2066 | + var gd_w = good['weight'] * good['buynum']; | |
| 2067 | + //-- 获取距离 -- | |
| 2068 | + var req_data = { | |
| 2069 | + store_id: os.stoid, | |
| 2070 | + order_amount: parseFloat(ord_price), | |
| 2071 | + lon: lon, lat: lat, | |
| 2072 | + pickup_id: bn_pick, | |
| 2073 | + goods_weight: gd_w | |
| 2074 | + } | |
| 2075 | + | |
| 2076 | + var is_next = 1; | |
| 2077 | + //获取同城配送参数 | |
| 2078 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 2079 | + is_json: 1, | |
| 2080 | + data: req_data | |
| 2081 | + }).then(res => { | |
| 2082 | + if (res.data.code == 0) { | |
| 2083 | + shipping_price = res.data.data; | |
| 2084 | + } else { | |
| 2085 | + is_next = 0; | |
| 2086 | + wx.showToast({ | |
| 2087 | + title: res.data.msg, icon: 'none', duration: 2000 | |
| 2088 | + }) | |
| 2089 | + } | |
| 2090 | + }) | |
| 2091 | + if (!is_next) { | |
| 2092 | + th.setData({show_submit: 1, disabled_btn: 1}) | |
| 2093 | + return false | |
| 2094 | + } | |
| 2095 | + exp_price = parseFloat(shipping_price).toFixed(2); | |
| 2096 | + } | |
| 2098 | 2097 | |
| 2099 | 2098 | ord_price = parseFloat(ord_price) - parseFloat(th.data.presell.presell_deposit); |
| 2100 | 2099 | if (ord_price < 0) ord_price = 0; |
| 2100 | + | |
| 2101 | 2101 | th.setData({ exp_price: exp_price, order_m: ord_price + parseFloat(exp_price), show_submit: 1, }) |
| 2102 | 2102 | |
| 2103 | 2103 | }) | ... | ... |
packageC/pages/presell/cart/cart2.js
| ... | ... | @@ -826,56 +826,10 @@ Page({ |
| 826 | 826 | //--看一下有没有订单优惠-- |
| 827 | 827 | var o_condition = parseFloat(order_m); |
| 828 | 828 | |
| 829 | - //判断是否同城配送,而且没有调用过 | |
| 830 | - if(th.data.bn_exp_type==2 && th.data.user_addr) { | |
| 831 | - | |
| 832 | - var lon=0;var lat=0; | |
| 833 | - //-- 获取距离 -- | |
| 834 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 835 | - is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 836 | - }).then(res=>{ | |
| 837 | - if(res.data.code==0){ | |
| 838 | - var data= JSON.parse(res.data.data); | |
| 839 | - if(data.status==0){ | |
| 840 | - lon=data.result.location.lng; | |
| 841 | - lat=data.result.location.lat; | |
| 842 | - } | |
| 843 | - } | |
| 844 | - }) | |
| 845 | - | |
| 846 | - | |
| 847 | - var gd_w = good['weight'] * good['buynum']; | |
| 848 | - //-- 获取距离 -- | |
| 849 | - var req_data = { | |
| 850 | - store_id: os.stoid, | |
| 851 | - order_amount: order_m, | |
| 852 | - lon: lon, lat: lat, | |
| 853 | - pickup_id: bn_pick, | |
| 854 | - goods_weight: gd_w | |
| 855 | - } | |
| 856 | - | |
| 857 | - var is_next=1; | |
| 858 | - //获取同城配送参数 | |
| 859 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 860 | - is_json: 1, | |
| 861 | - data: req_data | |
| 862 | - }).then(res => { | |
| 863 | - if (res.data.code == 0) { | |
| 864 | - var wl_txt = "formData.shipping_price"; | |
| 865 | - th.setData({ [wl_txt]: res.data.data, }) | |
| 866 | - }else{ | |
| 867 | - is_next=0; | |
| 868 | - wx.showToast({ | |
| 869 | - title: res.data.msg, icon: 'none', duration: 2000 | |
| 870 | - }) | |
| 871 | - } | |
| 872 | - }) | |
| 873 | - if(!is_next) return false | |
| 874 | - } | |
| 875 | 829 | |
| 876 | 830 | |
| 877 | 831 | if (o_condition > 0 && th.data.act.is_useorderyh) { |
| 878 | - th.check_is_order_prom(o_condition, function () { | |
| 832 | + th.check_is_order_prom(o_condition, async function () { | |
| 879 | 833 | var order_prom_amount = 0; |
| 880 | 834 | var order_prom_id = 0; |
| 881 | 835 | if (th.data.order_prom[th.data.bn_pick]) { |
| ... | ... | @@ -907,6 +861,55 @@ Page({ |
| 907 | 861 | th.setData({ [order_prom_txt1]: order_prom_id, [order_prom_txt2]: order_prom_amount }) |
| 908 | 862 | } |
| 909 | 863 | |
| 864 | + //判断是否同城配送,而且没有调用过 | |
| 865 | + if(th.data.bn_exp_type==2 && th.data.user_addr) { | |
| 866 | + | |
| 867 | + var lon=0;var lat=0; | |
| 868 | + //-- 获取距离 -- | |
| 869 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 870 | + is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 871 | + }).then(res=>{ | |
| 872 | + if(res.data.code==0){ | |
| 873 | + var data= JSON.parse(res.data.data); | |
| 874 | + if(data.status==0){ | |
| 875 | + lon=data.result.location.lng; | |
| 876 | + lat=data.result.location.lat; | |
| 877 | + } | |
| 878 | + } | |
| 879 | + }) | |
| 880 | + | |
| 881 | + | |
| 882 | + var gd_w = good['weight'] * good['buynum']; | |
| 883 | + //-- 获取距离 -- | |
| 884 | + var req_data = { | |
| 885 | + store_id: os.stoid, | |
| 886 | + order_amount: parseFloat(order_m), | |
| 887 | + lon: lon, lat: lat, | |
| 888 | + pickup_id: bn_pick, | |
| 889 | + goods_weight: gd_w | |
| 890 | + } | |
| 891 | + | |
| 892 | + var is_next=1; | |
| 893 | + //获取同城配送参数 | |
| 894 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 895 | + is_json: 1, | |
| 896 | + data: req_data | |
| 897 | + }).then(res => { | |
| 898 | + if (res.data.code == 0) { | |
| 899 | + var wl_txt = "formData.shipping_price"; | |
| 900 | + th.setData({ [wl_txt]: res.data.data, }) | |
| 901 | + }else{ | |
| 902 | + is_next=0; | |
| 903 | + wx.showToast({ | |
| 904 | + title: res.data.msg, icon: 'none', duration: 2000 | |
| 905 | + }) | |
| 906 | + } | |
| 907 | + }) | |
| 908 | + if(!is_next) return false | |
| 909 | + } | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 910 | 913 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
| 911 | 914 | order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); |
| 912 | 915 | |
| ... | ... | @@ -962,6 +965,52 @@ Page({ |
| 962 | 965 | var order_prom_txt2 = "formData.order_prom_amount"; |
| 963 | 966 | th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) |
| 964 | 967 | |
| 968 | + | |
| 969 | + //判断是否同城配送,而且没有调用过 | |
| 970 | + if(th.data.bn_exp_type==2 && th.data.user_addr) { | |
| 971 | + var lon=0;var lat=0; | |
| 972 | + //-- 获取距离 -- | |
| 973 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 974 | + is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 975 | + }).then(res=>{ | |
| 976 | + if(res.data.code==0){ | |
| 977 | + var data= JSON.parse(res.data.data); | |
| 978 | + if(data.status==0){ | |
| 979 | + lon=data.result.location.lng; | |
| 980 | + lat=data.result.location.lat; | |
| 981 | + } | |
| 982 | + } | |
| 983 | + }) | |
| 984 | + | |
| 985 | + var gd_w = good['weight'] * good['buynum']; | |
| 986 | + //-- 获取距离 -- | |
| 987 | + var req_data = { | |
| 988 | + store_id: os.stoid, | |
| 989 | + order_amount:parseFloat(order_m), | |
| 990 | + lon: lon, lat: lat, | |
| 991 | + pickup_id: bn_pick, | |
| 992 | + goods_weight: gd_w | |
| 993 | + } | |
| 994 | + | |
| 995 | + var is_next=1; | |
| 996 | + //获取同城配送参数 | |
| 997 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 998 | + is_json: 1, | |
| 999 | + data: req_data | |
| 1000 | + }).then(res => { | |
| 1001 | + if (res.data.code == 0) { | |
| 1002 | + var wl_txt = "formData.shipping_price"; | |
| 1003 | + th.setData({ [wl_txt]: res.data.data, }) | |
| 1004 | + }else{ | |
| 1005 | + is_next=0; | |
| 1006 | + wx.showToast({ | |
| 1007 | + title: res.data.msg, icon: 'none', duration: 2000 | |
| 1008 | + }) | |
| 1009 | + } | |
| 1010 | + }) | |
| 1011 | + if(!is_next) return false | |
| 1012 | + } | |
| 1013 | + | |
| 965 | 1014 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
| 966 | 1015 | order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); |
| 967 | 1016 | var atxt = "formData.total_amount"; | ... | ... |
pages/cart/cart2/cart2.js
| ... | ... | @@ -857,7 +857,7 @@ Page({ |
| 857 | 857 | //-- 如果商品有同城配送的参数的时候,一件代发商品不能显示同城配送按钮 -- |
| 858 | 858 | if(gd.is_same_city && th.data.is_same_city && gd.whsle_id<=0){ |
| 859 | 859 | |
| 860 | - getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+gg.pick_id, {}).then(res=>{ | |
| 860 | + await getApp().request.promiseGet("/api/weshop/pickup/get/"+os.stoid+"/"+gg.pick_id, {}).then(res=>{ | |
| 861 | 861 | if(res.data.code==0){ |
| 862 | 862 | var pk=res.data.data; |
| 863 | 863 | if(pk && pk.is_same_city){ |
| ... | ... | @@ -1018,7 +1018,6 @@ Page({ |
| 1018 | 1018 | if (gg.prom_type == 5) { |
| 1019 | 1019 | t.data.data.prom_id = gg.prom_id; |
| 1020 | 1020 | t.data.data.prom_type = 5; |
| 1021 | - // console.log('xxxxxxxxxxxxxxxxxx', gg.is_coupon) | |
| 1022 | 1021 | th.is_coupon = gg.is_coupon; |
| 1023 | 1022 | th.setData({ |
| 1024 | 1023 | is_coupon: gg.is_coupon |
| ... | ... | @@ -1052,6 +1051,12 @@ Page({ |
| 1052 | 1051 | if (dis_t > 0) { |
| 1053 | 1052 | distr_t = dis_t; |
| 1054 | 1053 | } |
| 1054 | + | |
| 1055 | + //-- 如果有一件代发的商品或者不是同城配送的配送 -- | |
| 1056 | + if(!narr[hi].show_same_city || narr[hi].whsle_id>0){ | |
| 1057 | + th.setData({show_same_city:0}) | |
| 1058 | + } | |
| 1059 | + | |
| 1055 | 1060 | } |
| 1056 | 1061 | //自选的时候,系统配置了默认的配送方式是物流的时候 |
| 1057 | 1062 | if (distr_t == 0 && th.data.json_d.pickupway && th.data.json_d.pickupway == 1) { |
| ... | ... | @@ -1927,8 +1932,52 @@ Page({ |
| 1927 | 1932 | t_o_condition=t_o_condition-whsle_goods_price; |
| 1928 | 1933 | } |
| 1929 | 1934 | |
| 1930 | - //-- 在选择到同城配送的时候 -- | |
| 1931 | - if(c_arr[i].exp_type==2 && th.data.user_addr){ | |
| 1935 | + | |
| 1936 | + | |
| 1937 | + var order_m = 0; | |
| 1938 | + //---判断是不是有订单优惠--- | |
| 1939 | + await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
| 1940 | + data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
| 1941 | + }).then(res => { | |
| 1942 | + if (res.data.code == 0) { | |
| 1943 | + var ord_prom = res.data.data; | |
| 1944 | + //么有使用券,或者活动没有限制使用优惠券 | |
| 1945 | + if (quan_price <= 0 || !ord_prom.is_xz_yh) { | |
| 1946 | + order_prom_id = ord_prom['id']; | |
| 1947 | + switch (ord_prom['type']) { | |
| 1948 | + case 0: | |
| 1949 | + order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
| 1950 | + order_prom_amount = (o_condition - order_m).toFixed(2); | |
| 1951 | + break; | |
| 1952 | + case 1: | |
| 1953 | + //order_m = o_condition - ord_prom['expression'];//满额优惠金额 | |
| 1954 | + var bs=1; | |
| 1955 | + if(ord_prom.is_bz){ | |
| 1956 | + bs=Math.floor(o_condition/ord_prom.money); | |
| 1957 | + } | |
| 1958 | + order_prom_amount = ord_prom['expression']; | |
| 1959 | + break; | |
| 1960 | + } | |
| 1961 | + } | |
| 1962 | + } | |
| 1963 | + }) | |
| 1964 | + | |
| 1965 | + cart_item.order_prom_amount = 0; | |
| 1966 | + //--订单优惠的显示-- | |
| 1967 | + if (order_prom_id > 0) { | |
| 1968 | + cart_item.order_amount = (o_price - quan_price - order_prom_amount).toFixed(2); | |
| 1969 | + cart_item.order_prom_id = order_prom_id; | |
| 1970 | + cart_item.order_prom_amount = order_prom_amount; | |
| 1971 | + } | |
| 1972 | + coupon_price = quan_price; | |
| 1973 | + if (cart_item.order_amount < 0) { | |
| 1974 | + cart_item.order_amount = 0; | |
| 1975 | + coupon_price = o_price; | |
| 1976 | + } | |
| 1977 | + | |
| 1978 | + | |
| 1979 | + //-- 在选择到同城配送的时候 -- | |
| 1980 | + if(c_arr[i].exp_type==2 && th.data.user_addr){ | |
| 1932 | 1981 | |
| 1933 | 1982 | var gd_w=0; |
| 1934 | 1983 | for (let ib in c_arr[i].goods) { |
| ... | ... | @@ -1953,7 +2002,7 @@ Page({ |
| 1953 | 2002 | |
| 1954 | 2003 | |
| 1955 | 2004 | var req_data={ |
| 1956 | - store_id:os.stoid, order_amount:t_o_condition, | |
| 2005 | + store_id:os.stoid, order_amount: parseFloat(cart_item.order_amount), | |
| 1957 | 2006 | lon:lon,lat:lat, pickup_id:c_arr[i].pickup_id, goods_weight:gd_w |
| 1958 | 2007 | } |
| 1959 | 2008 | var is_next=1; |
| ... | ... | @@ -1979,46 +2028,8 @@ Page({ |
| 1979 | 2028 | } |
| 1980 | 2029 | |
| 1981 | 2030 | |
| 1982 | - var order_m = 0; | |
| 1983 | - //---判断是不是有订单优惠--- | |
| 1984 | - await getApp().request.promiseGet("/api/weshop/promorder/getOrderPromotion", { | |
| 1985 | - data: { store_id: os.stoid, orderAmount: o_condition, user_id: getApp().globalData.user_id } | |
| 1986 | - }).then(res => { | |
| 1987 | - if (res.data.code == 0) { | |
| 1988 | - var ord_prom = res.data.data; | |
| 1989 | - //么有使用券,或者活动没有限制使用优惠券 | |
| 1990 | - if (quan_price <= 0 || !ord_prom.is_xz_yh) { | |
| 1991 | - order_prom_id = ord_prom['id']; | |
| 1992 | - switch (ord_prom['type']) { | |
| 1993 | - case 0: | |
| 1994 | - order_m = Math.round(o_condition * ord_prom['expression']) / 100;//满额打折 | |
| 1995 | - order_prom_amount = (o_condition - order_m).toFixed(2); | |
| 1996 | - break; | |
| 1997 | - case 1: | |
| 1998 | - //order_m = o_condition - ord_prom['expression'];//满额优惠金额 | |
| 1999 | - var bs=1; | |
| 2000 | - if(ord_prom.is_bz){ | |
| 2001 | - bs=Math.floor(o_condition/ord_prom.money); | |
| 2002 | - } | |
| 2003 | - order_prom_amount = ord_prom['expression']; | |
| 2004 | - break; | |
| 2005 | - } | |
| 2006 | - } | |
| 2007 | - } | |
| 2008 | - }) | |
| 2009 | 2031 | |
| 2010 | - cart_item.order_prom_amount = 0; | |
| 2011 | - //--订单优惠的显示-- | |
| 2012 | - if (order_prom_id > 0) { | |
| 2013 | - cart_item.order_amount = (o_price - quan_price - order_prom_amount).toFixed(2); | |
| 2014 | - cart_item.order_prom_id = order_prom_id; | |
| 2015 | - cart_item.order_prom_amount = order_prom_amount; | |
| 2016 | - } | |
| 2017 | - coupon_price = quan_price; | |
| 2018 | - if (cart_item.order_amount < 0) { | |
| 2019 | - cart_item.order_amount = 0; | |
| 2020 | - coupon_price = o_price; | |
| 2021 | - } | |
| 2032 | + | |
| 2022 | 2033 | |
| 2023 | 2034 | cart_item.total_amount = parseFloat(cart_item.total_amount) + parseFloat(cart_item.shipping_price); //总金额 |
| 2024 | 2035 | cart_item.order_amount = parseFloat(cart_item.order_amount) + parseFloat(cart_item.shipping_price); //总金额 |
| ... | ... | @@ -2424,65 +2435,9 @@ Page({ |
| 2424 | 2435 | var o_condition = parseFloat(order_m); |
| 2425 | 2436 | if(th.data.bn_goods.whsle_id>0){ |
| 2426 | 2437 | o_condition=0; |
| 2427 | - }else{ | |
| 2428 | - | |
| 2429 | - //判断是否同城配送,而且没有调用过 | |
| 2430 | - if(th.data.bn_exp_type==2 && th.data.user_addr) { | |
| 2431 | - var gd_w = 0, lon = 0, lat = 0; | |
| 2432 | - for (let ib in gd_arr_list) { | |
| 2433 | - let item_b = gd_arr_list[ib]; | |
| 2434 | - gd_w += item_b['weight'] * item_b['buynum']; | |
| 2435 | - } | |
| 2436 | - | |
| 2437 | - //-- 获取距离 -- | |
| 2438 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 2439 | - is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 2440 | - }).then(res=>{ | |
| 2441 | - if(res.data.code==0){ | |
| 2442 | - var data= JSON.parse(res.data.data); | |
| 2443 | - if(data.status==0){ | |
| 2444 | - lon=data.result.location.lng; | |
| 2445 | - lat=data.result.location.lat; | |
| 2446 | - } | |
| 2447 | - } | |
| 2448 | - }) | |
| 2449 | - | |
| 2450 | - var req_data = { | |
| 2451 | - store_id: os.stoid, order_amount: o_condition, | |
| 2452 | - lon: lon, lat: lat, pickup_id: bn_pick,goods_weight: gd_w | |
| 2453 | - } | |
| 2454 | - | |
| 2455 | - var is_next=1; | |
| 2456 | - | |
| 2457 | - //获取同城配送参数 | |
| 2458 | - await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 2459 | - is_json: 1,data: req_data | |
| 2460 | - }).then(res => { | |
| 2461 | - if (res.data.code == 0) { | |
| 2462 | - var wl_txt = "formData.shipping_price"; | |
| 2463 | - th.setData({ [wl_txt]: res.data.data, }) | |
| 2464 | - | |
| 2465 | - }else{ | |
| 2466 | - is_next=0; | |
| 2467 | - if(qfunc){ | |
| 2468 | - qfunc(); | |
| 2469 | - }else{ | |
| 2470 | - wx.showToast({ | |
| 2471 | - title: res.data.msg, | |
| 2472 | - icon: 'none', | |
| 2473 | - duration: 2000 | |
| 2474 | - }) | |
| 2475 | - } | |
| 2476 | - | |
| 2477 | - } | |
| 2478 | - }) | |
| 2479 | - if(!is_next) return false | |
| 2480 | - } | |
| 2481 | - | |
| 2482 | 2438 | } |
| 2483 | - | |
| 2484 | 2439 | if (o_condition > 0) { |
| 2485 | - th.check_is_order_prom(o_condition, function () { | |
| 2440 | + th.check_is_order_prom(o_condition,async function () { | |
| 2486 | 2441 | var order_prom_amount = 0; |
| 2487 | 2442 | var order_prom_id = 0; |
| 2488 | 2443 | if (th.data.order_prom[th.data.bn_pick] && th.data.order_prom[th.data.bn_pick]['money'] <= o_condition) { |
| ... | ... | @@ -2517,6 +2472,60 @@ Page({ |
| 2517 | 2472 | th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) |
| 2518 | 2473 | } |
| 2519 | 2474 | |
| 2475 | + //判断是否同城配送,而且没有调用过 | |
| 2476 | + if(th.data.bn_exp_type==2 && th.data.user_addr) { | |
| 2477 | + var gd_w = 0, lon = 0, lat = 0; | |
| 2478 | + for (let ib in gd_arr_list) { | |
| 2479 | + let item_b = gd_arr_list[ib]; | |
| 2480 | + gd_w += item_b['weight'] * item_b['buynum']; | |
| 2481 | + } | |
| 2482 | + | |
| 2483 | + //-- 获取距离 -- | |
| 2484 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 2485 | + is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 2486 | + }).then(res=>{ | |
| 2487 | + if(res.data.code==0){ | |
| 2488 | + var data= JSON.parse(res.data.data); | |
| 2489 | + if(data.status==0){ | |
| 2490 | + lon=data.result.location.lng; | |
| 2491 | + lat=data.result.location.lat; | |
| 2492 | + } | |
| 2493 | + } | |
| 2494 | + }) | |
| 2495 | + | |
| 2496 | + var req_data = { | |
| 2497 | + store_id: os.stoid, order_amount: o_condition, | |
| 2498 | + lon: lon, lat: lat, pickup_id: bn_pick,goods_weight: gd_w | |
| 2499 | + } | |
| 2500 | + | |
| 2501 | + var is_next=1; | |
| 2502 | + | |
| 2503 | + //获取同城配送参数 | |
| 2504 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 2505 | + is_json: 1,data: req_data | |
| 2506 | + }).then(res => { | |
| 2507 | + if (res.data.code == 0) { | |
| 2508 | + var wl_txt = "formData.shipping_price"; | |
| 2509 | + th.setData({ [wl_txt]: res.data.data, }) | |
| 2510 | + | |
| 2511 | + }else{ | |
| 2512 | + is_next=0; | |
| 2513 | + if(qfunc){ | |
| 2514 | + qfunc(); | |
| 2515 | + }else{ | |
| 2516 | + wx.showToast({ | |
| 2517 | + title: res.data.msg, | |
| 2518 | + icon: 'none', | |
| 2519 | + duration: 2000 | |
| 2520 | + }) | |
| 2521 | + } | |
| 2522 | + | |
| 2523 | + } | |
| 2524 | + }) | |
| 2525 | + if(!is_next) return false | |
| 2526 | + } | |
| 2527 | + | |
| 2528 | + | |
| 2520 | 2529 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
| 2521 | 2530 | order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); |
| 2522 | 2531 | |
| ... | ... | @@ -2583,6 +2592,59 @@ Page({ |
| 2583 | 2592 | var order_prom_txt2 = "formData.order_prom_amount"; |
| 2584 | 2593 | th.setData({ [order_prom_txt1]: 0, [order_prom_txt2]: 0 }) |
| 2585 | 2594 | |
| 2595 | + //判断是否同城配送,而且没有调用过 | |
| 2596 | + if(th.data.bn_exp_type==2 && th.data.user_addr) { | |
| 2597 | + var gd_w = 0, lon = 0, lat = 0; | |
| 2598 | + for (let ib in gd_arr_list) { | |
| 2599 | + let item_b = gd_arr_list[ib]; | |
| 2600 | + gd_w += item_b['weight'] * item_b['buynum']; | |
| 2601 | + } | |
| 2602 | + | |
| 2603 | + //-- 获取距离 -- | |
| 2604 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getGeocoder", { | |
| 2605 | + is_json: 1, data: {address:th.data.user_addr.more_address+th.data.user_addr.address} | |
| 2606 | + }).then(res=>{ | |
| 2607 | + if(res.data.code==0){ | |
| 2608 | + var data= JSON.parse(res.data.data); | |
| 2609 | + if(data.status==0){ | |
| 2610 | + lon=data.result.location.lng; | |
| 2611 | + lat=data.result.location.lat; | |
| 2612 | + } | |
| 2613 | + } | |
| 2614 | + }) | |
| 2615 | + | |
| 2616 | + var req_data = { | |
| 2617 | + store_id: os.stoid, order_amount: parseFloat(order_m), | |
| 2618 | + lon: lon, lat: lat, pickup_id: bn_pick,goods_weight: gd_w | |
| 2619 | + } | |
| 2620 | + | |
| 2621 | + var is_next=1; | |
| 2622 | + | |
| 2623 | + //获取同城配送参数 | |
| 2624 | + await getApp().request.promisePost("/api/weshop/order/sameCityExp/getMoney", { | |
| 2625 | + is_json: 1,data: req_data | |
| 2626 | + }).then(res => { | |
| 2627 | + if (res.data.code == 0) { | |
| 2628 | + var wl_txt = "formData.shipping_price"; | |
| 2629 | + th.setData({ [wl_txt]: res.data.data, }) | |
| 2630 | + | |
| 2631 | + }else{ | |
| 2632 | + is_next=0; | |
| 2633 | + if(qfunc){ | |
| 2634 | + qfunc(); | |
| 2635 | + }else{ | |
| 2636 | + wx.showToast({ | |
| 2637 | + title: res.data.msg, | |
| 2638 | + icon: 'none', | |
| 2639 | + duration: 2000 | |
| 2640 | + }) | |
| 2641 | + } | |
| 2642 | + | |
| 2643 | + } | |
| 2644 | + }) | |
| 2645 | + if(!is_next) return false | |
| 2646 | + } | |
| 2647 | + | |
| 2586 | 2648 | |
| 2587 | 2649 | total_m = parseFloat(total_m) + parseFloat(th.data.formData.shipping_price); |
| 2588 | 2650 | order_m = parseFloat(order_m) + parseFloat(th.data.formData.shipping_price); |
| ... | ... | @@ -2682,6 +2744,10 @@ Page({ |
| 2682 | 2744 | |
| 2683 | 2745 | //--------------------提交订单----------------------- |
| 2684 | 2746 | async submit_func() { |
| 2747 | + | |
| 2748 | + if(this.data.is_summit_ing) return false; | |
| 2749 | + this.data.is_summit_ing = 1; | |
| 2750 | + | |
| 2685 | 2751 | var th = this, pdata = new Array(); |
| 2686 | 2752 | var ff = true; |
| 2687 | 2753 | //------------立即购买------------- |
| ... | ... | @@ -3281,6 +3347,7 @@ Page({ |
| 3281 | 3347 | |
| 3282 | 3348 | |
| 3283 | 3349 | wx.showLoading({ title: "加载中" }); |
| 3350 | + th.setData({ submit: 1,}) | |
| 3284 | 3351 | wx.request({ |
| 3285 | 3352 | url: oo.url + '/api/weshop/order/createWxdOrder', |
| 3286 | 3353 | data: str, |
| ... | ... | @@ -3293,7 +3360,7 @@ Page({ |
| 3293 | 3360 | if (res.statusCode == 200) { |
| 3294 | 3361 | var data = res.data; |
| 3295 | 3362 | if (data.code == 0) { |
| 3296 | - console.log(th.data.is_b_now); | |
| 3363 | + th.setData({ submit: 1,}) | |
| 3297 | 3364 | //如果是购物车结算,还要删除购物车 |
| 3298 | 3365 | if (th.data.is_b_now == 0) { |
| 3299 | 3366 | console.log(th.data.cartlist_y); |
| ... | ... | @@ -3383,24 +3450,31 @@ Page({ |
| 3383 | 3450 | } |
| 3384 | 3451 | }) |
| 3385 | 3452 | return; |
| 3453 | + }else{ | |
| 3454 | + if (msg.length > 13) { | |
| 3455 | + msg = msg.slice(0, 13) + "\r\n" + msg.slice(13); | |
| 3456 | + } | |
| 3457 | + getApp().confirmBox(msg); | |
| 3458 | + th.data.is_summit_ing = 0; //是否提交中 | |
| 3459 | + th.setData({ | |
| 3460 | + submit: 0, | |
| 3461 | + }) | |
| 3386 | 3462 | } |
| 3387 | - if (msg.length > 13) { | |
| 3388 | - msg = msg.slice(0, 13) + "\r\n" + msg.slice(13); | |
| 3389 | - } | |
| 3390 | - getApp().confirmBox(msg); | |
| 3391 | - th.data.is_summit_ing = 0; //是否提交中 | |
| 3463 | + | |
| 3464 | + | |
| 3392 | 3465 | } |
| 3393 | 3466 | } else { |
| 3394 | 3467 | th.data.is_summit_ing = 0; //是否提交中 |
| 3395 | 3468 | console.log("index.js wx.request CheckCallUser statusCode" + res.statusCode); |
| 3469 | + th.setData({ | |
| 3470 | + submit: 0, | |
| 3471 | + }) | |
| 3396 | 3472 | } |
| 3397 | 3473 | }, |
| 3398 | 3474 | fail: function () { |
| 3399 | 3475 | th.data.is_summit_ing = 0; |
| 3400 | 3476 | wx.hideLoading(); |
| 3401 | 3477 | console.log("index.js wx.request CheckCallUser fail"); |
| 3402 | - }, | |
| 3403 | - complete: function () { | |
| 3404 | 3478 | th.setData({ |
| 3405 | 3479 | submit: 0, |
| 3406 | 3480 | }) |
| ... | ... | @@ -3917,6 +3991,7 @@ Page({ |
| 3917 | 3991 | |
| 3918 | 3992 | |
| 3919 | 3993 | var th = this; |
| 3994 | + var old_quan=null; | |
| 3920 | 3995 | if (isby == 1) { |
| 3921 | 3996 | using_quan[pickid] = { |
| 3922 | 3997 | coupon_no: item.no, |
| ... | ... | @@ -3927,13 +4002,16 @@ Page({ |
| 3927 | 4002 | }; |
| 3928 | 4003 | using_quan[pickid].isby = 1; |
| 3929 | 4004 | } else { |
| 4005 | + if(using_quan[pickid]) old_quan=using_quan[pickid]; | |
| 3930 | 4006 | using_quan[pickid] = { coupon_no: item.CashRepNo, money: item.Sum, is_nouse_red: 0 }; |
| 3931 | 4007 | using_quan[pickid].isby = 0; |
| 3932 | 4008 | } |
| 3933 | 4009 | this.setData({ using_quan: using_quan }); |
| 3934 | 4010 | if (th.data.is_b_now == 1) { |
| 3935 | 4011 | th.calculatePrice2(function () { |
| 3936 | - using_quan[pickid]=null; | |
| 4012 | + | |
| 4013 | + if(old_quan) using_quan[pickid]=old_quan; | |
| 4014 | + else using_quan[pickid]=null; | |
| 3937 | 4015 | th.setData({ using_quan: using_quan,submit:0 }); |
| 3938 | 4016 | wx.showToast({ |
| 3939 | 4017 | title: "不能使用优惠券,同城起送价不足", |
| ... | ... | @@ -3944,7 +4022,8 @@ Page({ |
| 3944 | 4022 | }); |
| 3945 | 4023 | } else { |
| 3946 | 4024 | th.calculatePrice(function () { |
| 3947 | - using_quan[pickid]=null; | |
| 4025 | + if(old_quan) using_quan[pickid]=old_quan; | |
| 4026 | + else using_quan[pickid]=null; | |
| 3948 | 4027 | th.setData({ using_quan: using_quan ,submit:0 }); |
| 3949 | 4028 | wx.showToast({ |
| 3950 | 4029 | title: "不能使用优惠券,同城起送价不足", |
| ... | ... | @@ -4792,15 +4871,9 @@ Page({ |
| 4792 | 4871 | tmplIds: [template_id], |
| 4793 | 4872 | success(res) { |
| 4794 | 4873 | func(); |
| 4795 | - th.setData({ | |
| 4796 | - submit: 0, | |
| 4797 | - }) | |
| 4798 | 4874 | }, |
| 4799 | 4875 | fail(res) { |
| 4800 | 4876 | func(); |
| 4801 | - th.setData({ | |
| 4802 | - submit: 0, | |
| 4803 | - }) | |
| 4804 | 4877 | } |
| 4805 | 4878 | }) |
| 4806 | 4879 | ... | ... |
pages/cart/cart2_inte/cart2_inte.js
| ... | ... | @@ -428,7 +428,7 @@ Page({ |
| 428 | 428 | calculatePrice2:async function () { |
| 429 | 429 | var th = this, good = this.data.bn_goods; |
| 430 | 430 | |
| 431 | - this.setData({show_submit:0}) | |
| 431 | + this.setData({submit:1}) | |
| 432 | 432 | wx.showLoading({ title: "处理中.", mask:true }) |
| 433 | 433 | //-----------计算商品总价-------------- |
| 434 | 434 | var allpice = good.shop_price * good.buynum; |
| ... | ... | @@ -544,7 +544,6 @@ Page({ |
| 544 | 544 | wx.showToast({ |
| 545 | 545 | title: "计算物流错误", icon: 'none',duration: 2000 |
| 546 | 546 | }) |
| 547 | - th.setData({ show_submit:0 }); | |
| 548 | 547 | wx.hideLoading(); |
| 549 | 548 | return false; |
| 550 | 549 | } |
| ... | ... | @@ -637,14 +636,14 @@ Page({ |
| 637 | 636 | if (th.data.bn_use_money == 1) { |
| 638 | 637 | if (amoney > order_m) { |
| 639 | 638 | order_m = order_m.toFixed(2); |
| 640 | - th.setData({ [txt]: order_m, [txt2]: 0, [txt4]: all_integral, show_submit: 1 }) | |
| 639 | + th.setData({ [txt]: order_m, [txt2]: 0, [txt4]: all_integral, show_submit: 1,submit:0 }) | |
| 641 | 640 | } else { |
| 642 | 641 | order_m = parseFloat(order_m - amoney); |
| 643 | 642 | order_m = order_m.toFixed(2); |
| 644 | - th.setData({ [txt]: amoney, [txt2]: order_m, [txt4]: all_integral, show_submit: 1 }) | |
| 643 | + th.setData({ [txt]: amoney, [txt2]: order_m, [txt4]: all_integral, show_submit: 1,submit:0 }) | |
| 645 | 644 | } |
| 646 | 645 | } else { |
| 647 | - th.setData({ [txt]: 0, [txt2]: order_m, [txt4]: all_integral, show_submit: 1 }) | |
| 646 | + th.setData({ [txt]: 0, [txt2]: order_m, [txt4]: all_integral, show_submit: 1,submit:0}) | |
| 648 | 647 | } |
| 649 | 648 | |
| 650 | 649 | wx.hideLoading(); | ... | ... |
pages/cart/cart2_inte/cart2_inte.wxml
| ... | ... | @@ -165,7 +165,7 @@ |
| 165 | 165 | <view class="payable">应付金额:<text class="co-red">¥{{formData.order_amount}}</text></view> |
| 166 | 166 | <view class="payable">应付积分:<text class="co-red">{{formData.integral}}积分</text></view> |
| 167 | 167 | </view> |
| 168 | - <button class="tips-btn" formType="submit" id="submitOrder">提交订单</button> | |
| 168 | + <button disabled="{{submit}}" class="tips-btn" formType="submit" id="submitOrder">提交订单</button> | |
| 169 | 169 | </view> |
| 170 | 170 | </form> |
| 171 | 171 | ... | ... |