|
121 | 121 | <span>{{foods.specfoods[0].price}}</span> |
122 | 122 | <span v-if="foods.specifications.length">起</span> |
123 | 123 | </section> |
124 | | - <buy-cart :shopId='shopId' :foods='foods' @moveInCart="listenInCart"></buy-cart> |
| 124 | + <buy-cart :shopId='shopId' :foods='foods' @moveInCart="listenInCart" @showChooseList="showChooseList" @showReduceTip="showReduceTip"></buy-cart> |
125 | 125 | </footer> |
126 | 126 | </section> |
127 | 127 | </li> |
|
252 | 252 | </section> |
253 | 253 | </transition> |
254 | 254 | </section> |
| 255 | + <section> |
| 256 | + <transition name="fade"> |
| 257 | + <div class="specs_cover" @click="showChooseList" v-if="showSpecs"></div> |
| 258 | + </transition> |
| 259 | + <transition name="fadeBounce"> |
| 260 | + <div class="specs_list" v-if="showSpecs"> |
| 261 | + <header class="specs_list_header"> |
| 262 | + <h4 class="ellipsis">{{choosedFoods.name}}</h4> |
| 263 | + <svg width="16" height="16" xmlns="http://www.w3.org/2000/svg" version="1.1"class="specs_cancel" @click="showChooseList"> |
| 264 | + <line x1="0" y1="0" x2="16" y2="16" stroke="#666" stroke-width="1.2"/> |
| 265 | + <line x1="0" y1="16" x2="16" y2="0" stroke="#666" stroke-width="1.2"/> |
| 266 | + </svg> |
| 267 | + </header> |
| 268 | + <section class="specs_details"> |
| 269 | + <h5 class="specs_details_title">{{choosedFoods.specifications[0].name}}</h5> |
| 270 | + <ul> |
| 271 | + <li v-for="(item, itemIndex) in choosedFoods.specifications[0].values" :class="{specs_activity: itemIndex == specsIndex}" @click="chooseSpecs(itemIndex)"> |
| 272 | + {{item}} |
| 273 | + </li> |
| 274 | + </ul> |
| 275 | + </section> |
| 276 | + <footer class="specs_footer"> |
| 277 | + <div class="specs_price"> |
| 278 | + <span>¥ </span> |
| 279 | + <span>{{choosedFoods.specfoods[specsIndex].price}}</span> |
| 280 | + </div> |
| 281 | + <div class="specs_addto_cart" @click="addSpecs(choosedFoods.category_id, choosedFoods.item_id, choosedFoods.specfoods[specsIndex].food_id, choosedFoods.specfoods[specsIndex].name, choosedFoods.specfoods[specsIndex].price, choosedFoods.specifications[0].values[specsIndex], choosedFoods.specfoods[specsIndex].packing_fee, choosedFoods.specfoods[specsIndex].sku_id, choosedFoods.specfoods[specsIndex].stock)">加入购物车</div> |
| 282 | + </footer> |
| 283 | + </div> |
| 284 | + </transition> |
| 285 | + </section> |
| 286 | + <transition name="fade"> |
| 287 | + <p class="show_delete_tip" v-if="showDeleteTip">多规格商品只能去购物车删除哦</p> |
| 288 | + </transition> |
255 | 289 | <loading v-show="showLoading || loadRatings"></loading> |
256 | 290 | <transition name="router-slid"> |
257 | 291 | <router-view></router-view> |
|
296 | 330 | ratingTagName: '',//评论的类型 |
297 | 331 | loadRatings: false, //加载更多评论是显示加载组件 |
298 | 332 | foodScroll: null, |
| 333 | + showSpecs: false,//控制显示食品规格 |
| 334 | + specsIndex: 0, //当前选中的规格索引值 |
| 335 | + choosedFoods: null, |
| 336 | + showDeleteTip: false, //多规格商品点击减按钮,弹出提示框 |
299 | 337 | } |
300 | 338 | }, |
301 | 339 | created(){ |
|
392 | 430 | this.foodScroll = new BScroll(element, { |
393 | 431 | probeType: 3, |
394 | 432 | click: true, |
395 | | - deceleration: 0.002, |
| 433 | + deceleration: 0.001, |
396 | 434 | probeType: 1, |
397 | 435 | }); |
398 | 436 | |
|
526 | 564 | this.showLoading = false; |
527 | 565 | } |
528 | 566 | }, |
| 567 | + //显示规格列表 |
| 568 | + showChooseList(foods){ |
| 569 | + if (foods) { |
| 570 | + this.choosedFoods = foods; |
| 571 | + } |
| 572 | + this.showSpecs = !this.showSpecs; |
| 573 | + this.specsIndex = 0; |
| 574 | + }, |
| 575 | + //记录当前所选规格的索引值 |
| 576 | + chooseSpecs(index){ |
| 577 | + this.specsIndex = index; |
| 578 | + }, |
| 579 | + //多规格商品加入购物车 |
| 580 | + addSpecs(category_id, item_id, food_id, name, price, specs, packing_fee, sku_id, stock){ |
| 581 | + this.ADD_CART({shopid: this.shopId, category_id, item_id, food_id, name, price, specs, packing_fee, sku_id, stock}); |
| 582 | + this.showChooseList(); |
| 583 | + }, |
| 584 | + //点击多规格商品的减按钮,弹出提示 |
| 585 | + showReduceTip(){ |
| 586 | + this.showDeleteTip = true; |
| 587 | + clearTimeout(this.timer); |
| 588 | + this.timer = setTimeout(() => { |
| 589 | + clearTimeout(this.timer); |
| 590 | + this.showDeleteTip = false; |
| 591 | + }, 3000); |
| 592 | + }, |
529 | 593 | }, |
530 | 594 | watch: { |
531 | 595 | //showLoading变化时说明组件已经获取初始化数据,在下一帧nextTick进行后续操作 |
|
1242 | 1306 | } |
1243 | 1307 | } |
1244 | 1308 | } |
| 1309 | + .specs_cover{ |
| 1310 | + position: fixed; |
| 1311 | + top: 0; |
| 1312 | + left: 0; |
| 1313 | + right: 0; |
| 1314 | + bottom: 0; |
| 1315 | + background-color: rgba(0,0,0,.4); |
| 1316 | + z-index: 17; |
| 1317 | + } |
| 1318 | + .specs_list{ |
| 1319 | + position: fixed; |
| 1320 | + top: 35%; |
| 1321 | + left: 15%; |
| 1322 | + width: 70%; |
| 1323 | + background-color: #fff; |
| 1324 | + z-index: 18; |
| 1325 | + border: 1px; |
| 1326 | + border-radius: 0.2rem; |
| 1327 | + .specs_list_header{ |
| 1328 | + h4{ |
| 1329 | + @include sc(.7rem, #222); |
| 1330 | + font-weight: normal; |
| 1331 | + text-align: center; |
| 1332 | + padding: .5rem; |
| 1333 | + } |
| 1334 | + .specs_cancel{ |
| 1335 | + position: absolute; |
| 1336 | + right: .5rem; |
| 1337 | + top: .5rem; |
| 1338 | + } |
| 1339 | + } |
| 1340 | + .specs_details{ |
| 1341 | + padding: .5rem; |
| 1342 | + .specs_details_title{ |
| 1343 | + @include sc(.6rem, #666); |
| 1344 | + } |
| 1345 | + ul{ |
| 1346 | + display: flex; |
| 1347 | + flex-wrap: wrap; |
| 1348 | + padding: .4rem 0; |
| 1349 | + li{ |
| 1350 | + font-size: .6rem; |
| 1351 | + padding: .3rem .5rem; |
| 1352 | + border: 0.025rem solid #ddd; |
| 1353 | + border-radius: .2rem; |
| 1354 | + margin-right: .5rem; |
| 1355 | + } |
| 1356 | + .specs_activity{ |
| 1357 | + border-color: #3199e8; |
| 1358 | + color: #3199e8; |
| 1359 | + } |
| 1360 | + } |
| 1361 | + } |
| 1362 | + .specs_footer{ |
| 1363 | + @include fj; |
| 1364 | + align-items: center; |
| 1365 | + background-color: #f9f9f9; |
| 1366 | + padding: 0.5rem; |
| 1367 | + border: 1px; |
| 1368 | + border-bottom-left-radius: .2rem; |
| 1369 | + border-bottom-right-radius: .2rem; |
| 1370 | + .specs_price{ |
| 1371 | + span{ |
| 1372 | + color: #ff6000; |
| 1373 | + } |
| 1374 | + span:nth-of-type(1){ |
| 1375 | + font-size: .5rem; |
| 1376 | + } |
| 1377 | + span:nth-of-type(2){ |
| 1378 | + font-size: .8rem; |
| 1379 | + font-weight: bold; |
| 1380 | + font-family: Helvetica Neue,Tahoma; |
| 1381 | + } |
| 1382 | + } |
| 1383 | + .specs_addto_cart{ |
| 1384 | + @include wh(4rem, 1.3rem); |
| 1385 | + background-color: #3199e8; |
| 1386 | + border: 1px; |
| 1387 | + border-radius: 0.15rem; |
| 1388 | + @include sc(.6rem, #fff); |
| 1389 | + text-align: center; |
| 1390 | + line-height: 1.3rem; |
| 1391 | + } |
| 1392 | + } |
| 1393 | + } |
| 1394 | + .show_delete_tip{ |
| 1395 | + position: fixed; |
| 1396 | + top: 50%; |
| 1397 | + left: 15%; |
| 1398 | + width: 70%; |
| 1399 | + transform: translateY(-50%); |
| 1400 | + background-color: rgba(0,0,0,.8); |
| 1401 | + z-index: 18; |
| 1402 | + @include sc(.65rem, #fff); |
| 1403 | + text-align: center; |
| 1404 | + padding: .5rem 0; |
| 1405 | + border: 1px; |
| 1406 | + border-radius: 0.25rem; |
| 1407 | + } |
1245 | 1408 | .fade-enter-active, .fade-leave-active { |
1246 | 1409 | transition: opacity .5s; |
1247 | 1410 | } |
|
0 commit comments