bottomSuspensionFrame.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <swiper class="box" :current-item-id="current" circular vertical disable-touch>
  3. <swiper-item class="swiper-item" item-id="index">
  4. <view class="item" v-for="item in index" :key="item.name"
  5. @click="item.name == showPageName ? update() : onClick('index', item.name)">
  6. <u-loading-icon v-if="item.loading" mode="circle" />
  7. <text v-else :style="{ fontWeight: item.name == showPageName ? 'bold' : 'normal' }">
  8. {{ item.name }}
  9. </text>
  10. </view>
  11. <image v-if="!sightseer" class="image" src="/static/c+selected.svg" mode="widthFix"
  12. @click="onClick('cloud', '工作台')" />
  13. </swiper-item>
  14. <swiper-item v-if="!sightseer" class="swiper-item" item-id="cloud">
  15. <image class="image" :src="showPageName == '工作台' ? '/static/c+unselected.svg' : '/static/c+selected.svg'"
  16. mode="widthFix" @click="onClick('cloud', '工作台')" />
  17. <block v-for="item in cloud" :key="item.name">
  18. <block v-if="item.name == '工作台'" />
  19. <view v-else class="item" @click="item.name == showPageName ? update() : onClick('cloud', item.name)">
  20. <u-loading-icon v-if="item.loading" mode="circle" />
  21. <text v-else :style="{ fontWeight: item.name == showPageName ? 'bold' : 'normal' }">
  22. {{ item.name }}
  23. </text>
  24. </view>
  25. </block>
  26. </swiper-item>
  27. </swiper>
  28. </template>
  29. <script>
  30. export default {
  31. data() {
  32. return {
  33. sightseer: true,
  34. current: "index",
  35. showPageName: "",
  36. indexLastPage: '',
  37. cloudLastPage: '',
  38. index: [{
  39. name: "首页"
  40. }, {
  41. name: "活动"
  42. }, {
  43. name: "案例"
  44. }, {
  45. name: "视频"
  46. }],
  47. cloud: [{
  48. name: "工作台"
  49. }, {
  50. name: "资料库"
  51. }, {
  52. name: "商学院"
  53. }, {
  54. name: "单品"
  55. }, {
  56. name: "首页"
  57. }],
  58. countDown: null,
  59. }
  60. },
  61. props: {
  62. onChange: {
  63. type: Function
  64. }
  65. },
  66. mounted() {
  67. this.init();
  68. // #ifdef !MP-WEIXIN
  69. this.onClick(this.$parent.$parent.swiperItemID, this.$parent.$parent.page)
  70. // #endif
  71. },
  72. methods: {
  73. init() {
  74. this.isInitializeLogin(render.bind(this))
  75. function render() {
  76. let sightseer = uni.getStorageSync('userMsg').usertype == 99;
  77. this.sightseer = sightseer;
  78. console.log('是否游客', sightseer)
  79. if (sightseer) this.index = this.index.concat({ name: "我的" })
  80. }
  81. },
  82. onClick(current, name, update = false, params = null) {
  83. if (name == '首页') current = 'index';
  84. const item = this[current].find(v => v.name == name),
  85. that = this;
  86. if (typeof item.loading != 'boolean' || update) {
  87. item.loading = true;
  88. update = true;
  89. }
  90. this[current + 'LastPage'] = name;
  91. this.current = current;
  92. this.showPageName = name;
  93. this.$emit("onChange", {
  94. current, name, update, callBack, params
  95. })
  96. function callBack(loading = false) {
  97. item.loading = loading;
  98. that[current] = JSON.parse(JSON.stringify(that[current]));
  99. }
  100. },
  101. update() {
  102. if (this.countDown) {
  103. this.onClick(this.current, this.showPageName, true)
  104. } else {
  105. this.countDown = setTimeout(() => {
  106. clearTimeout(this.countDown)
  107. this.countDown = null;
  108. }, 300)
  109. }
  110. },
  111. },
  112. }
  113. </script>
  114. <style lang="scss">
  115. .box {
  116. position: fixed;
  117. width: 355px;
  118. height: 50px;
  119. background: rgba(255, 255, 255, 0.95);
  120. box-shadow: 0px 0px 6px 1px rgba(0, 0, 0, 0.16);
  121. border-radius: 50px;
  122. left: 10px;
  123. bottom: 20px;
  124. z-index: 3;
  125. .swiper-item {
  126. display: flex;
  127. align-items: center;
  128. justify-content: space-between;
  129. width: 355px;
  130. height: 50px;
  131. padding: 0 30px;
  132. box-sizing: border-box;
  133. .item {
  134. font-family: Source Han Sans SC, Source Han Sans SC;
  135. font-size: 16px;
  136. color: #666666;
  137. padding: 10px;
  138. }
  139. .image {
  140. width: 40px;
  141. padding: 4px;
  142. }
  143. }
  144. }
  145. </style>