1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
| <script> import {setSinger} from '../api/index'; import {mixin} from '../mixins/index'; import { provinceAndCityData, regionData, provinceAndCityDataPlus, regionDataPlus, CodeToText, TextToCode } from 'element-china-area-data' export default { mixins: [mixin], data(){ return{ centerDialogVisible: false, options: provinceAndCityData, selectedOptions: [], registerForm:{ name: '', sex: '', birth: '', location: null, introduction: '' } } } methods:{ handleChange () { var loc = ""; for (let i = 0; i < this.selectedOptions.length; i++) { loc += CodeToText[this.selectedOptions[i]]; } this.registerForm.location = loc; }, addSinger(){ let d = this.registerForm.birth let datetime = d.getFullYear()+'-'+(d.getMonth()+1)+'-'+d.getDate() let params = new URLSearchParams() params.append('name',this.registerForm.name) params.append('sex',this.registerForm.sex) params.append('pic','/img/singerPic/user.png') params.append('birth',datetime) params.append('location',this.registerForm.location) params.append('introduction',this.registerForm.introduction) setSinger(params) .then((res) => { if(res.code == 1){ this.notify("添加成功","success"); }else{ this.notify("添加失败","error"); } }) .catch(err => { console.log(err); }); this.centerDialogVisible = false; }
} } </script>
|