AllWallbut.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div id="guide-button">
  3. <template v-if="showButtonList">
  4. <div id="old-exhibition1" v-if="titles[4]" @click="isShow(e)">
  5. <img
  6. class="exbutton"
  7. :class="[btnIndex == 4 ? 'hit' : '']"
  8. src="@/assets/images/exbutton.png"
  9. />
  10. <div class="button-text black-text">
  11. <a :href="jumpUrl[4]" :class="[btnIndex == 4 ? 'hit' : '']">
  12. {{ titles[e] }}</a
  13. >
  14. </div>
  15. </div>
  16. <div id="old-exhibition2" v-if="titles[3]" @click="isShow(d)">
  17. <img
  18. class="exbutton"
  19. :class="[btnIndex == 3 ? 'hit' : '']"
  20. src="@/assets/images/exbutton.png"
  21. />
  22. <div class="button-text black-text">
  23. <a :href="jumpUrl[3]" :class="[btnIndex == 3 ? 'hit' : '']">
  24. {{ titles[d] }}</a
  25. >
  26. </div>
  27. </div>
  28. <div id="old-exhibition" @click="isShow(c)">
  29. <img
  30. class="exbutton"
  31. :class="[btnIndex == 2 ? 'hit' : '']"
  32. src="@/assets/images/exbutton.png"
  33. />
  34. <div class="button-text black-text">
  35. <a :href="jumpUrl[2]" :class="[btnIndex == 2 ? 'hit' : '']">
  36. {{ titles[c] }}</a
  37. >
  38. </div>
  39. </div>
  40. <div id="cloud-exhibition" @click="isShow(b)">
  41. <img
  42. class="exbutton"
  43. :class="[btnIndex == 1 ? 'hit' : '']"
  44. src="@/assets/images/exbutton.png"
  45. />
  46. <div class="button-text black-text">
  47. <a :href="jumpUrl[1]" :class="[btnIndex == 1 ? 'hit' : '']">
  48. {{ titles[b] }}</a
  49. >
  50. </div>
  51. </div>
  52. </template>
  53. <template v-else>
  54. <div id="front"><img src="@/assets/images/front.png" /></div>
  55. <div id="back"><img src="@/assets/images/back.png" /></div>
  56. </template>
  57. <div id="mainbutton">
  58. <img
  59. class="exbutton"
  60. @touchstart="goStart"
  61. @touchmove="goMove"
  62. @touchend="goEnd"
  63. src="@/assets/images/mainbutton.png"
  64. />
  65. <div class="button-text">
  66. <a :href="jumpUrl[0]">{{ titles[a] }}</a>
  67. </div>
  68. <img
  69. :class="[showButtonList ? '' : 'arrowDown', 'arrow']"
  70. src="@/assets/images/arrow.png"
  71. @click.self="buttonList"
  72. />
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. export default {
  78. props: {
  79. titles: {
  80. type: Array,
  81. },
  82. jumpUrl: {
  83. type: Array,
  84. },
  85. },
  86. name: "GuideButton",
  87. data() {
  88. return {
  89. a: 0,
  90. b: 1,
  91. c: 2,
  92. d: 3,
  93. e: 4,
  94. showButtonList: false,
  95. hit: false,
  96. timeOutEvent: 0, // 长按事件定时器
  97. startPageY: 0,
  98. currentPageY: 0,
  99. btnHeight: 40,
  100. // titles:['点击看展','参加云展','往届博博会'],
  101. // jumpUrl:['',
  102. // 'http://www.expo-museums.com/Index/history/column/143',
  103. // 'http://www.expo-museums.com/Index/column/id/162'],
  104. };
  105. },
  106. methods: {
  107. change(val) {
  108. if (val===undefined) return;
  109. console.log(val);
  110. // if(val===1) val='德国博物馆'
  111. // else if(val===2) val='南京博物馆'
  112. // else if(val===3) val='南通博物馆'
  113. // else if(val===4) val='广东省博物馆'
  114. // else val='高淳博物馆'
  115. if (val === 0) {
  116. this.a = val;
  117. this.b = val + 1;
  118. this.c = val + 2;
  119. this.d = val + 3;
  120. this.e = val + 4;
  121. }
  122. if (val === 1) {
  123. this.a = val;
  124. this.b = val + 1;
  125. this.c = val + 2;
  126. this.d = val + 3;
  127. this.e = val - 1;
  128. }
  129. if (val === 2) {
  130. this.a = val;
  131. this.b = val + 1;
  132. this.c = val + 2;
  133. this.d = val - 1;
  134. this.e = val - 2;
  135. }
  136. if (val === 3) {
  137. this.a = val;
  138. this.b = val + 1;
  139. this.c = val - 1;
  140. this.d = val - 2;
  141. this.e = val - 3;
  142. }
  143. if (val === 4) {
  144. this.a = val;
  145. this.b = val - 1;
  146. this.c = val - 2;
  147. this.d = val - 3;
  148. this.e = val - 4;
  149. }
  150. },
  151. isShow(val) {
  152. this.buttonList();
  153. this.change(val);
  154. },
  155. pageJump(url) {
  156. window.location.href = url;
  157. // console.log('jump');
  158. },
  159. buttonList() {
  160. this.showButtonList = !this.showButtonList;
  161. // console.log('buttonlist',this.showButtonList);
  162. },
  163. goStart(event) {
  164. let _this = this;
  165. event.preventDefault();
  166. clearTimeout(_this.timeOutEvent);
  167. let touch = event.targetTouches[0];
  168. // console.log('起点',touch.pageY);
  169. this.startPageY = touch.pageY;
  170. // 开始触摸
  171. _this.timeOutEvent = setTimeout(() => {
  172. _this.timeOutEvent = 0;
  173. // console.log('处理长按事件');
  174. this.showButtonList = true;
  175. }, 1000);
  176. },
  177. goMove(event) {
  178. event.preventDefault();
  179. let touch = event.targetTouches[0];
  180. // console.log('移动中',touch.pageY);
  181. //1379-1440
  182. this.currentPageY = touch.pageY;
  183. },
  184. goEnd() {
  185. // 触发切换事件
  186. let temp;
  187. if (this.btnIndex === 4) temp = this.e;
  188. if (this.btnIndex === 3) temp = this.d;
  189. if (this.btnIndex === 2) temp = this.c;
  190. if (this.btnIndex === 1) temp = this.b;
  191. if (this.btnIndex === 0) temp = this.a;
  192. this.change(temp);
  193. // 1228 1260
  194. // let _this = this;
  195. clearTimeout(this.timeOutEvent);
  196. // _this.timeOutEvent !== 0
  197. // console.log('处理长按结束事件');
  198. if (this.btnIndex < this.titles.length && this.btnIndex >= 0) {
  199. this.pageJump(this.jumpUrl[this.btnIndex]);
  200. }
  201. this.showButtonList = false;
  202. this.startPageY = this.currentPageY = 0; //因为computed会缓存btnIndex,而需要在切换页面之后恢复原状,所以要改变
  203. },
  204. },
  205. computed: {
  206. btnIndex: function () {
  207. let index;
  208. let relativeY = this.startPageY - this.currentPageY;
  209. index = Math.floor(relativeY / this.btnHeight);
  210. // console.log(index);
  211. return index;
  212. },
  213. },
  214. beforeUpdate() {
  215. this.btnHeight = document.getElementById("mainbutton").clientHeight / 1.7;
  216. // console.log('btnheight',this.btnHeight);
  217. },
  218. };
  219. </script>
  220. <style scoped>
  221. /* #guide-button>div:henter .button-text{
  222. color:#ffffff;
  223. } */
  224. .hit {
  225. transform: scale(1.03);
  226. color: #ffffff;
  227. opacity: 1;
  228. transition: all 1s ease;
  229. }
  230. #mainbutton {
  231. position: absolute;
  232. top: 5.6rem;
  233. left: 50%;
  234. transform: translateX(-50%);
  235. width: 18.9rem;
  236. max-width:302px;
  237. max-height: 68px;
  238. height: 4.3rem;
  239. /* background: linear-gradient(180deg, #D16914, transparent);
  240. border-radius: 6px;*/
  241. }
  242. .arrow {
  243. position: inherit;
  244. top: 30%;
  245. right: 1.7rem;
  246. width: 1.2rem;
  247. }
  248. .arrow.arrowDown {
  249. transform-origin: center;
  250. transform: rotate(180deg);
  251. }
  252. .exbutton {
  253. width: 18.9rem;
  254. opacity: 0.8;
  255. }
  256. div.button-text {
  257. position: absolute;
  258. top: 40%;
  259. left: 50%;
  260. transform: translate(-50%, -50%);
  261. display: block;
  262. text-align: center;
  263. font-weight: normal;
  264. color: #ffffff;
  265. font-size: 1rem;
  266. font-family: "Microsoft YaHei", "serif";
  267. opacity: 1;
  268. }
  269. div.black-text {
  270. color: #000000;
  271. }
  272. #cloud-exhibition {
  273. position: absolute;
  274. top: 2.8rem;
  275. left: 50%;
  276. transform: translateX(-50%);
  277. width: 18.9rem;
  278. height: 4.3rem;
  279. z-index: 999;
  280. }
  281. #old-exhibition {
  282. position: absolute;
  283. top: 0;
  284. left: 50%;
  285. transform: translateX(-50%);
  286. width: 18.9rem;
  287. height: 4.3rem;
  288. z-index: 999;
  289. }
  290. #old-exhibition1,
  291. #old-exhibition2 {
  292. position: absolute;
  293. top: -5.6rem;
  294. left: 50%;
  295. transform: translateX(-50%);
  296. width: 18.9rem;
  297. height: 4.3rem;
  298. z-index: 999;
  299. }
  300. #old-exhibition2 {
  301. top: -2.8rem;
  302. }
  303. a {
  304. text-decoration: none;
  305. color: inherit;
  306. }
  307. #front {
  308. position: absolute;
  309. top: 4.9rem;
  310. left: 50%;
  311. transform: translateX(-50%);
  312. width: 18.1rem;
  313. }
  314. #front img {
  315. width: 100%;
  316. }
  317. #back {
  318. position: absolute;
  319. top: 4.25rem;
  320. left: 50%;
  321. transform: translateX(-50%);
  322. width: 16.2rem;
  323. }
  324. #back img {
  325. width: 100%;
  326. }
  327. </style>