Toolbar.vue 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <template>
  2. <div
  3. class="app-view-toolbar"
  4. :class="{ unable: !canEdit }"
  5. app-border
  6. dir-top
  7. >
  8. <div class="clip-center">
  9. <tabList :list='tablist' @clickItem="item=>{taboneActive = item}" :hiddenHover="true" :active="taboneActive" :id="'rand11'" :subId="'rand111'">
  10. </tabList>
  11. <tabList v-if="taboneActive.children.length > 0" :hiddenHover="true" :list='taboneActive.children' @clickItem="item=>{tabtowActive = item}"
  12. :active="tabtowActive" :id="'subrand111'" :subId="'subrand111'">
  13. </tabList>
  14. <div class="pano-con clip-scroller">
  15. <ul ref="clip" v-if="list.length>0">
  16. <li
  17. v-for="(item, i) in list"
  18. @click="activeItem = item"
  19. :class="{ 'li-active': item.sceneCode == activeItem.sceneCode }"
  20. :key="i"
  21. >
  22. <div class="typeli">
  23. <i
  24. class="iconfont iconscene_map_3d"
  25. :class="{ iconjump: item.type !== 'house' }"
  26. ></i>
  27. </div>
  28. <div class="img">
  29. <img :src="item.icon" alt="" />
  30. </div>
  31. <div class="ui-title">
  32. <span>{{ item.sceneTitle }}</span>
  33. </div>
  34. </li>
  35. </ul>
  36. <div class="no-record" v-else>
  37. 当前分组下暂无全景图
  38. </div>
  39. </div>
  40. </div>
  41. </div>
  42. </template>
  43. <script>
  44. import { getTabSceneList } from "@/api";
  45. import { mapGetters } from "vuex";
  46. import tabList from "@/components/tablist";
  47. let frame;
  48. let $scroll = null;
  49. export default {
  50. components: {tabList},
  51. data() {
  52. return {
  53. taboneActive: { children: [] },
  54. tabtowActive: "",
  55. type: "building",
  56. activeItem: "",
  57. canEdit: true,
  58. hasCheck: false,
  59. loadList:true
  60. };
  61. },
  62. computed: {
  63. ...mapGetters({
  64. vrlist: "vrlist",
  65. tablist:'tablist'
  66. }),
  67. list(){
  68. return this.vrlist.filter(item=>item.type!='4dkk')
  69. }
  70. },
  71. methods: {
  72. getTabSceneList(catalogId=null){
  73. if (!catalogId) {
  74. catalogId = this.taboneActive.children.length<=0 ? this.taboneActive.id : this.tabtowActive.id
  75. }
  76. getTabSceneList({catalogId},(data)=>{
  77. this.$store.commit("SetVrList", data.data||[]);
  78. })
  79. },
  80. handleType(item) {
  81. if (item.id == "house") {
  82. return this.$alert({
  83. content: "请在VR模型设置",
  84. });
  85. }
  86. this.type = item.id;
  87. }
  88. },
  89. created() {},
  90. watch: {
  91. taboneActive: {
  92. deep: true,
  93. handler: function (newVal) {
  94. if (newVal.children.length>0) {
  95. this.tabtowActive = newVal.children[0]
  96. }
  97. if (this.tabtowActive) {
  98. this.tabtowActive =
  99. newVal.children.find((item) => {
  100. return item.id == this.tabtowActive.id;
  101. }) || "";
  102. }
  103. if (newVal.id) {
  104. this.$emit("catalog", {
  105. level:1,
  106. data:newVal
  107. });
  108. if (newVal.children.length<=0) {
  109. this.getTabSceneList(newVal.id)
  110. }
  111. }
  112. }
  113. },
  114. tabtowActive: {
  115. deep: true,
  116. handler: function (newVal) {
  117. this.$emit("catalog", {
  118. level:2,
  119. data:newVal
  120. });
  121. if (newVal) {
  122. this.getTabSceneList(newVal.id)
  123. }
  124. },
  125. },
  126. '$route.meta.loadScene':{
  127. deep: true,
  128. immediate: true,
  129. handler: function (newVal) {
  130. if (newVal) {
  131. if (this.loadList) {
  132. this.taboneActive = this.tablist[0] || { children: [] };
  133. this.loadList = false
  134. }
  135. }
  136. }
  137. },
  138. list: {
  139. immediate: true,
  140. handler: function(newVal) {
  141. this.$nextTick(() => {
  142. if (!frame) {
  143. return;
  144. }
  145. frame.update();
  146. });
  147. this.activeItem = newVal[0]||''
  148. },
  149. },
  150. activeItem: {
  151. immediate: true,
  152. handler: function(newVal) {
  153. this.$bus.emit("currentPcode", newVal);
  154. this.$store.commit("SetActiveItem", newVal || "");
  155. if (newVal) {
  156. this.$bus.emit("initView", newVal.icon);
  157. }
  158. },
  159. },
  160. type() {
  161. this.hasCheck = true;
  162. },
  163. },
  164. mounted() {
  165. this.$nextTick(() => {
  166. if ($scroll == null) {
  167. $scroll = $(".clip-scroller")[0];
  168. frame = new PerfectScrollbar($scroll, {
  169. useBothWheelAxes: true,
  170. suppressScrollY: true,
  171. wheelSpeed: 0.8,
  172. });
  173. $($scroll).data("scrollbar", frame);
  174. }
  175. });
  176. this.$bus.on("setListThumb", (data) => {
  177. this.activeItem.icon = data.icon;
  178. this.activeItem.initVisual = JSON.stringify(data.initVisual);
  179. });
  180. this.$bus.on("canEdit", (data) => {
  181. this.canEdit = data;
  182. });
  183. },
  184. };
  185. </script>
  186. <style lang="less" scoped>
  187. .app-view-toolbar {
  188. overflow: visible;
  189. a {
  190. color: #fff;
  191. text-decoration: none;
  192. }
  193. .clip-center {
  194. flex: 1;
  195. display: flex;
  196. overflow: hidden;
  197. flex-direction: column;
  198. padding-top: 10px;
  199. margin: 0 10px;
  200. .pano-con {
  201. width: 100%;
  202. padding: 0;
  203. background: none;
  204. > ul {
  205. flex-wrap: unset;
  206. display: inline-block;
  207. white-space: nowrap;
  208. > li {
  209. display: inline-block;
  210. height: 128px;
  211. width: 128px;
  212. margin-top: 0;
  213. margin-right: 0;
  214. cursor: pointer;
  215. &:first-of-type {
  216. margin-left: 0;
  217. }
  218. }
  219. }
  220. }
  221. .clip-scroller {
  222. width: 100%;
  223. height: 100%;
  224. position: relative;
  225. padding-right: 20px;
  226. }
  227. }
  228. .no-record{
  229. width: 100%;
  230. height: 100%;
  231. display: flex;
  232. align-items: center;
  233. justify-content: center;
  234. }
  235. }
  236. .unable {
  237. &::before {
  238. content: "";
  239. z-index: 22;
  240. position: absolute;
  241. width: 100%;
  242. top: -10px;
  243. height: calc(100% + 10px);
  244. background: rgba(0, 0, 0, 0.4);
  245. }
  246. }
  247. </style>