index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <template>
  2. <view class="pwd-retrieve-container">
  3. <view style="wibackground-color: black;">
  4. <view style="width: 70vw;margin-left: 13vw;margin-top: 10vh;">
  5. <uni-forms ref="form" :value="user" labelWidth="0px">
  6. <uni-forms-item name="oldPassword">
  7. <!-- <uni-easyinput type="password" :styles="styles" :placeholderStyle="placeholderStyle"
  8. v-model="user.oldPassword" :placeholder="i18('请输入旧密码')" /> -->
  9. <view style="color: aliceblue;margin-left: 1vw;">{{i18('旧密码')}}{{oldPassword}}</view>
  10. <u-input :placeholder="i18('请输入旧密码')" v-show="oldPassword" :password="true" :styles="styles"
  11. color="#e7e7e7" v-model="user.oldPassword" style="border-radius: 20px;">
  12. <template slot="suffix">
  13. <uni-icons :type="oldPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
  14. @click="oldPasswordeye()"></uni-icons>
  15. </template>
  16. </u-input>
  17. <u-input :placeholder="i18('请输入旧密码')" v-show="!oldPassword" :password="false" :styles="styles"
  18. color="#e7e7e7" v-model="user.oldPassword" style="border-radius: 20px;">
  19. <template slot="suffix">
  20. <uni-icons :type="oldPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
  21. @click="oldPasswordeye()"></uni-icons>
  22. </template>
  23. </u-input>
  24. </uni-forms-item>
  25. <uni-forms-item name="newPassword">
  26. <!-- <uni-easyinput type="password" v-model="user.newPassword" :styles="styles" :placeholderStyle="placeholderStyle" :placeholder="i18('请输入新密码')" /> -->
  27. <view style="color: aliceblue;margin-left: 1vw;">{{i18('新密码')}}</view>
  28. <u-input :placeholder="i18('请输入新密码')" v-show="newPassword" :password="true" :styles="styles"
  29. color="#e7e7e7" v-model="user.newPassword" style="border-radius: 20px;">
  30. <template slot="suffix">
  31. <uni-icons :type="newPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
  32. @click="newPasswordeye()"></uni-icons>
  33. </template>
  34. </u-input>
  35. <u-input :placeholder="i18('请输入新密码')" v-show="!newPassword" :password="false" :styles="styles"
  36. color="#e7e7e7" v-model="user.newPassword" style="border-radius: 20px;">
  37. <template slot="suffix">
  38. <uni-icons :type="newPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
  39. @click="newPasswordeye()"></uni-icons>
  40. </template>
  41. </u-input>
  42. </uni-forms-item>
  43. <uni-forms-item name="confirmPassword">
  44. <!-- <uni-easyinput type="password" v-model="user.confirmPassword" :styles="styles" :placeholderStyle="placeholderStyle" :placeholder="i18('请确认新密码')" /> -->
  45. <view style="color: aliceblue;margin-left: 1vw;">{{i18('确认密码')}}</view>
  46. <u-input :placeholder="i18('请确认新密码')" v-show="confirmPassword" :password="true" :styles="styles"
  47. color="#e7e7e7" v-model="user.confirmPassword" style="border-radius: 20px;">
  48. <template slot="suffix">
  49. <uni-icons :type="confirmPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
  50. @click="confirmPasswordeye()"></uni-icons>
  51. </template>
  52. </u-input>
  53. <u-input :placeholder="i18('请确认新密码')" v-show="!confirmPassword" :password="false" :styles="styles"
  54. color="#e7e7e7" v-model="user.confirmPassword" style="border-radius: 20px;">
  55. <template slot="suffix">
  56. <uni-icons :type="confirmPassword ? 'eye': 'eye-slash'" size="25" style="color: aliceblue;"
  57. @click="confirmPasswordeye()"></uni-icons>
  58. </template>
  59. </u-input>
  60. </uni-forms-item>
  61. <button type="primary" style="background: #57B03D;color: white;border-radius: 20px;"
  62. @click="submit">{{i18('提交')}}</button>
  63. <view style="bottom: 80px;position: absolute;left: 10px;right:10px">
  64. <button type="warn" @click="" style="background: #ca2f14;color: white;border-radius: 20px;"
  65. @click="deleteUser">{{i18('注销账号')}}</button>
  66. </view>
  67. <!-- <view style="bottom: 10px;position: absolute;left: 10px;right:10px">
  68. <button type="warn" @click="" style="background: #57B03D;color: white" @click="handleLogout">{{i18('退出登录')}}</button>
  69. </view> -->
  70. </uni-forms>
  71. </view>
  72. </view>
  73. </view>
  74. </template>
  75. <script>
  76. import {
  77. updateUserPwd
  78. } from "@/api/system/user"
  79. import i18 from '@/utils/i18.js'
  80. export default {
  81. data() {
  82. return {
  83. placeholderStyle: "color:#bababa;font-size:14px",
  84. styles: {
  85. color: '#ffffff',
  86. borderColor: '#ffffff'
  87. },
  88. user: {
  89. oldPassword: undefined,
  90. newPassword: undefined,
  91. confirmPassword: undefined,
  92. },
  93. rules: {
  94. oldPassword: {
  95. rules: [{
  96. required: true,
  97. errorMessage: i18('旧密码不能为空')
  98. }]
  99. },
  100. newPassword: {
  101. rules: [{
  102. required: true,
  103. errorMessage: i18('新密码不能为空'),
  104. },
  105. {
  106. minLength: 6,
  107. maxLength: 20,
  108. errorMessage: i18('长度在 6 到 20 个字符')
  109. }
  110. ]
  111. },
  112. confirmPassword: {
  113. rules: [{
  114. required: true,
  115. errorMessage: i18('确认密码不能为空')
  116. }, {
  117. validateFunction: (rule, value, data) => data.newPassword === value,
  118. errorMessage: i18('两次输入的密码不一致')
  119. }]
  120. }
  121. },
  122. oldPassword: true,
  123. newPassword: true,
  124. confirmPassword: true,
  125. }
  126. },
  127. onReady() {
  128. this.$refs.form.setRules(this.rules)
  129. },
  130. onShow() {
  131. uni.setNavigationBarTitle({
  132. title: this.$t('page.modifypwd')
  133. })
  134. },
  135. methods: {
  136. eye(type) {
  137. if (type == 1) {
  138. this.oldPassword = !this.oldPassword
  139. } else if (type = 2) {
  140. } else {
  141. }
  142. },
  143. oldPasswordeye() {
  144. this.oldPassword = !this.oldPassword
  145. },
  146. confirmPasswordeye() {
  147. this.confirmPassword = !this.confirmPassword
  148. },
  149. newPasswordeye() {
  150. this.newPassword = !this.newPassword
  151. },
  152. i18(text) {
  153. return i18(text)
  154. },
  155. submit() {
  156. this.$refs.form.validate().then(res => {
  157. updateUserPwd(this.user.oldPassword, this.user.newPassword).then(response => {
  158. this.$modal.msgSuccess("修改成功")
  159. })
  160. })
  161. },
  162. handleLogout() {
  163. this.$modal.confirm('确定注销并退出系统吗?').then(() => {
  164. this.$store.dispatch('LogOut').then(() => {
  165. this.$tab.reLaunch('/pages/index')
  166. })
  167. })
  168. },
  169. deleteUser() {
  170. this.$modal.confirm('确定删除账号吗?').then(() => {
  171. this.$store.dispatch('DeleteUser').then(() => {
  172. this.$tab.reLaunch('/pages/index')
  173. })
  174. })
  175. }
  176. }
  177. }
  178. </script>
  179. <style lang="scss">
  180. page {
  181. background-image: url('/static/images/new/starts/bg2.jpg');
  182. background-size: cover;
  183. background-repeat: no-repeat;
  184. }
  185. .pwd-retrieve-container {
  186. padding-top: 36rpx;
  187. padding: 15px;
  188. line-height: 30px;
  189. }
  190. </style>