12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- const storageKey = {
- userId: 'userId'
- }
- function saveStorage(key: any, value: any) {
- let promise = new Promise((resolve, reject) => {
- wx.setStorage({
- key: key,
- data: value,
- success(res) {
- resolve(res)
- },
- fail(res) {
- reject(res)
- }
- })
- })
- return promise;
- }
- function getStorage(key: any) {
- let promise = new Promise((resolve, reject) => {
- wx.getStorage({
- key: key,
- success(res) {
- resolve(res)
- },
- fail(res) {
- reject(res)
- }
- })
- })
- return promise;
- }
- export const storage = {
- storageKey,
- saveStorage: function (key: any, value: any) {
- return saveStorage(key, value);
- },
- getStorage: function (key: any) {
- return getStorage(key)
- }
- }
|