|
@@ -1,12 +1,19 @@
|
|
|
import ColResult from '@/components/col-result'
|
|
|
import request from '@/helpers/request'
|
|
|
-import { List, Tab, Tabs } from 'vant'
|
|
|
+import { List, Popup } from 'vant'
|
|
|
import { defineComponent } from 'vue'
|
|
|
+import AddGoodsCart from '../../modal/add-goods-cart'
|
|
|
import Goods from '../goods'
|
|
|
import styles from './index.module.less'
|
|
|
|
|
|
export default defineComponent({
|
|
|
name: 'tab-list',
|
|
|
+ props: {
|
|
|
+ typeId: {
|
|
|
+ type: Number,
|
|
|
+ default: 0
|
|
|
+ }
|
|
|
+ },
|
|
|
data() {
|
|
|
return {
|
|
|
list: [],
|
|
@@ -14,49 +21,54 @@ export default defineComponent({
|
|
|
loading: false,
|
|
|
finished: false,
|
|
|
params: {
|
|
|
- page: 1,
|
|
|
- rows: 20
|
|
|
- }
|
|
|
+ productCategoryId: null as any,
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 20
|
|
|
+ },
|
|
|
+ addGoodsShow: false,
|
|
|
+ selectGoodsItem: {} as any
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
- // this.getList()
|
|
|
+ this.getList()
|
|
|
},
|
|
|
methods: {
|
|
|
- onSearch(value: string) {
|
|
|
+ onSearch() {
|
|
|
this.dataShow = true
|
|
|
this.loading = false
|
|
|
this.finished = false
|
|
|
this.list = []
|
|
|
- this.params.page = 1
|
|
|
+ this.params.pageNum = 1
|
|
|
this.getList()
|
|
|
},
|
|
|
async getList() {
|
|
|
- // try {
|
|
|
- // let params = this.params
|
|
|
- // const res: any = { data: {} }
|
|
|
- // // await request.post(
|
|
|
- // // '/api-student/courseGroup/queryPageCourseGroup',
|
|
|
- // // {
|
|
|
- // // data: {
|
|
|
- // // ...params
|
|
|
- // // }
|
|
|
- // // }
|
|
|
- // // )
|
|
|
- // this.loading = false
|
|
|
- // const result = res.data || {}
|
|
|
- // // 处理重复请求数据
|
|
|
- // if (this.list.length > 0 && result.pageNo === 1) {
|
|
|
- // return
|
|
|
- // }
|
|
|
- // this.list = this.list.concat(result.rows || [])
|
|
|
- // this.finished = result.pageNo >= result.totalPage
|
|
|
- // this.params.page = result.pageNo + 1
|
|
|
- // this.dataShow = this.list.length > 0
|
|
|
- // } catch {
|
|
|
- // this.dataShow = false
|
|
|
- // this.finished = true
|
|
|
- // }
|
|
|
+ try {
|
|
|
+ let params = this.params
|
|
|
+ this.typeId && (params.productCategoryId = this.typeId)
|
|
|
+ const res = await request.post('/api-mall-portal/product/search', {
|
|
|
+ data: {
|
|
|
+ ...params
|
|
|
+ }
|
|
|
+ })
|
|
|
+ this.loading = false
|
|
|
+ const result = res.data || {}
|
|
|
+ // 处理重复请求数据
|
|
|
+ if (this.list.length > 0 && result.pageNum === 1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.list = this.list.concat(result.list || [])
|
|
|
+ this.finished = result.pageNum >= result.totalPage
|
|
|
+ this.params.pageNum = result.pageNum + 1
|
|
|
+ this.dataShow = this.list.length > 0
|
|
|
+ } catch {
|
|
|
+ this.dataShow = false
|
|
|
+ this.finished = true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ onDetailClick(item: any) {},
|
|
|
+ onBuyClick(item: any) {
|
|
|
+ this.selectGoodsItem = item
|
|
|
+ this.addGoodsShow = true
|
|
|
}
|
|
|
},
|
|
|
render() {
|
|
@@ -71,15 +83,30 @@ export default defineComponent({
|
|
|
class={[styles.goodsList, 'mb12']}
|
|
|
onLoad={this.getList}
|
|
|
>
|
|
|
- {/* {this.list.map((item: any) => (
|
|
|
- ))} */}
|
|
|
- {[1, 2, 3, 4, 5, 6, 7, 8, 9, 10].map((item: any) => (
|
|
|
- <Goods style={{ marginTop: '12px' }} />
|
|
|
+ {this.list.map((item: any) => (
|
|
|
+ <Goods
|
|
|
+ style={{ marginTop: '12px' }}
|
|
|
+ item={item}
|
|
|
+ onItemClick={this.onDetailClick}
|
|
|
+ onBuyClick={this.onBuyClick}
|
|
|
+ />
|
|
|
))}
|
|
|
</List>
|
|
|
) : (
|
|
|
<ColResult btnStatus={false} classImgSize="SMALL" tips="暂无商品" />
|
|
|
)}
|
|
|
+
|
|
|
+ <Popup
|
|
|
+ show={this.addGoodsShow}
|
|
|
+ closeable
|
|
|
+ position="bottom"
|
|
|
+ round
|
|
|
+ onClose={() => {
|
|
|
+ this.addGoodsShow = false
|
|
|
+ }}
|
|
|
+ >
|
|
|
+ <AddGoodsCart item={this.selectGoodsItem} />
|
|
|
+ </Popup>
|
|
|
</div>
|
|
|
)
|
|
|
}
|