123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192 |
- <template>
- <div class="hello">
- <Header> </Header>
- <el-container>
- <el-card class="center-card">
- <template>
- <el-button type="text" class="goback-btn " ><router-link to="/item/index">{{$t('goback')}}</router-link></el-button>
- <el-tabs value="first" type="card">
-
- <el-tab-pane :label="$t('modify_password')" name="first">
- <el-form status-icon label-width="0px" class="passwordForm" v-model="passwordForm">
- <el-form-item label="" >
- <el-input type="text" auto-complete="off" v-model="passwordForm.username" placeholder="" :disabled="true"></el-input>
- </el-form-item>
- <el-form-item label="" >
- <el-input type="password" auto-complete="off" :placeholder="$t('old_password')" v-model="passwordForm.password"></el-input>
- </el-form-item>
- <el-form-item label="" >
- <el-input type="password" auto-complete="off" v-model="passwordForm.new_password" :placeholder="$t('new_password')"></el-input>
- </el-form-item>
- <el-form-item label="" >
- <el-button type="primary" style="width:100%;" @click="passwordFormSubmit" >{{$t('submit')}}</el-button>
- </el-form-item>
- </el-form>
- </el-tab-pane>
- </el-tabs>
- </template>
- </el-card>
- </el-container>
- <Footer> </Footer>
-
- </div>
- </template>
- <script>
- export default {
- name: 'Login',
- components : {
- },
- data () {
- return {
- passwordForm:{
- username:'',
- password:'',
- new_password:''
- },
- emailForm:{
- status:'',
- email:'',
- password:'',
- submit_text:''
- },
- userInfo:{
- }
- }
- },
- methods: {
- get_user_info(){
- var that = this ;
- var url = DocConfig.server+'/api/user/info';
- var params = new URLSearchParams();
- that.axios.post(url, params)
- .then(function (response) {
- if (response.data.error_code === 0 ) {
- var userInfo = response.data.data
- that.userInfo = userInfo;
- that.passwordForm.username = userInfo.username;
- that.emailForm.email = userInfo.email ;
- var status = that.$t("status")+':';
- if (userInfo.email.length > 0 ) {
- that.emailForm.submit_text =that.$t("modify") ;
- if (userInfo.email_verify > 0 ) {
- status += that.$t("status_1");
- }else{
- status += that.$t("status_2");
- }
- }else{
- status += that.$t("status_3");
- that.emailForm.submit_text =that.$t("binding") ;
- }
- that.emailForm.status = status ;
- }else{
- that.$alert(response.data.error_message);
- }
-
- })
- .catch(function (error) {
- console.log(error);
- });
- },
- passwordFormSubmit() {
- var that = this ;
- var url = DocConfig.server+'/api/user/resetPassword';
- var params = new URLSearchParams();
- params.append('new_password', this.passwordForm.new_password);
- params.append('password', this.passwordForm.password);
- that.axios.post(url, params)
- .then(function (response) {
- if (response.data.error_code === 0 ) {
- that.$message.success(that.$t("modify_success"));
- }else{
- that.$alert(response.data.error_message);
- }
-
- })
- .catch(function (error) {
- console.log(error);
- });
- },
- emailFormSubmit(){
- var that = this ;
- var url = DocConfig.server+'/api/user/updateEmail';
- var params = new URLSearchParams();
- params.append('email', this.emailForm.email);
- params.append('password', this.emailForm.password);
- that.axios.post(url, params)
- .then(function (response) {
- if (response.data.error_code === 0 ) {
- that.$alert(that.$t("update_email_success"));
- this.get_user_info();
- }else{
- that.$alert(response.data.error_message);
- }
-
- })
- .catch(function (error) {
- console.log(error);
- });
- }
- },
- mounted(){
-
- this.get_user_info();
- /*给body添加类,设置背景色*/
- document.getElementsByTagName("body")[0].className="grey-bg";
- document.title = this.$route.meta.title;
- },
- beforeDestroy(){
- /*去掉添加的背景色*/
- document.body.removeAttribute("class","grey-bg");
- }
-
- }
- </script>
- <!-- Add "scoped" attribute to limit CSS to this component only -->
- <style scoped>
- .center-card a {
- font-size: 12px;
- }
- .center-card{
- text-align: center;
- width: 600px;
- height: 500px;
- }
- .passwordForm,.emailForm{
- width:300px;
- margin: 0 auto ;
- margin-top: 50px;
- }
- .goback-btn{
- z-index: 999;
- margin-left: 500px;
- }
- </style>
|