| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- <script>
- export default {
- onLaunch: function() {
- this.updateApp()
- this.cacheDict()
- },
- methods:{
- //更新版本
- updateApp(){
- //更新版本
- const updateManager = uni.getUpdateManager();
- updateManager.onCheckForUpdate(function (res) {
- // 请求完新版本信息的回调
- console.log("是否有新版本:",res.hasUpdate);
- });
- updateManager.onUpdateReady(function (res) {
- uni.showModal({
- title: '更新提示',
- content: '新版本已经准备好,是否重启应用?',
- success(res) {
- if (res.confirm) {
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- updateManager.applyUpdate();
- }
- }
- });
-
- });
- updateManager.onUpdateFailed(function (res) {
- // 新的版本下载失败
- });
- },
- //缓存字典的值
- async cacheDict(){
- let dictCacheData=this.$cache.get('dict')
- if (!this.$isEmpty(dictCacheData)) {
- return
- }
- //有效时间
- let validTime=1*24*60*60*3
-
- //车辆类型
- let carTypeList=[]
- //车辆性质
- let carPropertiesList=[]
- //燃油类别
- let fuelCategoryList=[]
-
- // 请求字典begin
- // let res1=await this.$api.dict('car_type')
- // res1.list.forEach((item)=>{
- // let tmp={
- // value:item.dictKey,
- // label:item.dictValue
- // }
- // carTypeList.push(tmp)
- // })
-
- // let res2=await this.$api.dict('car_properties')
- // res2.list.forEach((item)=>{
- // let tmp={
- // value:item.dictKey,
- // label:item.dictValue
- // }
- // carPropertiesList.push(tmp)
- // })
-
- // let res3=await this.$api.dict('fuel_category')
- // res3.list.forEach((item)=>{
- // let tmp={
- // value:item.dictKey,
- // label:item.dictValue
- // }
- // fuelCategoryList.push(tmp)
- // })
- // 请求字典end
-
- //缓存字典的值begin
- // let dict={
- // carTypeList,
- // carPropertiesList,
- // fuelCategoryList
- // }
- // this.$cache.put('dict',dict,validTime)
- //缓存字典的值end
- },
- }
- }
- </script>
- <style lang="scss">
- @import "./static/iconfont.css";
- @import "uview-ui/index.scss";
-
- @import "@/assets/colorui/main.css";
- @import "@/assets/colorui/icon.css";
- @import "@/assets/colorui/app.css";
- </style>
|