|
@@ -240,7 +240,7 @@
|
|
|
* 扫码入库
|
|
|
*/
|
|
|
showPopups: function (item) {
|
|
|
- if(this.checkNum>=this.couponNum){
|
|
|
+ if (this.checkNum >= this.couponNum) {
|
|
|
api.toast({
|
|
|
msg: "最多使用" + this.couponNum + "张优惠券"
|
|
|
});
|
|
@@ -262,9 +262,6 @@
|
|
|
this.selectedData = item
|
|
|
this.$post(url, data, function (ret) {
|
|
|
if (ret.code == 0) {
|
|
|
- ret.data.map(function (e) {
|
|
|
- e.checked = false;
|
|
|
- })
|
|
|
_this.couponList = ret.data
|
|
|
}
|
|
|
})
|
|
@@ -272,15 +269,53 @@
|
|
|
selected: function (a) {
|
|
|
this.selectedData
|
|
|
var _this = this;
|
|
|
- this.store
|
|
|
- .filter(function (e) {
|
|
|
- return e.tirenumber == _this.selectedData.tirenumber
|
|
|
- })
|
|
|
- .forEach(function (e) {
|
|
|
- e.couponName = "-¥" + a.bonus;
|
|
|
- e.couponId = a.id;
|
|
|
- // e.checked=true
|
|
|
- })
|
|
|
+ if (a.checked == false && this.selectedData.couponId == "") {
|
|
|
+ var data = {
|
|
|
+ "id": a.id,
|
|
|
+ "status": 3,
|
|
|
+ "type": 'body',
|
|
|
+ "url": 'json'
|
|
|
+ }
|
|
|
+ this.store
|
|
|
+ .filter(function (e) {
|
|
|
+ return e.tirenumber == _this.selectedData.tirenumber
|
|
|
+ })
|
|
|
+ .forEach(function (e) {
|
|
|
+ e.couponName = "-¥" + a.bonus;
|
|
|
+ e.couponId = a.id;
|
|
|
+ })
|
|
|
+ } else if (a.checked == true && this.selectedData.couponId == a.id) {
|
|
|
+ var data = {
|
|
|
+ "id": a.id,
|
|
|
+ "status": 1,
|
|
|
+ "type": 'body',
|
|
|
+ "url": 'json'
|
|
|
+ }
|
|
|
+ this.store
|
|
|
+ .filter(function (e) {
|
|
|
+ return e.tirenumber == _this.selectedData.tirenumber
|
|
|
+ })
|
|
|
+ .forEach(function (e) {
|
|
|
+ e.couponName = "选择优惠券";
|
|
|
+ e.couponId = "";
|
|
|
+ })
|
|
|
+ } else if (a.checked == true && this.selectedData.couponId != a.id) {
|
|
|
+ api.toast({
|
|
|
+ msg: '此优惠券已被选中,请选择其它优惠券',
|
|
|
+ });
|
|
|
+ return
|
|
|
+ } else {
|
|
|
+ api.toast({
|
|
|
+ msg: '最多选一张',
|
|
|
+ });
|
|
|
+ return
|
|
|
+ }
|
|
|
+ var url = "Couponupdate",
|
|
|
+ _this = this;
|
|
|
+ this.$post(url, data, function (ret) {
|
|
|
+ if (ret.code == 0) {
|
|
|
+ }
|
|
|
+ })
|
|
|
this.checkNum = 0
|
|
|
this.store.map(function (cart, index) {
|
|
|
if (cart.couponName != "选择优惠券") {
|
|
@@ -338,7 +373,7 @@
|
|
|
},
|
|
|
mounted: function () {
|
|
|
this.init();
|
|
|
- }
|
|
|
+ },
|
|
|
})
|
|
|
}
|
|
|
</script>
|