Setting.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. <template>
  2. <div class="hello">
  3. <Header> </Header>
  4. <el-container>
  5. <el-card class="center-card">
  6. <template>
  7. <el-button type="text" class="goback-btn " ><router-link to="/item/index">{{$t('goback')}}</router-link></el-button>
  8. <el-tabs value="first" type="card">
  9. <el-tab-pane :label="$t('modify_password')" name="first">
  10. <el-form status-icon label-width="0px" class="passwordForm" v-model="passwordForm">
  11. <el-form-item label="" >
  12. <el-input type="text" auto-complete="off" v-model="passwordForm.username" placeholder="" :disabled="true"></el-input>
  13. </el-form-item>
  14. <el-form-item label="" >
  15. <el-input type="password" auto-complete="off" :placeholder="$t('old_password')" v-model="passwordForm.password"></el-input>
  16. </el-form-item>
  17. <el-form-item label="" >
  18. <el-input type="password" auto-complete="off" v-model="passwordForm.new_password" :placeholder="$t('new_password')"></el-input>
  19. </el-form-item>
  20. <el-form-item label="" >
  21. <el-button type="primary" style="width:100%;" @click="passwordFormSubmit" >{{$t('submit')}}</el-button>
  22. </el-form-item>
  23. </el-form>
  24. </el-tab-pane>
  25. </el-tabs>
  26. </template>
  27. </el-card>
  28. </el-container>
  29. <Footer> </Footer>
  30. </div>
  31. </template>
  32. <script>
  33. export default {
  34. name: 'Login',
  35. components : {
  36. },
  37. data () {
  38. return {
  39. passwordForm:{
  40. username:'',
  41. password:'',
  42. new_password:''
  43. },
  44. emailForm:{
  45. status:'',
  46. email:'',
  47. password:'',
  48. submit_text:''
  49. },
  50. userInfo:{
  51. }
  52. }
  53. },
  54. methods: {
  55. get_user_info(){
  56. var that = this ;
  57. var url = DocConfig.server+'/api/user/info';
  58. var params = new URLSearchParams();
  59. that.axios.post(url, params)
  60. .then(function (response) {
  61. if (response.data.error_code === 0 ) {
  62. var userInfo = response.data.data
  63. that.userInfo = userInfo;
  64. that.passwordForm.username = userInfo.username;
  65. that.emailForm.email = userInfo.email ;
  66. var status = that.$t("status")+':';
  67. if (userInfo.email.length > 0 ) {
  68. that.emailForm.submit_text =that.$t("modify") ;
  69. if (userInfo.email_verify > 0 ) {
  70. status += that.$t("status_1");
  71. }else{
  72. status += that.$t("status_2");
  73. }
  74. }else{
  75. status += that.$t("status_3");
  76. that.emailForm.submit_text =that.$t("binding") ;
  77. }
  78. that.emailForm.status = status ;
  79. }else{
  80. that.$alert(response.data.error_message);
  81. }
  82. })
  83. .catch(function (error) {
  84. console.log(error);
  85. });
  86. },
  87. passwordFormSubmit() {
  88. var that = this ;
  89. var url = DocConfig.server+'/api/user/resetPassword';
  90. var params = new URLSearchParams();
  91. params.append('new_password', this.passwordForm.new_password);
  92. params.append('password', this.passwordForm.password);
  93. that.axios.post(url, params)
  94. .then(function (response) {
  95. if (response.data.error_code === 0 ) {
  96. that.$message.success(that.$t("modify_success"));
  97. }else{
  98. that.$alert(response.data.error_message);
  99. }
  100. })
  101. .catch(function (error) {
  102. console.log(error);
  103. });
  104. },
  105. emailFormSubmit(){
  106. var that = this ;
  107. var url = DocConfig.server+'/api/user/updateEmail';
  108. var params = new URLSearchParams();
  109. params.append('email', this.emailForm.email);
  110. params.append('password', this.emailForm.password);
  111. that.axios.post(url, params)
  112. .then(function (response) {
  113. if (response.data.error_code === 0 ) {
  114. that.$alert(that.$t("update_email_success"));
  115. this.get_user_info();
  116. }else{
  117. that.$alert(response.data.error_message);
  118. }
  119. })
  120. .catch(function (error) {
  121. console.log(error);
  122. });
  123. }
  124. },
  125. mounted(){
  126. this.get_user_info();
  127. /*给body添加类,设置背景色*/
  128. document.getElementsByTagName("body")[0].className="grey-bg";
  129. document.title = this.$route.meta.title;
  130. },
  131. beforeDestroy(){
  132. /*去掉添加的背景色*/
  133. document.body.removeAttribute("class","grey-bg");
  134. }
  135. }
  136. </script>
  137. <!-- Add "scoped" attribute to limit CSS to this component only -->
  138. <style scoped>
  139. .center-card a {
  140. font-size: 12px;
  141. }
  142. .center-card{
  143. text-align: center;
  144. width: 600px;
  145. height: 500px;
  146. }
  147. .passwordForm,.emailForm{
  148. width:300px;
  149. margin: 0 auto ;
  150. margin-top: 50px;
  151. }
  152. .goback-btn{
  153. z-index: 999;
  154. margin-left: 500px;
  155. }
  156. </style>