app.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import {
  2. ApiModel
  3. } from "./utils/api";
  4. const _Http = new ApiModel();
  5. App({
  6. onLaunch() {
  7. /* 计算tabbar+iphone安全距离 tabbar页面+100rpx*/
  8. let safeAreaBottom = 0,
  9. capsule = wx.getMenuButtonBoundingClientRect(),
  10. height = 200,
  11. that = this;
  12. //获取轮播图
  13. this.getBanner();
  14. wx.getSystemInfo({
  15. success(res) {
  16. //计算底部安全距离高度
  17. safeAreaBottom += res.screenHeight - res.safeArea.bottom;
  18. //计算自定义导航的高度
  19. height = capsule.height + res.statusBarHeight + (capsule.top - res.statusBarHeight) + 8;
  20. that.globalData.safeAreaBottom = safeAreaBottom;
  21. //判断是否为平板
  22. if (res.model.slice(0, 4) == "iPad") return that.globalData.myNavBorHeight = height;
  23. that.globalData.myNavBorHeight = height * 2;
  24. }
  25. })
  26. },
  27. getBanner() {
  28. //轮播图
  29. _Http.basic({
  30. "classname": "publicmethod.bannermag.bannermag",
  31. "method": "query_bannerlocationlist",
  32. "content": {
  33. "siteid": "BWJ",
  34. "fclienttype": "MOBILE"
  35. }
  36. }).then(res => {
  37. if (res.msg != '成功') {
  38. this.globalData.count = this.globalData.count + 1;
  39. if (this.globalData.count > 3) this.getBanner();
  40. return;
  41. }
  42. this.globalData.bannerDataList = res.data;
  43. })
  44. },
  45. globalData: {
  46. myNavBorHeight: 0, //自定义头部导航高度
  47. safeAreaBottom: 0, //底部安全距离
  48. account_list: [], //用户列表
  49. bannerDataList: [], //轮播图列表
  50. servicehotline: '', //客服手机号
  51. msgFcount: "", //徽标数量
  52. count: 0, //banner 请求次数
  53. }
  54. })