/** * @Time 2019-12-12 * @Author Zhengjingyi * @Action 全局公共方法 */ import requestUrl from '@/services/config.env.js' const _Tools = { getComStorage:function(key){// 获取本地Storage return new Promise(function(resolve,reject) { uni.getStorage({ key: key, success: function (res){ resolve(res.data) }, fail: function(res){ reject(false) } }) }) }, setStorage:function(key,data){// 存储本地Storage return new Promise(function(resolve,reject) { uni.setStorage({ key: key, data:data, success: function (res){ } }) }) }, getStorage:function(){// 获取本地userInfo return new Promise(function(resolve,reject) { uni.getStorage({ key: 'userInfo', success: function (res){ resolve(res.data) }, fail: function(res){ reject(false) } }) }) }, getStorageAddressKey:function(){// 获取本地地址信息 return new Promise(function(resolve,reject) { uni.getStorage({ key: 'address_key', success: function (res){ resolve(res.data) } }) }) }, navigateTo:function(url){ //路由跳转:页面之间路由跳转 uni.navigateTo({ url:url }) }, redirectTo:function(url){ //路由跳转:关闭当前页跳转到新页面 uni.redirectTo({ url:url }) }, switchTabTo:function(url){ //路由跳转:底部 tab页 uni.switchTab({ url:url }) }, getWindowHeight:function(){ // 获取窗口高度 const {windowHeight, pixelRatio} = wx.getSystemInfoSync() return windowHeight }, adaptRichTextImg:function(res){ /** *@富文本实现图片自适应 *@style再添加自适应样式 */ const html = res.replace(/]*>/gi,function(match,capture){ let match1 = match.replace(/