| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382 |
- <template>
- <view class="content">
- <view class="status_bar" :style="{height: statusBarHeight}"></view>
- <!-- 搜索框 -->
- <view class="search-cont">
- <image class="w64 h64" src="/static/images/back_black.png"></image>
- <view class="inner">
- <!-- <image class="icon-search" src="../../static/images/search.png" mode=""></image> -->
- <input type="text" value="" placeholder="城口腊肉/香肠" confirm-type="搜索" @confirm="goSearch"
- :focus='setFocus' placeholder-style="font-size:28rpx;color:#BBBBBB;font-family: PingFang SC;" />
- <view class="line"></view>
- <view class="search">搜索</view>
- </view>
- </view>
- <!-- 搜索历史 -->
- <!-- <view class="title-box">
- <text class="title">历史搜索</text>
- <image src="../../static/images/del.png" mode="" @click="clearHistory"></image>
- </view>
- <view class="data-list">
- <view class="item" v-for="(item,index) in searchHistory" :key="index" @click="doSearch(item)">
- {{ item }}
- </view>
- </view> -->
- <!-- 热门搜索 -->
- <view class="title-box">
- <text class="title">热门搜索</text>
- <image class="w32 h32" src="/static/images/delete_icon.png"></image>
- </view>
- <view class="popular-list">
- <view class="item" v-for="(item,index) in topSearch" :key="index" @click="doSearch(item)">
- {{ item }}
- </view>
- </view>
- <!-- 推荐搜索 -->
- <view class="title-box">
- <text class="title">大家都在搜</text>
- <image class="w32 h32" src="/static/images/refresh_icon.png"></image>
- </view>
- <view class="data-list">
- <view class="item" v-for="(item,index) in topSearch" :key="index" @click="doSearch(item)">
- <text> {{ item }}</text>
- <image class="w40 h40 ml8" src="/static/images/hot.png"></image>
- </view>
- </view>
- <scroll-view class="card-group" scroll-x="true" show-scrollbar="false" enhanced="true" enable-flex="true">
- <!-- 今日热卖榜 -->
- <view class="card border1">
- <image class="card-bg" src="/static/images/hot_selling.png"></image>
- <view class="card-title">
- <image class="w40 h40 ml8" src="/static/images/hot.png"></image>
- <text class="title1">今日热卖榜</text>
- </view>
- <view class="product-list">
- <view class="product-item">
- <view class="left">
- <image class="photo" src="/static/images/img.png"></image>
- <view class="lable">1</view>
- </view>
- <view class="right">
- <view class="title">乌灵胶囊81粒养心安神失乌灵胶囊81粒养心安神失眠乌灵胶囊81粒养心安神失眠眠健...</view>
- <view class="txt">肌肉酸疼、扭伤拉伤</view>
- <view class="num-box">
- <view class="price"><text class="symbol">¥</text><text class="bold">89</text>.48</view>
- <view class="sale">已售 5485</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- <!-- 30天新品热销榜单 -->
- <view class="card ml24 border2">
- <image class="card-bg" src="/static/images/new_hot.png"></image>
- <view class="card-title">
- <image class="w40 h40 ml8" src="/static/images/new_product.png"></image>
- <text class="title1">30天新品热销榜单</text>
- </view>
- <view class="product-list">
- <view class="product-item">
- <view class="left">
- <image class="photo" src="/static/images/img.png"></image>
- <view class="lable">1</view>
- </view>
- <view class="right">
- <view class="title">乌灵胶囊81粒养心安神失乌灵胶囊81粒养心安神失眠乌灵胶囊81粒养心安神失眠眠健...</view>
- <view class="txt">肌肉酸疼、扭伤拉伤</view>
- <view class="num-box">
- <view class="price"><text class="symbol">¥</text><text class="bold">89</text>.48</view>
- <view class="sale">已售 5485</view>
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 状态栏的高度
- statusBarHeight: uni.getStorageSync('menuInfo').statusBarHeight,
- setFocus: false,
- // 历史搜索
- searchHistory: [],
- // 推荐搜索
- topSearch: []
- };
- },
- onShow() {
- this.setFocus = true
- this.searchHistory = this.utils.getHisSearch();
- var config = uni.getStorageSync('config');
- if (config != null && config != undefined && config != "") {
- this.topSearch = JSON.parse(config).hotSearch.split(',');
- }
- },
- methods: {
- // 清空历史搜索数据
- clearHistory() {
- this.utils.clearHisSearch();
- this.searchHistory = this.utils.getHisSearch();
- },
- doSearch(item) {
- uni.navigateTo({
- url: './productList?key=' + item
- })
- },
- goSearch(e) {
- if (e.detail.value != null && e.detail.value != "") {
- this.utils.addHisSearch(e.detail.value);
- }
- uni.navigateTo({
- url: './productList?key=' + e.detail.value
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #ffffff;
- }
- .content {
- .search-cont {
- display: flex;
- padding: 16rpx 30rpx;
- background-color: #FFFFFF;
- .inner {
- box-sizing: border-box;
- width: 436rpx;
- height: 64rpx;
- background: #F5F7FA;
- border-radius: 36rpx;
- display: flex;
- align-items: center;
- padding: 0 24rpx;
- .search {
- font-weight: 500;
- font-size: 28rpx;
- color: #333333;
- }
- .line {
- width: 2rpx;
- height: 24rpx;
- background: #999999;
- margin: 0 26rpx;
- }
- input {
- height: 60rpx;
- line-height: 60rpx;
- flex: 1;
- }
- }
- }
- .title-box {
- padding: 30rpx;
- display: flex;
- align-items: center;
- justify-content: space-between;
- .title {
- font-weight: 600;
- font-size: 32rpx;
- color: #000000;
- }
- image {
- width: 30rpx;
- height: 30rpx;
- }
- }
- .data-list {
- padding: 0rpx 10rpx 30rpx;
- display: grid;
- grid-template-columns: repeat(2, 1fr);
- /* 两列布局 */
- grid-gap: 20rpx;
- .item {
- padding: 0 30rpx;
- height: 56rpx;
- line-height: 56rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #4D4D4D;
- border-radius: 28rpx;
- margin: 0;
- display: flex;
- align-items: center;
- text-align: center;
- }
- }
- .popular-list {
- padding: 0rpx 10rpx 30rpx;
- display: flex;
- flex-wrap: wrap;
- .item {
- padding: 0 40rpx;
- height: 56rpx;
- line-height: 56rpx;
- font-size: 26rpx;
- font-family: PingFang SC;
- font-weight: 500;
- color: #4D4D4D;
- background: #F5F7FA;
- border-radius: 28rpx;
- margin: 0 20rpx 20rpx 0;
- }
- }
- .card-group {
- display: flex;
- padding: 0 24rpx;
- box-sizing: border-box;
- .card {
- width: 600rpx;
- padding: 26rpx 32rpx 0;
- background: #FFFFFF;
- border-radius: 24rpx 24rpx 24rpx 24rpx;
- position: relative;
- z-index: 0;
- .card-bg{
- width: 100%;
- height: 96rpx;
- position: absolute;
- top: 0;
- left: 0;
- border-radius: 24rpx 24rpx 0 0;
- z-index: -1;
- }
- .card-title {
- display: flex;
- align-items: center;
- font-weight: 600;
- font-size: 32rpx;
- margin-bottom: 34rpx;
- .title1 {
- color: #FF4400;
- }
- .title2 {
- color: #D46C0D;
- }
- }
- .product-list {
- .product-item {
- display: flex;
- align-items: center;
- margin-bottom: 40rpx;
- .left {
- margin-right: 22rpx;
- width: 120rpx;
- height: 120rpx;
- border-radius: 8rpx 8rpx 8rpx 8rpx;
- overflow: hidden;
- position: relative;
- .photo {
- width: 100%;
- height: 100%;
- }
- .lable {
- position: absolute;
- left: 0;
- top: 0;
- width: 32rpx;
- height: 32rpx;
- text-align: center;
- line-height: 32rpx;
- background: linear-gradient(135deg, #C1C5CD 0%, #A5AAB5 100%);
- border-radius: 8rpx 0rpx 8rpx 0rpx;
- font-family: Roboto, Roboto;
- font-weight: 500;
- font-size: 24rpx;
- color: #FFFFFF;
- }
- }
- .right {
- flex: 1;
- min-width: 0;
- .title {
- font-weight: 500;
- font-size: 28rpx;
- color: #333333;
- overflow: hidden;
- /* 隐藏溢出内容 */
- text-overflow: ellipsis;
- /* 显示省略号 */
- white-space: nowrap;
- /* 不换行 */
- }
- .txt {
- font-size: 22rpx;
- color: #999999;
- margin: 4rpx 0 20rpx;
- }
- .num-box {
- display: flex;
- justify-content: space-between;
- align-items: flex-end;
- .price {
- font-family: Roboto, Roboto;
- font-weight: 600;
- font-size: 26rpx;
- color: #FA341E;
- .symbol {
- font-size: 20rpx;
- }
- .bold {
- font-size: 36rpx;
- }
- }
- .sale {
- font-size: 21rpx;
- color: #999999;
- }
- }
- }
- }
- }
- }
- .border1{
- border: 1rpx solid rgba(241,89,38,0.5);
- }
- .border2{
- border: 1rpx solid rgba(244,160,7,0.5);
- }
- }
- }
- </style>
|