index.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <template>
  2. <view class="container body">
  3. <view class="info">
  4. <scroll-view scroll-y="true" class="scroll-view">
  5. <view class="list-scroll-view">
  6. <slot></slot>
  7. </view>
  8. </scroll-view>
  9. </view>
  10. <view class="foot" v-if="frameStyle&&frameStyle.useBar||false">
  11. <view class="list" v-for="(item,index) in list" :key="index" @tap="toPath(index,item)" v-if="item.is_use=='0'">
  12. <image class="image" :src="item.normal.length>0?item.normal[0].url:''" mode="" v-if="active!=index"></image>
  13. <image class="image" :src="item.active.length>0?item.active[0].url:''" mode="" v-else></image>
  14. <view class="name" :style="{color:active==index?frameStyle.barActive||'#FB1438':''}">{{item.name}}</view>
  15. </view>
  16. </view>
  17. </view>
  18. </template>
  19. <script>
  20. export default {
  21. props: {
  22. frameStyle: {
  23. type: Object
  24. }
  25. },
  26. data() {
  27. return {
  28. list: [],
  29. active: 0,
  30. };
  31. },
  32. created: function() {
  33. const that = this;
  34. // 强制更新
  35. that.forceUpdate();
  36. that.search()
  37. },
  38. methods: {
  39. search() {
  40. const that = this;
  41. let pages = getCurrentPages();
  42. let currentPage = pages[pages.length - 1];
  43. uni.getStorage({
  44. key: 'config',
  45. success: function(res) {
  46. if (res.data) {
  47. let bottom_menu = res.data.bottom_menu;
  48. let list = bottom_menu.list.sort((a, b) => {
  49. return a.sort - b.sort
  50. });
  51. that.$set(that, `list`, list);
  52. let data = list.find((i) => i.route == currentPage.route);
  53. if (data) {
  54. let index =
  55. list.findIndex((i) => i.route == currentPage.route);
  56. that.$set(that, `active`, index);
  57. }
  58. }
  59. },
  60. fail: function(err) {
  61. console.log(err);
  62. }
  63. })
  64. },
  65. toPath(index, item) {
  66. const that = this;
  67. that.$set(that, `active`, index);
  68. that.$emit('toPath', item)
  69. },
  70. // 强制更新
  71. forceUpdate() {
  72. // const updateManager = uni.getUpdateManager();
  73. // updateManager.onCheckForUpdate(function(res) {
  74. // // 请求完新版本信息的回调
  75. // console.log(res.hasUpdate);
  76. // console.log('3');
  77. // console.log('更新');
  78. // });
  79. // updateManager.onUpdateReady(function(res) {
  80. // uni.showModal({
  81. // title: '更新提示',
  82. // content: '新版本已经准备好,是否重启应用?',
  83. // success(res) {
  84. // if (res.confirm) {
  85. // console.log('2');
  86. // console.log('更新确定');
  87. // updateManager.applyUpdate();
  88. // }
  89. // }
  90. // });
  91. // });
  92. // updateManager.onUpdateFailed(function(res) {
  93. // console.log('1');
  94. // console.log('失败');
  95. // });
  96. }
  97. }
  98. }
  99. </script>
  100. <style lang="scss">
  101. .body {
  102. .info {
  103. position: relative;
  104. flex-grow: 1;
  105. }
  106. .foot {
  107. height: 8vh;
  108. overflow: hidden;
  109. background-color: var(--fffColor);
  110. display: flex;
  111. flex-direction: row;
  112. justify-content: space-around;
  113. border-top: 1px solid var(--f1Color);
  114. .list {
  115. padding: 1vw 0;
  116. text-align: center;
  117. .image {
  118. width: 7vw;
  119. height: 6vw;
  120. }
  121. .name {
  122. font-size: 12px;
  123. }
  124. }
  125. }
  126. }
  127. .scroll-view {
  128. position: absolute;
  129. top: 0;
  130. left: 0;
  131. right: 0;
  132. bottom: 0;
  133. .list-scroll-view {
  134. display: flex;
  135. flex-direction: column;
  136. }
  137. }
  138. </style>