2024-04-18 23:59:06 +08:00
|
|
|
<template>
|
|
|
|
<view class="content">
|
|
|
|
<view class="" style="padding: 30rpx;">
|
2024-04-19 18:08:04 +08:00
|
|
|
<u-search v-model="keyword" :showAction="true" actionText="搜索" :animation="true"
|
|
|
|
@change="hdChange"></u-search>
|
2024-04-18 23:59:06 +08:00
|
|
|
</view>
|
|
|
|
<view class="" v-if='!keyword' style="padding-left: 44rpx;">
|
|
|
|
<view style="margin: 60rpx 0 30rpx 14rpx;">
|
|
|
|
常用分类
|
|
|
|
</view>
|
|
|
|
<view class="types">
|
2024-04-20 18:02:16 +08:00
|
|
|
<view class="types-li" v-for="(item,index) in typeList" @click='hdChose(item)'>
|
2024-04-20 14:51:26 +08:00
|
|
|
{{item.label}}
|
2024-04-18 23:59:06 +08:00
|
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
|
|
|
|
<view style="margin: 60rpx 0 30rpx 14rpx;">
|
|
|
|
热门分类
|
|
|
|
</view>
|
|
|
|
<view class="types">
|
2024-04-19 18:08:04 +08:00
|
|
|
<view class="types-li" v-for="(item,index) in hotList" @click='hdChose(item)'>
|
|
|
|
{{item.label}}
|
2024-04-18 23:59:06 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
<view class="" v-else style="margin: 10rpx 0 0 30rpx;">
|
2024-04-19 18:08:04 +08:00
|
|
|
<view class="" v-if='searchList.length'>
|
|
|
|
<view class="keyword-li" v-for='item in searchList' @click='hdChose(item)'>
|
|
|
|
{{item.label}}
|
|
|
|
<u-line direction="row" color="#ECECEC"></u-line>
|
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
<view v-else style="text-align: center;margin-top: 50rpx;">
|
|
|
|
暂无搜索结果,点击 <text @click="navgo" style='color:#35BC3E;text-decoration: underline;'>手动选择</text>
|
2024-04-18 23:59:06 +08:00
|
|
|
</view>
|
|
|
|
</view>
|
|
|
|
|
|
|
|
</view>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
2024-04-19 18:08:04 +08:00
|
|
|
import {
|
|
|
|
categorySearch,
|
2024-04-20 14:51:26 +08:00
|
|
|
categoryHotcate,
|
|
|
|
categorySearchHistory,
|
2024-04-19 18:08:04 +08:00
|
|
|
} from '@/api/product.js'
|
2024-04-18 23:59:06 +08:00
|
|
|
export default {
|
|
|
|
data() {
|
|
|
|
return {
|
2024-04-22 18:05:44 +08:00
|
|
|
formData: {},
|
|
|
|
type: 'detail',
|
2024-04-19 18:08:04 +08:00
|
|
|
keyword: "",
|
|
|
|
mer_id: "",
|
|
|
|
searchList: [],
|
2024-04-20 18:02:16 +08:00
|
|
|
hotList: [],
|
|
|
|
typeList: []
|
2024-04-18 23:59:06 +08:00
|
|
|
}
|
2024-04-19 18:08:04 +08:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
hdChange() {
|
2024-04-20 18:02:16 +08:00
|
|
|
console.log(this.searchList)
|
2024-04-19 18:08:04 +08:00
|
|
|
categorySearch(this.mer_id, {
|
|
|
|
keyword: this.keyword
|
|
|
|
}).then(res => {
|
|
|
|
this.searchList = res.data
|
|
|
|
})
|
|
|
|
},
|
|
|
|
navgo() {
|
2024-04-23 08:45:17 +08:00
|
|
|
uni.redirectTo({
|
|
|
|
url: `/pages/product/addGoodDetail/goodsType?mer_id=${this.mer_id}&&type=${this.type}&&formData=${JSON.stringify(this.formData)}`
|
2024-04-19 18:08:04 +08:00
|
|
|
})
|
|
|
|
},
|
|
|
|
hdChose(item) {
|
2024-04-23 08:45:17 +08:00
|
|
|
this.formData.cate_name = item.label.includes('--') ? item.label
|
|
|
|
.split('--')[1] : item.label;
|
|
|
|
this.formData.cate_id = item.value
|
2024-04-20 14:51:26 +08:00
|
|
|
categorySearchHistory(this.mer_id, this.$store.state.app.userInfo.uid, {
|
|
|
|
cate_id: item.value
|
|
|
|
})
|
2024-04-22 18:05:44 +08:00
|
|
|
uni.redirectTo({
|
2024-04-23 08:45:17 +08:00
|
|
|
url: `/pages/product/addGood/addGood?mer_id=${this.mer_id}&&formData=${JSON.stringify(this.formData)}`
|
2024-04-19 18:08:04 +08:00
|
|
|
})
|
2024-04-23 08:45:17 +08:00
|
|
|
},
|
|
|
|
initFormData(option) {
|
|
|
|
this.mer_id = option.mer_id
|
|
|
|
if (option.type) {
|
|
|
|
this.type = 'simple'
|
|
|
|
}
|
|
|
|
this.formData = JSON.parse(option.formData)
|
2024-04-19 18:08:04 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
onLoad(option) {
|
2024-04-23 08:45:17 +08:00
|
|
|
this.initFormData(option)
|
2024-04-20 14:51:26 +08:00
|
|
|
categoryHotcate(
|
|
|
|
option.mer_id,
|
|
|
|
this.$store.state.app.userInfo.uid
|
|
|
|
).then(res => {
|
|
|
|
this.hotList = res.data.hot_cate.map(item => ({
|
2024-04-23 08:45:17 +08:00
|
|
|
label: item.cate_name,
|
|
|
|
value: item.store_category_id
|
|
|
|
}))
|
2024-04-20 18:02:16 +08:00
|
|
|
this.typeList = res.data.active_cate.map(item => ({
|
2024-04-19 18:08:04 +08:00
|
|
|
label: item.cate_name,
|
|
|
|
value: item.store_category_id
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
)
|
|
|
|
})
|
|
|
|
|
2024-04-18 23:59:06 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss'>
|
|
|
|
.MediumFont {
|
|
|
|
font-family: PingFangFamily;
|
|
|
|
}
|
|
|
|
|
|
|
|
.RegularFont {
|
|
|
|
font-family: PingFangRegular;
|
|
|
|
}
|
|
|
|
|
|
|
|
.content {
|
|
|
|
box-sizing: border-box;
|
|
|
|
background-color: #FFFFFF;
|
|
|
|
min-height: 100vh;
|
|
|
|
position: relative;
|
|
|
|
font-size: 28rpx;
|
2024-04-19 18:08:04 +08:00
|
|
|
font-family: PingFangRegular;
|
2024-04-18 23:59:06 +08:00
|
|
|
|
|
|
|
.types {
|
|
|
|
display: flex;
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
|
|
.types-li {
|
|
|
|
background-color: #F6F6F6;
|
|
|
|
border-radius: 8rpx 8rpx 8rpx 8rpx;
|
|
|
|
padding: 16rpx 24rpx;
|
|
|
|
margin-bottom: 46rpx;
|
|
|
|
margin-right: 20rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.keyword-li {
|
|
|
|
padding-right: 30rpx;
|
|
|
|
/* background-color: #F6F6F6; */
|
|
|
|
height: 100rpx;
|
|
|
|
line-height: 100rpx;
|
|
|
|
}
|
|
|
|
|
|
|
|
.keyword-li:active {
|
|
|
|
background-color: #F6F6F6;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|