CollectStoreItem.vue 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. <template>
  2. <div class="sld_vendor_item clearfix">
  3. <div class="sld_vendor fl">
  4. <div class="sld_vendor_logo sld_img_center">
  5. <coverImage :src="item.storeLogo" width="114" height="114"></coverImage>
  6. </div>
  7. <div class="sld_vendor_name">{{ item.storeName }}</div>
  8. <div class="sld_rate clearfix">
  9. <el-rate
  10. disabled
  11. :colors="colors"
  12. score-template="{score}"
  13. v-model="score"
  14. >
  15. </el-rate>
  16. </div>
  17. <div class="sld_vendor_top clearfix">
  18. <button class="fl" @click="unfollow(item.storeId)">
  19. {{ L["取消关注"] }}
  20. </button>
  21. </div>
  22. <div class="sld_vendor_bottom">
  23. <nuxt-link :to="'/store/'+ calcProductName(item.storeName) +'_'+ item.storeId" target="_blank">
  24. <i class="iconfont">&#xe654;</i>{{ L["进入店铺"] }}
  25. </nuxt-link>
  26. </div>
  27. </div>
  28. <div class="main_lbbox fl">
  29. <div class="sld_vendor_collect">
  30. <a
  31. id="newGoods"
  32. :class="1 === storeGoodsType ? 'sld_follow_on' : ''"
  33. @click="storeGoodsSwitch(1)"
  34. style="cursor: pointer"
  35. >{{ L["热销推荐"] }}({{ item.goodsList.length }})</a
  36. >
  37. <a
  38. id="recommendGoods"
  39. :class="{ sld_follow_on: 2 === storeGoodsType }"
  40. @click="storeGoodsSwitch(2)"
  41. style="cursor: pointer"
  42. >{{ L["本月上新"] }}({{ item.newGoodsList.length }})</a
  43. >
  44. </div>
  45. <div class="sld_vendor_goods clearfix">
  46. <div class="hd">
  47. <a href="javascript:;" class="next" @click="slideWin(1)" ref="next">
  48. <i class="iconfont">&#xe634;</i>
  49. </a>
  50. <a href="javascript:;" class="prev" @click="slideWin(0)" ref="prev">
  51. <i class="iconfont">&#xe634;</i>
  52. </a>
  53. </div>
  54. <div class="slide_wrap">
  55. <ul class="bd clearfix" v-if="2 == storeGoodsType">
  56. <li
  57. class="new_goods"
  58. v-for="(sub, subindex) in item.newGoodsList"
  59. :key="subindex"
  60. >
  61. <nuxt-link
  62. :to="'/goods/detail/'+ calcProductName(sub.goodsName) +'_'+ sub.defaultProductId"
  63. target="_blank"
  64. >
  65. <div class="sld_img sld_img_center">
  66. <!-- <img class="lazy" :src="sub.mainImage" alt=""> -->
  67. <coverImage
  68. :src="sub.mainImage"
  69. width="140"
  70. height="150"
  71. ></coverImage>
  72. </div>
  73. <p class="goods_name">{{ sub.goodsName }}</p>
  74. <p class="goods_price">{{ sub.goodsMoney }}</p>
  75. </nuxt-link>
  76. </li>
  77. <SldCommonEmpty
  78. v-show="!item.newGoodsList.length"
  79. totalHeight="228"
  80. paddingTop="50"
  81. />
  82. </ul>
  83. <ul class="bd clearfix" v-else>
  84. <li
  85. class="hot_goods"
  86. v-for="(sub, subindex) in item.goodsList"
  87. :key="subindex"
  88. >
  89. <nuxt-link
  90. :to="'/goods/detail/'+ calcProductName(sub.goodsName) +'_'+ sub.defaultProductId"
  91. target="_blank"
  92. >
  93. <div class="sld_img sld_img_center">
  94. <!-- <img class="lazy" :src="sub.mainImage" alt=""> -->
  95. <coverImage
  96. :src="sub.mainImage"
  97. width="140"
  98. height="150"
  99. ></coverImage>
  100. </div>
  101. <p class="goods_name">{{ sub.goodsName }}</p>
  102. <p class="goods_price">{{ sub.goodsMoney }}</p>
  103. </nuxt-link>
  104. </li>
  105. <SldCommonEmpty
  106. v-show="!item.goodsList.length"
  107. totalHeight="228"
  108. paddingTop="50"
  109. />
  110. </ul>
  111. </div>
  112. </div>
  113. </div>
  114. </div>
  115. </template>
  116. <script setup>
  117. import { getCurrentInstance, ref, onMounted, watch } from "vue";
  118. import { ElMessage, ElRate } from "element-plus";
  119. // import { lang_zn } from "@/assets/language/zh";
  120. import { getCurLanguage } from '@/composables/common.js';
  121. // const L = lang_zn;
  122. const L = getCurLanguage();
  123. definePageMeta({
  124. layout: "member",
  125. middleware: ["auth"],
  126. });
  127. const props = defineProps(["item", "ItemIndex", "collectStoreIndex"]);
  128. const emit = defineEmits(['collectStoreUpdate']);
  129. const { proxy } = getCurrentInstance();
  130. const storeGoodsType = ref(1);
  131. const colors = ref(["#E2231A", "#E2231A", "#E2231A"]);
  132. //商品滑动
  133. const notClickQuick = ref(true); //防止快速点击造成dom混乱
  134. const slideWin = (ltr) => {
  135. let ul = document.getElementsByClassName("bd")[props.ItemIndex];
  136. let liLength =
  137. storeGoodsType.value === 2
  138. ? ul.getElementsByClassName("new_goods").length
  139. : ul.getElementsByClassName("hot_goods").length;
  140. let isanimate = false;
  141. let nowMg = parseInt(getComputedStyle(ul, null).marginLeft);
  142. let max =
  143. liLength % 4 == 0
  144. ? liLength * 160
  145. : (Math.floor(liLength / 4) + 1) * 4 * 160;
  146. ul.style.width = max + "px";
  147. let slide_wrap_width =
  148. max -
  149. document.getElementsByClassName("slide_wrap")[props.ItemIndex].offsetWidth;
  150. if (notClickQuick.value) {
  151. notClickQuick.value = false;
  152. if (slide_wrap_width < 0 || isanimate) return;
  153. isanimate = true;
  154. let n = 160;
  155. if (ltr) {
  156. nowMg = nowMg - n * 4;
  157. ul.style.marginLeft =
  158. (slide_wrap_width >= Math.abs(nowMg) ? nowMg : nowMg + n * 4) + "px";
  159. } else {
  160. nowMg = nowMg + n * 4;
  161. ul.style.marginLeft = (nowMg <= 0 ? nowMg : 0) + "px";
  162. }
  163. proxy.$refs.next.style.backgroundColor =
  164. slide_wrap_width > Math.abs(nowMg) + 4 * 160 ? "#8d8b8b" : "#ccc";
  165. proxy.$refs.prev.style.backgroundColor = nowMg >= 0 ? "#ccc" : "#8d8b8b";
  166. isanimate = false;
  167. setTimeout(function () {
  168. notClickQuick.value = true;
  169. }, 500);
  170. } else {
  171. return;
  172. }
  173. };
  174. const score = ref(Number(props.item.serviceScore));
  175. //取消店铺关注
  176. const unfollow = (storeId) => {
  177. let params = {
  178. isCollect: false,
  179. storeIds: storeId,
  180. };
  181. post("v3/member/front/followStore/edit", params).then((res) => {
  182. if (res.state == 200) {
  183. emit("collectStoreUpdate");
  184. ElMessage(res.msg);
  185. }
  186. });
  187. };
  188. //设置或取消特殊关注店铺
  189. const topfollow = (followId, isTop) => {
  190. let params = {
  191. followId: followId,
  192. isTop: isTop,
  193. };
  194. post("v3/member/front/followStore/editSpecial", params).then((res) => {
  195. if (res.state == 200) {
  196. emit("collectStoreUpdate");
  197. ElMessage(res.msg);
  198. }
  199. });
  200. };
  201. watch(
  202. () => props.item,
  203. (ov, nv) => {
  204. score.value = Number(ov.serviceScore);
  205. }
  206. );
  207. const storeGoodsSwitch = (index) => {
  208. storeGoodsType.value = index;
  209. };
  210. onMounted(() => {});
  211. </script>
  212. <style lang="scss">
  213. @import "@/assets/style/member/collect.scss";
  214. </style>