<template>
  <div class="middle_width1200 shopmall_home">
    <div class="logo_wrap clearfix">
      <div class="title_guoxin fl">
        <router-link to="/shop/shopHome">
          <!-- <img src="@assets/img/shopmall/logo.png" class="logo"> -->
          <img :src="WebConfig.imgMajor" class="logo">
          <h2>网上商城</h2>
        </router-link>
      </div>
      <!--搜索-->
      <div class="search_inline fl">
        <el-input v-model="searchForm.keywords" placeholder="请输入商品名称、品牌" size="medium" @keyup.13.native="searchGood">
          <el-button slot="append" @click="searchGood">
            搜索
          </el-button>
        </el-input>
      </div>
    </div>
  </div>
</template>

<script>
import { getToken } from '@/assets/js/utils/auth'
// import { simpleSearch } from '@/api/shoppingmall/products'
/* vuex*/
import { mapGetters } from 'vuex'
export default {
  name: 'Search',
  data() {
    return {
      isLogin: false, // 是否登录
      // 搜索
      searchForm: {
        keywords: '',
        pageNo: 0,
        pageSize: 10
      }
    }
  },
  computed: {
    /* WebConfig 项目配置数据*/
    ...mapGetters(['WebConfig'])
  },
  created() {
    // 校验是否登录
    this.isLogin = !!getToken()
    if (getToken()) {
      this.isLogin = true
    }
  },
  methods: {
    // 搜索商品
    searchGood() {
      this.$router.push({
        path: '/shop/goodsClassList',
        query: { keywordsa: this.searchForm.keywords }
      })
    }
  }
}
</script>

<style scoped lang="less">
  @import "./index";
  .logo {
    width: 172px;
  }
</style>
