| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <view class="slot">
- <view class="toph">
- <u-search
- :placeholder="placeholder"
- :value="value"
- height="70"
- @search="searchConfirm"
- @custom="searchConfirm"
- ></u-search>
- <view class="goodsSort">
- <view class="item" :class="{'active':!sortTypes.price_sc && !sortTypes.sales_sc}" @click="changeSort(1)">
- <text>综合</text>
- </view>
- <view class="item" :class="{'active':['asc','desc'].includes(sortTypes.price_sc)}" @click="changeSort(2)">
- <text>价格</text>
- <view :class="['sortIcon',sortTypes.price_sc]"></view>
- </view>
- <view class="item" :class="{'active':sortTypes.sales_sc=='desc'}" @click="changeSort(3)">
- <text>销量</text>
- </view>
- </view>
- </view>
- <view class="siteBar"></view>
- </view>
- </template>
- <script>
- const app = getApp();
- export default {
- name: 'navbar-search',
- props: {
- title: {
- type: String,
- default: '搜索'
- },
- value: {
- type: String,
- default: ''
- },
- // 占位内容
- placeholder: {
- type: String,
- default: '请输入'
- },
- },
- data() {
- return {
- // 导航栏高度
- navBarHeight: app.globalData.navBarHeight,
- statusBarHeight: app.globalData.statusBarHeight,
- menuRight: app.globalData.menuRight,
- menuBotton: app.globalData.menuBotton,
- menuHeight: app.globalData.menuHeight,
- menuTop: app.globalData.menuTop,
- menuWidth: app.globalData.menuWidth,
- // 背景色
- searchBgColor: this.$appTheme.appThemeSearchBgColor,
- // 排序类型
- sortTypes:{
- price_sc:'',//desc 降序,asc升序
- sales_sc:'',//desc 降序,asc升序
- },
- /* // priceSort: [{
- // label: '默认排序',
- // value: 1,
- // },
- // {
- // label: '距离优先',
- // value: 2,
- // },
- // {
- // label: '价格优先',
- // value: 3,
- // }
- // ],
- // saleSort: [{
- // label: '去冰',
- // value: 1,
- // },
- // {
- // label: '加冰',
- // value: 2,
- // },
- // ], */
- };
- },
-
- methods: {
- // 搜索
- searchConfirm(e) {
- this.$emit('confirm', e);
- },
- changeSort(e){
- switch (e){
- case 1:
- // 综合
- this.sortTypes = {
- price_sc:'',
- sales_sc:'',
- }
- break;
- case 2:
- // 价格
- this.sortTypes.price_sc = this.sortTypes.price_sc=='desc'?'asc':'desc';
- this.sortTypes.sales_sc = '';
- break;
- case 3:
- // 销量
- this.sortTypes.sales_sc = 'desc';
- this.sortTypes.price_sc = '';
- break;
- default:
- break;
- }
- // this.sortType = e;
- this.$emit('sortType', this.sortTypes);
- }
- }
- };
- </script>
- <style lang="scss" scoped>
- .siteBar{
- height: 140rpx;
- }
- .toph {
- width: 100%;
- position: fixed;
- top: 0;
- left: 0;
- z-index: 899;
- overflow: hidden;
- background-color: $app-theme-bg-color;
- box-sizing: border-box;
- padding: 0 30rpx;
- }
- .goodsSort{
- display: flex;
- align-items: center;
- justify-content: space-between;
- padding: 0 30rpx;
- height: 80rpx;
- box-sizing: content-box;
- border-bottom: 1rpx solid $app-theme-border-color;
- .item{
- position: relative;
- text-align: center;
- display: flex;
- align-items: center;
- justify-content: space-between;
- color: $app-theme-text-gray-color;
- text{
- font-size: 30rpx;
- }
- .sortIcon{
- width: 18rpx;
- height: 30rpx;
- background-image: url('../../static/icon/sort.png');
- background-position: 0 0;
- background-size: auto 100%;
- margin-left: 10rpx;
- &.asc{
- background-position: 42rpx 0;
- }
- &.desc{
- background-position:20rpx 0;
- }
- }
- &.active{
- color: $app-theme-color;
- }
- &.priceAsc{
-
- }
- }
- }
- </style>
|