解决选择订单列表,和订单之间的交互
This commit is contained in:
parent
dad4d33d68
commit
dd452f81e6
|
@ -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",
|
||||
|
|
|
@ -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')
|
||||
//根据key名获取传递回来的参数,data就是map
|
||||
// eventBus.$on('selectaddress', function(data){
|
||||
// //赋值给首页的附近医院数据模型
|
||||
// console.log('selectaddress', data);
|
||||
// }.bind(this));
|
||||
|
||||
//根据key名获取传递回来的参数,data就是map
|
||||
this.$on('selectaddress', function (data) {
|
||||
//赋值给首页的附近医院数据模型
|
||||
console.log('selectaddress', data);
|
||||
}.bind(this));
|
||||
},
|
||||
store: orderStore,
|
||||
};
|
||||
</script>
|
||||
|
||||
|
|
|
@ -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);
|
||||
//传递一个map,choiceHospital是key,hospital是value
|
||||
// eventBus.$emit('selectaddress',item);
|
||||
this.$store.commit('changeAddressData', {
|
||||
...item
|
||||
});
|
||||
this.$router.go(-1);
|
||||
}
|
||||
},
|
||||
|
@ -62,8 +63,8 @@
|
|||
}
|
||||
});
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
store: orderStore,
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -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: {
|
||||
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue