设置缓存
handleShow (card) {
if (!this.form.activityEndTime) {
this.$message.error("请先选择活动结束时间");
return ;
} else if (this.selectTicket.length < 10){
this.$refs.dialog.show(null, this.form.activityEndTime);
} else {
this.$message.error("最多只能添加10张优惠券");
}
localStorage.setItem("activitySaved",JSON.stringify(this.form));
let test = JSON.parse(localStorage.activitySaved);
console.log(test);
},
通过特定页面进入读取缓存
beforeRouteEnter (from, to, next) {
next(vm => {
if (to.path.includes('/MarketingManage/Coupon/AddCoupon')) {
if (localStorage.getItem('activitySaved')){
vm.form = JSON.parse(localStorage.activitySaved);
console.log(2,vm.form.activityStartTime);
}
}
});
},
读取之后
return {
startPickerOptions: {
disabledDate (currentDate) {
console.log(2,_this.form.activityStartTime);
return _this.$moment().startOf('days').valueOf() > currentDate.getTime()
|| (_this.form.activityEndTime && currentDate.getTime() > _this.form.activityEndTime.getTime());
}
},
endPickerOptions: {
disabledDate (currentDate) {
return (_this.$moment().startOf('days').valueOf() + 86400000) > currentDate.getTime()
|| currentDate.getTime() <= _this.form.activityStartTime.getTime() - 86400000;
}
},
startTime: minutes >= 30 ? _this.$moment().add(1, 'hours').format('HH:00') : _this.$moment().format('HH:30'),
endTime: '00:00',
commitStatus: true
};
},
一只斗牛犬
相关分类