Authored by 陈峰

vue 2.0 100%

<div class="logistics-page" id="logistics">
<components :is="currentView" :company_id="company_id" :company_name="company_name" applyid='{{applyid}}' type='{{type}}' company_list='{{company_list}}' keep-alive></components>
<component
:is="currentView"
:company_id="company_id"
:company_name="company_name"
@change-view="changeView"
keep-alive
applyid='{{applyid}}'
type='{{type}}'
company_list='{{company_list}}'></component>
</div>
... ...
// import yoho from './yoho';
// import cookie from 'yoho-cookie';
// cookie.set('_YOHOUID', '15286052');
// cookie.set('_YOHOTOKEN', 'b98acd01a0b52a8d1f99df2639ad637e');
// cookie.set('_YOHOUID', '50000582', {
// path: '/',
// domain: '.yohoblk.com'
// });
// cookie.set('_YOHOTOKEN', '26ea92e1f3fc39dbdcdbb63125c58b2b', {
// path: '/',
// domain: '.yohoblk.com'
// });
// yoho.isApp = true;
// yoho.ready = cb => cb();
... ...
... ... @@ -13,8 +13,9 @@ new Vue({
logistics: Logistics,
logisticsCompany: LogisticsCompany
},
events: {
changeView: function(obj) {
methods: {
changeView(obj) {
console.log('obj', obj)
this.currentView = obj.view;
this.company_id = obj.company_id;
this.company_name = obj.company_name;
... ...
... ... @@ -18,7 +18,7 @@
<span>换货方式</span>
<i class="icon icon-right right"></i>
<select class="right select-mode" v-model="deliveryTpye">
<option v-for="mode in delivery" :value="mode.id">{{mode.name}}</option>
<option v-for="mode in delivery" :key="mode.id" :value="mode.id">{{mode.name}}</option>
</select>
</div>
</div>
... ... @@ -254,14 +254,14 @@
},
watch: {
// area code 改变,重新获取 换货方式
'address.areaCode': function(newVal, oldVal) {
'address.area_code'(newVal) {
$.get('/me/return/exchange/delivery', {
areaCode: newVal
})
.then(result => {
$.each(result.data, (index, obj) => {
if (obj.is_default === 'Y') {
this.deliveryTpye = obj.id
this.deliveryTpye = obj.id;
return false;
}
});
... ...
<template>
<div class="companylist-page">
<div class="search-input">
<input class="icon" type="text" placeholder="&#xe608; 搜索快递公司" v-model="inputname" @input="search">
<input class="icon" type="text" placeholder="搜索快递公司" v-model="inputname" @input="search">
</div>
<div class="company-data">
<div class="company-item" v-for="(value, key) in showData" :key="key">
<div class="company-item" v-for="(item, key) in currentList" :key="key">
<a class="tag" :name="key">{{ key }}</a>
<span v-for="val in item" :key="val.id" @click="select(val.id, val.company_name)">{{val.company_name}}</span>
</div>
... ... @@ -19,10 +19,9 @@
export default {
props: ['company_list'],
data() {
this.company_list = JSON.parse(this.company_list);
return {
inputname: '',
showData: this.company_list
currentList: JSON.parse(this.company_list)
};
},
components: {
... ... @@ -33,14 +32,14 @@
let inputname = this.inputname;
if (!inputname) {
this.showData = this.company_list;
this.currentList = this.currentList;
return;
}
let filter = {};
for (let k in this.company_list) {
this.company_list[k].forEach(d => {
for (let k in this.currentList) {
this.currentList[k].forEach(d => {
if (d.company_name.indexOf(inputname) > -1) {
if (!filter[k]) {
filter[k] = [];
... ... @@ -49,10 +48,10 @@
}
});
}
this.showData = filter;
this.currentList = filter;
},
select(companyId, companyName) {
this.$dispatch('changeView', {
this.$emit('change-view', {
view: 'logistics',
company_id: companyId,
company_name: companyName
... ... @@ -60,7 +59,7 @@
// 重置列表
this.inputname = '';
this.showData = this.company_list;
this.currentList = this.currentList;
}
}
};
... ...
... ... @@ -23,13 +23,14 @@
export default {
props: ['applyid', 'type', 'company_id', 'company_name'],
data() {
console.log(this.$p)
return {
num: '',
};
},
methods: {
companylist() {
this.$dispatch('changeView', {
this.$emit('change-view', {
view: 'logisticsCompany'
});
},
... ...