list.vue 7.61 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
<template>
  <view>
    <view id="header">
      <!--导航栏 navbar-->
      <u-navbar title="选款"
                :border-bottom="false"
                :background="{backgroundColor: 'whitesmoke'}">
      </u-navbar>
      <!--状态栏 tab-->
      <view>
        <u-tabs-swiper ref="uTabs" :list="status" :current="current" @change="tabsChange" :is-scroll="false"
                       name="label"
                       :bar-style="{display: 'none'}"
                       :active-item-style="{
                        fontSize: '32rpx',
                        color: '#AF8D66'
                      }"
                       swiperWidth="750"></u-tabs-swiper>
      </view>
      <!--状态栏 tab-->
李星剑's avatar
李星剑 committed
21
      <view v-if="!status[current].close">
22
        <view class="list-tip u-flex u-p-r-30 u-p-l-30" >
李星剑's avatar
李星剑 committed
23

24 25 26
          <text class="u-flex-1" v-if="current === 3">
            已选中{{ selectedLength}}
          </text>
李星剑's avatar
李星剑 committed
27 28 29 30
          <text class="u-flex-1" v-if="current !== 3">
            {{status[current].label}}总共 {{totalNum}}
          </text>
          <u-icon name="close" @click="closeTip"></u-icon>
31 32 33 34 35 36 37 38
        </view>
      </view>
    </view>
    <!-- 列表内容 -->
    <view class="u-p-r-30 u-p-l-30 body" :style="{ bottom: footerHeight+ 'px', top: headerHeight + 'px' }">
       <view v-for="(item,index) in data">
         <view class="u-flex u-p-t-12 u-p-b-12">
           <text class="u-flex-1">
李星剑's avatar
李星剑 committed
39
             {{ item.label }}({{item.children.length}} 款)
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93
           </text>
           <text class="" @click="collapse(index)">
             {{ activeIndex === index ? '收起': '展开' }}
           </text>
         </view>
         <view v-if="activeIndex === index">
           <view class="item bg-fff u-p-30" v-for="(children) in item.children">
             <view class="item-header u-m-b-22">
               <hs-tip-title title="夹克"></hs-tip-title>
             </view>
             <view class="item-body">
               <view>
                 风格 男装|上装|25~35岁|时尚休闲
               </view>
               <view class="u-flex u-m-t-24 u-m-b-30 ">
                 <view class="item-img">
                   <u-image class="item-img" src="https://cdn.uviewui.com/uview/example/fade.jpg" width="100%" height="100%"></u-image>
                 </view>
                 <view class="item-img">
                   <u-image class="item-img" src="https://cdn.uviewui.com/uview/example/fade.jpg" width="100%" height="100%"></u-image>
                 </view>
               </view>
               <view class="bd_split_line"></view>
             </view>
             <view class="item-footer text-right" v-if="children.status !== 3">
               <view class="item-footer-button">
                 <u-button plain shape="circle">放弃</u-button>
               </view>
               <view class="item-footer-button">
                 <u-button type="primary" shape="circle" >选中</u-button>
               </view>
             </view>
           </view>
         </view>

       </view>
    </view>

    <!--底部按钮-->
    <view class="footer" id="footer" v-if="current === 3">
      <view class="footer-btn">
        <view class="custom-style-round-circle custom-style-btn custom-style">
          <view class="custom-style-right submit">
            <view class="title">提交选中</view>
            <view class="desc">提交数量:<text class="color">2款</text></view>
          </view>
        </view>
      </view>
    </view>
  </view>
</template>

<script>
import status from './mixins/status'
李星剑's avatar
李星剑 committed
94
import dom from './mixins/dom'
95 96 97 98
import HsTipTitle from "../../components/hs-tip-title/hs-tip-title";
export default {
  name: "list",
  components: {HsTipTitle},
李星剑's avatar
李星剑 committed
99
  mixins: [status,dom],
100 101 102 103 104
  data() {
    return {
      current: 0, // tabs组件的current值,表示当前活动的tab选项
      activeIndex: 0,
      // data: ,
李星剑's avatar
李星剑 committed
105 106 107 108 109 110
      res: [
        {date: '12月11日', title: '立领夹克',status: 1},
        {date: '12月11日', title: '立领夹克',status: 1},
        {date: '12月10日', title: '立领夹克1',status: 1},
        {date: '12月10日', title: '立领夹克1',status: 1}
      ] , //列表数据源
111 112 113 114
    };
  },
  computed:{
    data(){
李星剑's avatar
李星剑 committed
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
      function arr2Tree(data, id = "colourGroup") {
        const newList = [],
            map = Array.from(
                new Set(
                    data.map((item) => {
                      return item[id];
                    })
                )
            );
        for (let i = 0; i < data.length; i++) {
          let item = data[i],
              name = item[id],
              index = map.indexOf(name);
          if (newList[index]) {
            newList[index]["children"].push(item);
          } else {
            newList.push({
              label: name,
              children: [item]
            });
          }
136
        }
李星剑's avatar
李星剑 committed
137 138 139 140
        return newList;
      }

      return arr2Tree(this.res,"date");
141 142
    },
    totalNum(){
李星剑's avatar
李星剑 committed
143
      return this.res.length
144 145
    },
    selectedLength(){
李星剑's avatar
李星剑 committed
146 147 148
      return this.res.filter((item) =>{
        return item.status == 1
      }).length;
149 150 151 152
    }
  },
  watch:{
    current(){
李星剑's avatar
李星剑 committed
153
      this.getHeaderHeight();
154 155 156 157
      this.getFooterHeight();
    }
  },
  methods: {
李星剑's avatar
李星剑 committed
158 159 160 161
    closeTip(){
      this.$set(this.status, this.current,{
        ...this.status[this.current],
        close: true
162
      })
李星剑's avatar
李星剑 committed
163
      this.getHeaderHeight()
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298
    },
    collapse(index){
      this.activeIndex = this.activeIndex === index ? null : index;
    },
    getList(){

    },
    // tabs通知swiper切换
    tabsChange(index) {
      this.current = index;
    },
  }
}
</script>

<style scoped lang="scss">
.list-tip{
  background: #AF8D66;
  line-height: 72rpx;
  color: rgba(0,0,0,0.60);
}
.item{
  background: #fff;
  border-radius: 8rpx;
  margin-bottom: 20rpx;
  &-img{
    width: 160rpx;
    height: 160rpx;
    margin-right: 20rpx;
    border-radius: 8rpx;
    overflow: hidden;
  }

  &-footer{
    &-button{
      width: 160rpx;
      height: 64rpx;
      margin-left: 20rpx;
      display: inline-block;
    }
  }
}
.bd_split_line {
  width: 100%;
  border-top: 1px solid #f6f6f6;
  margin: auto;
  position: relative;
  height: 30rpx;
  &::before {
    content: ' ';
    position: absolute;
    left: -45rpx;
    top: -15rpx;
    display: block;
    width: 30rpx;
    height: 30rpx;
    background: #f6f6f6;
    border-radius: 100rpx;
  }
  &::after {
    content: ' ';
    position: absolute;
    right: -45rpx;
    top: -15rpx;
    display: block;
    width: 30rpx;
    height: 30rpx;
    background: #f6f6f6;
    border-radius: 100rpx;
  }
}
@mixin vue-flex($direction: row) {
  /* #ifndef APP-NVUE */
  display: flex;
  flex-direction: $direction;
  /* #endif */
}
.custom-style{
  color: #fff; height: 88rpx; line-height: 88rpx;
  @include vue-flex;
  &-btn{
    overflow: hidden;
  }
  &-round-circle{
    border-radius: 100rpx;
  }
  /*background: #000;*/
  .custom-style-left{ width: 240rpx; background: #d6d6d6; text-align: center }
  .custom-style-right{ flex: 1; background: rgba(0,0,0,0.80);text-align: center}
  .save{
    font-size: 34rpx;
    color: #000000;
  }
  .submit{
    font-weight: 500;
    font-size: 34rpx;
    line-height: 100%;
    .title{
      margin: 8rpx 0;
    }
    .desc{

      font-size: 20rpx;
      .color{
        color: #DDA973;
      }
    }
  }
}
.body{
  position: absolute;
  width: 100%;
  height: auto;
  left: 0;
  right: 0;
  bottom: 0;
  top: 0;
  overflow-y: auto;

}
.footer {
  position: fixed;
  width: 100%;
  bottom: 0;

  z-index: 998;
  background: #fff;
  box-shadow: 0px -4rpx 6rpx 0px rgba(178,182,214,0.10);
  padding-bottom: constant(safe-area-inset-bottom);
  padding-bottom: env(safe-area-inset-bottom);
  .footer-btn{
    padding: 20rpx 60rpx;
  }
}
</style>