Blame view

src/store/modules/userRecommand.js 2.02 KB
7d2bdf29e   喻鹏   修改镜片选购逻辑 添加购物车和用户...
1
2
3
4
5
6
7
8
9
10
   import urlAlias from '../url';
   import request from '../request';
  
   const {
    recommandList
   } = urlAlias;
  
  const state = {
    recommandList: [],
  };
cc196c33c   喻鹏   购物车和用户推荐接口渲染
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
  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长度
          }
      
  }
7d2bdf29e   喻鹏   修改镜片选购逻辑 添加购物车和用户...
44
45
46
47
48
  const mutations = {
    INIT: (state, list) => {
      state.recommandList = list;
    },
  };
cc196c33c   喻鹏   购物车和用户推荐接口渲染
49
  let goodsList=[];
7d2bdf29e   喻鹏   修改镜片选购逻辑 添加购物车和用户...
50
51
52
53
54
  const actions = {
    getRecommandList({ commit }, param) {
      request({
        url: recommandList,
        success: (res) => {
cc196c33c   喻鹏   购物车和用户推荐接口渲染
55
56
57
58
59
60
  		  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)
7d2bdf29e   喻鹏   修改镜片选购逻辑 添加购物车和用户...
61
62
        },
        fail: (res) => {
cc196c33c   喻鹏   购物车和用户推荐接口渲染
63
64
65
66
  		  uni.showToast({
  			  title:"数据加载完了",
  			  icon:"none"
  		  })
7d2bdf29e   喻鹏   修改镜片选购逻辑 添加购物车和用户...
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
          console.log("fail status === > ", res);
        },
        complete: (res) => {
          console.log("complete status === > ", res);
        },
      })
    },
  };
  
  export default {
    namespaced: true,
    state,
    mutations,
    actions,
  };