MCPcopy
hub / github.com/coderwhy/LearnMiniProgram / _getGoodsData

Function _getGoodsData

pages/home/home.js:53–75  ·  view source on GitHub ↗
(type)

Source from the content-addressed store, hash-verified

51 })
52 },
53 _getGoodsData(type) {
54 // 1.获取页码
55 const page = this.data.goods[type].page + 1;
56
57 // 2.发送网络请求
58 getGoodsData(type, page).then(res => {
59 // console.log(res)
60 // 2.1.取出数据
61 const list = res.data.data.list;
62
63 // 2.2.将数据设置到对应type的list中
64 const oldList = this.data.goods[type].list;
65 oldList.push(...list)
66
67 // 2.3.将数据设置到data中的goods中
68 const typeKey = `goods.${type}.list`;
69 const pageKey = `goods.${type}.page`;
70 this.setData({
71 [typeKey]: oldList,
72 [pageKey]: page
73 })
74 })
75 },
76
77 // ------------------- 事件监听函数 -------------------------
78 handleTabClick(event) {

Callers

nothing calls this directly

Calls 1

getGoodsDataFunction · 0.90

Tested by

no test coverage detected