App.vue 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. <script>
  2. export default {
  3. onLaunch: function() {
  4. this.updateApp()
  5. this.cacheDict()
  6. },
  7. methods:{
  8. //更新版本
  9. updateApp(){
  10. //更新版本
  11. const updateManager = uni.getUpdateManager();
  12. updateManager.onCheckForUpdate(function (res) {
  13. // 请求完新版本信息的回调
  14. console.log("是否有新版本:",res.hasUpdate);
  15. });
  16. updateManager.onUpdateReady(function (res) {
  17. uni.showModal({
  18. title: '更新提示',
  19. content: '新版本已经准备好,是否重启应用?',
  20. success(res) {
  21. if (res.confirm) {
  22. // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
  23. updateManager.applyUpdate();
  24. }
  25. }
  26. });
  27. });
  28. updateManager.onUpdateFailed(function (res) {
  29. // 新的版本下载失败
  30. });
  31. },
  32. //缓存字典的值
  33. async cacheDict(){
  34. let dictCacheData=this.$cache.get('dict')
  35. if (!this.$isEmpty(dictCacheData)) {
  36. return
  37. }
  38. //有效时间
  39. let validTime=1*24*60*60*3
  40. //车辆类型
  41. let carTypeList=[]
  42. //车辆性质
  43. let carPropertiesList=[]
  44. //燃油类别
  45. let fuelCategoryList=[]
  46. // 请求字典begin
  47. // let res1=await this.$api.dict('car_type')
  48. // res1.list.forEach((item)=>{
  49. // let tmp={
  50. // value:item.dictKey,
  51. // label:item.dictValue
  52. // }
  53. // carTypeList.push(tmp)
  54. // })
  55. // let res2=await this.$api.dict('car_properties')
  56. // res2.list.forEach((item)=>{
  57. // let tmp={
  58. // value:item.dictKey,
  59. // label:item.dictValue
  60. // }
  61. // carPropertiesList.push(tmp)
  62. // })
  63. // let res3=await this.$api.dict('fuel_category')
  64. // res3.list.forEach((item)=>{
  65. // let tmp={
  66. // value:item.dictKey,
  67. // label:item.dictValue
  68. // }
  69. // fuelCategoryList.push(tmp)
  70. // })
  71. // 请求字典end
  72. //缓存字典的值begin
  73. // let dict={
  74. // carTypeList,
  75. // carPropertiesList,
  76. // fuelCategoryList
  77. // }
  78. // this.$cache.put('dict',dict,validTime)
  79. //缓存字典的值end
  80. },
  81. }
  82. }
  83. </script>
  84. <style lang="scss">
  85. @import "./static/iconfont.css";
  86. @import "uview-ui/index.scss";
  87. @import "@/assets/colorui/main.css";
  88. @import "@/assets/colorui/icon.css";
  89. @import "@/assets/colorui/app.css";
  90. </style>