123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121 |
- export default {
-
- data(k,v){
- if(v === undefined){
- return getApp().globalData[k];
- }
- else{
- getApp().globalData[k] = v;
- }
- },
-
- localData(k,v){
- if(v === undefined){
- return uni.getStorageSync(k);
- }
- else if(v === null){
- uni.removeStorage({
- key: k,
- fail(err){
- console.log(err,'uni.removeStorage');
- }
- });
- }
- else {
- uni.setStorage({
- key: k,
- data: v,
- fail(){
- console.log(err,'uni.setStorage');
- }
- });
- }
- },
- domainUrl(){
- return getApp().globalData.http_url
- },
- staticUrl(){
- return getApp().globalData.static_url
- },
-
- staticChat(){
- return getApp().globalData.static_url + '/static/chat/';
- },
-
- staticCircle(){
- return getApp().globalData.static_url + '/static/circle/';
- },
-
- staticPhoto(){
- return getApp().globalData.static_url + '/static/photo/';
- },
-
- staticVideoImg(){
- return getApp().globalData.static_url + '/static/photo/video_gif/';
- },
-
- 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;
- },
-
- getDowndloadVedio(url,cb){
-
- return url;
-
- let _this = this;
- let key = 'VEDIO_URL_'+ url;
- let address = this.localData(key);
- console.log(address)
- if(address == undefined || address == null || !address){
- const downloadTask = uni.downloadFile({
- url: url,
- success: (res) => {
- if (res.statusCode === 200) {
- uni.saveFile({
- tempFilePath: res.tempFilePath,
- success: function(red) {
-
- address = red.savedFilePath
- _this.localData(key,address);
- if(cb)cb(address)
- }
- });
- }
- }
- });
- downloadTask.onProgressUpdate((res) => {
- console.log('下载进度' + res.progress);
- console.log('已经下载的数据长度' + res.totalBytesWritten);
- console.log('预期需要下载的数据总长度' + res.totalBytesExpectedToWrite);
- });
- }else {
- if(cb)cb(address);
- return address
- }
- }
- }
|