Authored by 陈峰

commit

... ... @@ -15,73 +15,5 @@
</head>
<body>
<!--vue-ssr-outlet-->
<script>
(function(w, d, s, j, f) {
var a = d.createElement(s);
var m = d.getElementsByTagName(s)[0];
w.YohoAcquisitionObject = f;
w[f] = function() {
w[f].p = arguments;
};
a.async = 1;
a.src = j;
m.parentNode.insertBefore(a, m);
}(window, document, 'script', (document.location.protocol === 'https:' ? 'https:' : 'http:') + '//cdn.yoho.cn/yas-jssdk/2.4.15/yas.js', '_yas'));
(function() {
function getUid() {
var uid,
name = '_UID',
cookies = (document.cookie && document.cookie.split(';')) || [];
for (var i = 0; i < cookies.length; i++) {
if (cookies[i].indexOf(name) > -1) {
uid = decodeURIComponent(cookies[i].replace(name + '=', '').trim());
break;
}
}
if (!uid) return 0;
uid = uid.split('::');
if (!uid || uid.length < 4) {
return 0;
}
return uid[1];
}
function queryString() {
var vars = {},
hash,
i;
var hashes = window.location.search.slice(1).split('&');
for (i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars[hash[0]] = hash[1];
}
return vars;
}
var uid = getUid() || queryString().uid;
uid = uid === 0 ? '' : uid;
window._ozuid = uid; // 暴露ozuid
if (window._yas) {
window._yas(1 * new Date(), '2.4.15', 'yohoblk_m', uid, '', '');
}
}());
var _hmt = _hmt || [];
(function() {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?f7f9b12ad29dd4bc58f293770ea94dc8";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
</body>
</html>
... ...
export default [{
path: '/order',
path: '/ufo/order/:orderId(\\d+)',
name: 'order',
component: () => import(/* webpackChunkName: "channel" */ './order')
}];
... ...
... ... @@ -2,13 +2,36 @@
<LayoutApp>
<div class="order-page">
<div class="title">出售中</div>
<div class="product">
<p class="name">{{orderProduct}}</p>
<p>{{orderDetail}}</p>
</div>
</div>
</LayoutApp>
</template>
<script>
import {createNamespacedHelpers} from 'vuex';
const {mapState, mapActions} = createNamespacedHelpers('ufo/order');
export default {
name: 'OrderPage'
name: 'OrderPage',
computed: {
...mapState(['orderProduct', 'orderDetail'])
},
asyncData({store, router}) {
return store.dispatch('ufo/order/fetchProduct', {orderId: router.params.orderId});
},
created() {
},
mounted() {
this.fetchOrderDetail({orderId: this.$route.params.orderId});
},
methods: {
...mapActions(['fetchOrderDetail'])
}
};
</script>
... ...
... ... @@ -3,14 +3,17 @@ import Vuex from 'vuex';
import {createApi} from 'create-api';
import {createYoho} from './yoho';
import storeYoho from './yoho';
import storeUfo from './ufo';
Vue.use(Vuex);
export function createStore(context) {
const store = new Vuex.Store({
namespaced: true,
modules: {
yoho: createYoho()
yoho: storeYoho(),
ufo: storeUfo()
},
strict: process.env.NODE_ENV !== 'production'
});
... ...
import storeChannel from './channel';
import storeUser from './user';
import storePush from './push';
export default function() {
return {
namespaced: true,
modules: {
channel: storeChannel(),
user: storeUser(),
push: storePush(),
}
};
}
... ...
import storeOrder from './order';
export default function() {
return {
namespaced: true,
modules: {
order: storeOrder()
}
};
}
... ...
import * as Types from './types';
export default {
async fetchProduct({commit}, {orderId}) {
commit(Types.FETCH_ORDER_PRODUCT_REQUEST);
// const result = await this.$api.get('/getproductxxx', {orderId});
const result = await Promise.resolve({
code: 200,
data: {
name: '测试产品',
image: 'xxx'
}
});
if (result && result.code === 200) {
commit(Types.FETCH_ORDER_PRODUCT_SUCCESS, {
product: result.data
});
} else {
commit(Types.FETCH_ORDER_PRODUCT_FAILD);
}
},
async fetchOrderDetail({commit}, {orderId}) {
commit(Types.FETCH_ORDERDETAIL_REQUEST);
// const result = await this.$api.get('/getproductxxx', {orderId});
const result = await Promise.resolve({
code: 200,
data: {
name: '测试订单',
image: 'xxx'
}
});
if (result && result.code === 200) {
commit(Types.FETCH_ORDERDETAIL_SUCCESS, {
order: result.data
});
} else {
commit(Types.FETCH_ORDERDETAIL_FAILD);
}
}
};
... ...
import actions from './actions';
import mutations from './mutations';
export default function() {
return {
namespaced: true,
state: {
fetchingPro: false,
orderProduct: {},
fetchingOrder: false,
orderDetail: {}
},
actions,
mutations
};
}
... ...
import * as Types from './types';
export default {
[Types.FETCH_ORDER_PRODUCT_REQUEST](state) {
state.orderProduct = {};
state.fetchingPro = true;
},
[Types.FETCH_ORDER_PRODUCT_FAILD](state) {
state.fetchingPro = false;
},
[Types.FETCH_ORDER_PRODUCT_SUCCESS](state, {product}) {
state.fetchingPro = false;
state.orderProduct = product;
},
[Types.FETCH_ORDERDETAIL_REQUEST](state) {
state.orderDetail = {};
state.fetchingOrder = true;
},
[Types.FETCH_ORDERDETAIL_FAILD](state) {
state.fetchingOrder = false;
},
[Types.FETCH_ORDERDETAIL_SUCCESS](state, {order}) {
state.fetchingOrder = false;
state.orderDetail = order;
},
};
... ...
export const FETCH_ORDER_PRODUCT_REQUEST = 'FETCH_ORDER_PRODUCT_REQUEST';
export const FETCH_ORDER_PRODUCT_FAILD = 'FETCH_ORDER_PRODUCT_FAILD';
export const FETCH_ORDER_PRODUCT_SUCCESS = 'FETCH_ORDER_PRODUCT_SUCCESS';
export const FETCH_ORDERDETAIL_REQUEST = 'FETCH_ORDERDETAIL_REQUEST';
export const FETCH_ORDERDETAIL_FAILD = 'FETCH_ORDERDETAIL_FAILD';
export const FETCH_ORDERDETAIL_SUCCESS = 'FETCH_ORDERDETAIL_SUCCESS';
... ...
export function createYoho() {
import * as Types from './types';
export default function() {
return {
state: {
title: '',
... ... @@ -16,6 +18,18 @@ export function createYoho() {
direction: 'forword'
},
mutations: {
[Types.SET_ENV]() {
},
[Types.INIT_ROUTE_CHANGE]() {
},
[Types.ROUTE_CHANGE]() {
},
[Types.REPORT_YAS]() {
}
},
actions: {
}
... ...
... ... @@ -4,7 +4,7 @@ module.exports = [
cache: true,
},
{
route: /order/,
route: /ufo\/order/,
cache: true,
}
];
... ...