1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 |
- import { VueLikePage } from '../../utils/page'
- import Router from '../../utils/routes'
- import GoodsApi from '../../apis/goods'
- VueLikePage([], {
- data: {
- active: 0,
- categoryList: [],
- goodsList: []
- },
- methods: {
- async onLoad (options) {
- await this.getCategoryList()
- if (options.active) {
- this.setData({
- active: Number(options.active)
- })
- }
- },
- search (value) {
- },
- onChange (e) {
- const { index} = e.detail
- this.goodsListParams = {
- pageNum: 1,
- pageSize: 20,
- categoryId: this.data.categoryList[index].id
- }
- this.getCategoryGoodsList()
- },
- toDetail (e) {
- const { goods_id } = e.currentTarget.dataset
- Router.push({
- url: 'goodsDetail',
- query: {
- goods_id
- }
- })
- },
- getCategoryList () {
- return GoodsApi.getCategoryList().then(res => {
- this.setData({
- categoryList: res.data.list
- })
- })
- },
- toSearch () {
- Router.push('search')
- },
- async getCategoryGoodsList (data) {
- let res = await GoodsApi.getCategoryGoods(this.goodsListParams)
- this.setData({
- goodsList: res.data.list
- })
- }
- }
- })
|