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

This commit is contained in:
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",
"vant": "^1.3.1",
"vue": "^2.5.17",
"vue-router": "^3.0.1"
"vue-router": "^3.0.1",
"vuex": "^3.1.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.4.1",

View File

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

View File

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