menu.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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 && window.goldlog.record(`/${item.maidiancode}`, "", `snsScene=${item.maidiancode}&product=pcweb&pagename=中国网络文明建设成果展云展示`, "");
  144. setTimeout(() => {
  145. this.currentActive = {};
  146. }, 1000);
  147. if (item.id == "clear") {
  148. this.$bus.$emit("toggleClear", true);
  149. document.querySelector("#ifr").contentWindow.postMessage(
  150. {
  151. source: "toggleClear",
  152. data: true,
  153. },
  154. "*"
  155. );
  156. return;
  157. }
  158. item.path && this.$router.push(item.path);
  159. item.cp && this.$emit("opencp", item.cp);
  160. if (item.id == "like") {
  161. this.dianzan();
  162. }
  163. },
  164. onClickNavigate(type) {
  165. if (document.querySelector("#ifr").contentWindow.player.flying) {
  166. return;
  167. }
  168. if (type == "up") {
  169. this.$bus.$emit("ifrMessage", {
  170. events: "flyToPano",
  171. data: this.nextZhanXiang,
  172. });
  173. } else {
  174. this.$bus.$emit("ifrMessage", {
  175. events: "flyToPano",
  176. data: this.prevZhanXiang,
  177. });
  178. }
  179. },
  180. dianzan() {
  181. if (this.isShowGood) return;
  182. // getsupCount((res) => {
  183. // console.log(111111,res);
  184. // this.goodNum = Number(this.goodNum ? this.goodNum : (res.voteNum || 0) );
  185. this.isShowGood = true;
  186. setTimeout(() => {
  187. this.isShowGood = false;
  188. }, 2500);
  189. supCount(() => {});
  190. // });
  191. },
  192. toggle() {
  193. let fn = this.tourStatus ? "stopTour" : "startAndPlay";
  194. this.$bus.$emit("ifrMessage", {
  195. events: "toggleTour",
  196. data: fn,
  197. });
  198. },
  199. },
  200. mounted() {
  201. this.$bus.$on("toggleShowZX", (data) => {
  202. this.isShowZX = data;
  203. });
  204. this.$bus.$on("resetMenuActive", () => {
  205. this.currentActive = {};
  206. });
  207. },
  208. };
  209. </script>
  210. <style lang="less" scoped>
  211. .raside {
  212. position: fixed;
  213. top: 190px;
  214. right: 0;
  215. z-index: 999;
  216. height: 100%;
  217. display: flex;
  218. flex-direction: column;
  219. align-items: flex-end;
  220. .smenu {
  221. bottom: 22px;
  222. left: 0;
  223. position: fixed;
  224. transition: 0.3s ease all;
  225. width: 100%;
  226. .fandb {
  227. border-radius: 60px;
  228. width: 285px;
  229. height: 45px;
  230. position: absolute;
  231. left: 50%;
  232. bottom: 0;
  233. transform: translateX(-50%);
  234. border-radius: 31px;
  235. backdrop-filter: blur(6px);
  236. display: flex;
  237. justify-content: center;
  238. align-items: center;
  239. .line {
  240. display: inline-block;
  241. width: 1px;
  242. height: 45px;
  243. background: linear-gradient(180deg, rgba(255, 255, 255, 0.5) 0%, #ffffff 48%, rgba(255, 255, 255, 0.5) 100%);
  244. }
  245. > div {
  246. display: flex;
  247. cursor: pointer;
  248. width: 49%;
  249. justify-content: center;
  250. align-items: center;
  251. cursor: pointer;
  252. }
  253. }
  254. > ul {
  255. background-repeat: no-repeat;
  256. background-size: 100% 100%;
  257. display: flex;
  258. text-align: center;
  259. justify-content: center;
  260. align-items: center;
  261. text-align: center;
  262. position: absolute;
  263. right: 10px;
  264. bottom: 0;
  265. > li {
  266. display: inline-block;
  267. padding: 0 8px;
  268. > div {
  269. cursor: pointer;
  270. display: flex;
  271. flex-direction: column;
  272. text-align: center;
  273. justify-content: center;
  274. > div {
  275. width: 50px;
  276. height: 50px;
  277. overflow: hidden;
  278. background-position: 0 0;
  279. background-size: auto 100%;
  280. &.iactive {
  281. animation: boom-open-data 1s steps(25) forwards;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. .smtop {
  289. bottom: 162px;
  290. .good {
  291. bottom: 176px;
  292. }
  293. }
  294. .likeAddAnimate-enter-active,
  295. .likeAddAnimate-leave-active {
  296. transition: all 2.5s ease;
  297. }
  298. .likeAddAnimate-enter,
  299. .likeAddAnimate-leave {
  300. transform: translate(-10%, 0) scale(0);
  301. opacity: 0;
  302. }
  303. .likeAddAnimate-enter-to,
  304. .likeAddAnimate-leave-to {
  305. transform: translate(-10%, -70px) scale(1.05);
  306. opacity: 1;
  307. }
  308. .good {
  309. position: fixed;
  310. bottom: 36px;
  311. right: 230px;
  312. display: flex;
  313. z-index: 999;
  314. .pic {
  315. width: 35px;
  316. > img {
  317. width: 100%;
  318. height: 100%;
  319. }
  320. }
  321. .num {
  322. margin-top: 10px;
  323. margin-left: 0;
  324. }
  325. }
  326. }
  327. </style>