post.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <template>
  2. <view>
  3. <image style="width: 100%;" mode="widthFix" :src="config.index_post?config.index_post:''" show-menu-by-longpress="true"></image>
  4. </view>
  5. </template>
  6. <script>
  7. const app = getApp();
  8. const req = require("../../utils/request.js");
  9. export default {
  10. components: {},
  11. props: {},
  12. data() {
  13. return {
  14. systems: {},
  15. isTop:0,
  16. config:{}
  17. }
  18. },
  19. onLoad(options) {
  20. this.getConfig();
  21. },
  22. onShow() {
  23. },
  24. methods: {
  25. getConfig(){
  26. req.getRequest('/api/other/config',{},data=>{
  27. req.setStorage('configRes',JSON.stringify(data));
  28. this.config = data;
  29. })
  30. },
  31. },
  32. mounted() {
  33. const systemInfo = uni.getSystemInfoSync();
  34. // px转换到rpx的比例
  35. let pxToRpxScale = 750 / systemInfo.windowWidth;
  36. let systems = {
  37. ktxStatusHeight: systemInfo.statusBarHeight * pxToRpxScale, // 状态栏的高度
  38. navigationHeight: 44 * pxToRpxScale // 导航栏的高度
  39. };
  40. systems.barHeight = systems.ktxStatusHeight + systems.navigationHeight;
  41. this.systems = systems;
  42. },
  43. onPageScroll: function(e) {
  44. if (e.scrollTop > this.systems.barHeight) {
  45. this.isTop = 1;
  46. } else {
  47. this.isTop = 0;
  48. }
  49. }
  50. }
  51. </script>
  52. <style>
  53. @import "./post.css";
  54. </style>