123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- export default {
-
- data(k,v){
-
- k=uni.getStorageSync('access_token')+'_'+k;
-
- if(v === undefined){
- return getApp().globalData[k];
- }
- else{
- getApp().globalData[k] = v;
- }
- },
-
- localData(k,v){
- k=uni.getStorageSync('access_token')+'_'+k;
-
- if(v === undefined){
- return uni.getStorageSync(k);
- }
- else if(v === null){
- uni.removeStorage({
- key: k,
- fail(){
- uni.showModal({
- content: '删除本地数据失败',
- });
- }
- });
- }
- else {
- uni.setStorage({
- key: k,
- data: v,
- fail(){
- uni.showModal({
- content: '本地数据设置失败,请检测storage存储',
- });
- }
- });
- }
- },
- cache(k){
- k=uni.getStorageSync('access_token')+'_'+k;
- return uni.getStorageSync(k);
- },
- addData(k,v){
- k=uni.getStorageSync('access_token')+'_'+k;
-
-
- let data=uni.getStorageSync(k);
-
- if(v!=undefined){
-
- if(!data){
- data=[];
- v.map(item=>{
- data.push(item);
- })
-
- }
- else {
- v.map(item=>{
- data.unshift(item);
- })
- }
- }
-
- let item11=[];
- data.map(item=>{
- if(item!=null) {
- var add=1;
- item11.map(item2=>{
- if(item2.id==item.id) {
- add=0;
- }
- })
- if(add==1)
- item11.push(item);
- }
-
- })
- item11.sort((a, b) => parseInt(b.time)- parseInt(a.time));
- uni.setStorageSync(k,item11);
- return item11;
-
- },
-
- staticChat(){
- return getApp().globalData.static_url + '/static/chat/';
- },
-
- staticCircle(){
- return getApp().globalData.static_url + '/static/circle/';
- },
-
- staticPhoto(){
- return getApp().globalData.static_url + '/static/photo/';
- },
-
- chatTipsNum(){
- let num = 0,
- chat_list = uni.getStorageSync('chat_list');
- if(chat_list){
- for(let value of chat_list){
- num += (value.no_reader_num * 1);
- }
- }
- return num;
- },
- }
|