Commit f444267a4ecb8c5029ff3e536895d894041e6269

Authored by 王强
1 parent 251803a5

“优选”页面组件,基础组件和滚动组件完成,还差排名组件,引入goodsItem_2组件实现~

src/components/goodsItem_1/goodsItem_1.vue
... ... @@ -43,6 +43,6 @@
43 43 </script>
44 44  
45 45 <!-- Add "scoped" attribute to limit CSS to this component only -->
46   -<style rel="stylesheet/less" lang="less">
  46 +<style rel="stylesheet/less" lang="less" scoped>
47 47 @import './goodsItem_1';
48 48 </style>
49 49 \ No newline at end of file
... ...
src/components/goodsItem_2/goodsItem_2.vue
... ... @@ -38,6 +38,6 @@
38 38 </script>
39 39  
40 40 <!-- Add "scoped" attribute to limit CSS to this component only -->
41   -<style rel="stylesheet/less" lang="less">
  41 +<style rel="stylesheet/less" lang="less" scoped>
42 42 @import './goodsItem_2';
43 43 </style>
44 44 \ No newline at end of file
... ...
src/components/goodsItem_3/goodsItem_3.less 0 → 100644
  1 +@charset "UTF-8";
  2 +
  3 +.goods-item-3-box {
  4 + background-color: #ffffff;
  5 + padding: 20px 0;
  6 + width: 560px;
  7 + height: auto;
  8 + border-radius: 8px;
  9 + .main-box {
  10 + display: flex;
  11 + justify-content: space-between;
  12 + margin: 0 auto;
  13 + width: 520px;
  14 + height: auto;
  15 + .img-box {
  16 + display: flex;
  17 + justify-content: center;
  18 + align-items: center;
  19 + background-color: #F9F9F9;
  20 + margin: 0 auto;
  21 + width: 240px;
  22 + height: 240px;
  23 + border-radius: 8px;
  24 + overflow: hidden;
  25 + .simg {
  26 + display: block;
  27 + width: 240px;
  28 + }
  29 + }
  30 + .content-box {
  31 + display: flex;
  32 + flex-direction: column;
  33 + justify-content: space-around;
  34 + align-items: center;
  35 + width: 280px;
  36 + height: auto;
  37 + .top-box {
  38 + width: 220px;
  39 + .title {
  40 + color: #333333;
  41 + font-size: 30px;
  42 + white-space: nowrap;
  43 + text-overflow: ellipsis;
  44 + overflow: hidden;
  45 + }
  46 + .ads {
  47 + margin-top: 5px;
  48 + color: #333333;
  49 + font-size: 22px;
  50 + white-space: nowrap;
  51 + text-overflow: ellipsis;
  52 + overflow: hidden;
  53 + }
  54 + }
  55 + .bottom-box {
  56 + width: 220px;
  57 + .price-box {
  58 + display: flex;
  59 + justify-content: flex-start;
  60 + align-items: center;
  61 + margin-top: 20px;
  62 + .symbol {
  63 + color: #FC1541;
  64 + font-size: 20px;
  65 + }
  66 + .price {
  67 + color: #FC1541;
  68 + font-size: 30px;
  69 + white-space: nowrap;
  70 + text-overflow: ellipsis;
  71 + overflow: hidden;
  72 + }
  73 + }
  74 + .buttons-box {
  75 + margin-top: 20px;
  76 + .btn {
  77 + &.btn-primary {
  78 + display: flex;
  79 + justify-content: center;
  80 + align-items: center;
  81 + background-color: #EC1125;
  82 + color: #FFFFFF;
  83 + font-size: 24px;
  84 + width: 100%;
  85 + height: 46px;
  86 + border-radius: 6px;
  87 + white-space: nowrap;
  88 + text-overflow: ellipsis;
  89 + overflow: hidden;
  90 + }
  91 + }
  92 + }
  93 + }
  94 + }
  95 + }
  96 +}
0 97 \ No newline at end of file
... ...
src/components/goodsItem_3/goodsItem_3.vue 0 → 100644
  1 +<template>
  2 + <div class="goods-item-3-box" v-if="item" @click="jump(item)">
  3 + <div class="main-box">
  4 + <div class="img-box">
  5 + <img v-lazy="item.simg + SIGN.SMALL" class="simg" />
  6 + </div>
  7 + <div class="content-box">
  8 + <div class="top-box">
  9 + <div class="title">{{item.title}}</div>
  10 + <div class="ads">
  11 + {{item.ads}}
  12 + </div>
  13 + </div>
  14 + <div class="bottom-box">
  15 + <div class="price-box">
  16 + <div class="symbol">¥</div>
  17 + <div class="price">{{item.price}}</div>
  18 + </div>
  19 + <div class="buttons-box">
  20 + <div class="btn btn-primary" @click.stop.prevent @click="primary(item)">{{item.primaryText}}</div>
  21 + </div>
  22 + </div>
  23 + </div>
  24 + </div>
  25 + </div>
  26 +</template>
  27 +
  28 +<script>
  29 + export default {
  30 + data: function () {
  31 + return {
  32 +
  33 + }
  34 + },
  35 + props: ["item"],
  36 + methods: {
  37 +
  38 + /**
  39 + * 点击跳转
  40 + * @param {object} item [数据对象]
  41 + */
  42 + jump(item) {
  43 + this.$emit("jump", item);
  44 + },
  45 +
  46 + /**
  47 + * 主按钮点击事件
  48 + * @param {object} item [数据对象]
  49 + */
  50 + primary(item) {
  51 + this.$emit("primary", item);
  52 + }
  53 + }
  54 + }
  55 +</script>
  56 +
  57 +<!-- Add "scoped" attribute to limit CSS to this component only -->
  58 +<style rel="stylesheet/less" lang="less" scoped>
  59 + @import './goodsItem_3';
  60 +</style>
0 61 \ No newline at end of file
... ...
src/components/horizList/horizList.less
... ... @@ -4,8 +4,10 @@
4 4 background-color: transparent;
5 5 width: 100%;
6 6 height: auto;
7   - > .box {
  7 + .title-box + .box {
8 8 margin-top: 30px;
  9 + }
  10 + > .box {
9 11 width: 750px;
10 12 .h-box {
11 13 width: 100%;
... ... @@ -81,5 +83,22 @@
81 83 }
82 84 }
83 85 }
  86 + &.com-3 {
  87 + .h-box {
  88 + height: 292px;
  89 + .scroll-box {
  90 + padding-bottom: 26px;
  91 + > .box {
  92 + display: block;
  93 + .item-box {
  94 + padding-right: 30px;
  95 + &:first-child {
  96 + padding-left: 30px;
  97 + }
  98 + }
  99 + }
  100 + }
  101 + }
  102 + }
84 103 }
85 104 }
86 105 \ No newline at end of file
... ...
src/components/horizList/horizList.vue
1 1 <template>
2 2 <div class="horiz-list-box" v-if="lists && lists.length">
  3 + <slot name="title-box"></slot>
3 4 <div class="box" :class="'com-' + com + ' pid-' + pid">
4 5 <div class="h-box">
5 6 <div class="scroll-box" ref="scrollBox">
... ... @@ -12,16 +13,21 @@
12 13 -->
13 14  
14 15 <!-- 商品展示样式 1 -->
15   - <goods-item-1 v-if="com == '1'" @jump=jump @addCart=addCart
  16 + <goods-item-1 v-if="com == '1'" @jump="jump" @addCart="addCart"
16 17 :item="item"
17 18 :pid="pid">
18 19 </goods-item-1>
19 20  
20 21 <!-- 商品展示样式 2 -->
21   - <goods-item-2 v-if="com == '2'" @jump=jump
  22 + <goods-item-2 v-if="com == '2'" @jump="jump"
22 23 :item="item"
23 24 :pid="pid">
24 25 </goods-item-2>
  26 +
  27 + <!-- 商品展示样式 3 -->
  28 + <goods-item-3 v-if="com == '3'" @jump="jump" @primary="primary"
  29 + :item="item">
  30 + </goods-item-3>
25 31 </div>
26 32 </div>
27 33 </div>
... ... @@ -34,6 +40,7 @@
34 40 // 引入组件
35 41 import goodsItem1 from "@/components/goodsItem_1/goodsItem_1";
36 42 import goodsItem2 from "@/components/goodsItem_2/goodsItem_2";
  43 + import goodsItem3 from "@/components/goodsItem_3/goodsItem_3";
37 44  
38 45 export default {
39 46 data: function () {
... ... @@ -45,12 +52,14 @@
45 52 props: ["lists", "com", "pid"],
46 53 components: {
47 54 goodsItem1,
48   - goodsItem2
  55 + goodsItem2,
  56 + goodsItem3
49 57 },
50 58 methods: {
51 59  
52 60 /**
53 61 * 点击跳转
  62 + * @param {object} item [数据对象]
54 63 */
55 64 jump(item) {
56 65 this.$emit("jump", item);
... ... @@ -58,12 +67,21 @@
58 67  
59 68 /**
60 69 * 加入购物车
  70 + * @param {object} item [数据对象]
61 71 */
62 72 addCart(item) {
63 73 this.$emit("addCart", item);
64 74 },
65 75  
66 76 /**
  77 + * 主按钮点击事件
  78 + * @param {object} item [数据对象]
  79 + */
  80 + primary(item) {
  81 + this.$emit("primary", item);
  82 + },
  83 +
  84 + /**
67 85 * 设置横向滚动
68 86 * @param {object} wrapper [需要设置滚动的对象]
69 87 */
... ...
src/components/style_7/style_7.less
... ... @@ -17,5 +17,8 @@
17 17 height: auto;
18 18 }
19 19 }
  20 + .horiz-list-box {
  21 + margin-top: 30px;
  22 + }
20 23 }
21 24 }
22 25 \ No newline at end of file
... ...
src/components/style_7/style_7.vue
... ... @@ -85,6 +85,6 @@
85 85 </script>
86 86  
87 87 <!-- Add "scoped" attribute to limit CSS to this component only -->
88   -<style rel="stylesheet/less" lang="less">
  88 +<style rel="stylesheet/less" lang="less" scoped>
89 89 @import './style_7';
90 90 </style>
91 91 \ No newline at end of file
... ...
src/pages/com/com.vue
1 1 <template>
2 2 <div class="com">
3 3  
4   - <!-- 商品样式 滑动 -->
  4 + <!-- 商品样式 2 滑动 -->
5 5 <horiz-list @jump="jump"
6 6 :lists="lists"
7 7 com="2"
8   - pid="2">
  8 + pid="1">
9 9  
10 10 <!-- 标题 -->
11 11 <text-title-box slot="title-box"
... ... @@ -15,7 +15,18 @@
15 15 </text-title-box>
16 16 </horiz-list>
17 17  
  18 + <!-- 商品样式 3 滑动 -->
  19 + <horiz-list @jump="jump" @primary="primary"
  20 + :lists="lists3"
  21 + com="3">
18 22  
  23 + <!-- 标题 -->
  24 + <text-title-box slot="title-box"
  25 + :titles="{
  26 + title: '最新上架'
  27 + }">
  28 + </text-title-box>
  29 + </horiz-list>
19 30  
20 31 </div>
21 32 </template>
... ... @@ -62,6 +73,50 @@
62 73 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
63 74 price: "230.90"
64 75 }
  76 + ],
  77 + lists3: [
  78 + {
  79 + simg: "static/img/pic_1.jpg",
  80 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  81 + ads: "全面屏包罗万",
  82 + price: "230.90",
  83 + primaryText: "立即购买"
  84 + },
  85 + {
  86 + simg: "static/img/pic_2.jpg",
  87 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  88 + ads: "全面屏包罗万",
  89 + price: "230.90",
  90 + primaryText: "立即购买"
  91 + },
  92 + {
  93 + simg: "static/img/pic_3.jpg",
  94 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  95 + ads: "全面屏包罗万",
  96 + price: "230.90",
  97 + primaryText: "立即购买"
  98 + },
  99 + {
  100 + simg: "static/img/pic_1.jpg",
  101 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  102 + ads: "全面屏包罗万",
  103 + price: "230.90",
  104 + primaryText: "立即购买"
  105 + },
  106 + {
  107 + simg: "static/img/pic_2.jpg",
  108 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  109 + ads: "全面屏包罗万",
  110 + price: "230.90",
  111 + primaryText: "立即购买"
  112 + },
  113 + {
  114 + simg: "static/img/pic_3.jpg",
  115 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  116 + ads: "全面屏包罗万",
  117 + price: "230.90",
  118 + primaryText: "立即购买"
  119 + }
65 120 ]
66 121  
67 122  
... ... @@ -115,6 +170,18 @@
115 170 this.$parent.gotoDetail(options);
116 171 }
117 172 },
  173 +
  174 + /**
  175 + * 主按钮点击事件
  176 + * @param {object} item [数据对象]
  177 + */
  178 + primary(item) {
  179 +
  180 +
  181 + console.log("primary", item);
  182 +
  183 +
  184 + },
118 185  
119 186  
120 187  
... ...