bottomSuspensionFrame.vue 4.5 KB

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