SliderStoreAbout.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. <template>
  2. <div class="sld_store_list_about">
  3. <div class="sld_vendor_goods clearfix">
  4. <div class="hd">
  5. <a href="javascript:;" class="next" @click="slideWin(1)" ref="next">
  6. <i class="iconfont"></i>
  7. </a>
  8. <a href="javascript:;" class="prev" @click="slideWin(0)" ref="prev">
  9. <i class="iconfont"></i>
  10. </a>
  11. </div>
  12. <div class="slide_wrap_about">
  13. <ul class="bd_about clearfix">
  14. <li
  15. class="new_goods_about"
  16. v-for="(item, index) in itemData"
  17. :key="index"
  18. >
  19. <div class="sld_img sld-img-center" >
  20. <div
  21. class="img"
  22. :style="{
  23. backgroundImage: 'url(' + item.imgUrl + ')',
  24. }"
  25. ></div>
  26. <div class="magnifier_icon flex_row_center_center" @click="toggleBigImg(item.imgUrl)"><i class="iconfont icon-sousuo"></i></div>
  27. </div>
  28. </li>
  29. <div class="empty" v-show="itemData.length == 0">
  30. <img src="/goods/empty_data.png" alt="" />
  31. <p>{{L['暂无展示']}}</p>
  32. </div>
  33. </ul>
  34. </div>
  35. </div>
  36. <el-dialog
  37. v-if="showModel"
  38. align-center
  39. width="100%"
  40. class="self_modal"
  41. :model-value="modalVisible"
  42. :show-close="true"
  43. @close="toggleBigImg('')"
  44. >
  45. <img :src="imgBig"/>
  46. </el-dialog>
  47. </div>
  48. </template>
  49. <script setup>
  50. // import { lang_zn } from "@/assets/language/zh.js";
  51. import { getCurLanguage } from '@/composables/common.js';
  52. import {ElDialog} from 'element-plus';
  53. // const L = lang_zn;
  54. const L = getCurLanguage();
  55. const props = defineProps(["itemData", "itemIndex"]);
  56. const { proxy } = getCurrentInstance();
  57. const showModel = ref(false)
  58. const modalVisible = ref(true)
  59. const imgBig = ref()
  60. //查看大图
  61. const toggleBigImg = (val) => {
  62. showModel.value = !showModel.value
  63. imgBig.value = val
  64. }
  65. //滑动
  66. const notClickQuick = ref(true); //防止快速点击造成dom混乱
  67. const slideWin = (ltr) => {
  68. let ul = document.getElementsByClassName("bd_about")[props.itemIndex];
  69. let liLength =ul.getElementsByClassName("new_goods_about").length;
  70. let max =
  71. liLength % 1 == 0
  72. ? liLength * 380
  73. : (Math.floor(liLength / 6) + 1) * 1 * 380;
  74. let nowMg = parseInt(getComputedStyle(ul, null).marginLeft);
  75. let slide_wrap_width = max - document.getElementsByClassName("slide_wrap_about")[props.itemIndex].offsetWidth;
  76. ul.style.width = max + "px";
  77. if (notClickQuick.value) {
  78. notClickQuick.value = false;
  79. if (slide_wrap_width < 0) return;
  80. let n = 380;
  81. if (ltr) {
  82. nowMg = nowMg - n * 1;
  83. ul.style.marginLeft =
  84. (slide_wrap_width >= Math.abs(nowMg) ? nowMg : nowMg + n * 1) + "px";
  85. } else {
  86. nowMg = nowMg + n * 1;
  87. ul.style.marginLeft = (nowMg <= 0 ? nowMg : 0) + "px";
  88. }
  89. proxy.$refs.next.style.backgroundColor = slide_wrap_width > Math.abs(nowMg) + 1 * 380 ? "#8d8b8b" : "#ccc";
  90. proxy.$refs.prev.style.backgroundColor = nowMg >= 0 ? "#ccc" : "#8d8b8b";
  91. setTimeout(function () {
  92. notClickQuick.value = true;
  93. }, 500);
  94. }
  95. };
  96. onMounted(() => {
  97. setTimeout(function () {
  98. if (props.itemData.length < 2) {
  99. proxy.$refs.next.style.backgroundColor = "#ccc";
  100. proxy.$refs.prev.style.backgroundColor = "#ccc";
  101. }
  102. }, 1000);
  103. });
  104. </script>
  105. <style lang="scss">
  106. .self_modal{
  107. height: 95vh;
  108. display: flex;
  109. justify-content: center;
  110. align-items: center;
  111. background: transparent;
  112. header,.el-dialog__body{
  113. padding: 0;
  114. }
  115. img{
  116. display: block;
  117. margin: 0 auto;
  118. height: 95vh;
  119. }
  120. .el-dialog__headerbtn{
  121. background: #fff;
  122. }
  123. }
  124. </style>
  125. <style lang="scss" scoped>
  126. @import "@/assets/style/storeListAbout.scss";
  127. @import "@/assets/style/store/contac-about.scss";
  128. </style>