Showing
9 changed files
with
99 additions
and
36 deletions
| @@ -1011,15 +1011,22 @@ Page({ | @@ -1011,15 +1011,22 @@ Page({ | ||
| 1011 | couponArr.push(item) | 1011 | couponArr.push(item) |
| 1012 | } | 1012 | } |
| 1013 | if (item.id == id && couponArr.length > 0) { | 1013 | if (item.id == id && couponArr.length > 0) { |
| 1014 | - couponArr.forEach(item => { | 1014 | + couponArr.forEach((item,index) => { |
| 1015 | let match = obj.find(b => b.id === item.id); | 1015 | let match = obj.find(b => b.id === item.id); |
| 1016 | if (match) { | 1016 | if (match) { |
| 1017 | item.number = match.number; | 1017 | item.number = match.number; |
| 1018 | } | 1018 | } |
| 1019 | + item.grant_num = item.grant_num*1 | ||
| 1020 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 1021 | + if(item.number>item.grant_num){ | ||
| 1022 | + item.number = item.grant_num | ||
| 1023 | + } | ||
| 1019 | }); | 1024 | }); |
| 1020 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 1021 | - this.setcouponFun(couponArr) | ||
| 1022 | - this.couponModal.showModal() | 1025 | + if(couponArr.length>0){ |
| 1026 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 1027 | + this.setcouponFun(couponArr) | ||
| 1028 | + this.couponModal.showModal() | ||
| 1029 | + } | ||
| 1023 | } | 1030 | } |
| 1024 | console.log('未领取的券列表-----------', couponArr); | 1031 | console.log('未领取的券列表-----------', couponArr); |
| 1025 | this.setData({ | 1032 | this.setData({ |
| @@ -966,15 +966,22 @@ Page({ | @@ -966,15 +966,22 @@ Page({ | ||
| 966 | couponArr.push(item) | 966 | couponArr.push(item) |
| 967 | } | 967 | } |
| 968 | if (item.id == id && couponArr.length > 0) { | 968 | if (item.id == id && couponArr.length > 0) { |
| 969 | - couponArr.forEach(item => { | 969 | + couponArr.forEach((item,index) => { |
| 970 | let match = obj.find(b => b.id === item.id); | 970 | let match = obj.find(b => b.id === item.id); |
| 971 | if (match) { | 971 | if (match) { |
| 972 | item.number = match.number; | 972 | item.number = match.number; |
| 973 | } | 973 | } |
| 974 | + item.grant_num = item.grant_num*1 | ||
| 975 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 976 | + if(item.number>item.grant_num){ | ||
| 977 | + item.number = item.grant_num | ||
| 978 | + } | ||
| 974 | }); | 979 | }); |
| 975 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 976 | - this.setcouponFun(couponArr) | ||
| 977 | - this.couponModal.showModal() | 980 | + if(couponArr.length>0){ |
| 981 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 982 | + this.setcouponFun(couponArr) | ||
| 983 | + this.couponModal.showModal() | ||
| 984 | + } | ||
| 978 | } | 985 | } |
| 979 | console.log('未领取的券列表-----------', couponArr); | 986 | console.log('未领取的券列表-----------', couponArr); |
| 980 | this.setData({ | 987 | this.setData({ |
| @@ -966,15 +966,22 @@ Page({ | @@ -966,15 +966,22 @@ Page({ | ||
| 966 | couponArr.push(item) | 966 | couponArr.push(item) |
| 967 | } | 967 | } |
| 968 | if (item.id == id && couponArr.length > 0) { | 968 | if (item.id == id && couponArr.length > 0) { |
| 969 | - couponArr.forEach(item => { | 969 | + couponArr.forEach((item,index) => { |
| 970 | let match = obj.find(b => b.id === item.id); | 970 | let match = obj.find(b => b.id === item.id); |
| 971 | if (match) { | 971 | if (match) { |
| 972 | item.number = match.number; | 972 | item.number = match.number; |
| 973 | } | 973 | } |
| 974 | + item.grant_num = item.grant_num*1 | ||
| 975 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 976 | + if(item.number>item.grant_num){ | ||
| 977 | + item.number = item.grant_num | ||
| 978 | + } | ||
| 974 | }); | 979 | }); |
| 975 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 976 | - this.setcouponFun(couponArr) | ||
| 977 | - this.couponModal.showModal() | 980 | + if(couponArr.length>0){ |
| 981 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 982 | + this.setcouponFun(couponArr) | ||
| 983 | + this.couponModal.showModal() | ||
| 984 | + } | ||
| 978 | } | 985 | } |
| 979 | console.log('未领取的券列表-----------', couponArr); | 986 | console.log('未领取的券列表-----------', couponArr); |
| 980 | this.setData({ | 987 | this.setData({ |
| @@ -965,15 +965,22 @@ Page({ | @@ -965,15 +965,22 @@ Page({ | ||
| 965 | couponArr.push(item) | 965 | couponArr.push(item) |
| 966 | } | 966 | } |
| 967 | if (item.id == id && couponArr.length > 0) { | 967 | if (item.id == id && couponArr.length > 0) { |
| 968 | - couponArr.forEach(item => { | 968 | + couponArr.forEach((item,index) => { |
| 969 | let match = obj.find(b => b.id === item.id); | 969 | let match = obj.find(b => b.id === item.id); |
| 970 | if (match) { | 970 | if (match) { |
| 971 | item.number = match.number; | 971 | item.number = match.number; |
| 972 | } | 972 | } |
| 973 | + item.grant_num = item.grant_num*1 | ||
| 974 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 975 | + if(item.number>item.grant_num){ | ||
| 976 | + item.number = item.grant_num | ||
| 977 | + } | ||
| 973 | }); | 978 | }); |
| 974 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 975 | - this.setcouponFun(couponArr) | ||
| 976 | - this.couponModal.showModal() | 979 | + if(couponArr.length>0){ |
| 980 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 981 | + this.setcouponFun(couponArr) | ||
| 982 | + this.couponModal.showModal() | ||
| 983 | + } | ||
| 977 | } | 984 | } |
| 978 | console.log('未领取的券列表-----------', couponArr); | 985 | console.log('未领取的券列表-----------', couponArr); |
| 979 | this.setData({ | 986 | this.setData({ |
| @@ -922,15 +922,22 @@ Page({ | @@ -922,15 +922,22 @@ Page({ | ||
| 922 | couponArr.push(item) | 922 | couponArr.push(item) |
| 923 | } | 923 | } |
| 924 | if (item.id == id && couponArr.length > 0) { | 924 | if (item.id == id && couponArr.length > 0) { |
| 925 | - couponArr.forEach(item => { | 925 | + couponArr.forEach((item,index) => { |
| 926 | let match = obj.find(b => b.id === item.id); | 926 | let match = obj.find(b => b.id === item.id); |
| 927 | if (match) { | 927 | if (match) { |
| 928 | item.number = match.number; | 928 | item.number = match.number; |
| 929 | } | 929 | } |
| 930 | + item.grant_num = item.grant_num*1 | ||
| 931 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 932 | + if(item.number>item.grant_num){ | ||
| 933 | + item.number = item.grant_num | ||
| 934 | + } | ||
| 930 | }); | 935 | }); |
| 931 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 932 | - this.setcouponFun(couponArr) | ||
| 933 | - this.couponModal.showModal() | 936 | + if(couponArr.length>0){ |
| 937 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 938 | + this.setcouponFun(couponArr) | ||
| 939 | + this.couponModal.showModal() | ||
| 940 | + } | ||
| 934 | } | 941 | } |
| 935 | console.log('未领取的券列表-----------', couponArr); | 942 | console.log('未领取的券列表-----------', couponArr); |
| 936 | this.setData({ | 943 | this.setData({ |
| @@ -966,15 +966,22 @@ Page({ | @@ -966,15 +966,22 @@ Page({ | ||
| 966 | couponArr.push(item) | 966 | couponArr.push(item) |
| 967 | } | 967 | } |
| 968 | if (item.id == id && couponArr.length > 0) { | 968 | if (item.id == id && couponArr.length > 0) { |
| 969 | - couponArr.forEach(item => { | 969 | + couponArr.forEach((item,index) => { |
| 970 | let match = obj.find(b => b.id === item.id); | 970 | let match = obj.find(b => b.id === item.id); |
| 971 | if (match) { | 971 | if (match) { |
| 972 | item.number = match.number; | 972 | item.number = match.number; |
| 973 | } | 973 | } |
| 974 | + item.grant_num = item.grant_num*1 | ||
| 975 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 976 | + if(item.number>item.grant_num){ | ||
| 977 | + item.number = item.grant_num | ||
| 978 | + } | ||
| 974 | }); | 979 | }); |
| 975 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 976 | - this.setcouponFun(couponArr) | ||
| 977 | - this.couponModal.showModal() | 980 | + if(couponArr.length>0){ |
| 981 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 982 | + this.setcouponFun(couponArr) | ||
| 983 | + this.couponModal.showModal() | ||
| 984 | + } | ||
| 978 | } | 985 | } |
| 979 | console.log('未领取的券列表-----------', couponArr); | 986 | console.log('未领取的券列表-----------', couponArr); |
| 980 | this.setData({ | 987 | this.setData({ |
| @@ -965,15 +965,22 @@ Page({ | @@ -965,15 +965,22 @@ Page({ | ||
| 965 | couponArr.push(item) | 965 | couponArr.push(item) |
| 966 | } | 966 | } |
| 967 | if (item.id == id && couponArr.length > 0) { | 967 | if (item.id == id && couponArr.length > 0) { |
| 968 | - couponArr.forEach(item => { | 968 | + couponArr.forEach((item,index) => { |
| 969 | let match = obj.find(b => b.id === item.id); | 969 | let match = obj.find(b => b.id === item.id); |
| 970 | if (match) { | 970 | if (match) { |
| 971 | item.number = match.number; | 971 | item.number = match.number; |
| 972 | } | 972 | } |
| 973 | + item.grant_num = item.grant_num*1 | ||
| 974 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 975 | + if(item.number>item.grant_num){ | ||
| 976 | + item.number = item.grant_num | ||
| 977 | + } | ||
| 973 | }); | 978 | }); |
| 974 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 975 | - this.setcouponFun(couponArr) | ||
| 976 | - this.couponModal.showModal() | 979 | + if(couponArr.length>0){ |
| 980 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 981 | + this.setcouponFun(couponArr) | ||
| 982 | + this.couponModal.showModal() | ||
| 983 | + } | ||
| 977 | } | 984 | } |
| 978 | console.log('未领取的券列表-----------', couponArr); | 985 | console.log('未领取的券列表-----------', couponArr); |
| 979 | this.setData({ | 986 | this.setData({ |
| @@ -999,15 +999,22 @@ Page({ | @@ -999,15 +999,22 @@ Page({ | ||
| 999 | couponArr.push(item) | 999 | couponArr.push(item) |
| 1000 | } | 1000 | } |
| 1001 | if (item.id == id && couponArr.length > 0) { | 1001 | if (item.id == id && couponArr.length > 0) { |
| 1002 | - couponArr.forEach(item => { | 1002 | + couponArr.forEach((item,index) => { |
| 1003 | let match = obj.find(b => b.id === item.id); | 1003 | let match = obj.find(b => b.id === item.id); |
| 1004 | if (match) { | 1004 | if (match) { |
| 1005 | item.number = match.number; | 1005 | item.number = match.number; |
| 1006 | } | 1006 | } |
| 1007 | + item.grant_num = item.grant_num*1 | ||
| 1008 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 1009 | + if(item.number>item.grant_num){ | ||
| 1010 | + item.number = item.grant_num | ||
| 1011 | + } | ||
| 1007 | }); | 1012 | }); |
| 1008 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 1009 | - this.setcouponFun(couponArr) | ||
| 1010 | - this.couponModal.showModal() | 1013 | + if(couponArr.length>0){ |
| 1014 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 1015 | + this.setcouponFun(couponArr) | ||
| 1016 | + this.couponModal.showModal() | ||
| 1017 | + } | ||
| 1011 | } | 1018 | } |
| 1012 | console.log('未领取的券列表-----------', couponArr); | 1019 | console.log('未领取的券列表-----------', couponArr); |
| 1013 | this.setData({ | 1020 | this.setData({ |
| @@ -352,15 +352,22 @@ Page({ | @@ -352,15 +352,22 @@ Page({ | ||
| 352 | couponArr.push(item) | 352 | couponArr.push(item) |
| 353 | } | 353 | } |
| 354 | if (item.id == id && couponArr.length > 0) { | 354 | if (item.id == id && couponArr.length > 0) { |
| 355 | - couponArr.forEach(item => { | 355 | + couponArr.forEach((item,index) => { |
| 356 | let match = obj.find(b => b.id === item.id); | 356 | let match = obj.find(b => b.id === item.id); |
| 357 | if (match) { | 357 | if (match) { |
| 358 | item.number = match.number; | 358 | item.number = match.number; |
| 359 | } | 359 | } |
| 360 | + item.grant_num = item.grant_num*1 | ||
| 361 | + if(item.grant_num < 0 || item.grant_num == 0) couponArr.splice(index,1) | ||
| 362 | + if(item.number>item.grant_num){ | ||
| 363 | + item.number = item.grant_num | ||
| 364 | + } | ||
| 360 | }); | 365 | }); |
| 361 | - totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 362 | - this.setcouponFun(couponArr) | ||
| 363 | - this.couponModal.showModal() | 366 | + if(couponArr.length>0){ |
| 367 | + totalPrice = couponArr.reduce((sum, item) => sum + item.price * item.number, 0); | ||
| 368 | + this.setcouponFun(couponArr) | ||
| 369 | + this.couponModal.showModal() | ||
| 370 | + } | ||
| 364 | } | 371 | } |
| 365 | console.log('未领取的券列表-----------', couponArr); | 372 | console.log('未领取的券列表-----------', couponArr); |
| 366 | this.setData({ | 373 | this.setData({ |
-
Please register or login to post a comment