Commit c4d1d430c72973811c707f485d43d7650c2b69a9
1 parent
f2d5d54e
修改商品详情
Showing
1 changed file
with
249 additions
and
298 deletions
packageA/pages/goodsInfo/goodsInfo.js
| ... | ... | @@ -447,7 +447,7 @@ Page({ |
| 447 | 447 | sto_sele_name: e.pickup_name, |
| 448 | 448 | sto_sele_id: e.pickup_id, |
| 449 | 449 | sto_sele_distr: e.distr_type, |
| 450 | - sto_sele_keyid:e.keyid, | |
| 450 | + sto_sele_keyid:e.keyid, | |
| 451 | 451 | }) |
| 452 | 452 | } |
| 453 | 453 | } |
| ... | ... | @@ -562,6 +562,9 @@ Page({ |
| 562 | 562 | // <---- 秒杀 |
| 563 | 563 | |
| 564 | 564 | |
| 565 | + | |
| 566 | + | |
| 567 | + | |
| 565 | 568 | |
| 566 | 569 | |
| 567 | 570 | |
| ... | ... | @@ -826,21 +829,7 @@ Page({ |
| 826 | 829 | }); |
| 827 | 830 | }, |
| 828 | 831 | |
| 829 | - //获取redis中的数量 | |
| 830 | - async getactLen(func) { | |
| 831 | - var r_num = 0, | |
| 832 | - prom_type = this.data.prom_type, | |
| 833 | - prom_id = this.data.prom_id; | |
| 834 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | |
| 835 | - 1: 1 | |
| 836 | - }).then(res => { | |
| 837 | - var em = res; | |
| 838 | - if (em.data.code == 0) { | |
| 839 | - r_num = em.data.data; | |
| 840 | - } | |
| 841 | - }) | |
| 842 | - func(r_num); | |
| 843 | - }, | |
| 832 | + | |
| 844 | 833 | |
| 845 | 834 | //------------加入购物车-------------- |
| 846 | 835 | addCart: async function(t) { |
| ... | ... | @@ -848,8 +837,7 @@ Page({ |
| 848 | 837 | var ind = t.currentTarget.dataset.openSpecModal_ind; |
| 849 | 838 | var action= t.currentTarget.dataset.action; |
| 850 | 839 | if(!ind) ind = t.currentTarget.dataset.openspecmodal_ind; |
| 851 | - // 活动ID | |
| 852 | - var prom_id = th.data.prom_id; | |
| 840 | + | |
| 853 | 841 | th.setData({ |
| 854 | 842 | open_ind_store: ind |
| 855 | 843 | }); |
| ... | ... | @@ -859,127 +847,99 @@ Page({ |
| 859 | 847 | return false; |
| 860 | 848 | }; |
| 861 | 849 | |
| 862 | - // 秒杀活动 | |
| 863 | - if(this.data.prom_type == 1) { | |
| 864 | - | |
| 865 | - this.data.sele_g.viplimited = this.data.sele_g.buy_limit; | |
| 866 | - | |
| 867 | - // 每人最大限购数 | |
| 868 | - th.data.sele_g.viplimited = th.data.sele_g.buy_limit; | |
| 869 | - | |
| 870 | - //----获取用户活动购买数---- | |
| 871 | - // 已经付款的单数,已经成功购买的数量 | |
| 872 | - var gd_buy_num = 0; | |
| 873 | - await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum?store_id="+os.stoid+"&user_id="+getApp().globalData.user_id+"&card_id="+th.data.options.goods_id+"&prom_type="+th.data.options.prom_type+"&prom_id="+th.data.options.prom_id, { | |
| 874 | - }).then(res => { | |
| 875 | - gd_buy_num = !res.data.data.promcardbuynum ? 0 : res.data.data.promcardbuynum; | |
| 876 | - }); | |
| 877 | - | |
| 878 | - | |
| 879 | - // 检查redis库存量 | |
| 880 | - var redisNum = 0; | |
| 881 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { | |
| 882 | - if (res.data.code == 0) { | |
| 883 | - redisNum = !res.data.data ? 0 : res.data.data; | |
| 884 | - }; | |
| 885 | - }); | |
| 886 | - | |
| 887 | - | |
| 888 | - // 有库存的情况下,走秒杀活动流程 否则 走正常购买流程 | |
| 889 | - // 没有库存,已抢光的情况下,走正常购买流程 | |
| 890 | - if(redisNum > 0 && !this.data.is_normal) { | |
| 891 | - // 输入的数量 | |
| 892 | - var t = th.data.goodsInputNum; | |
| 893 | - // 获取购物车同款数量 | |
| 894 | - var cartGoodsNum = 0; | |
| 895 | - | |
| 896 | - // 购物车 | |
| 897 | - if (action != "buy") { | |
| 898 | - await getApp().request.promiseGet("/api/weshop/cartService/page?store_id="+os.stoid+"&user_id="+oo.user_id+"&service_id="+th.data.data.id, | |
| 899 | - { }).then(res => { | |
| 900 | - if (res.data.data.pageData.length > 0) { | |
| 901 | - const tmpObj = res.data.data.pageData; | |
| 902 | - | |
| 903 | - tmpObj.forEach(v => { | |
| 904 | - cartGoodsNum += parseInt(v.goods_num); | |
| 905 | - }); | |
| 906 | - | |
| 907 | - } | |
| 908 | - | |
| 909 | - }); | |
| 850 | + | |
| 851 | + // 秒杀活动 | |
| 852 | + if(this.data.prom_type == 1) { | |
| 853 | + // 如果是秒杀活动下的单独购买,is_normal为1 | |
| 854 | + if(this.data.openSpecModal_flash_normal) this.data.is_normal = 1; | |
| 855 | + | |
| 856 | + if(!this.data.is_normal) {// 秒杀购买 | |
| 857 | + | |
| 858 | + // 获取redis当前可以购买的数量 | |
| 859 | + // 如果数量为0,设置和显示已抢光 | |
| 860 | + // 否则,进一步判断是否超出限购或超出库存 | |
| 861 | + await this.getactLen().then(async function(res) { | |
| 862 | + let curNum = th.data.goodsInputNum; | |
| 863 | + // res: redis可购买数量 | |
| 864 | + console.log('当前可以购买的数量:', res); | |
| 865 | + if(res <= 0) { | |
| 866 | + // 可购买数量<=0, 设置和显示已抢光 | |
| 867 | + th.setData({ | |
| 868 | + prom_r_null: 1, | |
| 869 | + }); | |
| 870 | + wx.showModal({ | |
| 871 | + title: '超出活动库存', | |
| 872 | + }); | |
| 873 | + return false; | |
| 874 | + } else { | |
| 875 | + // 可购买数量>0 | |
| 876 | + // 计算自己还可以购买的数量 | |
| 877 | + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b | |
| 878 | + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 | |
| 879 | + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 | |
| 880 | + let actInfo = th.data.sele_g; | |
| 881 | + await th.get_buy_num2().then(function (data) { | |
| 882 | + let limited = actInfo.buy_limit; // 限购数量a | |
| 883 | + let promcardbuynum = data.data.data.promcardbuynum; | |
| 884 | + let buyedNum = promcardbuynum; // 自己已经购买的数量b | |
| 885 | + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c | |
| 910 | 886 | |
| 911 | - // 输入的数量 + 购物车同款商品的数量 | |
| 912 | - t = parseInt(t) + parseInt(cartGoodsNum); | |
| 913 | - } | |
| 914 | - | |
| 915 | - // 剩余购买数量 | |
| 916 | - let num = th.data.sele_g.viplimited - gd_buy_num; | |
| 917 | - num = num < 0 ? 0 : num; | |
| 918 | - | |
| 919 | - if (t > redisNum) { | |
| 920 | - wx.showToast({ | |
| 887 | + if(canBuyNum <= 0) { | |
| 888 | + canBuyNum = 0; | |
| 889 | + }; | |
| 890 | + | |
| 891 | + if(limited > res) { | |
| 892 | + if(curNum > res) { // t当前增减的数量 | |
| 893 | + wx.showModal({ | |
| 921 | 894 | title: '超出活动库存', |
| 922 | - icon: 'none' | |
| 923 | - }); | |
| 924 | - | |
| 925 | - // 开启限购 | |
| 926 | - if (th.data.sele_g.viplimited > 0) { | |
| 927 | - | |
| 928 | - if (action != "buy") { | |
| 929 | - if (t > num) { | |
| 930 | - th.setData({goodsInputNum: num - cartGoodsNum < 0 ? 0 : num - cartGoodsNum}); | |
| 931 | - } | |
| 932 | - if (redisNum < num) { | |
| 933 | - th.setData({goodsInputNum: redisNum - cartGoodsNum < 0 ? 0 : redisNum - cartGoodsNum}); | |
| 934 | - } | |
| 935 | - } else { | |
| 936 | - if (num > redisNum) { | |
| 937 | - th.setData({goodsInputNum: redisNum}); | |
| 938 | - } else { | |
| 939 | - th.setData({goodsInputNum: num}); | |
| 940 | - } | |
| 941 | - } | |
| 942 | - | |
| 943 | - | |
| 944 | - | |
| 945 | - | |
| 946 | - } else { | |
| 947 | - th.setData({goodsInputNum: redisNum}); | |
| 948 | - } | |
| 949 | - | |
| 950 | - return false; | |
| 951 | - } | |
| 952 | - | |
| 953 | - // 以下小于等于库存 | |
| 954 | - if (t <= redisNum) { | |
| 955 | - if (th.data.sele_g.viplimited > 0) { | |
| 956 | - | |
| 957 | - if (t > num) { | |
| 958 | - wx.showToast({ | |
| 959 | - title: '超出活动限购数量', | |
| 960 | - icon: 'none' | |
| 961 | - }); | |
| 962 | - | |
| 963 | - if (num > redisNum) { | |
| 964 | - th.setData({goodsInputNum: redisNum}); | |
| 965 | - } else { | |
| 966 | - th.setData({goodsInputNum: num}); | |
| 967 | - } | |
| 968 | - return false; | |
| 969 | - } | |
| 970 | - | |
| 971 | - } | |
| 972 | - } | |
| 895 | + }); | |
| 896 | + th.setData({ | |
| 897 | + goodsInputNum: res, | |
| 898 | + }); | |
| 899 | + return false; | |
| 900 | + }; | |
| 901 | + }; | |
| 973 | 902 | |
| 974 | - | |
| 903 | + if(limited <= res) { | |
| 904 | + if(curNum > limited) { | |
| 905 | + wx.showModal({ | |
| 906 | + title: '超出限购数量', | |
| 907 | + }); | |
| 908 | + th.setData({ | |
| 909 | + goodsInputNum: canBuyNum, | |
| 910 | + }); | |
| 911 | + return false; | |
| 912 | + }; | |
| 913 | + }; | |
| 914 | + | |
| 915 | + | |
| 916 | + }); | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 975 | 920 | }; |
| 921 | + }); | |
| 922 | + | |
| 976 | 923 | }; |
| 977 | 924 | |
| 978 | 925 | |
| 926 | + }; | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 979 | 939 | |
| 980 | 940 | |
| 981 | 941 | |
| 982 | - if(action=="buy"){ // 立即购买 | |
| 942 | + if(action=="buy"){ | |
| 983 | 943 | //--------------此时操作的数据------------ |
| 984 | 944 | var newd = { |
| 985 | 945 | id: th.data.data.id, |
| ... | ... | @@ -1001,30 +961,14 @@ Page({ |
| 1001 | 961 | newd['prom_type'] = 0; |
| 1002 | 962 | newd['prom_price'] = this.data.data.shop_price; |
| 1003 | 963 | }; |
| 1004 | - | |
| 1005 | - // 判断是否为0库存的情况 | |
| 1006 | - var tmpRedisNum = 0; | |
| 1007 | - // 检查redis库存量 | |
| 1008 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { | |
| 1009 | - if (res.data.code == 0) { | |
| 1010 | - tmpRedisNum = res.data.data; | |
| 1011 | - }; | |
| 1012 | - }); | |
| 1013 | - if(this.data.prom_type == 1 && tmpRedisNum == 0) { | |
| 1014 | - newd['prom_type'] = 0; | |
| 1015 | - newd['prom_price'] = this.data.data.shop_price; | |
| 1016 | - }; | |
| 1017 | 964 | |
| 1018 | 965 | // console.log('newd++++++++', newd); |
| 1019 | 966 | th.buyNow(newd); |
| 1020 | - } else { // 购物车 | |
| 967 | + } else { | |
| 968 | + | |
| 1021 | 969 | |
| 1022 | - // 购买数量大于0的才能加入到购物车 | |
| 1023 | - if (th.data.goodsInputNum <= 0) { | |
| 1024 | - th.closeSpecModal(); | |
| 1025 | - return false; | |
| 1026 | - } | |
| 1027 | - | |
| 970 | + | |
| 971 | + | |
| 1028 | 972 | var newd = { |
| 1029 | 973 | service_id: th.data.data.id, |
| 1030 | 974 | service_sn:th.data.data.service_sn, |
| ... | ... | @@ -1050,19 +994,7 @@ Page({ |
| 1050 | 994 | newd['money'] = th.data.prom_price; |
| 1051 | 995 | }; |
| 1052 | 996 | }; |
| 1053 | - | |
| 1054 | - // 判断是否为0库存的情况 | |
| 1055 | - var tmpRedisNum = 0; | |
| 1056 | - // 检查redis库存量 | |
| 1057 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/1/" + prom_id, {}).then(res => { | |
| 1058 | - if (res.data.code == 0) { | |
| 1059 | - tmpRedisNum = res.data.data; | |
| 1060 | - }; | |
| 1061 | - }); | |
| 1062 | - if(th.data.options.prom_type == 1 && tmpRedisNum == 0) { | |
| 1063 | - newd['prom_type'] = 0; | |
| 1064 | - newd['money'] = th.data.data.shop_price; | |
| 1065 | - }; | |
| 997 | + | |
| 1066 | 998 | |
| 1067 | 999 | //----先看会员在购物车中是否加入了该商品----- |
| 1068 | 1000 | getApp().request.get("/api/weshop/cartService/page", { |
| ... | ... | @@ -1159,142 +1091,121 @@ Page({ |
| 1159 | 1091 | }, |
| 1160 | 1092 | |
| 1161 | 1093 | //------检查数量是不是超出限购------ |
| 1162 | - checkCartNum: function(t) { | |
| 1094 | + checkCartNum: async function(t) { | |
| 1095 | + var th = this; | |
| 1163 | 1096 | |
| 1164 | - if(this.data.prom_type != 1) { | |
| 1165 | - this.setData({goodsInputNum: t}); | |
| 1166 | - return false; | |
| 1097 | + if(!th.data.def_pick_store) { | |
| 1098 | + wx.showModal({title: '请选择门店',}); | |
| 1099 | + return false; | |
| 1167 | 1100 | }; |
| 1168 | 1101 | |
| 1169 | - var th = this; | |
| 1170 | - | |
| 1171 | - // if(this.data.prom_act.is_shop_buy && this.data.options.prom_type != 1) { | |
| 1172 | - | |
| 1173 | - if(t == 0) return false; | |
| 1174 | - // th.setData({goodsInputNum:t}); | |
| 1102 | + // 非秒杀活动 | |
| 1103 | + if(this.data.prom_type != 1) { | |
| 1104 | + this.setData({ | |
| 1105 | + goodsInputNum: t, | |
| 1106 | + }); | |
| 1107 | + }; | |
| 1175 | 1108 | |
| 1176 | - // if(this.data.options.prom_type == 1 && !this.data.openSpecModal_flash_normal) { | |
| 1177 | - | |
| 1178 | - this.get_buy_num(this.data.sele_g, async function () { | |
| 1179 | - th.data.sele_g.viplimited = th.data.sele_g.buy_limit; | |
| 1180 | - | |
| 1181 | - //--判断商品是否超出限购-- | |
| 1182 | - // if (th.data.g_buy_num != null && th.data.sele_g.viplimited > 0) { | |
| 1183 | - // if(!th.data.prom_act.is_shop_buy) { | |
| 1184 | - | |
| 1185 | - // if (th.data.sele_g.viplimited > 0) { | |
| 1186 | - // var gd_buy_num = th.data.sele_g.buy_num; | |
| 1187 | - | |
| 1188 | - // if (t + gd_buy_num> th.data.sele_g.viplimited) { | |
| 1189 | - // wx.showModal({ | |
| 1190 | - // title: '超出商品限购', | |
| 1191 | - // }); | |
| 1192 | - | |
| 1193 | - // var num = th.data.sele_g.viplimited - gd_buy_num; | |
| 1194 | - // if (num <= 0) num = 1; | |
| 1195 | - // th.setData({goodsInputNum: num}) | |
| 1196 | - // return false; | |
| 1197 | - // } | |
| 1198 | - // }; | |
| 1199 | - | |
| 1200 | - | |
| 1201 | - // 单独购买 | |
| 1202 | - if(th.data.openSpecModal_flash_normal) th.data.is_normal = 1; | |
| 1203 | - | |
| 1204 | - // 秒杀:判断活动是否抢光 | |
| 1205 | - if (th.data.sele_g.prom_type == 1 && !th.data.is_normal) { | |
| 1206 | - var redis_num = 0; | |
| 1207 | - //------判断活动是否抢光----- | |
| 1208 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + | |
| 1209 | - os.stoid + "/" + th.data.sele_g.prom_type + "/" + th.data.sele_g.prom_id, { | |
| 1210 | - 1: 1 | |
| 1211 | - }).then(res => { | |
| 1212 | - redis_num = res.data.data; | |
| 1109 | + // 秒杀活动 | |
| 1110 | + if(this.data.prom_type == 1) { | |
| 1111 | + // 如果是秒杀活动下的单独购买,is_normal为1 | |
| 1112 | + if(this.data.openSpecModal_flash_normal) this.data.is_normal = 1; | |
| 1113 | + | |
| 1114 | + if(this.data.is_normal) {// 单独购买 | |
| 1115 | + this.setData({ | |
| 1116 | + goodsInputNum: t, | |
| 1117 | + }); | |
| 1118 | + } else {// 秒杀购买 | |
| 1119 | + | |
| 1120 | + // 获取redis当前可以购买的数量 | |
| 1121 | + // 如果数量为0,设置和显示已抢光 | |
| 1122 | + // 否则,进一步判断是否超出限购或超出库存 | |
| 1123 | + await this.getactLen().then(async function(res) { | |
| 1124 | + // res: redis可购买数量 | |
| 1125 | + console.log('当前可以购买的数量:', res); | |
| 1126 | + if(res <= 0) { | |
| 1127 | + // 可购买数量<=0, 设置和显示已抢光 | |
| 1128 | + th.setData({ | |
| 1129 | + prom_r_null: 1, | |
| 1130 | + }); | |
| 1131 | + } else { | |
| 1132 | + // 可购买数量>0 | |
| 1133 | + // 计算自己还可以购买的数量 | |
| 1134 | + // 自己还可购买的数量c = 每人活动限购数量a - 自己已经购买的数量b | |
| 1135 | + // 如果限购数量a>redis可购买数量d,当增加数量t>d, 提示超出库存 | |
| 1136 | + // 如果限购数量a<=redis可购买数量d, 当增加数量t>a,提示超出限购 | |
| 1137 | + let actInfo = th.data.sele_g; | |
| 1138 | + await th.get_buy_num2().then(function (data) { | |
| 1139 | + let limited = actInfo.buy_limit; // 限购数量a | |
| 1140 | + let promcardbuynum = data.data.data.promcardbuynum; | |
| 1141 | + let buyedNum = promcardbuynum; // 自己已经购买的数量b | |
| 1142 | + let canBuyNum = limited - buyedNum; // 自己还可购买的数量c | |
| 1143 | + | |
| 1144 | + if(canBuyNum <= 0) { | |
| 1145 | + canBuyNum = 0; | |
| 1146 | + }; | |
| 1147 | + | |
| 1148 | + if(limited > res) { | |
| 1149 | + if(t > res) { // t当前增减的数量 | |
| 1150 | + wx.showModal({ | |
| 1151 | + title: '超出活动库存', | |
| 1213 | 1152 | }); |
| 1214 | - | |
| 1215 | - if (t > redis_num) { | |
| 1216 | - wx.showToast({ | |
| 1217 | - // title: '超出商品活动库存', | |
| 1218 | - title: '超出活动库存', | |
| 1219 | - icon: 'none', | |
| 1220 | - }); | |
| 1221 | - th.setData({goodsInputNum: redis_num}) | |
| 1222 | - return false; | |
| 1223 | - } | |
| 1153 | + th.setData({ | |
| 1154 | + goodsInputNum: res, | |
| 1155 | + }); | |
| 1156 | + return false; | |
| 1224 | 1157 | }; |
| 1225 | - | |
| 1226 | - //--秒杀:判断商品是否超出活动限购-- | |
| 1227 | - if (th.data.sele_g.viplimited > 0 && !th.data.is_normal && th.data.prom_type == 1) { | |
| 1228 | - var gd_buy_num = th.data.promcardbuynum; | |
| 1229 | - | |
| 1230 | - // 如果限购数量>活动库存数量,增加数量时会先超过库存数量,此时应该提示“超出活动库存”; | |
| 1231 | - // 如果限购数量<=活动库存数量,增加数量时会先超过限购数量,此时应提示“超出活动限购数量” | |
| 1232 | - if(th.data.sele_g.viplimited > th.data.sele_g.goods_num) { | |
| 1233 | - | |
| 1234 | - // 计算还可以购买的数量:库存量 - 已购数 | |
| 1235 | - var num = th.data.sele_g.goods_num - gd_buy_num; | |
| 1236 | - if(num < 0) num = 0; | |
| 1237 | - if(t > num) { | |
| 1238 | - wx.showToast({ | |
| 1239 | - title: '超出活动库存', | |
| 1240 | - icon: 'none', | |
| 1241 | - }); | |
| 1242 | - | |
| 1243 | - th.setData({goodsInputNum: num}) | |
| 1244 | - return false; | |
| 1245 | - | |
| 1246 | - }; | |
| 1247 | - | |
| 1248 | - } else { | |
| 1249 | - if ((t + gd_buy_num> th.data.sele_g.viplimited) && (t<=th.data.sele_g.goods_num)) { | |
| 1250 | - wx.showToast({ | |
| 1251 | - title: '超出活动限购数量', | |
| 1252 | - icon: 'none', | |
| 1253 | - }); | |
| 1254 | - | |
| 1255 | - var num = th.data.sele_g.viplimited - gd_buy_num; | |
| 1256 | - if (num <= 0) num = 1; | |
| 1257 | - th.setData({goodsInputNum: num}) | |
| 1258 | - return false; | |
| 1259 | - }; | |
| 1260 | - }; | |
| 1261 | - | |
| 1262 | - | |
| 1263 | - | |
| 1158 | + }; | |
| 1159 | + | |
| 1160 | + if(limited <= res) { | |
| 1161 | + if(t>limited) { | |
| 1162 | + wx.showModal({ | |
| 1163 | + title: '超出限购数量', | |
| 1164 | + }); | |
| 1165 | + th.setData({ | |
| 1166 | + goodsInputNum: canBuyNum, | |
| 1167 | + }); | |
| 1168 | + return false; | |
| 1264 | 1169 | }; |
| 1265 | - | |
| 1266 | - //--秒杀:判断商品是否超出活动限购-- | |
| 1267 | - // if (th.data.prom_buy_num != -1 && th.data.prom_buy_limit > 0 && !th.data.is_normal) { | |
| 1268 | - // if (t + th.data.prom_buy_num > th.data.prom_buy_limit) { | |
| 1269 | - // wx.showModal({ | |
| 1270 | - // title: '超出商品活动限购', | |
| 1271 | - // }); | |
| 1170 | + }; | |
| 1171 | + | |
| 1172 | + th.setData({ | |
| 1173 | + goodsInputNum: t, | |
| 1174 | + }); | |
| 1175 | + }); | |
| 1176 | + }; | |
| 1177 | + }); | |
| 1272 | 1178 | |
| 1273 | - // var num = th.data.prom_buy_limit - th.data.prom_buy_num; | |
| 1274 | - // if (num < 0) num = 0; | |
| 1275 | - // th.setData({goodsInputNum: num}) | |
| 1276 | - // return false; | |
| 1277 | - // }; | |
| 1278 | - // }; | |
| 1179 | + } | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + }; | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1279 | 1189 | |
| 1280 | 1190 | |
| 1281 | 1191 | |
| 1282 | 1192 | |
| 1283 | 1193 | |
| 1284 | 1194 | // var e = th.data.sele_g.goods_num; |
| 1285 | - var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | |
| 1286 | - if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | |
| 1287 | - if (!th.data.def_pick_store) { | |
| 1288 | - wx.showModal({title: '请选择门店',}); | |
| 1289 | - return false; | |
| 1290 | - } else { | |
| 1291 | - // e = th.data.def_pick_store.CanOutQty; | |
| 1292 | - } | |
| 1293 | - } | |
| 1294 | - | |
| 1295 | - th.setData({goodsInputNum: t}); | |
| 1195 | + // var p_type = th.data.prom_type; //&& p_type!=1 && p_type!=4 | |
| 1196 | + // if (th.data.sales_rules == 2 && (p_type != 1 && p_type != 4 && p_type != 6 || th.data.openSpecModal_inte_normal == 1 || th.data.is_normal == 1)) { | |
| 1197 | + // if (!th.data.def_pick_store) { | |
| 1198 | + // wx.showModal({title: '请选择门店',}); | |
| 1199 | + // return false; | |
| 1200 | + // } else { | |
| 1201 | + // e = th.data.def_pick_store.CanOutQty; | |
| 1202 | + // } | |
| 1203 | + // } | |
| 1204 | + | |
| 1205 | + | |
| 1206 | + // th.setData({goodsInputNum: t}); | |
| 1296 | 1207 | |
| 1297 | - }); | |
| 1208 | + // }); | |
| 1298 | 1209 | |
| 1299 | 1210 | |
| 1300 | 1211 | }, |
| ... | ... | @@ -1326,12 +1237,10 @@ Page({ |
| 1326 | 1237 | return false; |
| 1327 | 1238 | } |
| 1328 | 1239 | |
| 1329 | - var ind = t.currentTarget.dataset.ind; | |
| 1330 | - | |
| 1240 | + var ind = t.currentTarget.dataset.ind; | |
| 1331 | 1241 | this.setData({ |
| 1332 | 1242 | openSpecModal: !0, |
| 1333 | - openSpecModal_ind: ind, | |
| 1334 | - goodsInputNum: 1, | |
| 1243 | + openSpecModal_ind: ind, | |
| 1335 | 1244 | }); |
| 1336 | 1245 | |
| 1337 | 1246 | }, |
| ... | ... | @@ -3288,19 +3197,18 @@ Page({ |
| 3288 | 3197 | |
| 3289 | 3198 | |
| 3290 | 3199 | //获取redis中的数量 |
| 3291 | - async getactLen(func) { | |
| 3292 | - var r_num = 0, | |
| 3293 | - prom_type = this.data.prom_type, | |
| 3294 | - prom_id = this.data.prom_id; | |
| 3295 | - await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | |
| 3200 | + async getactLen() { | |
| 3201 | + let prom_type = this.data.options.prom_type; | |
| 3202 | + let prom_id = this.data.options.prom_id; | |
| 3203 | + return await getApp().request.promiseGet("/api/weshop/activitylist/getActLen/" + os.stoid + "/" + prom_type + "/" + prom_id, { | |
| 3296 | 3204 | 1: 1 |
| 3297 | 3205 | }).then(res => { |
| 3298 | - var em = res; | |
| 3299 | - if (em.data.code == 0) { | |
| 3300 | - r_num = em.data.data; | |
| 3301 | - } | |
| 3206 | + if (res.data.code == 0) { | |
| 3207 | + // 当前可以购买的数量 | |
| 3208 | + let r_num = res.data.data; | |
| 3209 | + return r_num; | |
| 3210 | + }; | |
| 3302 | 3211 | }) |
| 3303 | - func(r_num); | |
| 3304 | 3212 | }, |
| 3305 | 3213 | |
| 3306 | 3214 | |
| ... | ... | @@ -3539,7 +3447,7 @@ Page({ |
| 3539 | 3447 | //----获取商品购买数---- |
| 3540 | 3448 | if (th.data.prom_type == 1) { |
| 3541 | 3449 | //----获取活动购买数---- |
| 3542 | - getApp().request.get("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
| 3450 | + getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
| 3543 | 3451 | data: { |
| 3544 | 3452 | store_id: os.stoid, |
| 3545 | 3453 | user_id: user_id, |
| ... | ... | @@ -3567,6 +3475,49 @@ Page({ |
| 3567 | 3475 | }, |
| 3568 | 3476 | |
| 3569 | 3477 | |
| 3478 | + get_buy_num2: async function () { | |
| 3479 | + // var map = this.data.g_buy_num, | |
| 3480 | + var th = this, | |
| 3481 | + user_id = getApp().globalData.user_id; | |
| 3482 | + // if (user_id == null) { | |
| 3483 | + // // map.set(gd.goods_id, 0); | |
| 3484 | + // th.setData({ | |
| 3485 | + // // g_buy_num: map, | |
| 3486 | + // prom_buy_num: 0, | |
| 3487 | + // }); | |
| 3488 | + // "function" == typeof func && func(); | |
| 3489 | + // return false; | |
| 3490 | + // } | |
| 3491 | + | |
| 3492 | + | |
| 3493 | + //----获取商品购买数---- | |
| 3494 | + | |
| 3495 | + //----获取活动购买数---- | |
| 3496 | + return await getApp().request.promiseGet("/api/weshop/rechargeServicelist/getUserBuyGoodsNum", { | |
| 3497 | + data: { | |
| 3498 | + store_id: os.stoid, | |
| 3499 | + user_id: user_id, | |
| 3500 | + card_id: th.data.options.goods_id, | |
| 3501 | + prom_type: th.data.options.prom_type, | |
| 3502 | + prom_id: th.data.options.prom_id | |
| 3503 | + }, | |
| 3504 | + //-----获取----- | |
| 3505 | + success: function (tt) { | |
| 3506 | + if (tt.data.code == 0) { | |
| 3507 | + // map.set(gd.goods_id, g_buy_num); | |
| 3508 | + th.setData({ | |
| 3509 | + // g_buy_num: map, | |
| 3510 | + promcardbuynum: tt.data.data.promcardbuynum, | |
| 3511 | + cardbuynum: tt.data.data.cardbuynum, | |
| 3512 | + }); | |
| 3513 | + } | |
| 3514 | + } | |
| 3515 | + }); | |
| 3516 | + | |
| 3517 | + | |
| 3518 | + }, | |
| 3519 | + | |
| 3520 | + | |
| 3570 | 3521 | |
| 3571 | 3522 | |
| 3572 | 3523 | ... | ... |