"use strict";var img=require("../../utils/imgbase64");Component({data:{storage:[],limitSize:0,currentSize:0,isShowManage:!1,addPopupClass:"",isShowMask:!1,isDeleteMode:!1,checkedStorage:[],addInfo:{key:"",value:"",title:"添加",disabled:!1},img:img},lifetimes:{created:function(){},attached:function(){this.componentInit()},detached:function(){}},methods:{componentInit:function(){this.setData({addInfo:{key:"",value:"",title:"添加",disabled:!1}}),this.getStorageInfo()},openDeleteMode:function(){this.setData({isDeleteMode:!0}),this.closeAll()},cancelDelete:function(){this.setData({isDeleteMode:!1})},showAddPopup:function(){this.setData({isShowManage:!1,addPopupClass:"add-dialog-active",addInfo:{key:"",value:"",title:"添加",disabled:!1}})},getStorageInfo:function(){var a=[],t=wx.getStorageInfoSync();this.setData({limitSize:t.limitSize}),this.setData({currentSize:t.currentSize}),t.keys.forEach(function(t){var e={key:t,value:wx.getStorageSync(t),isModify:!1,ischecked:!1};a.push(e)}),a=a.filter(function(t){return-1==["dokit-mocklist","dokit-tpllist"].indexOf(t.key)}),this.setData({storage:a})},closeAddPopup:function(){this.closeAll()},closeAll:function(){this.setData({isShowManage:!1,isShowMask:!1,addPopupClass:""})},openManageMeau:function(){this.setData({isShowManage:!0,isShowMask:!0})},clearStorage:function(){var e=this;this.data.checkedStorage.length&&wx.showModal({title:"提示",content:"确定删除选中内容？",success:function(t){t.confirm&&(e.data.checkedStorage.forEach(function(t){wx.removeStorageSync(t)}),e.componentInit())}})},clearAll:function(){var e=this;this.setData({isShowManage:!1}),wx.showModal({title:"提示",content:"确定要清除所有吗？",success:function(t){t.confirm&&(wx.getStorageInfoSync().keys.forEach(function(t){-1==["dokit-mocklist","dokit-tpllist"].indexOf(t)&&wx.removeStorageSync(t)}),e.componentInit());e.closeAll()}})},checkboxChange:function(t){this.setData({checkedStorage:t.detail.value})},modifyItemValue:function(t){this.setData({isShowMask:!0,addPopupClass:"add-dialog-active",addInfo:{key:t.currentTarget.dataset.key,value:t.currentTarget.dataset.value,title:"修改",disabled:!0}})},bingAddInfoKey:function(t){this.setData({"addInfo.key":t.detail.value})},bingAddInfoValue:function(t){this.setData({"addInfo.value":t.detail.value})},addStorage:function(){this.data.addInfo.key&&this.data.addInfo.value&&(wx.setStorageSync(this.data.addInfo.key,this.data.addInfo.value),this.componentInit()),this.closeAll()},onGoBack:function(){this.triggerEvent("toggle",{componentType:"dokit"})}}});