3
This commit is contained in:
122
mallplusui-web-pc/src/api/goods.js
Normal file
122
mallplusui-web-pc/src/api/goods.js
Normal file
@@ -0,0 +1,122 @@
|
||||
import request from './public'
|
||||
// 商品列表
|
||||
export const getAllGoods = (params) => {
|
||||
return request.post('/goods.getlist', params)
|
||||
}
|
||||
// 获取购物车列表
|
||||
export const getCartList = (params) => {
|
||||
return request.post('/cart.getlist', params)
|
||||
}
|
||||
// 加入购物车
|
||||
export const addCart = (params) => {
|
||||
return request.post('/cart.add', params)
|
||||
}
|
||||
// 删除购物车
|
||||
export const delCart = (params) => {
|
||||
return request.post('/cart.del', params)
|
||||
}
|
||||
// 删除购物车勾选商品
|
||||
export const delCartChecked = (params) => {
|
||||
return request.post('/api/cart/delCartChecked', params)
|
||||
}
|
||||
// 编辑购物车
|
||||
export const cartEdit = (params) => {
|
||||
return request.post('/api/cart/cartEdit', params)
|
||||
}
|
||||
// 全选
|
||||
export const editCheckAll = (params) => {
|
||||
return request.post('/api/cart/editCheckAll', params)
|
||||
}
|
||||
// 删除整条购物车
|
||||
export const cartDel = (params) => {
|
||||
return request.post('/api/member/cartDel', params)
|
||||
}
|
||||
// 获取用户地址
|
||||
export const addressList = (params) => {
|
||||
return request.post('/user.getusership', params)
|
||||
}
|
||||
// 通过id获取地址
|
||||
export const getAddress = (params) => {
|
||||
return request.post('/user.getshipdetail', params)
|
||||
}
|
||||
// 设为默认
|
||||
export const addressUpdate = (params) => {
|
||||
return request.post('/user.vuesaveusership', params)
|
||||
}
|
||||
// 添加收货地址
|
||||
export const addressAdd = (params) => {
|
||||
return request.post('/user.vuesaveusership', params)
|
||||
}
|
||||
// 删除收货地址
|
||||
export const addressDel = (params) => {
|
||||
return request.post('/user.removeship', params)
|
||||
}
|
||||
// 预览订单
|
||||
export const submitPreview = (params) => {
|
||||
return request.post('/submitPreview', params)
|
||||
}
|
||||
// 生成订单
|
||||
export const submitOrder = (params) => {
|
||||
return request.post('/order.create', params)
|
||||
}
|
||||
// 支付
|
||||
export const payMent = (params) => {
|
||||
return request.post('/api/order/payOrder', params)
|
||||
}
|
||||
// 获取用户订单
|
||||
export const orderList = (params) => {
|
||||
return request.post('/order.getorderlist', params)
|
||||
}
|
||||
// 获取单个订单详情
|
||||
export const getOrderDet = (params) => {
|
||||
return request.post('/order.details', params)
|
||||
}
|
||||
// 取消订单
|
||||
export const cancelOrder = (params) => {
|
||||
return request.post('/order.cancel', params)
|
||||
}
|
||||
// 商品详情
|
||||
export const productDet = (params) => {
|
||||
return request.post('/goods.getdetial', params)
|
||||
}
|
||||
// 删除订单
|
||||
export const delOrder = (params) => {
|
||||
return request.post('/api/member/delOrder', params)
|
||||
}
|
||||
// 商品列表
|
||||
export const getSearch = (params) => {
|
||||
return request.post('/goods.getlist', params)
|
||||
}
|
||||
// 快速搜索
|
||||
export const getQuickSearch = (params) => {
|
||||
return request.post('/goods.getlist', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成支付二维码(模式一)并在页面上显示
|
||||
*/
|
||||
export const scanCode = (params) => {
|
||||
return request.post('/api/wxpay/scanCode1', params)
|
||||
}
|
||||
/**
|
||||
* 扫码支付模式二
|
||||
* 已测试
|
||||
*/
|
||||
export const scanCode2 = (params) => {
|
||||
return request.post('/api/wxpay/scanCode2', params)
|
||||
}
|
||||
|
||||
/**
|
||||
* 扫码支付模式一回调
|
||||
* 已测试
|
||||
*/
|
||||
export const wxpay = (params) => {
|
||||
return request.post('/api/wxpay/wxpay', params)
|
||||
}
|
||||
/**
|
||||
* 刷卡支付
|
||||
* 已测试
|
||||
*/
|
||||
export const micropay = (params) => {
|
||||
return request.post('/api/wxpay/micropay', params)
|
||||
}
|
||||
50
mallplusui-web-pc/src/api/index.js
Normal file
50
mallplusui-web-pc/src/api/index.js
Normal file
@@ -0,0 +1,50 @@
|
||||
import request from './public'
|
||||
// 登陆
|
||||
export const userLogin = (params) => {
|
||||
return request.post('/user.login', params)
|
||||
}
|
||||
// 退出登陆
|
||||
export const loginOut = (params) => {
|
||||
return request.post('/user.logout', params)
|
||||
}
|
||||
// 用户信息
|
||||
export const userInfo = (params) => {
|
||||
return request.post('/user.info', params)
|
||||
}
|
||||
// 注册账号
|
||||
export const register = (params) => {
|
||||
return request.post('/user.reg', params)
|
||||
}
|
||||
// 上传图片
|
||||
export const upload = (params) => {
|
||||
return request.post('/upload', params)
|
||||
}
|
||||
// 修改头像
|
||||
export const updateheadimage = (params) => {
|
||||
return request.post('/user.editinfo', params)
|
||||
}
|
||||
// 捐赠列表
|
||||
export const thanksList = (params) => {
|
||||
return request.post('/api/member/thanks', params)
|
||||
}
|
||||
// 首页接口
|
||||
export const productHome = (params) => {
|
||||
return request.post('/pc.getpageconfig', params)
|
||||
}
|
||||
// 首页接口
|
||||
export const navList = (params) => {
|
||||
return request.post('/home.navlist', params)
|
||||
}
|
||||
// 推荐板块
|
||||
export const recommend = (params) => {
|
||||
return request.post('/hotProductList/list', params)
|
||||
}
|
||||
// 捐赠板块
|
||||
export const thank = (params) => {
|
||||
return request.post('/api/goods/thank', params)
|
||||
}
|
||||
// 极验验证码
|
||||
export const geetest = (params) => {
|
||||
return request.post('/api/member/geetestInit?t=' + (new Date()).getTime(), params)
|
||||
}
|
||||
|
||||
178
mallplusui-web-pc/src/api/login.js
Normal file
178
mallplusui-web-pc/src/api/login.js
Normal file
@@ -0,0 +1,178 @@
|
||||
import axios from 'axios'
|
||||
import Qs from "qs";
|
||||
import { getStore } from '/utils/storage'
|
||||
import toLogin from './login'
|
||||
const instance = axios.create({
|
||||
transformRequest: [
|
||||
function(data) {
|
||||
data = Qs.stringify(data);
|
||||
return data;
|
||||
}
|
||||
],
|
||||
// www.yjlive.cn
|
||||
baseURL: "http://127.0.0.1:8083/",
|
||||
timeout: 30000
|
||||
});
|
||||
instance.defaults.headers.post["Content-Type"] =
|
||||
"application/x-www-form-urlencoded";
|
||||
const defaultOpt = { login: true };
|
||||
const methodsToken = [
|
||||
"user.info",
|
||||
"user.editinfo",
|
||||
"user.changeavatar",
|
||||
"user.logout",
|
||||
"user.addgoodsbrowsing",
|
||||
"user.delgoodsbrowsing",
|
||||
"user.goodsbrowsing",
|
||||
"user.goodscollection",
|
||||
"user.goodscollectionlist",
|
||||
"user.vuesaveusership",
|
||||
"user.saveusership",
|
||||
"user.getshipdetail",
|
||||
"user.setdefship",
|
||||
"user.editship",
|
||||
"user.removeship",
|
||||
"user.getusership",
|
||||
"api/wxpay/user.pay",
|
||||
"user.orderevaluate",
|
||||
"user.getuserdefaultship",
|
||||
"user.issign",
|
||||
"user.sign",
|
||||
"user.mypoint",
|
||||
"user.userpointlog",
|
||||
"user.getbankcardlist",
|
||||
"user.getdefaultbankcard",
|
||||
"user.addbankcard",
|
||||
"user.removebankcard",
|
||||
"user.setdefaultbankcard",
|
||||
"user.getbankcardinfo",
|
||||
"user.editpwd",
|
||||
"user.forgotpwd",
|
||||
"user.recommend",
|
||||
"user.balancelist",
|
||||
"user.sharecode",
|
||||
"user.cash",
|
||||
"user.cashlist",
|
||||
"user.myinvite",
|
||||
"user.activationinvite",
|
||||
"coupon.getcoupon",
|
||||
"coupon.usercoupon",
|
||||
"cart.add",
|
||||
"cart.del",
|
||||
"cart.getlist",
|
||||
"cart.setnums",
|
||||
"cart.getnumber",
|
||||
"order.cancel",
|
||||
"order.del",
|
||||
"order.details",
|
||||
"order.confirm",
|
||||
"order.getlist",
|
||||
"order.create",
|
||||
"submitPreview",
|
||||
"order.getship",
|
||||
"order.getorderlist",
|
||||
"order.getorderstatusnum",
|
||||
"order.aftersaleslist",
|
||||
"order.aftersalesinfo",
|
||||
"order.aftersalesstatus",
|
||||
"order.addaftersales",
|
||||
"order.sendreship",
|
||||
"order.iscomment",
|
||||
"payments.getinfo",
|
||||
"user.getuserpoint",
|
||||
"coupon.getcouponkey",
|
||||
"store.isclerk",
|
||||
"store.storeladinglist",
|
||||
"store.ladinginfo",
|
||||
"store.lading",
|
||||
"store.ladingdel",
|
||||
"distribution_center-api-info",
|
||||
"distribution_center-api-applydistribution",
|
||||
"distribution_center-api-setstore",
|
||||
"distribution_center-api-myorder",
|
||||
"pintuan.pintuanteam",
|
||||
"lottery-api-getLotteryConfig",
|
||||
"lottery-api-lottery",
|
||||
"lottery-api-lotteryLog"
|
||||
];
|
||||
|
||||
function baseRequest(options) {
|
||||
const token = getStore('token');
|
||||
const headers = options.headers || {};
|
||||
|
||||
headers["Accept"] = "application/json";
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
||||
headers["authorization"] = token;
|
||||
headers["storeid"] = 2;
|
||||
options.headers = headers;
|
||||
if (options.login && !token) {
|
||||
// toLogin();
|
||||
// return Promise.reject({ msg: "未登录", toLogin: true });
|
||||
}
|
||||
console.log(options);
|
||||
var url = options.url.substring(1, options.url.length);
|
||||
// 判断token是否存在
|
||||
if (methodsToken.indexOf(url) >= 0) {
|
||||
if (!token) {
|
||||
// this.$router.push({path: '/page/Login/login'})
|
||||
toLogin();
|
||||
return Promise.reject({ msg: "未登录", toLogin: true });
|
||||
} else {
|
||||
//data.authorization = userToken;
|
||||
}
|
||||
}
|
||||
|
||||
return instance(options).then(res => {
|
||||
const data = res.data || {};
|
||||
if (res.status !== 200)
|
||||
return Promise.reject({ msg: "请求失败", res, data });
|
||||
|
||||
if ([410000, 410001, 410002, 100].indexOf(data.status) !== -1) {
|
||||
// this.$router.push({path: '/page/Login/login'})
|
||||
toLogin();
|
||||
return Promise.reject({ msg: res.data.msg, res, data, toLogin: true });
|
||||
} else if (data.code === 200) {
|
||||
return Promise.resolve(data, res);
|
||||
} else {
|
||||
return Promise.reject({ msg: res.data.msg, res, data });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* http 请求基础类
|
||||
* 参考文档 https://www.kancloud.cn/yunye/axios/234845
|
||||
*
|
||||
*/
|
||||
const request = ["post", "put", "patch"].reduce((request, method) => {
|
||||
/**
|
||||
*
|
||||
* @param url string 接口地址
|
||||
* @param data object get参数
|
||||
* @param options object axios 配置项
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
request[method] = (url, data, options = {}) => {
|
||||
return baseRequest(
|
||||
Object.assign({ url, data, method }, defaultOpt, options)
|
||||
);
|
||||
};
|
||||
return request;
|
||||
}, {});
|
||||
|
||||
["get", "delete", "head"].forEach(method => {
|
||||
/**
|
||||
*
|
||||
* @param url string 接口地址
|
||||
* @param params object get参数
|
||||
* @param options object axios 配置项
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
request[method] = (url, params = {}, options = {}) => {
|
||||
return baseRequest(
|
||||
Object.assign({ url, params, method }, defaultOpt, options)
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
export default request;
|
||||
179
mallplusui-web-pc/src/api/public.js
Normal file
179
mallplusui-web-pc/src/api/public.js
Normal file
@@ -0,0 +1,179 @@
|
||||
import axios from 'axios'
|
||||
import Qs from "qs";
|
||||
import { getStore } from '/utils/storage'
|
||||
import toLogin from './login'
|
||||
const instance = axios.create({
|
||||
transformRequest: [
|
||||
function(data) {
|
||||
data = Qs.stringify(data);
|
||||
return data;
|
||||
}
|
||||
],
|
||||
// www.yjlive.cn
|
||||
baseURL: "http://mall.yyundong.com/portalapi/",
|
||||
// baseURL: "http://www.yyundong.com:8083/",
|
||||
timeout: 30000
|
||||
});
|
||||
instance.defaults.headers.post["Content-Type"] =
|
||||
"application/x-www-form-urlencoded";
|
||||
const defaultOpt = { login: true };
|
||||
const methodsToken = [
|
||||
"user.info",
|
||||
"user.editinfo",
|
||||
"user.changeavatar",
|
||||
"user.logout",
|
||||
"user.addgoodsbrowsing",
|
||||
"user.delgoodsbrowsing",
|
||||
"user.goodsbrowsing",
|
||||
"user.goodscollection",
|
||||
"user.goodscollectionlist",
|
||||
"user.vuesaveusership",
|
||||
"user.saveusership",
|
||||
"user.getshipdetail",
|
||||
"user.setdefship",
|
||||
"user.editship",
|
||||
"user.removeship",
|
||||
"user.getusership",
|
||||
"api/wxpay/user.pay",
|
||||
"user.orderevaluate",
|
||||
"user.getuserdefaultship",
|
||||
"user.issign",
|
||||
"user.sign",
|
||||
"user.mypoint",
|
||||
"user.userpointlog",
|
||||
"user.getbankcardlist",
|
||||
"user.getdefaultbankcard",
|
||||
"user.addbankcard",
|
||||
"user.removebankcard",
|
||||
"user.setdefaultbankcard",
|
||||
"user.getbankcardinfo",
|
||||
"user.editpwd",
|
||||
"user.forgotpwd",
|
||||
"user.recommend",
|
||||
"user.balancelist",
|
||||
"user.sharecode",
|
||||
"user.cash",
|
||||
"user.cashlist",
|
||||
"user.myinvite",
|
||||
"user.activationinvite",
|
||||
"coupon.getcoupon",
|
||||
"coupon.usercoupon",
|
||||
"cart.add",
|
||||
"cart.del",
|
||||
"cart.getlist",
|
||||
"cart.setnums",
|
||||
"cart.getnumber",
|
||||
"order.cancel",
|
||||
"order.del",
|
||||
"order.details",
|
||||
"order.confirm",
|
||||
"order.getlist",
|
||||
"order.create",
|
||||
"submitPreview",
|
||||
"order.getship",
|
||||
"order.getorderlist",
|
||||
"order.getorderstatusnum",
|
||||
"order.aftersaleslist",
|
||||
"order.aftersalesinfo",
|
||||
"order.aftersalesstatus",
|
||||
"order.addaftersales",
|
||||
"order.sendreship",
|
||||
"order.iscomment",
|
||||
"payments.getinfo",
|
||||
"user.getuserpoint",
|
||||
"coupon.getcouponkey",
|
||||
"store.isclerk",
|
||||
"store.storeladinglist",
|
||||
"store.ladinginfo",
|
||||
"store.lading",
|
||||
"store.ladingdel",
|
||||
"distribution_center-api-info",
|
||||
"distribution_center-api-applydistribution",
|
||||
"distribution_center-api-setstore",
|
||||
"distribution_center-api-myorder",
|
||||
"pintuan.pintuanteam",
|
||||
"lottery-api-getLotteryConfig",
|
||||
"lottery-api-lottery",
|
||||
"lottery-api-lotteryLog"
|
||||
];
|
||||
|
||||
function baseRequest(options) {
|
||||
const token = getStore('token');
|
||||
const headers = options.headers || {};
|
||||
|
||||
headers["Accept"] = "application/json";
|
||||
headers["Content-Type"] = "application/x-www-form-urlencoded";
|
||||
headers["authorization"] = token;
|
||||
headers["storeid"] = 2;
|
||||
options.headers = headers;
|
||||
if (options.login && !token) {
|
||||
// toLogin();
|
||||
// return Promise.reject({ msg: "未登录", toLogin: true });
|
||||
}
|
||||
console.log(options);
|
||||
var url = options.url.substring(1, options.url.length);
|
||||
// 判断token是否存在
|
||||
if (methodsToken.indexOf(url) >= 0) {
|
||||
if (!token) {
|
||||
// this.$router.push({path: '/page/Login/login'})
|
||||
toLogin();
|
||||
return Promise.reject({ msg: "未登录", toLogin: true });
|
||||
} else {
|
||||
//data.authorization = userToken;
|
||||
}
|
||||
}
|
||||
|
||||
return instance(options).then(res => {
|
||||
const data = res.data || {};
|
||||
if (res.status !== 200)
|
||||
return Promise.reject({ msg: "请求失败", res, data });
|
||||
|
||||
if ([410000, 410001, 410002, 100].indexOf(data.status) !== -1) {
|
||||
// this.$router.push({path: '/page/Login/login'})
|
||||
toLogin();
|
||||
return Promise.reject({ msg: res.data.msg, res, data, toLogin: true });
|
||||
} else if (data.code === 200) {
|
||||
return Promise.resolve(data, res);
|
||||
} else {
|
||||
return Promise.reject({ msg: res.data.msg, res, data });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* http 请求基础类
|
||||
* 参考文档 https://www.kancloud.cn/yunye/axios/234845
|
||||
*
|
||||
*/
|
||||
const request = ["post", "put", "patch"].reduce((request, method) => {
|
||||
/**
|
||||
*
|
||||
* @param url string 接口地址
|
||||
* @param data object get参数
|
||||
* @param options object axios 配置项
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
request[method] = (url, data, options = {}) => {
|
||||
return baseRequest(
|
||||
Object.assign({ url, data, method }, defaultOpt, options)
|
||||
);
|
||||
};
|
||||
return request;
|
||||
}, {});
|
||||
|
||||
["get", "delete", "head"].forEach(method => {
|
||||
/**
|
||||
*
|
||||
* @param url string 接口地址
|
||||
* @param params object get参数
|
||||
* @param options object axios 配置项
|
||||
* @returns {AxiosPromise}
|
||||
*/
|
||||
request[method] = (url, params = {}, options = {}) => {
|
||||
return baseRequest(
|
||||
Object.assign({ url, params, method }, defaultOpt, options)
|
||||
);
|
||||
};
|
||||
});
|
||||
|
||||
export default request;
|
||||
48
mallplusui-web-pc/src/main.js
Normal file
48
mallplusui-web-pc/src/main.js
Normal file
@@ -0,0 +1,48 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App'
|
||||
import router from './router'
|
||||
import store from './store/'
|
||||
import VueLazyload from 'vue-lazyload'
|
||||
import infiniteScroll from 'vue-infinite-scroll'
|
||||
import VueCookie from 'vue-cookie'
|
||||
import { userInfo } from './api'
|
||||
import { Button, Pagination, Checkbox, Icon, Autocomplete, Loading, Message, Notification, Steps, Step, Table, TableColumn, Input, Dialog, Select, Option } from 'element-ui'
|
||||
import { getStore } from '/utils/storage'
|
||||
import VueContentPlaceholders from 'vue-content-placeholders'
|
||||
Vue.use(VueContentPlaceholders)
|
||||
Vue.use(Button)
|
||||
Vue.use(Pagination)
|
||||
Vue.use(Checkbox)
|
||||
Vue.use(Icon)
|
||||
Vue.use(Autocomplete)
|
||||
Vue.use(Steps)
|
||||
Vue.use(Step)
|
||||
Vue.use(Table)
|
||||
Vue.use(TableColumn)
|
||||
Vue.use(Input)
|
||||
Vue.use(Dialog)
|
||||
Vue.use(Select)
|
||||
Vue.use(Option)
|
||||
Vue.use(Loading.directive)
|
||||
Vue.prototype.$loading = Loading.service
|
||||
Vue.prototype.$notify = Notification
|
||||
Vue.prototype.$message = Message
|
||||
Vue.use(infiniteScroll)
|
||||
Vue.use(VueCookie)
|
||||
Vue.use(VueLazyload, {
|
||||
// preLoad: 1.3,
|
||||
// error: 'dist/error.png',
|
||||
loading: '/static/images/load.gif'
|
||||
// attempt: 1
|
||||
})
|
||||
Vue.config.productionTip = false
|
||||
const whiteList = ['/home', '/goods', '/login', '/register', '/goodsDetails', '/thanks', '/search', '/refreshsearch',
|
||||
'/refreshgoods'] // 不需要登陆的页面
|
||||
|
||||
/* eslint-disable no-new */
|
||||
new Vue({
|
||||
el: '#app',
|
||||
store,
|
||||
router,
|
||||
render: h => h(App)
|
||||
})
|
||||
80
mallplusui-web-pc/src/router/index.js
Normal file
80
mallplusui-web-pc/src/router/index.js
Normal file
@@ -0,0 +1,80 @@
|
||||
import Vue from 'vue'
|
||||
import Router from 'vue-router'
|
||||
const Index = () => import('/page/index.vue')
|
||||
const Login = () => import('/page/Login/login.vue')
|
||||
const Register = () => import('/page/Login/register.vue')
|
||||
const Home = () => import('/page/Home/home.vue')
|
||||
const GoodS = () => import('/page/Goods/goods.vue')
|
||||
const goodsDetails = () => import('/page/Goods/goodsDetails.vue')
|
||||
const Cart = () => import('/page/Cart/cart.vue')
|
||||
const order = () => import('/page/Order/order.vue')
|
||||
const user = () => import('/page/User/user.vue')
|
||||
const orderList = () => import('/page/User/children/order.vue')
|
||||
const information = () => import('/page/User/children/information.vue')
|
||||
const addressList = () => import('/page/User/children/addressList.vue')
|
||||
const coupon = () => import('/page/User/children/coupon.vue')
|
||||
const aihuishou = () => import('/page/User/children/aihuishou.vue')
|
||||
const support = () => import('/page/User/children/support.vue')
|
||||
const checkout = () => import('/page/Checkout/checkout.vue')
|
||||
const payment = () => import('/page/Order/payment.vue')
|
||||
const paysuccess = () => import('/page/Order/paysuccess.vue')
|
||||
const Thanks = () => import('/page/Thanks/thanks.vue')
|
||||
const Search = () => import('/page/Search/search.vue')
|
||||
const RefreshSearch = () => import('/page/Refresh/refreshsearch.vue')
|
||||
const RefreshGoods = () => import('/page/Refresh/refreshgoods.vue')
|
||||
const orderDetail = () => import('/page/User/children/orderDetail.vue')
|
||||
const Alipay = () => import('/page/Order/alipay.vue')
|
||||
const Wechat = () => import('/page/Order/wechat.vue')
|
||||
const QQpay = () => import('/page/Order/qqpay.vue')
|
||||
Vue.use(Router)
|
||||
export default new Router({
|
||||
routes: [
|
||||
{
|
||||
path: '/',
|
||||
component: Index,
|
||||
name: 'index',
|
||||
redirect: '/home',
|
||||
children: [
|
||||
{path: 'home', component: Home},
|
||||
{path: 'goods', component: GoodS},
|
||||
{path: 'goodsDetails', name: 'goodsDetails', component: goodsDetails},
|
||||
{path: 'thanks', name: 'thanks', component: Thanks},
|
||||
{path: '/refreshgoods', name: 'refreshgoods', component: RefreshGoods}
|
||||
]
|
||||
},
|
||||
{path: '/login', name: 'login', component: Login},
|
||||
{path: '/register', name: 'register', component: Register},
|
||||
{path: '/cart', name: 'cart', component: Cart},
|
||||
{path: '/refreshsearch', name: 'refreshsearch', component: RefreshSearch},
|
||||
{
|
||||
path: '/order',
|
||||
name: 'order',
|
||||
component: order,
|
||||
children: [
|
||||
{path: 'paysuccess', name: 'paysuccess', component: paysuccess},
|
||||
{path: 'payment', name: 'payment', component: payment},
|
||||
{path: '/search', name: 'search', component: Search},
|
||||
{path: 'alipay', name: 'alipay', component: Alipay},
|
||||
{path: 'wechat', name: 'wechat', component: Wechat},
|
||||
{path: 'qqpay', name: 'qqpay', component: QQpay}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/user',
|
||||
name: 'user',
|
||||
component: user,
|
||||
redirect: '/user/orderList',
|
||||
children: [
|
||||
{path: 'orderList', name: '订单列表', component: orderList},
|
||||
{path: 'orderDetail', name: '订单详情', component: orderDetail},
|
||||
{path: 'information', name: '账户资料', component: information},
|
||||
{path: 'addressList', name: '收货地址', component: addressList},
|
||||
{path: 'coupon', name: '我的优惠', component: coupon},
|
||||
{path: 'support', name: '售后服务', component: support},
|
||||
{path: 'aihuishou', name: '以旧换新', component: aihuishou}
|
||||
]
|
||||
},
|
||||
{path: '/checkout', name: 'checkout', component: checkout},
|
||||
{path: '*', redirect: '/home'}
|
||||
]
|
||||
})
|
||||
1
mallplusui-web-pc/src/store/action.js
Normal file
1
mallplusui-web-pc/src/store/action.js
Normal file
@@ -0,0 +1 @@
|
||||
export default {}
|
||||
25
mallplusui-web-pc/src/store/index.js
Normal file
25
mallplusui-web-pc/src/store/index.js
Normal file
@@ -0,0 +1,25 @@
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
import mutations from './mutations'
|
||||
import action from './action'
|
||||
Vue.use(Vuex)
|
||||
|
||||
const state = {
|
||||
login: false, // 是否登录
|
||||
userInfo: null, // 用户信息
|
||||
cartList: [], // 加入购物车列表
|
||||
showMoveImg: false, // 显示飞入图片
|
||||
elLeft: 0,
|
||||
elTop: 0,
|
||||
moveImgUrl: null,
|
||||
cartPositionT: 0, // 购物车位置
|
||||
cartPositionL: 0,
|
||||
receiveInCart: false, // 是否进入购物车
|
||||
showCart: false // 是否显示购物车
|
||||
}
|
||||
|
||||
export default new Vuex.Store({
|
||||
state,
|
||||
action,
|
||||
mutations
|
||||
})
|
||||
8
mallplusui-web-pc/src/store/mutation-types.js
Normal file
8
mallplusui-web-pc/src/store/mutation-types.js
Normal file
@@ -0,0 +1,8 @@
|
||||
export const INIT_BUYCART = 'INIT_BUYCART'
|
||||
export const ADD_CART = 'ADD_CART'
|
||||
export const GET_USERINFO = 'GET_USERINFO'
|
||||
export const RECORD_USERINFO = 'RECORD_USERINFO'
|
||||
export const ADD_ANIMATION = 'ADD_ANIMATION'
|
||||
export const SHOW_CART = 'SHOW_CART'
|
||||
export const REDUCE_CART = 'REDUCE_CART'
|
||||
export const EDIT_CART = 'EDIT_CART'
|
||||
135
mallplusui-web-pc/src/store/mutations.js
Normal file
135
mallplusui-web-pc/src/store/mutations.js
Normal file
@@ -0,0 +1,135 @@
|
||||
import {
|
||||
INIT_BUYCART,
|
||||
ADD_CART,
|
||||
GET_USERINFO,
|
||||
RECORD_USERINFO,
|
||||
ADD_ANIMATION,
|
||||
SHOW_CART,
|
||||
REDUCE_CART,
|
||||
EDIT_CART
|
||||
} from './mutation-types'
|
||||
import { setStore, getStore } from '../utils/storage'
|
||||
export default {
|
||||
// 网页初始化时从本地缓存获取购物车数据
|
||||
[INIT_BUYCART] (state) {
|
||||
let initCart = getStore('buyCart')
|
||||
if (initCart) {
|
||||
state.cartList = JSON.parse(initCart)
|
||||
}
|
||||
},
|
||||
// 加入购物车
|
||||
[ADD_CART] (state, {productId, salePrice, productName, productImg, productNum = 1}) {
|
||||
let cart = state.cartList // 购物车
|
||||
let falg = true
|
||||
let goods = {
|
||||
productId,
|
||||
salePrice,
|
||||
productName,
|
||||
productImg
|
||||
}
|
||||
if (cart.length) { // 有内容
|
||||
cart.forEach(item => {
|
||||
if (item.productId === productId) {
|
||||
if (item.productNum >= 0) {
|
||||
falg = false
|
||||
item.productNum += productNum
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
if (!cart.length || falg) {
|
||||
goods.productNum = productNum
|
||||
goods.checked = '1'
|
||||
cart.push(goods)
|
||||
}
|
||||
state.cartList = cart
|
||||
// 存入localStorage
|
||||
setStore('buyCart', cart)
|
||||
},
|
||||
// 加入购物车动画
|
||||
[ADD_ANIMATION] (state, {moveShow, elLeft, elTop, img, cartPositionT, cartPositionL, receiveInCart}) {
|
||||
state.showMoveImg = moveShow
|
||||
if (elLeft) {
|
||||
state.elLeft = elLeft
|
||||
state.elTop = elTop
|
||||
}
|
||||
state.moveImgUrl = img
|
||||
state.receiveInCart = receiveInCart
|
||||
if (cartPositionT) {
|
||||
state.cartPositionT = cartPositionT
|
||||
state.cartPositionL = cartPositionL
|
||||
}
|
||||
},
|
||||
// 是否显示购物车
|
||||
[SHOW_CART] (state, {showCart}) {
|
||||
// let timer = null
|
||||
state.showCart = showCart
|
||||
// clearTimeout(timer)
|
||||
// if (showCart) {
|
||||
// timer = setTimeout(() => {
|
||||
// state.showCart = false
|
||||
// }, 5000)
|
||||
// }
|
||||
},
|
||||
// 移除商品
|
||||
[REDUCE_CART] (state, {productId}) {
|
||||
let cart = state.cartList
|
||||
cart.forEach((item, i) => {
|
||||
if (item.productId === productId) {
|
||||
if (item.productNum > 1) {
|
||||
item.productNum--
|
||||
} else {
|
||||
cart.splice(i, 1)
|
||||
}
|
||||
}
|
||||
})
|
||||
state.cartList = cart
|
||||
// 存入localStorage
|
||||
setStore('buyCart', state.cartList)
|
||||
},
|
||||
// 修改购物车
|
||||
[EDIT_CART] (state, {productId, productNum, checked}) {
|
||||
let cart = state.cartList
|
||||
if (productNum) {
|
||||
cart.forEach((item, i) => {
|
||||
if (item.productId === productId) {
|
||||
item.productNum = productNum
|
||||
item.checked = checked
|
||||
}
|
||||
})
|
||||
} else if (productId) {
|
||||
cart.forEach((item, i) => {
|
||||
if (item.productId === productId) {
|
||||
cart.splice(i, 1)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
cart.forEach((item) => {
|
||||
item.checked = checked ? '1' : '0'
|
||||
})
|
||||
}
|
||||
state.cartList = cart
|
||||
// 存入localStorage
|
||||
setStore('buyCart', state.cartList)
|
||||
},
|
||||
// 记录用户信息
|
||||
[RECORD_USERINFO] (state, info) {
|
||||
state.userInfo = info
|
||||
state.login = true
|
||||
setStore('userInfo', info)
|
||||
},
|
||||
// 获取用户信息
|
||||
[GET_USERINFO] (state, info) {
|
||||
if (state.userInfo && (state.userInfo.username !== info.username)) {
|
||||
return
|
||||
}
|
||||
if (!state.login) {
|
||||
return
|
||||
}
|
||||
if (!info.message) {
|
||||
state.userInfo = {...info}
|
||||
} else {
|
||||
state.userInfo = null
|
||||
}
|
||||
}
|
||||
}
|
||||
26
mallplusui-web-pc/src/utils/storage.js
Normal file
26
mallplusui-web-pc/src/utils/storage.js
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* 存储localStorage
|
||||
*/
|
||||
export const setStore = (name, content) => {
|
||||
if (!name) return
|
||||
if (typeof content !== 'string') {
|
||||
content = JSON.stringify(content)
|
||||
}
|
||||
window.localStorage.setItem(name, content)
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取localStorage
|
||||
*/
|
||||
export const getStore = name => {
|
||||
if (!name) return
|
||||
return window.localStorage.getItem(name)
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除localStorage
|
||||
*/
|
||||
export const removeStore = name => {
|
||||
if (!name) return
|
||||
window.localStorage.removeItem(name)
|
||||
}
|
||||
Reference in New Issue
Block a user