Toolbar.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  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="info.catalogRoot" @clickItem="item=>{taboneActive = item}" :hiddenHover="true" :active="taboneActive" :id="'rand11'" :subId="'rand111'">
  10. </tabList>
  11. <tabList v-if="childTab.length > 1" :list="childTab" :hiddenHover="true" @clickItem="item=>{tabtowActive = item}"
  12. :active="tabtowActive" :id="'subrand11'" :subId="'subrand111'">
  13. </tabList>
  14. <div class="pano-con clip-scroller">
  15. <ul ref="clip" v-if="scenes.length>0">
  16. <li
  17. v-for="(item, i) in scenes"
  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 iconedit_type_3d"
  25. :class="{ iconedit_type_panorama: item.type !== 'house' }"
  26. ></i>
  27. </div>
  28. <div class="img">
  29. <img v-if="item.icon" :src="item.icon+`?${Math.random()}`" 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 { mapGetters } from "vuex";
  45. import tabList from "@/components/tablist";
  46. let frame;
  47. let $scroll = null;
  48. export default {
  49. name: 'whatisthis',
  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. childTab:[],
  61. scenes:[],
  62. };
  63. },
  64. computed: {
  65. ...mapGetters({
  66. info: "info",
  67. })
  68. },
  69. methods: {
  70. undateScroll(){
  71. this.$nextTick(() => {
  72. if ($scroll == null) {
  73. $scroll = $(".clip-scroller")[0];
  74. frame = new PerfectScrollbar($scroll, {
  75. useBothWheelAxes: true,
  76. suppressScrollY: true,
  77. wheelSpeed: 0.8,
  78. });
  79. $($scroll).data("scrollbar", frame);
  80. }
  81. });
  82. },
  83. updateInfo(){
  84. let iidx = this.info.scenes.findIndex(item=>this.activeItem.sceneCode == item.sceneCode)
  85. if (iidx>-1) {
  86. this.info.scenes[iidx] = {
  87. ...this.activeItem
  88. }
  89. }
  90. this.$store.commit("SetInfo", this.info);
  91. }
  92. },
  93. created() {},
  94. watch: {
  95. taboneActive: {
  96. deep:true,
  97. handler: function (newVal,oldVal) {
  98. let temp = []
  99. newVal.children && newVal.children.forEach(item=>{
  100. this.info.catalogs.forEach(sub=>{
  101. if (item==sub.id) {
  102. temp.push(sub)
  103. }
  104. })
  105. })
  106. this.childTab = temp
  107. if (this.childTab.length == 1 || newVal!=oldVal) {
  108. this.tabtowActive = this.childTab[0]
  109. }
  110. },
  111. },
  112. tabtowActive: {
  113. immediate:true,
  114. handler: function (newVal) {
  115. if (!newVal) {
  116. this.tabtowActive = this.childTab[0]
  117. } else{
  118. let arr = this.info.scenes.filter(item=>{
  119. return newVal.id == item.category && item.type!='4dkk'
  120. })
  121. this.scenes = arr.sort((a,b)=>a.weight-b.weight)
  122. this.activeItem = this.scenes[0]
  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 = { children: [] };
  133. setTimeout(() => {
  134. this.taboneActive = this.info.catalogRoot[0] || { children: [] };
  135. this.loadList = false
  136. });
  137. }
  138. }
  139. }
  140. },
  141. activeItem: {
  142. handler: function(newVal) {
  143. this.$bus.emit("currentPcode", newVal);
  144. this.$store.commit("SetActiveItem", newVal || "");
  145. this.updateInfo()
  146. if (newVal) {
  147. this.$bus.emit("initView", newVal.icon||'');
  148. }
  149. },
  150. },
  151. type() {
  152. this.hasCheck = true;
  153. },
  154. },
  155. mounted() {
  156. this.undateScroll()
  157. this.$bus.on("setListThumb", (data) => {
  158. this.activeItem.icon = data.icon;
  159. this.activeItem.initVisual = JSON.stringify(data.initVisual);
  160. });
  161. this.$bus.on("canEdit", (data) => {
  162. this.canEdit = data;
  163. });
  164. this.$bus.on("scenesChange", ()=> {
  165. this.loadList = true;
  166. this.undateScroll()
  167. });
  168. },
  169. };
  170. </script>
  171. <style lang="less" scoped>
  172. .app-view-toolbar {
  173. background: green;
  174. a {
  175. color: #fff;
  176. text-decoration: none;
  177. }
  178. .clip-center {
  179. flex: 1;
  180. display: flex;
  181. overflow: hidden;
  182. flex-direction: column;
  183. padding-top: 10px;
  184. margin: 0 10px;
  185. .pano-con {
  186. width: 100%;
  187. padding: 0;
  188. background: none;
  189. > ul {
  190. flex-wrap: unset;
  191. display: inline-block;
  192. white-space: nowrap;
  193. > li {
  194. display: inline-block;
  195. height: 128px;
  196. width: 128px;
  197. margin-top: 0;
  198. margin-right: 0;
  199. cursor: pointer;
  200. &:first-of-type {
  201. margin-left: 0;
  202. }
  203. }
  204. }
  205. }
  206. .clip-scroller {
  207. width: 100%;
  208. height: 100%;
  209. position: relative;
  210. padding-right: 20px;
  211. }
  212. }
  213. .no-record{
  214. width: 100%;
  215. height: 100%;
  216. display: flex;
  217. align-items: center;
  218. justify-content: center;
  219. }
  220. }
  221. </style>