Commit 3b266c4a0e853ba62adef1e5b3972754af6fdc4a

Authored by sfmind
1 parent 9e69f6e6

完善产品页静态布局

yudao-ui-app/pages/product/product.vue
1 1 <template>
2 2 <view class="container">
3   - <u-swiper :list="product.images" @change="e => currentNum = e.current" :autoplay="false" height="750rpx" radius="0" indicatorStyle="right: 20px">
  3 + <u-swiper :list="product.images" @change="e => (currentNum = e.current)" :autoplay="false" height="750rpx" radius="0" indicatorStyle="right: 20px">
4 4 <view slot="indicator" class="indicator-num">
5 5 <text class="indicator-num__text">{{ currentNum + 1 }}/{{ product.images.length }}</text>
6 6 </view>
... ... @@ -14,49 +14,125 @@
14 14 <u--text :lines="3" size="12px" color="#939393" :text="product.desc"></u--text>
15 15 </view>
16 16 <view class="price-and-cart">
17   - <u--text-price color="red" size="16" intSize="26" :text="product.price"></u--text-price>
  17 + <custom-text-price color="red" size="16" intSize="26" :price="product.price"></custom-text-price>
18 18 </view>
19 19 </view>
20 20 <view class="prod-favor">
21 21 <u-icon name="star" color="#2979ff" size="28"></u-icon>
22 22 </view>
23   -
24 23 </view>
25 24  
26 25 <u-gap height="8" bgColor="#f3f3f3"></u-gap>
27   - <view class="info-box">
28   - <text class="info-title">配送</text>
29   -<!-- <text>快递配送</text>
30   - <text>到店自提</text>-->
  26 + <view class="row-box">
  27 + <view class="row-left">规格</view>
  28 + <view class="row-right" @click="skuPopup = true">
  29 + <view class="row-content">
  30 + <view class="sku-box">
  31 + <view v-if="product.sku.length > 0" class="sku-item">
  32 + <view class="sku-desc">{{ product.sku[currentSkuIndex].desc }}</view>
  33 + </view>
  34 + </view>
  35 + </view>
  36 + <view class="row-more">
  37 + <u-icon name="more-dot-fill" color="#939393" size="14"></u-icon>
  38 + </view>
  39 + </view>
31 40 </view>
32 41  
33   - <u-gap height="8" bgColor="#f3f3f3"></u-gap>
34   - <view class="info-box" @click="showPromPopup">
35   - <text class="info-title">促销</text>
36   - </view>
  42 + <!-- 商品SKU选择弹窗 -->
  43 + <u-popup :show="skuPopup" :round="10" :closeable="true" :closeOnClickOverlay="false" @close="skuPopup = false">
  44 + <view class="sku-popup-slot">
  45 + <view class="current-sku-info">
  46 + <u--image class="current-sku-img" :showLoading="true" :src="product.sku[currentSkuIndex].image" width="120rpx" height="120rpx"></u--image>
  47 + <view class="current-sku-desc">
  48 + <view class="name">{{ product.sku[currentSkuIndex].desc }}</view>
  49 + <custom-text-price color="red" size="12" intSize="18" :price="product.sku[currentSkuIndex].price"></custom-text-price>
  50 + <view class="current-sku-stock">库存: {{ 1 }}</view>
  51 + </view>
  52 + </view>
  53 + <view class="sku-selection">
  54 + <view class="sku-item" :class="{ active: currentSkuIndex === index }" v-for="(item, index) in product.sku" :key="item.id" @click="handleSkuItemClick(index)">{{ item.desc }}</view>
  55 + </view>
  56 + <view class="sku-num-box">
  57 + <view class="text">选择数量</view>
  58 + <u-number-box integer></u-number-box>
  59 + </view>
  60 + <view class="sku-btn-group">
  61 + <view class="btn-item-main">
  62 + <u-button type="warning" shape="circle" size="small" text="加入购物车"></u-button>
  63 + </view>
  64 + <view class="btn-item-main">
  65 + <u-button type="error" shape="circle" size="small" text="立即购买"></u-button>
  66 + </view>
  67 + </view>
  68 + </view>
  69 + </u-popup>
37 70  
38   - <view>
39   - <u-popup :show="promotionPopup" :round="10" :closeable="true" :closeOnClickOverlay="false" @close="closePromPopup">
40   - <view class="prom-popup-slot">
41   - <view class="prom-title">促销信息</view>
42   - <view class="prom-list">
43   - <view class="prom-item">全场满500减100</view>
44   - <view class="prom-item">全场满300减50</view>
45   - <view class="prom-item">全场满200减20</view>
46   - <view class="prom-item">全场满100减5</view>
  71 + <u-gap height="8" bgColor="#f3f3f3"></u-gap>
  72 + <view class="row-box">
  73 + <view class="row-left">配送</view>
  74 + <view class="row-right">
  75 + <view class="row-content">
  76 + <view class="delivery-box">
  77 + <view class="delivery-item" v-for="(item, index) in deliveryType" :key="item.id">
  78 + <u-icon name="checkmark-circle" color="#2979ff" size="16"></u-icon>
  79 + <text class="delivery-name">{{ item.name }}</text>
  80 + </view>
47 81 </view>
48 82 </view>
49   - </u-popup>
  83 + <view class="row-more"></view>
  84 + </view>
50 85 </view>
51 86  
52 87 <u-gap height="8" bgColor="#f3f3f3"></u-gap>
53   - <view class="info-box">
54   - <text class="info-title">领券</text>
  88 + <view class="row-box">
  89 + <view class="row-left">促销</view>
  90 + <view class="row-right" v-if="promotionList.length > 0" @click="promotionPopup = true">
  91 + <view class="row-content">
  92 + <view class="prom-box">
  93 + <view class="prom-item">
  94 + <view class="prom-title">{{ promotionList[0].title }}</view>
  95 + <text class="prom-desc">{{ promotionList[0].desc }}</text>
  96 + </view>
  97 + </view>
  98 + </view>
  99 + <view class="row-more">
  100 + <u-icon name="more-dot-fill" color="#939393" size="14"></u-icon>
  101 + </view>
  102 + </view>
55 103 </view>
56 104  
  105 + <!-- 促销信息弹窗 -->
  106 + <u-popup :show="promotionPopup" :round="10" :closeable="true" :closeOnClickOverlay="false" @close="promotionPopup = false">
  107 + <view class="prom-popup-slot">
  108 + <view class="prom-info">促销信息</view>
  109 + <view class="prom-list">
  110 + <view v-for="(item, index) in promotionList" :key="index.id" class="prom-item">
  111 + <view class="prom-title">{{ item.title }}</view>
  112 + <text class="prom-desc">{{ item.desc }}</text>
  113 + </view>
  114 + </view>
  115 + </view>
  116 + </u-popup>
  117 +
57 118 <u-gap height="8" bgColor="#f3f3f3"></u-gap>
58   - <view class="info-box">
59   - <text class="info-title">已选</text>
  119 + <view class="row-box">
  120 + <view class="row-left">领券</view>
  121 + <view class="row-right" @click="handleCouponClick">
  122 + <view class="row-content">
  123 + <view class="coupon-box">
  124 + <view v-if="couponList.length > 0" class="coupon-list">
  125 + <view v-for="(item, index) in couponList" :key="item.id" class="coupon-item">
  126 + <view v-if="index < 2" class="coupon-desc">{{ item.desc }}</view>
  127 + </view>
  128 + </view>
  129 + <view class="coupon-total">共 {{ couponList.length }} 张</view>
  130 + </view>
  131 + </view>
  132 + <view class="row-more">
  133 + <u-icon name="more-dot-fill" color="#939393" size="14"></u-icon>
  134 + </view>
  135 + </view>
60 136 </view>
61 137  
62 138 <u-gap height="8" bgColor="#f3f3f3"></u-gap>
... ... @@ -65,46 +141,39 @@
65 141 <view class="evaluation-title">评价</view>
66 142 <view class="evaluation-info">
67 143 <view class="evan-type-list">
68   - <view class="evan-type-item" v-for="(item, index) in evanTypeList" :key="index" @click="handleEvanTypeClick(index)">
69   - {{item.name}}({{item.count}})
70   - </view>
  144 + <view class="evan-type-item" :class="{ active: currentEvanIndex === index }" v-for="(item, index) in evanTypeList" :key="item.id" @click="handleEvanTypeClick(index)"> {{ item.name }}({{ item.count }}) </view>
71 145 </view>
72 146 <view class="comment-empty" v-if="true">
73 147 <u-empty mode="comment" icon="/static/images/empty/comment.png"></u-empty>
74 148 </view>
75   - <view v-else class="comment-list" style="min-height: 50px">
76   -
77   - </view>
  149 + <view v-else class="comment-list" style="min-height: 50px"> </view>
78 150 </view>
79 151 </view>
80 152 </view>
81 153  
82 154 <view class="fixed-btn-box">
83 155 <view class="btn-group">
84   - <view class="btn-item">
  156 + <navigator class="btn-item" url="/pages/index/index" open-type="switchTab" hover-class="none">
85 157 <u-icon name="home" :size="24"></u-icon>
86 158 <view class="btn-text">首页</view>
87   - </view>
88   - <view class="btn-item">
  159 + </navigator>
  160 + <navigator class="btn-item" url="/pages/xxx/xxx" open-type="navigate" hover-class="none">
89 161 <u-icon name="server-man" :size="24"></u-icon>
90 162 <view class="btn-text">客服</view>
91   - </view>
92   - <view class="btn-item">
  163 + </navigator>
  164 + <navigator class="btn-item" url="/pages/cart/cart" open-type="switchTab" hover-class="none">
93 165 <u-icon name="bag" :size="24"></u-icon>
94 166 <view class="btn-text">购物车</view>
95   - </view>
96   - <view style="width: 200rpx">
  167 + </navigator>
  168 + <view class="btn-item-main">
97 169 <u-button type="warning" shape="circle" size="small" text="加入购物车"></u-button>
98 170 </view>
99   - <view style="width: 200rpx">
  171 + <view class="btn-item-main">
100 172 <u-button type="error" shape="circle" size="small" text="立即购买"></u-button>
101 173 </view>
102 174 </view>
103 175 </view>
104   -
105   -
106 176 </view>
107   -
108 177 </template>
109 178  
110 179 <script>
... ... @@ -113,15 +182,86 @@ export default {
113 182 return {
114 183 current: 0,
115 184 currentNum: 0,
  185 + currentSkuIndex: 0,
  186 + skuPopup: false,
116 187 product: {
117 188 id: '',
118 189 images: ['https://cdn.uviewui.com/uview/album/1.jpg', 'https://cdn.uviewui.com/uview/album/2.jpg', 'https://cdn.uviewui.com/uview/album/3.jpg'],
119 190 title: '山不在高,有仙则名。水不在深,有龙则灵。斯是陋室,惟吾德馨。',
120 191 desc: '山不在于高,有了神仙就会有名气。水不在于深,有了龙就会有灵气。这是简陋的房子,只是我品德好就感觉不到简陋了。',
121   - price: '13.00'
  192 + price: '13.00',
  193 + sku: [
  194 + {
  195 + id: 0,
  196 + image: 'https://cdn.uviewui.com/uview/album/1.jpg',
  197 + price: 13.0,
  198 + desc: '山不在高,有仙则名。'
  199 + },
  200 + {
  201 + id: 1,
  202 + image: 'https://cdn.uviewui.com/uview/album/2.jpg',
  203 + price: 11.0,
  204 + desc: '水不在深,有龙则灵。'
  205 + },
  206 + {
  207 + id: 2,
  208 + image: 'https://cdn.uviewui.com/uview/album/3.jpg',
  209 + price: 10.0,
  210 + desc: '斯是陋室,惟吾德馨。'
  211 + }
  212 + ]
122 213 },
  214 + deliveryType: [
  215 + {
  216 + id: 0,
  217 + name: '快递配送'
  218 + },
  219 + {
  220 + id: 1,
  221 + name: '到店自提'
  222 + }
  223 + ],
123 224 promotionPopup: false,
124   - currentEvanType: 0,
  225 + promotionList: [
  226 + {
  227 + id: 0,
  228 + title: '满额减',
  229 + desc: '全场满500减100'
  230 + },
  231 + {
  232 + id: 1,
  233 + title: '满额减',
  234 + desc: '全场满300减50'
  235 + },
  236 + {
  237 + id: 2,
  238 + title: '满额减',
  239 + desc: '全场满200减20'
  240 + },
  241 + {
  242 + id: 3,
  243 + title: '满额减',
  244 + desc: '全场满100减5'
  245 + }
  246 + ],
  247 + couponList: [
  248 + {
  249 + id: 0,
  250 + title: '优惠券',
  251 + desc: '满50减10'
  252 + },
  253 + {
  254 + id: 1,
  255 + title: '优惠券',
  256 + desc: '满30减5'
  257 + },
  258 + {
  259 + id: 2,
  260 + title: '优惠券',
  261 + desc: '满20减2'
  262 + }
  263 + ],
  264 + currentEvanIndex: 0,
125 265 evanTypeList: [
126 266 {
127 267 id: '0',
... ... @@ -147,60 +287,53 @@ export default {
147 287 id: '4',
148 288 name: '有图',
149 289 count: 0
150   - },
  290 + }
151 291 ]
152 292 }
153 293 },
154 294 onLoad(e) {
155 295 if (!e.productId) {
156   - uni.$u.toast('请求参数错误');
  296 + uni.$u.toast('请求参数错误')
157 297 } else {
158   - this.product.id = e.productId;
159   - this.loadProductData();
  298 + this.product.id = e.productId
  299 + this.loadProductData()
160 300 // TODO 请求接口获取商品详情数据
161 301 }
162   - console.log(e);
163 302 },
164 303 methods: {
165   - loadProductData(){
166   -
167   - },
168   - showPromPopup() {
169   - this.promotionPopup = true
170   - },
171   - closePromPopup(){
172   - this.promotionPopup = false
  304 + loadProductData() {},
  305 + handleSkuItemClick(index) {
  306 + this.currentSkuIndex = index
173 307 },
174   - handleEvanTypeClick(e) {
175   - this.currentEvanType = e.index;
  308 + handleCouponClick() {
  309 + // TODO 未登录去登录,登录则跳转优惠券页面
176 310 },
177   -
  311 + handleEvanTypeClick(index) {
  312 + this.currentEvanIndex = index
  313 + // TODO 展示评论
  314 + }
178 315 },
179   - computed: {
180   -
181   - }
  316 + computed: {}
182 317 }
183 318 </script>
184 319  
185 320 <style lang="scss" scoped>
186   -
187 321 .indicator-num {
  322 + @include flex-center;
188 323 padding: 2px 0;
189 324 background-color: rgba(0, 0, 0, 0.35);
190 325 border-radius: 100px;
191 326 width: 35px;
192   - @include flex;
193   - justify-content: center;
194 327  
195 328 &__text {
196   - color: #FFFFFF;
  329 + color: #ffffff;
197 330 font-size: 12px;
198 331 }
199 332 }
200 333  
201 334 .product-box {
202 335 padding: 40rpx 40rpx 10rpx 40rpx;
203   - display: flex;
  336 + @include flex;
204 337 border-bottom: $custom-border-style;
205 338 .prod-info {
206 339 padding-right: 30rpx;
... ... @@ -208,8 +341,7 @@ export default {
208 341 padding-bottom: 10rpx;
209 342 }
210 343 .price-and-cart {
211   - display: flex;
212   - justify-content: space-between;
  344 + @include flex-space-between;
213 345 }
214 346 }
215 347 .prod-favor {
... ... @@ -217,28 +349,174 @@ export default {
217 349 }
218 350 }
219 351  
220   -.info-box {
221   - padding: 15rpx 30rpx;
222   - .info-title {
223   - font-size: 30rpx;
  352 +.row-box {
  353 + @include flex-left;
  354 + padding: 0 30rpx;
  355 + height: 70rpx;
  356 + .row-left {
  357 + width: 70rpx;
  358 + font-size: 22rpx;
  359 + color: #939393;
  360 + }
  361 +
  362 + .row-right {
  363 + @include flex-space-between;
  364 + width: 620rpx;
  365 +
  366 + .row-content {
  367 + width: 590rpx;
  368 +
  369 + .delivery-box {
  370 + @include flex-left;
  371 + .delivery-item {
  372 + margin-right: 20rpx;
  373 + @include flex-left;
  374 + font-size: 14rpx;
  375 + .delivery-name {
  376 + margin-left: 5rpx;
  377 + }
  378 + }
  379 + }
  380 +
  381 + .prom-box {
  382 + @include flex-left;
  383 + .prom-item {
  384 + @include flex-left;
  385 + font-size: 12rpx;
  386 + .prom-title {
  387 + padding: 1rpx 10rpx;
  388 + border: 1rpx solid red;
  389 + border-radius: 5rpx;
  390 + color: red;
  391 + transform: scale(0.9);
  392 + }
  393 + .prom-desc {
  394 + margin-left: 15rpx;
  395 + }
  396 + }
  397 + }
  398 +
  399 + .coupon-box {
  400 + @include flex-space-between;
  401 + .coupon-list {
  402 + @include flex-left;
  403 + .coupon-item {
  404 + @include flex-left;
  405 + font-size: 12rpx;
  406 + .coupon-desc {
  407 + padding: 2rpx 15rpx;
  408 + margin-right: 15rpx;
  409 + background: red;
  410 + color: #ffffff;
  411 + }
  412 + }
  413 + }
  414 + .coupon-total {
  415 + color: #939393;
  416 + font-size: 12rpx;
  417 + padding: 0 15rpx;
  418 + }
  419 + }
  420 +
  421 + .sku-box {
  422 + @include flex-space-between;
  423 + .sku-item {
  424 + @include flex-left;
  425 + font-size: 12rpx;
  426 + .sku-desc {
  427 + margin-left: 15rpx;
  428 + font-weight: 700;
  429 + }
  430 + }
  431 + }
  432 + }
  433 +
  434 + .row-more {
  435 + @include flex-right;
  436 + width: 30rpx;
  437 + }
  438 + }
  439 +}
  440 +
  441 +.sku-popup-slot {
  442 + width: 750rpx;
  443 + .current-sku-info {
  444 + @include flex;
  445 + padding: 30rpx 100rpx 0 30rpx;
  446 + .current-sku-img {
  447 + border-radius: 10rpx;
  448 + /deep/ * {
  449 + border-radius: 10rpx;
  450 + }
  451 + }
  452 + .current-sku-desc {
  453 + padding: 0 30rpx;
  454 + font-size: 28rpx;
  455 + .current-sku-stock {
  456 + height: 40rpx;
  457 + line-height: 40rpx;
  458 + color: #666666;
  459 + font-size: 24rpx;
  460 + }
  461 + }
  462 + }
  463 + .sku-selection {
  464 + margin: 30rpx;
  465 + font-size: 26rpx;
  466 + color: #939393;
  467 + .sku-item {
  468 + margin-bottom: 20rpx;
  469 + border-radius: 6rpx;
  470 + padding: 5rpx 15rpx;
  471 + border: 1rpx solid #e3e3e3;
  472 + width: fit-content !important;
  473 + &.active {
  474 + color: #666666;
  475 + border: 1rpx solid #666666;
  476 + }
  477 + }
  478 + }
  479 + .sku-num-box {
  480 + @include flex-space-between padding: 30rpx;
  481 + .text {
  482 + font-size: 30rpx;
  483 + }
  484 + }
  485 + .sku-btn-group {
  486 + @include flex-space-around;
  487 + height: 100rpx;
  488 + .btn-item-main {
  489 + width: 350rpx;
  490 + }
224 491 }
225 492 }
226 493  
227 494 .prom-popup-slot {
228 495 width: 750rpx;
229 496 min-height: 500rpx;
230   - .prom-title {
  497 + .prom-info {
231 498 background: #f3f3f3;
232   - line-height: 100rpx;
  499 + line-height: 90rpx;
233 500 padding-left: 30rpx;
234 501 font-size: 36rpx;
235 502 border-radius: 10px 10px 0 0;
236 503 }
237   - .prom-list{
  504 + .prom-list {
238 505 padding: 30rpx;
239   - .prom-item{
240   - line-height: 40rpx;
241   - font-size: 24rpx;
  506 + .prom-item {
  507 + @include flex-left;
  508 + font-size: 14rpx;
  509 + margin-bottom: 15rpx;
  510 + .prom-title {
  511 + padding: 1rpx 10rpx;
  512 + border: 1rpx solid red;
  513 + border-radius: 5rpx;
  514 + color: red;
  515 + transform: scale(0.9);
  516 + }
  517 + .prom-desc {
  518 + margin-left: 15rpx;
  519 + }
242 520 }
243 521 }
244 522 }
... ... @@ -251,34 +529,36 @@ export default {
251 529 background: $custom-bg-color;
252 530 padding-bottom: 120rpx;
253 531  
254   - .evaluation-title{
  532 + .evaluation-title {
255 533 border-radius: 20rpx 20rpx 0 0;
256 534 padding: 20rpx 30rpx;
257 535 border-bottom: $custom-border-style;
258 536 font-size: 30rpx;
259 537 }
260 538  
261   - .evaluation-info{
262   -
  539 + .evaluation-info {
263 540 }
264 541  
265   - .evan-type-list{
  542 + .evan-type-list {
266 543 padding: 20rpx;
267   - display: flex;
268   - align-items: center;
269   - justify-content: space-around;
  544 + @include flex-space-around;
270 545  
271 546 .evan-type-item {
272 547 border-radius: 8rpx;
273   - padding: 8rpx 12rpx;
  548 + padding: 7rpx 12rpx;
274 549 background: #f3f3f3;
275 550 font-size: 12rpx;
276 551 text-align: center;
  552 + &.active {
  553 + background: #ffffff;
  554 + border: 1rpx solid red;
  555 + padding: 5rpx 10rpx;
  556 + color: red;
  557 + }
277 558 }
278 559 }
279 560  
280 561 .comment-empty {
281   -
282 562 }
283 563 }
284 564 }
... ... @@ -292,23 +572,21 @@ export default {
292 572 border-top: $custom-border-style;
293 573  
294 574 width: 750rpx;
295   - display: flex;
296   - align-items: center;
297   - justify-content: space-around;
  575 + @include flex-space-around;
298 576 height: 100rpx;
299 577  
300 578 .btn-item {
301 579 width: 80rpx;
302   - display: flex;
303   - flex-direction: column;
304   - align-items: center;
  580 + @include flex-center(column);
305 581 .btn-text {
306 582 font-size: 12rpx;
307 583 color: #666666;
308 584 }
309 585 }
  586 +
  587 + .btn-item-main {
  588 + width: 200rpx;
  589 + }
310 590 }
311 591 }
312   -
313   -
314 592 </style>
... ...