catgory2.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357
  1. <template>
  2. <div class="pc_temp02">
  3. <div class="left">
  4. <div class="classification-box" v-if="basicCategory.data">
  5. <div
  6. class="classification-cell"
  7. v-for="(item, ind) in basicCategory.data.slice(0, 10)"
  8. :key="ind"
  9. @click.stop="toCategoryChild({id: item.id})"
  10. >
  11. <div class="first-class">{{ item.name }}</div>
  12. <div class="secondary-class">
  13. <div
  14. class="secondary-name"
  15. @click.stop="toCategoryChild({ id: obj.id })"
  16. v-for="(obj, bidx) in item.children"
  17. :key="bidx"
  18. >
  19. {{ obj.name }}
  20. </div>
  21. </div>
  22. </div>
  23. <div
  24. class="classification-cell"
  25. v-if="basicCategory.total > 10"
  26. @click.stop="toUrl('category')"
  27. >
  28. <div class="first-class">查看更多分类</div>
  29. </div>
  30. </div>
  31. <div class="recommend">
  32. <div class="reTitle">
  33. <div class="line"></div>
  34. 店铺热销
  35. </div>
  36. <div class="goodLis">
  37. <div class="goods_wrap flex">
  38. <div
  39. class="goods"
  40. v-for="(item, index) in hotGoods"
  41. :key="index"
  42. @click="toGoods(item)"
  43. >
  44. <img v-lazy="item.thumb" />
  45. <div class="goods_info flex flex-col">
  46. <div class="title">{{ item.title }}</div>
  47. <div class="price col_red">
  48. <span
  49. style="
  50. font-size: 14px;
  51. color: #666;
  52. display: inline-block;
  53. margin-right: 10px;
  54. "
  55. >{{
  56. basic_info.lang &&
  57. basic_info.lang.goods &&
  58. basic_info.lang.goods.price
  59. ? basic_info.lang.goods.price
  60. : "现价"
  61. }}:</span
  62. ><span style="font-size: 18px">¥</span>{{ item.price }}
  63. </div>
  64. </div>
  65. </div>
  66. <div class="no-goods" v-if="hotGoods && hotGoods.length <= 0">
  67. 暂无更多
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. </div>
  73. <div class="right">
  74. <div class="class-box">
  75. {{ slides.parent && slides.parent.name ? slides.parent.name : "全部" }}
  76. > <span style="color: var(--color)">{{ slides.name }}</span>
  77. </div>
  78. <set @changeStatus="changeStatus" @changeCategory='changeCategory' :child='slides.children' ></set>
  79. <goods :list="goodList" :pc_temp="true"></goods>
  80. </div>
  81. </div>
  82. </template>
  83. <script>
  84. import { mapState } from "vuex";
  85. import goods from "~/components/default/goods";
  86. import set from "~/components/default/set";
  87. export default {
  88. props: {
  89. slides:{
  90. type: null,
  91. },
  92. goodList:{
  93. type: null,
  94. },
  95. hotGoods: {
  96. type: null,
  97. },
  98. },
  99. components: {
  100. goods,
  101. set,
  102. },
  103. data() {
  104. return {
  105. };
  106. },
  107. computed: {
  108. ...mapState(["basicSet", "basicCategory", "basic_info"]),
  109. },
  110. methods: {
  111. changeCategory(thrId){
  112. console.log('eeeeeeee',thrId)
  113. this.$emit('changeCategory', thrId);
  114. },
  115. toUrl(url,params,query) {
  116. this.$router.push(this.fun.getUrl(url,params,query));
  117. },
  118. toGoods(item) {
  119. let id = item.id || item.goods_id;
  120. if(this.$baseURL) {
  121. // 静态部署环境下
  122. window.open(this.fun.getSiteRoot() + "/plugins/shop_server/goods?i=" +this.fun.getKeyByI()+'&id='+id, "_blank");
  123. }else {
  124. window.open(this.fun.getSiteRoot() + "/plugins/shop_server/goods/"+ id +"?i=" +this.fun.getKeyByI(), "_blank");
  125. }
  126. },
  127. toCategoryChild(params) {
  128. if (this.category_template === "03") {
  129. if (this.$baseURL) {
  130. // 静态部署环境下
  131. this.$router.push(this.fun.getUrl("category_child", {}, params));
  132. } else {
  133. this.$router.push(this.fun.getUrl("category_child-id", params));
  134. }
  135. } else {
  136. if (this.$baseURL) {
  137. // 静态部署环境下
  138. this.$router.push(this.fun.getUrl("catelist", {}, params));
  139. } else {
  140. this.$router.push(this.fun.getUrl("catelist-id", params));
  141. }
  142. }
  143. },
  144. changeStatus(obj) {
  145. if (obj.sort_name == 1) {
  146. this.sort_name = "comment_num"
  147. } else if (obj.sort_name == 2) {
  148. this.sort_name = "show_sales"
  149. } else if (obj.sort_name == 3) {
  150. this.sort_name = "price"
  151. }
  152. if (obj.sort_status == 1) {
  153. this.sort_status = "desc";
  154. } else {
  155. this.sort_status = "asc";
  156. }
  157. this.brandId = obj.brandId;
  158. this.filterId = obj.filterId;
  159. this.$emit('handleChange', {
  160. brandId:this.brandId,
  161. filterId:this.filterId.toString(),
  162. sort_name: this.sort_name,
  163. sort_status: this.sort_status,
  164. page: 1,
  165. key: 'good'
  166. });
  167. // this.handleCurrentChange({page: 1}, 'good')
  168. },
  169. // handleCurrentChange(val, flag) {
  170. // this.fun.$post('goods.goods.search-goods',
  171. // {
  172. // search: {category: this.$route.params.id,brand_id:this.brandId,filtering:this.filterId.toString()},
  173. // page: val.page,
  174. // order_field: this.sort_name,
  175. // order_by: this.sort_status,
  176. // }, '正在获取').then(res => {
  177. // if (res.result === 1) {
  178. // if(flag !== 'good') {
  179. // document.body.scrollIntoView(); //滚回顶部
  180. // }else {
  181. // this.$nextTick(()=> {
  182. // document.documentElement.scrollTop = document.getElementById('index_content').offsetTop - 115;
  183. // });
  184. // }
  185. // this.$emit('change',res.data);
  186. // } else {
  187. // this.$emit('change',{
  188. // data: [],
  189. // total: 0,
  190. // });
  191. // this.$message.error(res.msg);
  192. // }
  193. // })
  194. // }
  195. },
  196. };
  197. </script>
  198. <style lang="scss" scoped>
  199. .pc_temp02 {
  200. display: flex;
  201. .left {
  202. margin-right: 15px;
  203. .recommend {
  204. width: 220px;
  205. border-radius: 8px;
  206. padding: 7px;
  207. background: #fff;
  208. box-sizing: border-box;
  209. margin-top: 20px;
  210. .goodLis {
  211. width: 100%;
  212. margin-top: 6px;
  213. display: flex;
  214. .goods_wrap {
  215. flex-wrap: wrap;
  216. justify-content: center;
  217. padding-top: 10px;
  218. .goods {
  219. padding-top: 10px;
  220. border: 1px solid rgba(191, 191, 191, 0.3);
  221. border-radius: 6px;
  222. // box-shadow: 1px 1px 2px rgba(191, 191, 191, 0.3);
  223. width: 200px;
  224. display: flex;
  225. flex-direction: column;
  226. align-items: center;
  227. background: #fff;
  228. // margin-right: 12px;
  229. box-sizing: border-box;
  230. margin-bottom: 20px;
  231. cursor: pointer;
  232. overflow: hidden;
  233. transition: all 0.5s ease;
  234. img {
  235. width: 170px;
  236. height: 170px;
  237. overflow: hidden;
  238. }
  239. .goods_info {
  240. width: 100%;
  241. font-size: 16px;
  242. padding: 15px;
  243. height: 130px;
  244. box-sizing: border-box;
  245. flex-wrap: wrap;
  246. justify-content: space-between;
  247. align-items: flex-start;
  248. .title {
  249. overflow: hidden;
  250. text-overflow: ellipsis;
  251. display: -webkit-box;
  252. -webkit-line-clamp: 2;
  253. -webkit-box-orient: vertical;
  254. }
  255. .price {
  256. font-size: 18px;
  257. }
  258. }
  259. }
  260. .goods:hover {
  261. opacity: 0.8;
  262. box-shadow: 0px 4px 8px 0px rgba(191, 191, 191, 0.6);
  263. img {
  264. transform: scale(1.04);
  265. transition: all 0.5s ease;
  266. }
  267. }
  268. .goods:nth-child(5n) {
  269. margin-right: 0;
  270. }
  271. .no-goods {
  272. margin: 20px auto;
  273. font-size: 16px;
  274. color: var(--color);
  275. text-align: center;
  276. }
  277. }
  278. }
  279. .reTitle {
  280. margin-left: 10px;
  281. display: flex;
  282. font-size: 16px;
  283. .line {
  284. width: 4px;
  285. height: 20px;
  286. background: var(--color);
  287. border-radius: 2px;
  288. margin-right: 10px;
  289. }
  290. }
  291. }
  292. }
  293. .right {
  294. background: #fff;
  295. flex: 1;
  296. padding: 9px 17px;
  297. border-radius: 8px;
  298. }
  299. .class-box {
  300. margin: 15px 0;
  301. }
  302. }
  303. .classification-box {
  304. background-color: #fff;
  305. width: 220px;
  306. height: 480px;
  307. padding: 8px 16px;
  308. box-sizing: border-box;
  309. border-top: 6px solid var(--dark_color);
  310. overflow-y: scroll;
  311. scrollbar-width: none; /* Firefox */
  312. -ms-overflow-style: none; /* IE 10+ */
  313. margin-top: -10px;
  314. .classification-cell {
  315. display: flex;
  316. flex-direction: column;
  317. padding-top: 4px;
  318. .first-class {
  319. font-size: 14px;
  320. line-height: 28px;
  321. color: #000000;
  322. font-weight: bold;
  323. &:hover {
  324. cursor: pointer;
  325. color: var(--color);
  326. }
  327. }
  328. .secondary-class {
  329. display: flex;
  330. flex-wrap: wrap;
  331. .secondary-name {
  332. font-size: 12px;
  333. color: #8c8c8c;
  334. padding-right: 8px;
  335. text-align: left;
  336. min-width: 50%;
  337. box-sizing: border-box;
  338. line-height: 26px;
  339. &:hover {
  340. cursor: pointer;
  341. color: var(--color);
  342. }
  343. }
  344. }
  345. }
  346. .classification-cell:first-child {
  347. padding: 0;
  348. }
  349. }
  350. .classification-box::-webkit-scrollbar {
  351. display: none; /* Chrome Safari */
  352. }
  353. </style>