MIP.util.platform.start()
if(window.location.origin != 'https://m.happymh.com'){
MIP.setData({sys:{isHost:false}});
}
MIP.setData({"sys":{"linkType":"html"}})
var storage = MIP.util.customStorage(0);
var user = storage.get("_u");
var uBookcase = storage.get("_bc");
var uHistory = storage.get("_ht");
var bc_time = storage.get("_bc_time");
if(user !== null){
user = JSON.parse(user)
uBookcase = JSON.parse(uBookcase)
uHistory = JSON.parse(uHistory)
MIP.setData({"user":{"detail":user,"uHistory":uHistory ? uHistory : [],"uBookcase": uBookcase ? uBookcase : [],"bc_time":bc_time}});
}
MIP.watch('user.changeTime', function (newVal, oldVal) {
if(newVal !== 0){
var user = MIP.getData("user");
var detail = user.detail;
var bookcase = user.uBookcase;
var history = user.uHistory;
storage.set("_u",JSON.stringify(detail));
storage.set("_bc",JSON.stringify(bookcase));
storage.set("_ht",JSON.stringify(history));
storage.set("_bc_time",user.bc_time);
}
})
MIP.watch('user.action', function (newVal, oldVal) {
if(newVal === 'exit'){
var expireOld = new Date((new Date()).getTime() - 24 * 3600000 * 365);
var host = location.host;
var mainHost = host.replace('m.', '.');
document.cookie = "sf_token=; expires=" + expireOld+"; Path=/ ; domain="+mainHost;
document.cookie = "sf_token=; expires=" + expireOld+"; Path=/";
storage.clear();
}
})
MIP.watch('sys.toastMsg.visible', function (newVal, oldVal) {
var toastConfig = MIP.getData("sys.toastMsg");
if(newVal === true){
setTimeout(function(){
MIP.setData({sys:{toastMsg:{visible:false}}})
},toastConfig.timeout)
}
})