解决选择订单列表,和订单之间的交互

pull/1/head
sin 2019-04-10 21:48:31 +08:00
parent dad4d33d68
commit dd452f81e6
4 changed files with 48 additions and 24 deletions

View File

@ -12,7 +12,8 @@
"axios": "^0.18.0", "axios": "^0.18.0",
"vant": "^1.3.1", "vant": "^1.3.1",
"vue": "^2.5.17", "vue": "^2.5.17",
"vue-router": "^3.0.1" "vue-router": "^3.0.1",
"vuex": "^3.1.0"
}, },
"devDependencies": { "devDependencies": {
"@vue/cli-plugin-babel": "^3.4.1", "@vue/cli-plugin-babel": "^3.4.1",

View File

@ -12,8 +12,8 @@
<strong>选择地址</strong> <strong>选择地址</strong>
</template> </template>
<template v-else> <template v-else>
<strong>张三 138****6520</strong> <strong>{{addressData.name}} {{addressData.mobile}}</strong>
<div>广东省深圳市南山区科技园</div> <div>{{addressData.address}}</div>
</template> </template>
</van-cell> </van-cell>
<div style="height:15px;"></div> <div style="height:15px;"></div>
@ -57,12 +57,16 @@
<script> <script>
import {createOrder} from '../../api/order'; import {createOrder} from '../../api/order';
import orderStore from '../../store/order'
import eventBus from '../eventBus'; import eventBus from '../eventBus';
export default { export default {
data() { data() {
return { return {
type: "add1", type: "add",
addressData: {
},
products: [ products: [
{ {
imageURL: imageURL:
@ -105,7 +109,7 @@
onSubmit() { onSubmit() {
this.$toast("点击按钮"); this.$toast("点击按钮");
const { skuId, quantity } = this.$route.query; const { skuId, quantity } = this.$route.query;
const userAddressId = 1; const userAddressId = this.addressData.id;
const remark = ''; const remark = '';
const orderItems = [{ const orderItems = [{
@ -120,23 +124,18 @@
}) })
}, },
}, },
mounted: function() {
if (this.$store.state.addressData.name) {
this.type = 'add1';
} else {
this.type = 'add';
}
this.addressData = this.$store.state.addressData;
},
activated() { activated() {
console.log('activated')
//keydatamap
// eventBus.$on('selectaddress', function(data){
// //
// console.log('selectaddress', data);
// }.bind(this));
//keydatamap
this.$on('selectaddress', function (data) {
//
console.log('selectaddress', data);
}.bind(this));
}, },
store: orderStore,
}; };
</script> </script>

View File

@ -18,6 +18,7 @@
import {GetAddressList} from "../../../api/user.js"; import {GetAddressList} from "../../../api/user.js";
import { AddressList } from 'vant'; import { AddressList } from 'vant';
import eventBus from '../../eventBus'; import eventBus from '../../eventBus';
import orderStore from '../../../store/order'
export default { export default {
components: { components: {
@ -43,9 +44,9 @@
if (!this.isSelect) { if (!this.isSelect) {
return; return;
} }
this.$emit('selectaddress', item); this.$store.commit('changeAddressData', {
//mapchoiceHospitalkeyhospitalvalue ...item
// eventBus.$emit('selectaddress',item); });
this.$router.go(-1); this.$router.go(-1);
} }
}, },
@ -62,8 +63,8 @@
} }
}); });
}) })
} },
store: orderStore,
} }
</script> </script>

View File

@ -0,0 +1,23 @@
import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex);
// 挂载
export default new Vuex.Store({
state: {
addressData: {
},
},
mutations: {
changeAddressData: function (state, payload) {
state.addressData = payload;
}
},
actions: {
},
getters: {
}
});