clone 开源的 Shopping
This commit is contained in:
51
mobile-web/src/config/components.js
Normal file
51
mobile-web/src/config/components.js
Normal file
@@ -0,0 +1,51 @@
|
||||
|
||||
import headerNav from '../components/header/nav';
|
||||
|
||||
import navigate from '../components/footer/navigate.vue'
|
||||
import productcard from '../components/common/productcard.vue'
|
||||
import {
|
||||
Tag,
|
||||
Col,
|
||||
Icon,
|
||||
Cell,
|
||||
CellGroup,
|
||||
Swipe,
|
||||
Toast,
|
||||
SwipeItem,
|
||||
GoodsAction,
|
||||
GoodsActionBigBtn,
|
||||
GoodsActionMiniBtn,
|
||||
Actionsheet,
|
||||
Sku,
|
||||
Card,Button,SwipeCell,Dialog,Tab, Tabs,Row,Checkbox, CheckboxGroup, SubmitBar,NavBar,Tabbar, TabbarItem,Panel,List,Step, Steps,Field ,
|
||||
Badge, BadgeGroup,Popup,Stepper,RadioGroup, Radio,Picker,Uploader,Info
|
||||
} from 'vant';
|
||||
|
||||
const components=[
|
||||
Tag,
|
||||
Col,
|
||||
Icon,
|
||||
Cell,
|
||||
CellGroup,
|
||||
Swipe,
|
||||
SwipeItem,
|
||||
GoodsAction,
|
||||
GoodsActionBigBtn,
|
||||
GoodsActionMiniBtn,
|
||||
Actionsheet,
|
||||
Sku,
|
||||
Card,
|
||||
Button,
|
||||
SwipeCell ,
|
||||
Dialog ,
|
||||
headerNav,
|
||||
Tab, Tabs,Toast,Row,Checkbox, CheckboxGroup, SubmitBar,NavBar ,Tabbar, TabbarItem,navigate,Panel,List ,Step, Steps,Field ,
|
||||
Badge, BadgeGroup,Popup,productcard,Stepper,RadioGroup, Radio,Picker,Uploader,Info
|
||||
]
|
||||
|
||||
|
||||
export default (Vue)=>{
|
||||
components.forEach(Component => {
|
||||
Vue.component(Component.name, Component)
|
||||
});
|
||||
}
|
||||
25
mobile-web/src/config/env.js
Normal file
25
mobile-web/src/config/env.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* 配置编译环境和线上环境之间的切换
|
||||
*
|
||||
* baseUrl: 域名地址
|
||||
* routerMode: 路由模式
|
||||
* dataSources:数据源
|
||||
*/
|
||||
|
||||
let baseUrl = '';
|
||||
let routerMode = 'hash';
|
||||
let dataSources='local';//local=本地,其他值代表非本地
|
||||
|
||||
|
||||
if (process.env.NODE_ENV == 'development') {
|
||||
baseUrl='';
|
||||
|
||||
}else if(process.env.NODE_ENV == 'production'){
|
||||
baseUrl = '';
|
||||
}
|
||||
|
||||
export {
|
||||
baseUrl,
|
||||
routerMode,
|
||||
dataSources,
|
||||
}
|
||||
10
mobile-web/src/config/rem.js
Normal file
10
mobile-web/src/config/rem.js
Normal file
@@ -0,0 +1,10 @@
|
||||
(function(d, w) {
|
||||
const doc = d.documentElement;
|
||||
function rem() {
|
||||
const width = Math.min(doc.getBoundingClientRect().width, 768);
|
||||
doc.style.fontSize = width / 7.5 + 'px';
|
||||
}
|
||||
rem();
|
||||
w.addEventListener('resize', rem);
|
||||
})(document, window);
|
||||
|
||||
94
mobile-web/src/config/request.js
Normal file
94
mobile-web/src/config/request.js
Normal file
@@ -0,0 +1,94 @@
|
||||
|
||||
import axios from 'axios'
|
||||
import {baseUrl,dataSources} from './env';
|
||||
import datas from '../data/data';
|
||||
|
||||
|
||||
const service =axios.create({
|
||||
baseURL: baseUrl, // api 的 base_url
|
||||
timeout: 5000, // request timeout
|
||||
});
|
||||
|
||||
|
||||
const servicef =function(parameter){
|
||||
if(dataSources=='local'){
|
||||
//定义回调函数和axios一致
|
||||
const promist = new Promise(function(resolve,reject){
|
||||
var data=datas[parameter.url];
|
||||
if(typeof data=='string'){
|
||||
data= JSON.parse(data);
|
||||
}
|
||||
resolve(data);
|
||||
})
|
||||
return promist;
|
||||
}
|
||||
return service(parameter);
|
||||
}
|
||||
|
||||
|
||||
service.interceptors.request.use(
|
||||
config => {
|
||||
// Do something before request is sent
|
||||
// if (store.getters.token) {
|
||||
// // 让每个请求携带token-- ['X-Token']为自定义key 请根据实际情况自行修改
|
||||
// config.headers['X-Token'] = getToken()
|
||||
// }
|
||||
|
||||
return config
|
||||
},
|
||||
error => {
|
||||
// Do something with request error
|
||||
console.log(error) // for debug
|
||||
Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
// response interceptor
|
||||
service.interceptors.response.use(
|
||||
//response => response,
|
||||
/**
|
||||
* 下面的注释为通过在response里,自定义code来标示请求状态
|
||||
* 当code返回如下情况则说明权限有问题,登出并返回到登录页
|
||||
* 如想通过 xmlhttprequest 来状态码标识 逻辑可写在下面error中
|
||||
* 以下代码均为样例,请结合自生需求加以修改,若不需要,则可删除
|
||||
*/
|
||||
response => {
|
||||
const res = response.data;
|
||||
if (res.ResultCode !== 200) {
|
||||
// Message({
|
||||
// message: res.message,
|
||||
// type: 'error',
|
||||
// duration: 5 * 1000
|
||||
// })
|
||||
// // 50008:非法的token; 50012:其他客户端登录了; 50014:Token 过期了;
|
||||
// if (res.code === 50008 || res.code === 50012 || res.code === 50014) {
|
||||
// // 请自行在引入 MessageBox
|
||||
// // import { Message, MessageBox } from 'element-ui'
|
||||
// MessageBox.confirm('你已被登出,可以取消继续留在该页面,或者重新登录', '确定登出', {
|
||||
// confirmButtonText: '重新登录',
|
||||
// cancelButtonText: '取消',
|
||||
// type: 'warning'
|
||||
// }).then(() => {
|
||||
// store.dispatch('FedLogOut').then(() => {
|
||||
// location.reload() // 为了重新实例化vue-router对象 避免bug
|
||||
// })
|
||||
// })
|
||||
// }
|
||||
console.log(1);
|
||||
return Promise.reject('error')
|
||||
} else {
|
||||
if(typeof response.data.Tag=='string'){
|
||||
return JSON.parse(response.data.Tag);
|
||||
}else{
|
||||
return response.data.Tag;
|
||||
}
|
||||
}
|
||||
},
|
||||
error => {
|
||||
|
||||
return Promise.reject(error)
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
export default servicef
|
||||
200
mobile-web/src/config/router.js
Normal file
200
mobile-web/src/config/router.js
Normal file
@@ -0,0 +1,200 @@
|
||||
import Vue from 'vue';
|
||||
import Router from 'vue-router';
|
||||
|
||||
Vue.use(Router);
|
||||
|
||||
const routes = [
|
||||
{
|
||||
path: '*',
|
||||
redirect: '/home'
|
||||
},
|
||||
{
|
||||
name: 'home',
|
||||
component: () => import('../page/index'),
|
||||
meta: {
|
||||
title: '首页'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login',
|
||||
component: () => import('../page/account/login'),
|
||||
meta: {
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login/password',
|
||||
component: () => import('../page/account/password'),
|
||||
meta: {
|
||||
title: '登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login/phone',
|
||||
component: () => import('../page/account/phonelogin'),
|
||||
meta: {
|
||||
title: '手机号登录'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/login/register',
|
||||
component: () => import('../page/account/register'),
|
||||
meta: {
|
||||
title: '注册'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/index',
|
||||
component: () => import('../page/user/index'),
|
||||
name: 'user',
|
||||
meta: {
|
||||
title: '会员中心'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/info',
|
||||
component: () => import('../page/user/info/detail'),
|
||||
name: 'user',
|
||||
meta: {
|
||||
title: '账号管理'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/address',
|
||||
component: () => import('../page/user/address/list'),
|
||||
meta: {
|
||||
title: '我的地址'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/address/edit',
|
||||
component: () => import('../page/user/address/edit'),
|
||||
meta: {
|
||||
title: '修改地址'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/favorite',
|
||||
component: () => import('../page/user/favorite/list'),
|
||||
meta: {
|
||||
title: '我的收藏'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/coupon',
|
||||
component: () => import('../page/user/coupon/list'),
|
||||
meta: {
|
||||
title: '我的优惠券'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/order',
|
||||
component: () => import('../page/user/order/list'),
|
||||
meta: {
|
||||
title: '我的订单'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/order/:id',
|
||||
component: () => import('../page/user/order/list'),
|
||||
meta: {
|
||||
title: '我的订单'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/order/info/:id',
|
||||
component: () => import('../page/user/order/info'),
|
||||
meta: {
|
||||
title: '我的订单'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/order/logistics/:id',
|
||||
component: () => import('../page/user/order/logistics'),
|
||||
meta: {
|
||||
title: '订单追踪'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/aftersale',
|
||||
component: () => import('../page/user/aftersale/list'),
|
||||
meta: {
|
||||
title: '售后'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/aftersale/apply',
|
||||
component: () => import('../page/user/aftersale/apply'),
|
||||
meta: {
|
||||
title: '申请售后'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/aftersale/detail',
|
||||
component: () => import('../page/user/aftersale/detail'),
|
||||
meta: {
|
||||
title: '服务单详情'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/user/aftersale/track/:id',
|
||||
component: () => import('../page/user/aftersale/track'),
|
||||
meta: {
|
||||
title: '进度详情'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/product/:id',
|
||||
component: () => import('../page/product/detail'),
|
||||
meta: {
|
||||
title: '商品详情'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/search',
|
||||
component: () => import('../page/product/list'),
|
||||
meta: {
|
||||
title: '商品列表'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'cart',
|
||||
component: () => import('../page/cart/index'),
|
||||
meta: {
|
||||
title: '购物车'
|
||||
}
|
||||
},
|
||||
{
|
||||
path: '/order',
|
||||
component: () => import('../page/shipping/order'),
|
||||
meta: {
|
||||
title: '确认订单'
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'category',
|
||||
component: () => import('../page/category/index'),
|
||||
meta: {
|
||||
title: '分类'
|
||||
}
|
||||
},
|
||||
];
|
||||
|
||||
// add route path
|
||||
routes.forEach(route => {
|
||||
route.path = route.path || '/' + (route.name || '');
|
||||
});
|
||||
|
||||
const router = new Router({ routes });
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
const title = to.meta && to.meta.title;
|
||||
if (title) {
|
||||
document.title = title;
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
||||
export {
|
||||
router
|
||||
};
|
||||
Reference in New Issue
Block a user