|
@@ -1,69 +1,75 @@
|
|
|
/*
|
|
|
* @LastEditors: gcz
|
|
|
*/
|
|
|
-
|
|
|
+import { searchApi } from "@/service/index.js";
|
|
|
const addr = {
|
|
|
state: {
|
|
|
parentId: "156052",
|
|
|
+ parentName: '',
|
|
|
vuexSelectCity: "",
|
|
|
vuexSelectDistrict: "",
|
|
|
vuexSelectStreet: "",
|
|
|
-
|
|
|
+ // 市
|
|
|
vuexCityList: [],
|
|
|
+ // 区
|
|
|
vuexDistrictList: [],
|
|
|
- vuexStreetList: []
|
|
|
+ // 乡镇
|
|
|
+ vuexStreetList: [],
|
|
|
+ selectCity: {},
|
|
|
+ selectDistrict: {},
|
|
|
+ selectStreet: {}
|
|
|
},
|
|
|
mutations: {
|
|
|
- changeCityList(state, t) {
|
|
|
- state.vuexCityList = t;
|
|
|
+ // 获取市
|
|
|
+ changeCityList(state, cityList) {
|
|
|
+ state.vuexCityList = cityList;
|
|
|
},
|
|
|
- changeDistrictList(state, n) {
|
|
|
- state.vuexDistrictList = n;
|
|
|
+ // 获取区
|
|
|
+ changeDistrictList(state, districtList) {
|
|
|
+ state.vuexDistrictList = districtList;
|
|
|
},
|
|
|
- changeStreetList(state, n) {
|
|
|
- state.vuexStreetList = n;
|
|
|
+ // 获取乡镇
|
|
|
+ changeStreetList(state, streetList) {
|
|
|
+ state.vuexStreetList = streetList;
|
|
|
},
|
|
|
-
|
|
|
- changeSelectCity(state, n) {
|
|
|
- state.vuexSelectCity = n;
|
|
|
+ // 城市选择data
|
|
|
+ changeSelectCity(state, cityData) {
|
|
|
+ state.vuexSelectCity = cityData;
|
|
|
},
|
|
|
- changeSelectCityName(state, adName) {
|
|
|
- state.vuexSelectCityName = adName;
|
|
|
+ // 区县选择data
|
|
|
+ changeSelectDistrict(state, districtData) {
|
|
|
+ state.vuexSelectDistrict = districtData;
|
|
|
},
|
|
|
- changeSelectDistrict(state, n) {
|
|
|
- state.vuexSelectDistrict = n;
|
|
|
+ // 乡镇选择data
|
|
|
+ changeSelectStreet(state, streetData) {
|
|
|
+ state.vuexSelectStreet = streetData;
|
|
|
},
|
|
|
- changeSelectStreet(state, n) {
|
|
|
- state.vuexSelectStreet = n;
|
|
|
+ // 改变省市县级联选择获取数据
|
|
|
+ changeParentId(state, n) {
|
|
|
+ state.parentId = n.parentId;
|
|
|
+ state.parentName = n.name;
|
|
|
+ state.mapLevel = n.mapLevel;
|
|
|
}
|
|
|
- // addGoods(state, g) {
|
|
|
- // state.goods.push(g)
|
|
|
- // },
|
|
|
- // delGoods(state, idx) {
|
|
|
- // state.goods.splice(idx, 1)
|
|
|
- // }
|
|
|
},
|
|
|
actions: {
|
|
|
- searchArea(context,name) {
|
|
|
- searchApi({ parentId: "156052" }).then(res => {
|
|
|
- console.log(res);
|
|
|
- console.log(name);
|
|
|
- // if (name == "city") {
|
|
|
- // this.vuexCityList = res.data;
|
|
|
- // } else if (name == "county") {
|
|
|
- // this.vuexDistrictList = res.data;
|
|
|
- // } else {
|
|
|
- // this.cityOptions = res.data;
|
|
|
- // }
|
|
|
+ // 获取省市县
|
|
|
+ searchArea({ commit }, params = {}) {
|
|
|
+ console.log(params)
|
|
|
+ searchApi({ parentId: params.parentId }).then(res => {
|
|
|
+ if (params.mapLevel == "city") {
|
|
|
+ commit("changeDistrictList", res.data);
|
|
|
+ commit("changeSelectDistrict",{value:params.parentId,label:params.name})
|
|
|
+ } else if (params.mapLevel == "district") {
|
|
|
+ commit("changeStreetList", res.data);
|
|
|
+ commit("changeSelectStreet",{value:params.parentId,label:params.name})
|
|
|
+ } else {
|
|
|
+ commit("changeCityList", res.data);
|
|
|
+ commit("changeSelectCity",{value:params.parentId,label:params.name})
|
|
|
+ }
|
|
|
+ commit("changeParentId", params)
|
|
|
});
|
|
|
- }
|
|
|
+ },
|
|
|
|
|
|
- // add({ commit }, g) {
|
|
|
- // commit('addGoods', g)
|
|
|
- // },
|
|
|
- // del({ commit }, idx) {
|
|
|
- // commit('delGoods', idx)
|
|
|
- // }
|
|
|
}
|
|
|
};
|
|
|
|