存入数据
setStorage(dataType, data) {
let { gdc } = this.props.data;
let self = this;
let key = gdc.userId + "_" + gameName + "_" + dataType;
my.setStorage({
key: key,
data: data,
success: function (res) {//存入成功
console.log(res)
},
fail: function () {//存入失败
this.setStorage(type, data);
}
});
},
读取数据
getStorage(dataType) {
let { gdc } = this.props.data;
let key = gdc.userId + "_" + gameName + "_" + dataType;
let res = my.getStorageSync({ key: key });
if (res.data) {
return res.data;
} else {
return false;
}
},
删除数据
removeStorage(type) {
let { gdc } = this.props.data;
let dataType = type;
let key = gdc.userId + "_" + gameName + "_" + dataType;
my.removeStorageSync({
key: key,
success: function () {
console.log('删除成功!');
}
});
},