menu.vue 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231
  1. <template>
  2. <div class="smenu">
  3. <audio ref="vbgm" class="noshow" loop :src="require(`@/assets/audio/bgm.mp3`)">
  4. </audio>
  5. <template v-if="!tourStatus">
  6. <div class="sdaolan">
  7. <img :src="require(`@/assets/images/project/daolan_${theme}.png`)" alt="">
  8. <div @click="toggle" class="daolan">
  9. <img :src="require(`@/assets/images/project/menu/daolan.png`)" alt="">
  10. <p>自动观展</p>
  11. </div>
  12. </div>
  13. <ul :style="{
  14. backgroundImage: `url(${require(`@/assets/images/project/menu_${theme}.png`)})`,
  15. }">
  16. <li v-for="(item,i) in menu" :key="i">
  17. <div @click="onClick(item)">
  18. <img v-if="item.id!='bgm'" :src="require(`@/assets/images/project/menu/${item.id}.png`)" alt="">
  19. <img v-else :src="require(`@/assets/images/project/menu/${isBgm?item.muted:item.id}.png`)" alt="">
  20. <span>{{item.name}}</span>
  21. </div>
  22. </li>
  23. </ul>
  24. </template>
  25. <div class="stoptour" v-else>
  26. <div @click="toggle" class="daolan">
  27. <img :src="require(`@/assets/images/project/menu/zanting.png`)" alt="">
  28. <p>暂停观展</p>
  29. </div>
  30. </div>
  31. <transition name="likeAddAnimate">
  32. <div class="good" v-show="isShowGood">
  33. <div class="pic">
  34. <img :src="require(`@/assets/images/project/icon/zan_${theme}.png`)" alt="" />
  35. </div>
  36. <div class="num">+{{ goodNum + 1 }}</div>
  37. </div>
  38. </transition>
  39. </div>
  40. </template>
  41. <script>
  42. import { supCount,getsupCount } from "@/config/api";
  43. let menu = [
  44. {
  45. id:'home',
  46. name:'首页',
  47. path:{name:'home'}
  48. },
  49. {
  50. id:'daka',
  51. name:'打卡',
  52. cp:'daka'
  53. },
  54. {
  55. id:'content',
  56. name:'留言',
  57. cp:'vcontent'
  58. },
  59. {
  60. id:'zan',
  61. name:'点赞'
  62. },
  63. {
  64. id:'qrcode',
  65. name:'分享',
  66. cp:'qrcode'
  67. },
  68. {
  69. id:'bgm',
  70. name:'播放',
  71. muted:'jingyin'
  72. }
  73. ]
  74. export default {
  75. props:['tourStatus'],
  76. data(){
  77. return {
  78. menu,
  79. goodNum:1099,
  80. isShowGood:false,
  81. isBgm:false
  82. }
  83. },
  84. watch:{
  85. isBgm(newVal){
  86. !newVal?this.$refs.vbgm.pause():this.$refs.vbgm.play()
  87. },
  88. tourStatus(newVal){
  89. if (newVal) {
  90. this.isBgm = false
  91. }
  92. }
  93. },
  94. methods:{
  95. onClick(item){
  96. item.path && this.$router.push(item.path)
  97. item.cp && this.$emit('opencp',item.cp)
  98. item.id=='bgm' && (this.isBgm=!this.isBgm)
  99. item.id=='zan' && this.dianzan()
  100. },
  101. dianzan(){
  102. if (this.isShowGood) return
  103. getsupCount(res=>{
  104. this.goodNum = res.data
  105. this.isShowGood = true
  106. setTimeout(() => {
  107. this.isShowGood = false
  108. }, 2500);
  109. supCount(()=>{})
  110. })
  111. },
  112. toggle(){
  113. let fn = this.tourStatus?'stopTour':'startAndPlay'
  114. this.$bus.$emit('ifrMessage',{
  115. events:'toggleTour',
  116. data:fn
  117. })
  118. }
  119. },
  120. mounted(){
  121. this.isBgm = true
  122. }
  123. }
  124. </script>
  125. <style lang="less" scoped>
  126. .smenu{
  127. position: fixed;
  128. bottom: 4%;
  129. transform: translateX(-50%);
  130. left: 50%;
  131. z-index: 999;
  132. display: flex;
  133. align-items: center;
  134. .sdaolan,.stoptour{
  135. margin-right: 20px;
  136. position: relative;
  137. cursor: pointer;
  138. .daolan{
  139. position: absolute;
  140. top: 52%;
  141. left: 50%;
  142. transform: translate(-50%,-50%);
  143. width: 80px;
  144. text-align: center;
  145. >img{
  146. width: 30px;
  147. }
  148. }
  149. }
  150. .stoptour{
  151. .daolan{
  152. position: absolute;
  153. top: 50%;
  154. left: 50%;
  155. transform: translate(-50%,-50%);
  156. width: 80px;
  157. text-align: center;
  158. >img{
  159. width: 40px;
  160. }
  161. }
  162. }
  163. >ul{
  164. background-repeat: no-repeat;
  165. background-size: 100% 100%;
  166. width: 557px;
  167. height: 91px;
  168. display: flex;
  169. text-align: center;
  170. justify-content: center;
  171. align-items: center;
  172. text-align: center;
  173. >li{
  174. display: inline-block;
  175. padding: 0 26px;
  176. &:not(&:last-of-type){
  177. border-right: 1px solid #fff;
  178. }
  179. >div{
  180. cursor: pointer;
  181. >img{
  182. width: 40px;
  183. }
  184. }
  185. }
  186. }
  187. }
  188. .likeAddAnimate-enter-active,
  189. .likeAddAnimate-leave-active {
  190. transition: all 2.5s ease;
  191. }
  192. .likeAddAnimate-enter,
  193. .likeAddAnimate-leave {
  194. transform: translate(-30%, 0) scale(0);
  195. opacity: 0;
  196. }
  197. .likeAddAnimate-enter-to,
  198. .likeAddAnimate-leave-to {
  199. transform: translate(-30%, -110px) scale(1.2);
  200. opacity: 1;
  201. }
  202. .good {
  203. position: absolute;
  204. bottom: 36px;
  205. right: 160px;
  206. display: flex;
  207. .pic {
  208. width: 35px;
  209. > img {
  210. width: 100%;
  211. height: 100%;
  212. }
  213. }
  214. .num {
  215. margin-top: 10px;
  216. margin-left: 10px;
  217. }
  218. }
  219. .noshow{
  220. position: fixed;
  221. top: -100px;
  222. left: -100px;
  223. opacity: 0;
  224. visibility: hidden;
  225. }
  226. </style>