import urlAlias from '../url'; import request from '../request'; const { category, shopList, search, } = urlAlias; let initData = {"name":"志平防蓝光-防辐射电脑网课眼镜","id":"9","imgurl":"", "price":0,"trade_num":"102","rsSon":{"pic":"9_FDB33D.jpg","model_pic":null,"in_price":"6000","sku_value":"80_83", "discount":"45","kc":"0","sku_name":"1.56非球面防蓝光_黑透+蓝纹","Max_Price":158,"Min_Price":99}} var initArr = [1,2,3,4,5,6,7,8] let list = [] initArr.forEach(function (value) { list.push(initData) }); let categoryList = [ { "type": "checkbox", "name": "产品", "value": "category", "submenu": [ { "label": "镜框", "name": "镜框", "value": "1" }, { "label": "镜片", "name": "镜片", "value": "2" }, { "label": "特种镜", "name": "特种镜", "value": "146" } ], "groups": [ "001" ] }, { "type": "radio", "name": "规则", "value": "px", "submenu": [ { "name": "按价格排", "value": "1" }, { "name": "按销量排", "value": "2" } ], "groups": [ "002" ] }, { "type": "radio", "name": "排序", "value": "sort", "submenu": [ { "name": "从高到低", "value": "1" }, { "name": "从低到高", "value": "2" } ], "groups": [ "003" ] }, { "type": "filter", "name": "筛选", "value": "filter", "submenu": [ { "type": "checkbox", "name": "性别", "value": "sex", "submenu": [ { "label": "男性", "name": "男性", "value": "27" }, { "label": "女性", "name": "女性", "value": "28" } ] }, { "type": "checkbox", "name": "年龄", "value": "age", "submenu": [ { "label": "通用", "name": "通用", "value": "24" } ] }, { "type": "checkbox", "name": "适用场景", "value": "sense", "submenu": [ { "label": "行政风", "name": "行政风", "value": "53" }, { "label": "青春学子风", "name": "青春学子风", "value": "54" }, { "label": "运动风", "name": "运动风", "value": "55" }, { "label": "简约-极简文艺范", "name": "简约-极简文艺范", "value": "56" }, { "label": "奶奶风", "name": "奶奶风", "value": "57" }, { "label": "流线洛可可", "name": "流线洛可可", "value": "58" }, { "label": "自然舒视角", "name": "自然舒视角", "value": "59" }, { "label": "无界人文系", "name": "无界人文系", "value": "60" }, { "label": "有机未来时", "name": "有机未来时", "value": "61" }, { "label": "立体巴洛克", "name": "立体巴洛克", "value": "62" }, { "label": "多元新风尚", "name": "多元新风尚", "value": "63" }, { "label": "理性几何派", "name": "理性几何派", "value": "64" }, { "label": "轻简北欧风", "name": "轻简北欧风", "value": "65" }, { "label": "质感哥特潮", "name": "质感哥特潮", "value": "66" }, { "label": "时尚", "name": "时尚", "value": "67" }, { "label": "复古", "name": "复古", "value": "68" }, { "label": "商务", "name": "商务", "value": "69" }, { "label": "休闲", "name": "休闲", "value": "70" }, { "label": "折射率", "name": "折射率", "value": "285" } ] }, { "type": "checkbox", "name": "价格", "value": "price", "submenu": [ { "name": "100以下", "value": "1,100" }, { "name": "100-300", "value": "100,300" }, { "name": "300-1000", "value": "300,1000" }, { "name": "1000以上", "value": "1000,-1" } ] }, { "type": "checkbox", "name": "材质", "value": "glasscate", "submenu": [ { "label": "购易", "name": "购易", "value": "72" }, { "label": "海俪恩", "name": "海俪恩", "value": "73" }, { "label": "沙漠风暴", "name": "沙漠风暴", "value": "74" }, { "label": "古诗", "name": "古诗", "value": "75" }, { "label": "暴龙", "name": "暴龙", "value": "76" }, { "label": "犀牛", "name": "犀牛", "value": "77" }, { "label": "Ray-Ban雷朋", "name": "Ray-Ban雷朋", "value": "78" }, { "label": "PARIM派丽蒙", "name": "PARIM派丽蒙", "value": "79" }, { "label": "石狼", "name": "石狼", "value": "80" }, { "label": "木九十", "name": "木九十", "value": "81" } ] }, { "type": "checkbox", "name": "品牌", "value": "brand", "submenu": [ { "label": "购易", "name": "购易", "value": "72" }, { "label": "海俪恩", "name": "海俪恩", "value": "73" }, { "label": "沙漠风暴", "name": "沙漠风暴", "value": "74" }, { "label": "古诗", "name": "古诗", "value": "75" }, { "label": "暴龙", "name": "暴龙", "value": "76" }, { "label": "犀牛", "name": "犀牛", "value": "77" }, { "label": "Ray-Ban雷朋", "name": "Ray-Ban雷朋", "value": "78" }, { "label": "PARIM派丽蒙", "name": "PARIM派丽蒙", "value": "79" }, { "label": "石狼", "name": "石狼", "value": "80" }, { "label": "木九十", "name": "木九十", "value": "81" } ] } ], "groups": [ "001", "002", "003" ], } ] //初始化数据是为了显示默认骨架 const state = { categoryList: [], list: list }; const mutations = { LIST: (state, list) => { state.list = list; }, CATEGORY: (state, categoryList) => { state.categoryList = categoryList; } }; const actions = { category({ commit }, param) { return new Promise((resolve) => request({ url: category, success: (res) => { //分类的镜架 let data = res.data.data.list; for (let i = 0; i <= data.length; i++) { if (data[i] && data[i].type !== 'filter') { data[i].type = 'hierarchy'; } } data.unshift({ type: "hierarchy", name: "全部", value: "all", isNoPull: true, }); commit('CATEGORY', data); resolve(data) }, fail: (res) => { console.log("fail status === > ", res); } })) }, list({ commit }, param) { return new Promise((resolve) => request({ url: shopList, success: (res) => { console.log('shopListshopListshopListshopListshopListshopListshopListshopListshopListshopListshopListshopList',res.data.data.list); commit('LIST', res.data.data.list) resolve(res.data) }, fail: (res) => { console.log("fail status === > ", res); }, complete: (res) => { state.isLoading = false; }, })) }, search({ commit }, { params, keyword }) { const uid = uni.getStorageSync('uid'); return new Promise((resolve) => request({ url: search, data: { params: JSON.stringify(params), uid, way: 1, keyword, }, success: (res) => { commit('LIST', res.data.data); resolve(res.data) }, fail: (res) => { console.log("fail status === > ", res); } })) }, }; export default { namespaced: true, state, mutations, actions, };