Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var that = this;
var lists = this.carts;
var cartIds = [];
var left = [];
for (var i = 0; i < lists.length; i++) {
if (lists[i].isCheck) {
cartIds.push(lists[i].id);
} else {
left.push(lists[i]);
}
}
cartIds = cartIds.join();
if (cartIds == "") {
Toast("请选择要删除的购物车物品");
} else {
Dialog.confirm({
title: "提示",
message: "确认删除?"
})
.then(() => {
// on confirm
post("shop/api/delCart", {
ids: cartIds,
PHPSESSID: window.localStorage.getItem("PHPSESSID")
}).then(res => {
that.carts = left;
});
let delLen = cartIds.split(",").length;
let num = that.$store.state.cartShopNum;
let lastCartNum = num - delLen;
that.$store.commit("getCartShopNum", {
num: lastCartNum
onOrder() {
if (!this.addressInfo.name) {
return Toast(this.$t("m.strategies.address"));
}
Dialog.confirm({
message: this.$t("m.order.orderConfirm")
})
.then(() => {
this.addOrder("payed");
// on confirm
})
.catch(() => {
// on cancel
this.addOrder("paying");
});
},
async onDone() {
getCoupons () {
Dialog.confirm({
message: '开通绿卡,立享此券',
confirmButtonText: "开卡领券",
confirmButtonColor: '#60b86a'
}).then(() => {
// 跳转到开通会员界面
this.$router.push({ name: 'vipPay' });
}).catch(() => {
// on cancel
});
},
// 开通绿卡支付
logOut () {
Dialog.confirm({
message: this.$t('mine.loginInfo')
}).then(() => {
// on confirm
this.LOGIN_OUT();
Toast({
message: this.$t('mine.infoSuccess'),
duration: 800
});
this.$router.back();
}).catch(() => {
// on cancel
});
}
}
reduceGoods (goodsID, goodsNum) {
if (goodsNum > 1) {
// 3.1 通过goodsID减少商品
this.REDUCE_GOODS({
goodsID
});
} else if (goodsNum === 1) {
Dialog.confirm({
title: '温馨提示',
message: '确定删除该商品吗?'
}).then(() => {
// on confirm 确认删除
this.REDUCE_GOODS({ goodsID });
}).catch(() => {
// on cancel
});
}
},
// 4.增加商品数量 保证传递数据和 mutations 一致
showDialog() {
Dialog.confirm({
title: '标题',
message: '弹窗内容'
})
.then(() => {
// on confirm
})
.catch(() => {
// on cancel
})
},
showCustomDialog() {
// type: 'warning'
// }).then(() => {
// store.dispatch('FedLogOut').then(() => {
// location.reload() // 为了重新实例化vue-router对象 避免bug
// })
// })
// }
// TODO token 过期
// TODO 需要拿 refresh token 置换
if (code === 1002001011 // 访问令牌不存在
|| code === 1002001013 // 访问令牌已失效
|| code === 1002001017 // 刷新令牌不存在
|| code === 1002001018 // 刷新令牌已过期
|| code === 1002001019) { // 刷新令牌已失效
Dialog.confirm({
title: '系统提示',
message: res.message,
confirmButtonText: '重新登陆',
beforeClose: function (action, done) {
done();
if (action === 'confirm') {
// debugger;
// this.$router.push({ path: '/login' })
// TODO 跳转到登陆页.不是很优雅
location.replace('/#login');
location.reload();
}
}
});
} else if (code === 1002001012) { // 访问令牌已过期
return refreshToken(response);
signOut () {
Dialog.confirm({
title: '登出',
message: '确定要登出吗?'
}).then(() => {
cookie.remove('assent_token')
this.isSignIn = false
this.Toast('你已登出!')
}).catch(() => {
this.Toast('你已取消操作!')
});
}
}
onRemove(id, index) {
Dialog.confirm({
message: this.$t("m.message.deleteSure")
}).then(() => {
this.sureRemove(id, index);
});
},
onDelete() {
Dialog.confirm({
message: this.$t("message.deleteSure")
}).then(() => {
this.sureDelete();
});
},
onBackOther() {