Commit eab0f03b46516d4a97959a1a6e50cb972f0c2132

Authored by 王强
1 parent 997d5677

“优选”页面下部组件完成

src/components/flagLeftTop/flagLeftTop.less 0 → 100644
  1 +@charset "UTF-8";
  2 +
  3 +.flag-left-top-box {
  4 + .box {
  5 + position: absolute;
  6 + top: -6px;
  7 + left: 10px;
  8 + z-index: 10;
  9 + .flag-img {
  10 + display: block;
  11 + width: 46px;
  12 + height: auto;
  13 + }
  14 + }
  15 +}
... ...
src/components/flagLeftTop/flagLeftTop.vue 0 → 100644
  1 +<template>
  2 + <div class="flag-left-top-box" v-if="flag">
  3 + <div class="box">
  4 + <img :src="flag" class="flag-img" mode="widthFix" />
  5 + </div>
  6 + </div>
  7 +</template>
  8 +
  9 +<script>
  10 + export default {
  11 + data: function () {
  12 + return {
  13 +
  14 + }
  15 + },
  16 + props: ["flag"]
  17 + }
  18 +</script>
  19 +
  20 +<!-- Add "scoped" attribute to limit CSS to this component only -->
  21 +<style rel="stylesheet/less" lang="less" scoped>
  22 + @import './flagLeftTop';
  23 +</style>
... ...
src/components/goodsItem_2/goodsItem_2.less
... ... @@ -5,22 +5,25 @@
5 5 padding: 20px 0;
6 6 width: 240px;
7 7 height: auto;
8   - border-radius: 8px;
9   - .img-box {
10   - display: flex;
11   - justify-content: center;
12   - align-items: center;
13   - background-color: #F9F9F9;
14   - margin: 0 auto;
15   - width: 200px;
16   - height: 200px;
17   - border-radius: 8px;
18   - overflow: hidden;
19   - .simg {
20   - display: block;
21   - width: 200px;
22   - }
23   - }
  8 + border-radius: 8px;
  9 + .top-box {
  10 + position: relative;
  11 + .img-box {
  12 + display: flex;
  13 + justify-content: center;
  14 + align-items: center;
  15 + background-color: #F9F9F9;
  16 + margin: 0 auto;
  17 + width: 200px;
  18 + height: 200px;
  19 + border-radius: 8px;
  20 + overflow: hidden;
  21 + .simg {
  22 + display: block;
  23 + width: 200px;
  24 + }
  25 + }
  26 + }
24 27 .content-box {
25 28 margin: 0 auto;
26 29 width: 200px;
... ... @@ -50,8 +53,11 @@
50 53 }
51 54 }
52 55 }
53   -
54   - &.pid-2 { // 排名样式
  56 +
  57 + &.pid-2 { // 排名样式
  58 + background-color: transparent;
  59 + padding: 0;
  60 + width: 200px;
55 61 .content-box {
56 62 .price-box {
57 63 justify-content: center;
... ... @@ -67,4 +73,4 @@
67 73 }
68 74 }
69 75 }
70   -}
71 76 \ No newline at end of file
  77 +}
... ...
src/components/goodsItem_2/goodsItem_2.vue
1 1 <template>
2 2 <div class="goods-item-2-box" :class="'pid-' + pid" v-if="item" @click="jump(item)">
3   - <div class="img-box">
4   - <img v-lazy="item.simg + SIGN.SMALL" class="simg" />
5   - </div>
  3 + <div class="top-box">
  4 + <div class="img-box">
  5 + <img v-lazy="item.simg + SIGN.SMALL" class="simg" />
  6 + </div>
  7 + <slot name="flag"></slot>
  8 + </div>
6 9 <div class="content-box">
7 10 <div class="title" v-if="pid == undefined || pid == '1'">{{item.title}}</div>
8 11 <div class="price-box">
... ... @@ -20,12 +23,12 @@
20 23 export default {
21 24 data: function () {
22 25 return {
23   -
  26 +
24 27 }
25 28 },
26 29 props: ["item", "pid"],
27 30 methods: {
28   -
  31 +
29 32 /**
30 33 * 点击跳转
31 34 * @param {object} item [数据对象]
... ... @@ -40,4 +43,4 @@
40 43 <!-- Add "scoped" attribute to limit CSS to this component only -->
41 44 <style rel="stylesheet/less" lang="less" scoped>
42 45 @import './goodsItem_2';
43   -</style>
44 46 \ No newline at end of file
  47 +</style>
... ...
src/components/horizList/horizList.vue
... ... @@ -6,10 +6,21 @@
6 6 <div class="scroll-box" ref="scrollBox">
7 7 <div class="box" :style="'width: ' + scrollItemBox + 'vw'">
8 8 <div class="item-box" v-for="(item, index) in lists" :key="index">
9   -
10   - <!--
11   - com=1:goodsItem_1组件,pid:1、3,固定不滚动,2、4,滚动
12   - com=2:goodsItem_2组件,pid: 1,带标题,2、不带标题,显示附加信息
  9 +
  10 + <!--
  11 + com=1:goodsItem_1组件,pid:1、3,固定不滚动;2、4,滚动
  12 + 事件:
  13 + @jump:整个点击跳转事件
  14 + @addCart:右下角加入购物车按钮事件,已阻止事件冒泡
  15 +
  16 + com=2:goodsItem_2组件,pid: 1,带标题,不显示附加信息;2、不带标题,显示附加信息
  17 + 事件:
  18 + @jump:整个点击跳转事件
  19 +
  20 + com=3:goodsItem_3组件,无pid参数
  21 + 事件:
  22 + @jump:整个点击跳转事件
  23 + @primary:右下角红色主按钮点击事件,已阻止事件冒泡
13 24 -->
14 25  
15 26 <!-- 商品展示样式 1 -->
... ... @@ -56,7 +67,7 @@
56 67 goodsItem3
57 68 },
58 69 methods: {
59   -
  70 +
60 71 /**
61 72 * 点击跳转
62 73 * @param {object} item [数据对象]
... ... @@ -86,13 +97,13 @@
86 97 * @param {object} wrapper [需要设置滚动的对象]
87 98 */
88 99 setScrollBox(wrapper) {
89   -
  100 +
90 101 // box滚动元素宽度,item对象
91 102 let scrollItemBox = 0;
92 103 let clientWidth = wrapper.clientWidth;
93 104 let multiple = clientWidth / 750;
94 105 let childrens = wrapper.children[0].children;
95   -
  106 +
96 107 // 遍历子元素,获取box宽度
97 108 for (let i = 0; i < childrens.length; i++) {
98 109 scrollItemBox += childrens[i].clientWidth;
... ... @@ -148,4 +159,4 @@
148 159 <!-- Add "scoped" attribute to limit CSS to this component only -->
149 160 <style rel="stylesheet/less" lang="less">
150 161 @import './horizList';
151   -</style>
152 162 \ No newline at end of file
  163 +</style>
... ...
src/components/horizListFlex/horizListFlex.less 0 → 100644
  1 +@charset "UTF-8";
  2 +
  3 +.horiz-list-flex-box {
  4 + .container-box {
  5 + display: flex;
  6 + justify-content: space-evenly;
  7 + align-items: center;
  8 + background-color: #ffffff;
  9 + margin: 0 auto;
  10 + padding: 25px 0 30px 0;
  11 + width: 690px;
  12 + height: auto;
  13 + border-radius: 12px;
  14 + }
  15 +}
... ...
src/components/horizListFlex/horizListFlex.vue 0 → 100644
  1 +<template>
  2 + <div class="horiz-list-flex-box" v-if="lists && lists.length">
  3 + <slot name="title-box"></slot>
  4 + <div class="container-box">
  5 + <div class="item-box" v-for="(item, index) in lists" :key="index">
  6 +
  7 + <!--
  8 + com=1:goodsItem_1组件,pid:1、3,固定不滚动;2、4,滚动
  9 + 事件:
  10 + @jump:整个点击跳转事件
  11 + @addCart:右下角加入购物车按钮事件,已阻止事件冒泡
  12 +
  13 + com=2:goodsItem_2组件,pid: 1,带标题,不显示附加信息;2、不带标题,显示附加信息
  14 + 事件:
  15 + @jump:整个点击跳转事件
  16 +
  17 + com=3:goodsItem_3组件,无pid参数
  18 + 事件:
  19 + @jump:整个点击跳转事件
  20 + @primary:右下角红色主按钮点击事件,已阻止事件冒泡
  21 + -->
  22 +
  23 + <!-- 商品展示样式 1 -->
  24 + <goods-item-1 v-if="com == '1'" @jump="jump" @addCart="addCart"
  25 + :item="item"
  26 + :pid="pid">
  27 + </goods-item-1>
  28 +
  29 + <!-- 商品展示样式 2 -->
  30 + <goods-item-2 v-if="com == '2'" @jump="jump"
  31 + :item="item"
  32 + :pid="pid">
  33 +
  34 + <!-- 左上角角标icon -->
  35 + <flag-left-top slot="flag" v-if="flags && flags[index]"
  36 + :flag="flags[index]">
  37 + </flag-left-top>
  38 + </goods-item-2>
  39 +
  40 + <!-- 商品展示样式 3 -->
  41 + <goods-item-3 v-if="com == '3'" @jump="jump" @primary="primary"
  42 + :item="item">
  43 + </goods-item-3>
  44 + </div>
  45 + </div>
  46 + </div>
  47 +</template>
  48 +
  49 +<script>
  50 + // 引入组件
  51 + import goodsItem1 from "@/components/goodsItem_1/goodsItem_1";
  52 + import goodsItem2 from "@/components/goodsItem_2/goodsItem_2";
  53 + import goodsItem3 from "@/components/goodsItem_3/goodsItem_3";
  54 + import flagLeftTop from "@/components/flagLeftTop/flagLeftTop";
  55 +
  56 + export default {
  57 + data: function () {
  58 + return {
  59 +
  60 + }
  61 + },
  62 + props: ["lists", "com", "pid", "flags"],
  63 + components: {
  64 + goodsItem1,
  65 + goodsItem2,
  66 + goodsItem3,
  67 + flagLeftTop
  68 + }
  69 + }
  70 +</script>
  71 +
  72 +<!-- Add "scoped" attribute to limit CSS to this component only -->
  73 +<style rel="stylesheet/less" lang="less" scoped>
  74 + @import './horizListFlex';
  75 +</style>
... ...
src/pages/com/com.less
1 1 @charset "UTF-8";
2 2  
3 3 .com {
4   - background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(249, 249, 249, 1) 100%);
5   -}
6 4 \ No newline at end of file
  5 + background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(249, 249, 249, 1) 10%, rgba(249, 249, 249, 1) 100%);
  6 + // background: linear-gradient(180deg, rgba(255, 255, 255, 1) 0%, rgba(0, 0, 0, 1) 10%, rgba(0, 0, 0, 1) 100%);
  7 + padding-top: 50px;
  8 + .components-box {
  9 + margin-bottom: 50px;
  10 + &:last-child {
  11 + margin-bottom: 0;
  12 + }
  13 + }
  14 +}
... ...
src/pages/com/com.vue
1 1 <template>
2 2 <div class="com">
3 3  
  4 + <!-- 商品样式 2 横排flex -->
  5 + <horiz-list-flex class="components-box"
  6 + :lists="lists4"
  7 + com="2"
  8 + pid="2"
  9 + :flags="['static/img/icon_n1.png', 'static/img/icon_n2.png', 'static/img/icon_n3.png']">
  10 +
  11 + <!-- 标题 -->
  12 + <text-title-box slot="title-box"
  13 + :titles="{
  14 + title: '热销商品'
  15 + }">
  16 + </text-title-box>
  17 + </horiz-list-flex>
  18 +
  19 + <!-- 商品样式 3 滑动 -->
  20 + <horiz-list @jump="jump" @primary="primary"
  21 + :lists="lists3"
  22 + com="3">
  23 +
  24 + <!-- 标题 -->
  25 + <text-title-box slot="title-box"
  26 + :titles="{
  27 + title: '最新上架'
  28 + }">
  29 + </text-title-box>
  30 + </horiz-list>
  31 +
4 32 <!-- 商品样式 2 滑动 -->
5 33 <horiz-list @jump="jump"
6 34 :lists="lists"
... ... @@ -14,7 +42,7 @@
14 42 }">
15 43 </text-title-box>
16 44 </horiz-list>
17   -
  45 +
18 46 <!-- 商品样式 3 滑动 -->
19 47 <horiz-list @jump="jump" @primary="primary"
20 48 :lists="lists3"
... ... @@ -23,11 +51,16 @@
23 51 <!-- 标题 -->
24 52 <text-title-box slot="title-box"
25 53 :titles="{
26   - title: '最新上架'
  54 + title: '猜你喜欢'
27 55 }">
28 56 </text-title-box>
29 57 </horiz-list>
30   -
  58 +
  59 +
  60 +
  61 +
  62 +
  63 +
31 64 </div>
32 65 </template>
33 66  
... ... @@ -36,6 +69,7 @@
36 69 // 引入组件
37 70 import { Toast, Indicator } from "mint-ui";
38 71 import horizList from "@/components/horizList/horizList";
  72 + import horizListFlex from "@/components/horizListFlex/horizListFlex";
39 73 import textTitleBox from "@/components/textTitleBox/textTitleBox";
40 74  
41 75 export default {
... ... @@ -44,74 +78,97 @@
44 78 title: "",
45 79 lists: [
46 80 {
47   - simg: "static/img/pic_1.jpg",
  81 + simg: "static/img/pic_4.png",
48 82 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
49 83 price: "230.90"
50 84 },
51 85 {
52   - simg: "static/img/pic_2.jpg",
  86 + simg: "static/img/pic_4.png",
53 87 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
54 88 price: "230.90"
55 89 },
56 90 {
57   - simg: "static/img/pic_3.jpg",
  91 + simg: "static/img/pic_4.png",
58 92 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
59 93 price: "230.90"
60 94 },
61 95 {
62   - simg: "static/img/pic_1.jpg",
  96 + simg: "static/img/pic_4.png",
63 97 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
64 98 price: "230.90"
65 99 },
66 100 {
67   - simg: "static/img/pic_2.jpg",
  101 + simg: "static/img/pic_4.png",
68 102 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
69 103 price: "230.90"
70 104 },
71 105 {
72   - simg: "static/img/pic_3.jpg",
  106 + simg: "static/img/pic_4.png",
73 107 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
74 108 price: "230.90"
75 109 }
76 110 ],
77 111 lists3: [
78 112 {
79   - simg: "static/img/pic_1.jpg",
  113 + simg: "static/img/pic_4.png",
80 114 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
81 115 ads: "全面屏包罗万",
82 116 price: "230.90",
83 117 primaryText: "立即购买"
84 118 },
85 119 {
86   - simg: "static/img/pic_2.jpg",
  120 + simg: "static/img/pic_4.png",
87 121 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
88 122 ads: "全面屏包罗万",
89 123 price: "230.90",
90 124 primaryText: "立即购买"
91 125 },
92 126 {
93   - simg: "static/img/pic_3.jpg",
  127 + simg: "static/img/pic_4.png",
94 128 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
95 129 ads: "全面屏包罗万",
96 130 price: "230.90",
97 131 primaryText: "立即购买"
98 132 },
99 133 {
100   - simg: "static/img/pic_1.jpg",
  134 + simg: "static/img/pic_4.png",
101 135 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
102 136 ads: "全面屏包罗万",
103 137 price: "230.90",
104 138 primaryText: "立即购买"
105 139 },
106 140 {
107   - simg: "static/img/pic_2.jpg",
  141 + simg: "static/img/pic_4.png",
108 142 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
109 143 ads: "全面屏包罗万",
110 144 price: "230.90",
111 145 primaryText: "立即购买"
112 146 },
113 147 {
114   - simg: "static/img/pic_3.jpg",
  148 + simg: "static/img/pic_4.png",
  149 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  150 + ads: "全面屏包罗万",
  151 + price: "230.90",
  152 + primaryText: "立即购买"
  153 + }
  154 + ],
  155 + lists4: [
  156 + {
  157 + simg: "static/img/pic_4.png",
  158 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  159 + ads: "全面屏包罗万",
  160 + price: "230.90",
  161 + primaryText: "立即购买"
  162 + },
  163 + {
  164 + simg: "static/img/pic_4.png",
  165 + title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
  166 + ads: "全面屏包罗万",
  167 + price: "230.90",
  168 + primaryText: "立即购买"
  169 + },
  170 + {
  171 + simg: "static/img/pic_4.png",
115 172 title: "传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐传统汉堡焗套餐",
116 173 ads: "全面屏包罗万",
117 174 price: "230.90",
... ... @@ -128,6 +185,7 @@
128 185 },
129 186 components: {
130 187 horizList,
  188 + horizListFlex,
131 189 textTitleBox,
132 190  
133 191  
... ... @@ -137,7 +195,7 @@
137 195 // 设置标题
138 196 this.$set(this, "title", "ccdd");
139 197  
140   -
  198 +
141 199  
142 200  
143 201  
... ... @@ -163,14 +221,14 @@
163 221  
164 222  
165 223 console.log(options);
166   -
  224 +
167 225  
168 226  
169 227  
170 228 this.$parent.gotoDetail(options);
171 229 }
172 230 },
173   -
  231 +
174 232 /**
175 233 * 主按钮点击事件
176 234 * @param {object} item [数据对象]
... ... @@ -179,11 +237,11 @@
179 237  
180 238  
181 239 console.log("primary", item);
182   -
  240 +
183 241  
184 242 },
185 243  
186   -
  244 +
187 245  
188 246 },
189 247 head: {
... ... @@ -205,7 +263,7 @@
205 263 }
206 264 },
207 265 mounted() {
208   -
  266 +
209 267 }
210 268 }
211 269 </script>
... ...
static/img/icon_n1.png 0 → 100644

1.22 KB

static/img/icon_n2.png 0 → 100644

1.59 KB

static/img/icon_n3.png 0 → 100644

1.89 KB

static/img/pic_4.png 0 → 100644

21.8 KB