userRecommand.js
2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import urlAlias from '../url';
import request from '../request';
const {
recommandList
} = urlAlias;
const state = {
recommandList: [],
};
const data = {
"code": 1,
"msg": "请求成功",
"data": {
// list 表示商品数据列表
"list": [
{
model_pic: null,
p_name: "1.61防蓝光镜片 非球面_枪色款镜架商务男士防蓝光眼镜",
p_root_index: "1", //对应goodType
pic: "http://localhost/sys-glass/image/picture.png",
pid: "96",
real_price: "17800",
sk_id: "1448",
sku_name: "1.61防蓝光镜片 非球面_枪色款镜架",
trade_num: "0",
},
{
"sk_id": "39",
"pic": "/static/img/goods/p1.jpg",
"p_name": "1.56防蓝光镜片非球面_黑银色镜架防蓝光眼镜超轻不压鼻",
"old_price": "18000",
"real_price": "9900",
"trade_num": 123, // 对应购买人数
"p_root_index": 2, // 对应跳转的详情页
"pid":4, // 产品id
},
],
pagesnum:1, // 懒加载要用到的页数
pagessize:10,// 每次请求返回的list长度
}
}
const mutations = {
INIT: (state, list) => {
state.recommandList = list;
},
};
let goodsList=[];
const actions = {
getRecommandList({ commit }, param) {
request({
url: recommandList,
success: (res) => {
console.log('userRecommand-parm',param)
console.log(res.data.data)
// const Res={...res.data.data.list,...data.data.list}
goodsList=[...goodsList,...res.data.data]
// console.log(res.data)
commit('INIT', goodsList)
},
fail: (res) => {
uni.showToast({
title:"数据加载完了",
icon:"none"
})
console.log("fail status === > ", res);
},
complete: (res) => {
console.log("complete status === > ", res);
},
})
},
};
export default {
namespaced: true,
state,
mutations,
actions,
};