| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- <template>
- <view class="goods" :style="{height:getGoodsHeight + 'rpx!important'}">
- <view class="top">
- <h3>商品列表</h3>
- <u-search placeholder="搜索" v-model="keyword" :showAction="false"></u-search>
- </view>
- <view class="goodsBox">
- <view class="left">
- <view class="a1">111</view>
- <view class="a2">222</view>
- </view>
- <view class="right">
- <view class="goodsLi" v-for="(item,index) in goodsList" :key="index" @click="activeGoods(item)"
- :class="activeList.some(i => i.goodsId === item.goodsId)?'activeGoodsLi':''">
- <view class="title">
- {{item.goodsName}}
- </view>
- <view class="priceA">
- ¥{{item.priceB}} + {{item.internage}}积分
- </view>
- <view class="priceB">
- 原价:<text>{{item.priceA}}元</text>
- </view>
- <img v-if="activeList.some(i => i.goodsId === item.goodsId)" class="icon"
- src="@/static/images/icon_gx@2x.png" alt="">
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- mapGetters
- } from "vuex"
- export default {
- data() {
- return {
- keyword: "",
- goodsList: [{
- goodsId: 1,
- goodsName: "A鲁花花生油鲁花花生油鲁花花生油花生油",
- priceA: 2200.58,
- priceB: 2045.99,
- internage: 200,
- }, {
- goodsId: 2,
- goodsName: "B鲁花花生油鲁花花生油鲁花花生油花生油",
- priceA: 2200.58,
- priceB: 2045.99,
- internage: 200,
- }, {
- goodsId: 3,
- goodsName: "C鲁花花生油鲁花花生油鲁花花生油花生油",
- priceA: 2200.58,
- priceB: 2045.99,
- internage: 200,
- }],
- activeList: [],
- }
- },
- computed: {
- ...mapGetters(['getGoodsHeight'])
- },
- onLoad() {
- console.log()
- },
- methods: {
- activeGoods(row) {
- const CheckExistInt = this.activeList.findIndex(i => i.goodsId === row.goodsId)
- if (CheckExistInt === -1) {
- this.activeList.push(row)
- } else {
- this.activeList.splice(CheckExistInt, 1)
- }
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .goods {
- border-top-left-radius: 32rpx;
- border-top-right-radius: 32rpx;
- background-color: #fff;
- margin-top: -52rpx;
- display: flex;
- flex-direction: column;
- &>.top {
- height: 144rpx;
- padding: 32rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- &>h3 {
- font-weight: bold;
- color: #222;
- font-size: 32rpx;
- margin-right: 50rpx;
- }
- }
- &>.goodsBox {
- flex: 1;
- height: 1px;
- display: flex;
- &>.left {
- overflow: auto;
- width: 192rpx;
- height: 100%;
- background-color: #a4a4a4;
- flex-shrink: 0;
- &>.a1 {
- height: 600rpx;
- background-color: red;
- }
- &>.a2 {
- height: 600rpx;
- background-color: skyblue;
- }
- }
- &>.right {
- overflow: auto;
- margin: 0rpx 24rpx 0rpx 40rpx;
- height: 100%;
- flex: 1;
- &>.activeGoodsLi {
- border: 2rpx solid #F57737 !important;
- }
- &>.goodsLi {
- position: relative;
- padding: 28rpx 36rpx 32rpx 28rpx;
- background-color: #F9F9F9;
- border-radius: 28rpx;
- overflow: hidden;
- margin-bottom: 32rpx;
- border: 2rpx solid transparent;
- &>.icon {
- width: 32rpx;
- height: 32rpx;
- position: absolute;
- bottom: 0;
- right: 0;
- }
- &>.title {
- margin-bottom: 24rpx;
- color: #222;
- font-size: 28rpx;
- font-weight: 500;
- overflow: hidden;
- -webkit-line-clamp: 1;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-box-orient: vertical;
- }
- &>.priceA {
- flex: 1;
- color: #EB5757;
- font-weight: bold;
- font-size: 32rpx;
- margin-bottom: 8rpx;
- }
- &>.priceB {
- flex: 1;
- font-size: 24rpx;
- color: #828282;
- &>text {
- text-decoration: line-through;
- }
- }
- }
- }
- }
- }
- </style>
|