data.js 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import http from './http.js'
  2. import config from './config.js'
  3. export default {
  4. get_home_list(_this, data = {}, isLoading = false){
  5. if(uni.getStorageSync('list')){
  6. _this['list'] = uni.getStorageSync('list')
  7. _this['title'] = uni.getStorageSync('title')
  8. }else{
  9. http.Post(config.homeData, data, isLoading).then((res) => {
  10. // 数据
  11. let list = res['data']['data']
  12. // console.log(list)
  13. _this['list'] = list
  14. // 系统设置中的标题
  15. let titles = res['data']['config']
  16. _this.title[0] = titles.title
  17. _this.title[1] = titles.subtitle
  18. uni.setStorageSync('title',_this.title)
  19. uni.setStorageSync('list',list)
  20. }).catch(err=>{})
  21. }
  22. },
  23. check_data_update(_this, data = {}, isLoading = false){
  24. http.Post(config.checkDataUpdate, data, isLoading).then((res) => {
  25. _this['timeStr'] = res['data']['timeStr']
  26. if(uni.getStorageSync('timeStr') != _this['timeStr']){
  27. // 比对本地缓存与服务器缓存,不同则重新获取数据
  28. uni.setStorageSync('timeStr',_this['timeStr'])
  29. _this.clearCache()
  30. }
  31. }).catch(err=>{})
  32. }
  33. }