HTML:

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
<title>省市联动+对应经销商</title>
<link rel="stylesheet" type="text/css" href="css/public.css" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<!--rem.js-->
<script src="js/rem.js"></script>
<style> </style>
</head>
<body>
<div id="app" v-cloak>
<div class="box">
<div class='p1'>
<div class="city">
<div>
<select v-model="province.index" @change="changeProvince">
<option :value="item.id" v-for="(item,index) in province.data">{{item.name}}</option>
</select>
</div>
<div>
<select v-model="city.index" @change="changeCity">
<option :value="item.id" v-for="(item,index) in city.data">{{item.name}}</option>
</select>
</div>
</div>
</div>
<div class='p1'>
<div class="dealer">
<select v-model = "curDealer_id" @change="changeDealer">
<option :value="item.dealer_id" v-for="(item,index) in dealer" >{{item.name}}</option>
</select>
</div>
</div>
<div style="color:#fff;">
<p>省:{{province.index}}</p>
<p>城市:{{city.index}}</p>
<p>经销商:{{curDealer_id}}</p>
</div>
</div> </div>
</div>
<!--公用js-->
<script src="js/jquery_1.12.3_jquery.min.js"></script>
<script src="js/vue.js"></script>
<!--当前页面js-->
<script src="js/index.js"></script>
</body>
</html>

INDEX.JS

var AJAXURL = 'http://mall.faw-vw.com/';
var app = new Vue({
el: "#app",
data: {
province: {
index: 0, //省id ,默认第一个
data: [] //数据
},
city: {
index: 0, //城市id ,默认第一个
data: [] //数据
},
dealer:[],
curDealer_id:'',
}, mounted: function () {
var _this = this;
_this.getProvince();
},
methods:{
// 获取参与经销商省市,默认展示第一条数据
getProvince() {
var _this = this;
var data = [
{id: "110000", name: "北京市"},
{id: "120000", name: "天津市"},
{id: "130000", name: "河北省"},
{id: "140000", name: "山西省"},
{id: "150000", name: "内蒙古自治区"},
{id: "210000", name: "辽宁省"},
{id: "220000", name: "吉林省"},
{id: "230000", name: "黑龙江省"},
{id: "310000", name: "上海市"},
{id: "320000", name: "江苏省"},
{id: "330000", name: "浙江省"},
{id: "340000", name: "安徽省"},
{id: "350000", name: "福建省"},
{id: "360000", name: "江西省"},
{id: "370000", name: "山东省"},
{id: "410000", name: "河南省"},
{id: "420000", name: "湖北省"},
{id: "430000", name: "湖南省"},
{id: "440000", name: "广东省"},
{id: "450000", name: "广西壮族自治区"},
{id: "460000", name: "海南省"},
{id: "500000", name: "重庆市"},
{id: "510000", name: "四川省"},
{id: "520000", name: "贵州省"},
{id: "530000", name: "云南省"},
{id: "540000", name: "西藏自治区"},
{id: "610000", name: "陕西省"},
{id: "620000", name: "甘肃省"},
{id: "630000", name: "青海省"},
{id: "640000", name: "宁夏回族自治区"},
{id: "650000", name: "新疆维吾尔自治区"},
];
_this.province.data =data;
_this.province.index = data[0].id;
_this.getCity(_this.province.index);
},
getCity(provinceId) {
var _this = this;
// 返回数据格式
var data = {
children:[
{id: "230100", name: "哈尔滨市"},
{id: "230200", name: "齐齐哈尔市"},
{id: "230300", name: "鸡西市"},
{id: "230400", name: "鹤岗市"},
{id: "230500", name: "双鸭山市"},
{id: "230600", name: "大庆市"},
{id: "230700", name: "伊春市"},
{id: "230800", name: "佳木斯市"},
{id: "230900", name: "七台河市"},
{id: "231000", name: "牡丹江市"},
{id: "231100", name: "黑河市"},
{id: "231200", name: "绥化市"},
{id: "232700", name: "大兴安岭地区"},
]
}
$.ajax({
url: window.AJAXURL + "/Dealer/Index/getChildRegions",
type: 'post',
contentType: 'application/x-www-form-urlencoded',
data: {
id: provinceId,
},
success: function(res) {
_this.city.data = res.data.children;
_this.city.index = res.data.children[0].id //默认展示
_this.getDealer();
}
});
},
getDealer() {
var _this = this;
// 返回数据格式
var data = {
vehicles:[
{name: "山西志国星赛车发展有限公司",dealer_id: "224"},
{name: "山西志国星赛车发展有限公司",dealer_id: "224"},
]
}
$.ajax({
url: window.AJAXURL + "/Dealer/NewCar/oneOfNewCarList",
type: 'post',
contentType: 'application/x-www-form-urlencoded',
data: {
vehicle_id:184,
city_id: _this.city.index,
sort_field:1,
no_page:1,
},
success: function(res) {
var vehicles = res.data.vehicles;
_this.dealer = vehicles;
if(vehicles.length>0){
_this.curDealer_id = vehicles[0].dealer_id;
}
}
});
},
changeProvince(){
this.getCity(this.province.index)
},
changeCity(){
this.getDealer()
},
changeDealer(e){
var _this = this;
var hh = app.dealer.filter(function(c,i,a){
if(c.dealer_id==_this.curDealer_id){
return c
}
})
console.log(_this.curDealer_id,1)
console.log(hh,2)
_this.curDealer_id = hh[0].dealer_id //获取当前option的id值
console.log('当前id:'+_this.curDealer_id)
}, }, })

CSS:

.box{background:#330000;width:300px;height:300px;margin:20px auto;padding:30px}
.p1 .city{display:flex;margin-left:2%}
.p1{border-bottom:1px solid rgba(255,255,255,0.5);width:100%;margin-bottom:5%}
.p1 .city > div{width:55%;margin-right:7%;display:flex;align-items:center;justify-content:space-between;background:url(../images/arrow_Down.png) no-repeat 100% center}
.p1 .city > div:last-child{margin-right:0}
.p1 select{height:27px;font-size:14px;color:#fff;border:none;background-color:transparent;padding-bottom:5px;overflow:hidden;white-space:nowrap;width:100%;text-overflow:ellipsis}
.p1 .dealer{border-bottom:1px solid rgba(255,255,255,0.5);position:relative;width:100%;background:url(../images/arrow_Down.png) no-repeat 100% center}
.p1 select option{color:#000}

select省市联动+对应经销商、自定义箭头的更多相关文章

  1. select省市联动选择城市 asp.net mvc4

    本文在 http://www.cnblogs.com/darrenji/p/3606703.html(感谢博主的分享)基础上加入全国各省市,从文件中读取全国省市县,组成省市联动的选择标签 在Model ...

  2. select自定义箭头问题 。。。和一行内不同颜色的整体鼠标滑过变色

    1.select自定义箭头问题 用<select><option></option></select>的时候自带的三角箭头与需要的三角不同,这是还要求有 ...

  3. Json 基于jQuery+JSON的省市联动效果

    helloweba.com 作者:月光光 时间:2012-09-12 21:57 标签: jQuery  JSON  Ajax  省市联动     省市区联动下拉效果在WEB中应用非常广泛,尤其在一些 ...

  4. jquery省市联动,根据公司需求而写

    //author:guan //2015-05-25 //省市联动 //实用说明,页面引用如下js //<script src="../js/jquery-1.6.3.min.js&q ...

  5. AJAX案例四:省市联动

    <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"% ...

  6. Dynamic CRM 2013学习笔记(八)过滤查找控件 (类似省市联动)

    我们经常要实现类似省市联动一样的功能,常见的就是二个查找控件,一个选择了省后,另一个市的查找控件就自动过滤了,只显示当前省下的市,而不是所有的市.当然这是最简单的,实际工作中还有更复杂的功能要通过过滤 ...

  7. [JS]以下是JS省市联动菜单代码

    以下是JS省市联动菜单代码: 代码一: <html> <head> <title></title> <script language=" ...

  8. Ado.Net小练习03(省市联动)

    前台界面:          后台代码: namespace _04省市联动 {     public partial class Form1 : Form     {         public ...

  9. Ajax省市联动

    以JQuery为JS,写的Ajax省市联动. 代码如下: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN&q ...

  10. html + ashx 实现Ajax省市联动

    基本思路:1.了解数据库中省和市的表结构及关联主键 2.创建html页面及select标签 3.通过ajax向ashx(一般处理程序)发送后台请求完成联动效果 表结构: 这里,开始创建一个命为demo ...

随机推荐

  1. 开发一个最简单的iOS App

    开发一个最简单的iOS App 大家好,我是孜孜不倦学习的Zhangbeihai. 上月底我组织了[组队学习]TensorFlow 入门课程(中文) ,截至目前有300多同学加入.主要就是 Tenso ...

  2. 成功解决pycharm 的setting中的Error occurred when installing package 'Keras'

    成功解决pycharm 的setting中的Error occurred when installing package 'Keras' 刚刚开始学习python在安装package上碰了不上壁. M ...

  3. Chaos 测试下的若干 NebulaGraph Raft 问题分析

    Raft 是一种广泛使用的分布式共识算法.NebulaGraph 底层采用 Raft 算法实现 metad 和 storaged 的分布式功能.Raft 算法使 NebulaGraph 中的 meta ...

  4. pycharm 小技巧

    ctrl键 + B 查看定义源代码 alt键 + enter键 查看帮助 ctrl键 + shift键 + -号 所有代码隐藏 ctrl键 + shift键 + +号 所有代码展示 ctrl键 + D ...

  5. k8s本地联调工具kt-connect

    1.Kt Connect简介 KT Connect ( Kubernetes Developer Tool ) 是轻量级的面向 Kubernetes 用户的开发测试环境治理辅助工具.其核心是通过建立本 ...

  6. 【进阶篇】Redis实战之Jedis使用技巧详解

    一.摘要 在上一篇文章中,我们详细的介绍了 redis 的安装和常见的操作命令,以及可视化工具的介绍. 刚知道服务端的操作知识,还是远远不够的,如果想要真正在项目中得到应用,我们还需要一个 redis ...

  7. LeetCode-01 两数之和(Two Sum)

    题目描述 给定一个整数数组和一个目标值,找出数组中和为目标值的两个数, 你可以假设每个输入只对应一个答案,且同样的元素不能被重复利用. 示例 给定数组 nums = [2, 7, 11, 15], t ...

  8. C语言常用知识总结

    在 C 语言中,常量是一种固定值的标识符,它的值在程序执行期间不会改变. C 语言中有几种不同类型的常量: 字符常量:用单引号括起来的单个字符,例如 'A'.'b'.'1' 等. 字符串常量:用双引号 ...

  9. [Leetcode]设计循环队列

    题目   代码 class MyCircularQueue { public: /** Initialize your data structure here. Set the size of the ...

  10. element上传图片组件使用方法|图片回显|格式转换base64

    upload上传组件的使用方法 上传图片后自动上传(也可以手动上传),图片上传成功后由后端返回特定图片地址,在表单提交后将表单数据同图片地址一并返回即可完成图片上传功能. 组件HTML <!-- ...