移动端提前缓存城市数据,避免编辑地址时等待请求

pull/1/MERGE
hejinfu1026 2022-01-14 09:50:15 +08:00
parent f4e2327095
commit fc25cdfa02
2 changed files with 21 additions and 18 deletions

View File

@ -1,12 +1,12 @@
let domain = 'https://xxx.xxx' let domain = 'xxx.xxx'
module.exports = { module.exports = {
// 请求域名 格式: https://您的域名 // 请求域名 格式: https://您的域名
// #ifdef MP // #ifdef MP
HTTP_REQUEST_URL: domain, HTTP_REQUEST_URL: domain,
// #endif // #endif
HTTP_ADMIN_URL:'https://xxx.xxx.xxx', //PC后台的API请求地址上传图片用 HTTP_ADMIN_URL:'xxx.xxx.xxx', //PC后台的API请求地址上传图片用
// #ifdef H5 // #ifdef H5
//H5接口是浏览器地址 //H5接口是浏览器地址
// HTTP_REQUEST_URL: window.location.protocol+"//"+window.location.host, // HTTP_REQUEST_URL: window.location.protocol+"//"+window.location.host,

View File

@ -125,22 +125,12 @@
<script> <script>
let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px'; let sysHeight = uni.getSystemInfoSync().statusBarHeight + 'px';
import Cache from '@/utils/cache'; import Cache from '@/utils/cache';
import { import {BACK_URL} from '@/config/cache';
BACK_URL import {getMenuList} from '@/api/user.js';
} from '@/config/cache'; import {orderData} from '@/api/order.js';
import { import {toLogin} from '@/libs/login.js';
getMenuList import {getCity} from '@/api/api.js';
// setVisit import {mapGetters} from "vuex";
} from '@/api/user.js';
import {
orderData
} from '@/api/order.js';
import {
toLogin
} from '@/libs/login.js';
import {
mapGetters
} from "vuex";
// #ifdef H5 // #ifdef H5
import Auth from '@/libs/wechat'; import Auth from '@/libs/wechat';
// #endif // #endif
@ -218,6 +208,7 @@
that.$set(that, 'pageHeight', app.globalData.windowHeight); that.$set(that, 'pageHeight', app.globalData.windowHeight);
// #endif // #endif
that.$set(that, 'MyMenus', app.globalData.MyMenus); that.$set(that, 'MyMenus', app.globalData.MyMenus);
if (!this.$Cache.has('cityList')) this.getCityList();
if (that.isLogin == false) { if (that.isLogin == false) {
// #ifdef H5 // #ifdef H5
toLogin() toLogin()
@ -355,6 +346,18 @@
this.openAuto() this.openAuto()
// #endif // #endif
} }
},
//
getCityList: function() {
let that = this;
getCity().then(res => {
let oneDay = 24 * 3600 * 1000;
this.$Cache.setItem({
name: 'cityList',
value: res.data,
expires: oneDay * 7
}); //
})
} }
} }
} }