123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- <template>
- <mobile-frame :frameStyle="frameStyle" @toPath="toPath">
- <view class="main">
- <view class="one">
- <input type="text" placeholder="搜索商品" @tap="toCommon('pagesHome/market/search')"
- placeholder-class="placss">
- </view>
- <view class="two">
- <view class="two_1">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="list-scroll-view">
- <view class="list" :class="[active==index?'listActive':'']" v-for="(item,index) in typeList"
- :key="index" @tap="toChange(index,item)">
- <text>{{item.label}}</text>
- </view>
- </view>
- </scroll-view>
- </view>
- <view class="two_2">
- <scroll-view scroll-y="true" class="scroll-view">
- <view class="list-scroll-view">
- <view class="list" v-for="(item,index) in list" :key="index"
- @tap="toCommon('pagesHome/market/search',item,'2')">
- <view class="title">
- {{item.label}}
- </view>
- <view class="market" v-if="item.children&&item.children.length>0">
- <view class="marketList" v-for="(tag,indexs) in item.children" :key="indexs"
- @tap.stop="toCommon('pagesHome/market/search',tag,'3')">
- <image class="image" :src="tag.file&&tag.file.length>0?tag.file[0].url:''"
- mode=""></image>
- <view class="name">
- {{tag.label}}
- </view>
- </view>
- </view>
- <view class="market" v-else>
- <view class="marketList" @tap.stop="toCommon('pagesHome/market/search',item,'3')">
- <image class="image" :src="item.file&&item.file.length>0?item.file[0].url:''"
- mode=""></image>
- <view class="name">
- {{item.label}}
- </view>
- </view>
- </view>
- </view>
- </view>
- </scroll-view>
- </view>
- </view>
- </view>
- </mobile-frame>
- </template>
- <script>
- export default {
- data() {
- return {
- frameStyle: {
- useBar: true
- },
- active: '0',
- typeList: [],
- list: [],
- // 一级
- classa: {},
- };
- },
- onLoad: function() {
- const that = this;
- that.searchOther();
- },
- methods: {
- async searchOther() {
- const that = this;
- let res;
- res = await that.$api(`/goodsTags`, 'GET', {
- status: '0'
- })
- if (res.errcode == '0') {
- that.$set(that, `typeList`, res.data);
- if (res.total > 0) {
- that.searchRight(res.data[0]);
- that.$set(that, `classa`, res.data[0]);
- }
- }
- },
- toChange(index, e) {
- const that = this;
- that.$set(that, `list`, []);
- that.$set(that, `active`, index);
- that.searchRight(e);
- that.$set(that, `classa`, e);
- },
- // 查询左侧信息
- async searchRight(e) {
- const that = this;
- let info = {};
- if (e.id) info.pid = e.id;
- const res = await that.$api(`/goodsTags/tree`, 'GET', {
- ...info
- })
- if (res.errcode == '0' && res.data.length > 0) {
- that.$set(that, `list`, res.data[0].children)
- }
- },
- // 公共跳转
- toCommon(e, code, num) {
- const that = this;
- if (num == '2') {
- uni.navigateTo({
- url: `/${e}?tags=${code.code}&pid=${that.classa._id}`
- })
- } else {
- uni.navigateTo({
- url: `/${e}?tags=${code.code}`
- })
- }
- },
- // 菜单跳转
- toPath(e) {
- if (e && e.route && e.type == '0') {
- uni.redirectTo({
- url: `/${e.route}`
- })
- } else {
- uni.navigateTo({
- url: `/${e.route}`
- })
- }
- }
- }
- }
- </script>
- <style lang="scss">
- .main {
- display: flex;
- flex-direction: column;
- width: 100vw;
- height: 91vh;
- .one {
- padding: 2vw;
- border: 1px solid var(--f1Color);
- input {
- background-color: var(--fFB1Color);
- border-radius: 30px;
- padding: 2vw;
- color: var(--fffColor);
- font-size: var(--font15Size);
- }
- .placss {
- color: var(--fffColor);
- }
- }
- .two {
- height: 83vh;
- display: flex;
- flex-direction: row;
- .two_1 {
- position: relative;
- width: 25vw;
- background-color: #fafafa;
- display: flex;
- flex-direction: column;
- .list {
- text-align: center;
- padding: 2.5vw 0;
- border-bottom: 1px solid var(--f1Color);
- text {
- font-size: var(--font14Size);
- }
- }
- .listActive {
- background-color: var(--fffColor);
- }
- }
- .two_2 {
- padding: 2vw;
- flex-grow: 1;
- position: relative;
- display: flex;
- flex-direction: column;
- .list {
- margin: 0 0 2vw 0;
- padding: 2vw;
- .title {
- font-size: var(--font16Size);
- margin: 0 0 2vw 0;
- }
- .market {
- display: flex;
- flex-direction: row;
- flex-wrap: wrap;
- .marketList {
- text-align: center;
- margin: 0 2vw 2vw 0;
- width: 22vw;
- .image {
- width: 100%;
- height: 15vw;
- }
- .name {
- font-size: var(--font14Size);
- }
- }
- .marketList:nth-child(3n) {
- margin: 0 0 2vw 0;
- }
- }
- }
- }
- }
- }
- .scroll-view {
- position: absolute;
- top: 0;
- left: 0;
- right: 0;
- bottom: 0;
- .list-scroll-view {
- display: flex;
- flex-direction: column;
- }
- }
- </style>
|