menu.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. <template>
  2. <div class="raside">
  3. <vsearch @isshowSearch="handleShowSearch" />
  4. <div v-show="!showsearch">
  5. <rmenu :tourStatus="tourStatus" @play="toggle" />
  6. <div class="smenu">
  7. <template>
  8. <ul>
  9. <li v-for="(item, i) in menu" :key="i">
  10. <div @click="onClick(item)">
  11. <div
  12. :title="item.name"
  13. :class="{ iactive: currentActive.id == item.id }"
  14. :style="{ backgroundImage: `url(${require(`@/assets/images/proj2022/xueliezhen/${item.id}.png`)})` }"
  15. ></div>
  16. <span>{{ item.name }}</span>
  17. </div>
  18. </li>
  19. </ul>
  20. </template>
  21. <transition name="likeAddAnimate">
  22. <div class="good" v-show="isShowGood">
  23. <div class="num">+{{ 1 }}</div>
  24. </div>
  25. </transition>
  26. </div>
  27. </div>
  28. </div>
  29. </template>
  30. <script>
  31. import { supCount, getsupCount } from "@/config/api";
  32. import vsearch from "./raside/search.vue";
  33. import rmenu from "./raside/rmenu.vue";
  34. import { Booth } from "@/data/booth.js";
  35. import { g_findCloseNum } from "@/utils/index.js";
  36. let findNextItem = (arr, currentItem) => {
  37. let idx = arr.findIndex((item) => item == currentItem);
  38. if (idx == arr.length - 1) {
  39. idx = 0;
  40. } else {
  41. idx += 1;
  42. }
  43. return arr[idx];
  44. };
  45. let findPrevItem = (arr, currentItem) => {
  46. let idx = arr.findIndex((item) => item == currentItem);
  47. if (idx == 0) {
  48. idx = arr.length - 1;
  49. } else {
  50. idx -= 1;
  51. }
  52. return arr[idx];
  53. };
  54. let menu = [
  55. {
  56. id: "like",
  57. maidiancode: "p_func1",
  58. name: "点赞",
  59. },
  60. {
  61. id: "message",
  62. name: "留言",
  63. maidiancode: "p_func2",
  64. cp: "vcontent",
  65. },
  66. {
  67. id: "share",
  68. name: "分享",
  69. maidiancode: "p_func3",
  70. cp: "qrcode",
  71. },
  72. {
  73. id: "clear",
  74. name: "清屏",
  75. },
  76. ];
  77. export default {
  78. props: ["tourStatus", "currentPanoid"],
  79. data() {
  80. return {
  81. menu,
  82. goodNum: 1099,
  83. isShowGood: false,
  84. showsearch: false,
  85. isShowZX: true,
  86. currentActive: {},
  87. flying: false,
  88. };
  89. },
  90. components: { vsearch, rmenu },
  91. computed: {
  92. nextZhanXiang() {
  93. let zhanqu = Booth.find((item) => item.id === this.theme);
  94. let panoArr = zhanqu.company.map((item) => item.panoId);
  95. let currentIdx = panoArr.indexOf(this.currentPanoid);
  96. let nextPanoItem = "";
  97. if (currentIdx > -1) {
  98. if (currentIdx == panoArr.length - 1) {
  99. zhanqu = findNextItem(Booth, zhanqu);
  100. nextPanoItem = zhanqu.company[0];
  101. } else {
  102. currentIdx += 1;
  103. nextPanoItem = zhanqu.company[currentIdx];
  104. }
  105. } else {
  106. let ttt = g_findCloseNum(
  107. zhanqu.company.map((item) => item.panoId),
  108. this.currentPanoid
  109. );
  110. nextPanoItem = zhanqu.company.find((item) => item.panoId == ttt);
  111. }
  112. return nextPanoItem;
  113. },
  114. prevZhanXiang() {
  115. let zhanqu = Booth.find((item) => item.id === this.theme);
  116. let panoArr = zhanqu.company.map((item) => item.panoId);
  117. let currentIdx = panoArr.indexOf(this.currentPanoid);
  118. let prevPanoItem = "";
  119. if (currentIdx > -1) {
  120. if (currentIdx == 0) {
  121. zhanqu = findPrevItem(Booth, zhanqu);
  122. prevPanoItem = zhanqu.company[zhanqu.company.length - 1];
  123. } else {
  124. currentIdx -= 1;
  125. prevPanoItem = zhanqu.company[currentIdx];
  126. }
  127. } else {
  128. let ttt = g_findCloseNum(
  129. zhanqu.company.map((item) => item.panoId),
  130. this.currentPanoid
  131. );
  132. prevPanoItem = zhanqu.company.find((item) => item.panoId == ttt);
  133. }
  134. return prevPanoItem;
  135. },
  136. },
  137. methods: {
  138. handleShowSearch(data) {
  139. this.showsearch = data;
  140. },
  141. onClick(item) {
  142. this.currentActive = item;
  143. item.maidiancode &&
  144. window.goldlog.record(`/spec.1.1`, "", `snsScene=${item.maidiancode}&product=pcweb&pagename=中国网络文明建设成果展云展示`, "");
  145. setTimeout(() => {
  146. this.currentActive = {};
  147. }, 1000);
  148. if (item.id == "clear") {
  149. this.$bus.$emit("toggleClear", true);
  150. document.querySelector("#ifr").contentWindow.postMessage(
  151. {
  152. source: "toggleClear",
  153. data: true,
  154. },
  155. "*"
  156. );
  157. return;
  158. }
  159. item.path && this.$router.push(item.path);
  160. item.cp && this.$emit("opencp", item.cp);
  161. if (item.id == "like") {
  162. this.dianzan();
  163. }
  164. },
  165. onClickNavigate(type) {
  166. if (document.querySelector("#ifr").contentWindow.player.flying) {
  167. return;
  168. }
  169. if (type == "up") {
  170. this.$bus.$emit("ifrMessage", {
  171. events: "flyToPano",
  172. data: this.nextZhanXiang,
  173. });
  174. } else {
  175. this.$bus.$emit("ifrMessage", {
  176. events: "flyToPano",
  177. data: this.prevZhanXiang,
  178. });
  179. }
  180. },
  181. dianzan() {
  182. if (this.isShowGood) return;
  183. // getsupCount((res) => {
  184. // console.log(111111,res);
  185. // this.goodNum = Number(this.goodNum ? this.goodNum : (res.voteNum || 0) );
  186. this.isShowGood = true;
  187. setTimeout(() => {
  188. this.isShowGood = false;
  189. }, 2500);
  190. supCount(() => {});
  191. // });
  192. },
  193. toggle() {
  194. let fn = this.tourStatus ? "stopTour" : "startAndPlay";
  195. this.$bus.$emit("ifrMessage", {
  196. events: "toggleTour",
  197. data: fn,
  198. });
  199. },
  200. },
  201. mounted() {
  202. this.$bus.$on("toggleShowZX", (data) => {
  203. this.isShowZX = data;
  204. });
  205. this.$bus.$on("resetMenuActive", () => {
  206. this.currentActive = {};
  207. });
  208. },
  209. };
  210. </script>
  211. <style lang="less" scoped>
  212. .raside {
  213. position: fixed;
  214. top: 170px;
  215. right: 0;
  216. z-index: 999;
  217. height: 100%;
  218. display: flex;
  219. flex-direction: column;
  220. align-items: flex-end;
  221. .smenu {
  222. bottom: 22px;
  223. left: 0;
  224. position: fixed;
  225. transition: 0.3s ease all;
  226. width: 100%;
  227. .fandb {
  228. border-radius: 60px;
  229. width: 285px;
  230. height: 45px;
  231. position: absolute;
  232. left: 50%;
  233. bottom: 0;
  234. transform: translateX(-50%);
  235. border-radius: 31px;
  236. backdrop-filter: blur(6px);
  237. display: flex;
  238. justify-content: center;
  239. align-items: center;
  240. .line {
  241. display: inline-block;
  242. width: 1px;
  243. height: 45px;
  244. background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, #ffffff 48%, rgba(255, 255, 255, 0.5) 100%);
  245. }
  246. > div {
  247. display: flex;
  248. cursor: pointer;
  249. width: 49%;
  250. justify-content: center;
  251. align-items: center;
  252. cursor: pointer;
  253. }
  254. }
  255. > ul {
  256. background-repeat: no-repeat;
  257. background-size: 100% 100%;
  258. display: flex;
  259. text-align: center;
  260. justify-content: center;
  261. align-items: center;
  262. text-align: center;
  263. position: absolute;
  264. right: 10px;
  265. bottom: 0;
  266. > li {
  267. display: inline-block;
  268. padding: 0 8px;
  269. > div {
  270. cursor: pointer;
  271. display: flex;
  272. flex-direction: column;
  273. text-align: center;
  274. justify-content: center;
  275. > div {
  276. width: 50px;
  277. height: 50px;
  278. overflow: hidden;
  279. background-position: 0 0;
  280. background-size: auto 100%;
  281. &.iactive {
  282. animation: boom-open-data 1s steps(25) forwards;
  283. }
  284. }
  285. }
  286. }
  287. }
  288. }
  289. .smtop {
  290. bottom: 162px;
  291. .good {
  292. bottom: 176px;
  293. }
  294. }
  295. .likeAddAnimate-enter-active,
  296. .likeAddAnimate-leave-active {
  297. transition: all 2.5s ease;
  298. }
  299. .likeAddAnimate-enter,
  300. .likeAddAnimate-leave {
  301. transform: translate(-10%, 0) scale(0);
  302. opacity: 0;
  303. }
  304. .likeAddAnimate-enter-to,
  305. .likeAddAnimate-leave-to {
  306. transform: translate(-10%, -70px) scale(1.05);
  307. opacity: 1;
  308. }
  309. .good {
  310. position: fixed;
  311. bottom: 36px;
  312. right: 230px;
  313. display: flex;
  314. z-index: 999;
  315. .pic {
  316. width: 35px;
  317. > img {
  318. width: 100%;
  319. height: 100%;
  320. }
  321. }
  322. .num {
  323. margin-top: 10px;
  324. margin-left: 0;
  325. }
  326. }
  327. }
  328. </style>