UNPKG

gxd-vue-library

Version:

依赖与element Ui插件库,聚福宝福利PC端插件库

98 lines (88 loc) 2.24 kB
'use strict'; import {mapActions} from "vuex"; // this.handleGetParentCodeForSubCityList({parent_code: 0}, (res) => { // console.log(res) // }) // // this.handleGetAllCityList((res) => { // console.log(res) // }) // // this.handleGetCityForTree({city_code: 350900}, (res) => { // console.log(res) // }) // this.handleGetProvinceAndCityTree((res) => { // console.log(res) // }) export default { methods: { ...mapActions('city', [ 'getParentCodeForSubCityList', 'getAllCityList', 'getProvinceAndCityList', 'getCityForTree' ]), /** * @description 获取省与城市树 * @param resolve {Function} 回调方法 */ handleGetProvinceAndCityTree(resolve){ this.getProvinceAndCityList({}) .then(res => { resolve(res.data) }) .catch(error => { resolve([]) console.error(error); }) }, /** * @description 通过城市获取县与街道树 * @param resolve {Function} 回调方法 * @param params {Object} 参数 * @param params.city_code {String} 城市code */ handleGetCityForTree(params, resolve) { this.getCityForTree(params) .then(res => { resolve(res.data) }) .catch(error => { resolve([]) console.error(error); }) }, /** * @description 获取城市列表 * @param resolve {Function} 回调方法 */ handleGetAllCityList(resolve){ this.getAllCityList({}) .then(res=>{ resolve(res) }) .catch(error => { resolve([]) console.error(error); }) }, /** * @description 通过父级获取子级城市列 * @param resolve {Function} 回调方法 * @param params {Object} 参数 * @param params.parent_code {String} 省code 默认:0 */ handleGetParentCodeForSubCityList(params, resolve){ if(params.parent_code) params.parent_code = 0; this.getParentCodeForSubCityList(params) .then(res=>{ resolve(res) console.log(res) }) .catch(error => { resolve([]) console.error(error); }) }, } }