resetInfo.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template>
  2. <view class="form">
  3. <view class="formContent">
  4. <view class="row noBorder">
  5. <view class="label">用户名:</view>
  6. <input class="formInput" type="text" :value="userId" disabled />
  7. </view>
  8. <view class="row noBorder">
  9. <view class="label">姓名:</view>
  10. <input class="formInput" type="text" :value="name" disabled />
  11. </view>
  12. <view class="row">
  13. <view class="label">新密码:</view>
  14. <input class="formInput" type="text" password @input="e=>onKeyInput(e,'password')" />
  15. </view>
  16. <view class="row">
  17. <view class="label">确认新密码:</view>
  18. <input class="formInput" type="text" password @input="e=>onKeyInput(e,'confirmPassword')" />
  19. </view>
  20. </view>
  21. <button type="primary" class="commitBtn" @click="commitHandle">确认修改</button>
  22. <tm-modal v-if="showModal">
  23. <view class="modalContent">
  24. <view class="inner">
  25. <image class="normalTipIcon" src="/static/normalTipIcon.png" ></image>
  26. <view class="tipText">
  27. {{modalText}}
  28. </view>
  29. <view class="comfirmBtn" @click="goback">确定</view>
  30. </view>
  31. </view>
  32. </tm-modal>
  33. </view>
  34. </template>
  35. <script>
  36. // import uploadImage from '../../components/tm-upload-img/tm-upload-img.vue'
  37. import encryption from "../../utils/crypto.js";
  38. export default {
  39. data() {
  40. return {
  41. showModal:false,
  42. userId:'',
  43. name:'',
  44. password:'',
  45. confirmPassword:'',
  46. modalText:'',
  47. ifCompleted:false
  48. };
  49. },
  50. onLoad(){
  51. // console.log(window.location.host);
  52. this.name = uni.getStorageSync('name');
  53. this.userId = uni.getStorageSync('code');
  54. },
  55. mounted() {
  56. },
  57. methods: {
  58. commitHandle(){
  59. console.log(this.password,this.confirmPassword);
  60. if(this.password&&this.confirmPassword){
  61. if(this.password != this.confirmPassword){
  62. this.modalText = '两次密码输入不一致!';
  63. this.showModal = true;
  64. return;
  65. }
  66. this.$store.dispatch({
  67. type: 'resetInfo/commActions',
  68. payload: {
  69. key: 'reSetPsdName',
  70. data: {
  71. password: encryption(this.password),
  72. confirmPassword: encryption(this.confirmPassword)
  73. }
  74. }
  75. }).then(data=>{
  76. if(data){
  77. this.ifCompleted = true;
  78. this.modalText = '密码修改成功,前往重新登录!';
  79. this.showModal = true
  80. }
  81. })
  82. }else {
  83. this.modalText = '请完整填写表单信息!';
  84. this.showModal = true
  85. }
  86. },
  87. logOut() {
  88. this.$store.dispatch({
  89. type: 'home/commActions',
  90. payload: {
  91. key: 'logout',
  92. }
  93. }).then((data)=>{
  94. if(data){
  95. uni.removeStorageSync('hiId');
  96. uni.removeStorageSync('permissions');
  97. uni.removeStorageSync('token');
  98. uni.removeStorageSync('code');
  99. uni.removeStorageSync('nowPermission');
  100. uni.removeStorageSync('id');
  101. uni.removeStorageSync('name');
  102. // uni.setStorageSync('hospSign', this.hospSign);
  103. uni.redirectTo({
  104. url: `/pages/login/login?hospSign=${uni.getStorageSync('hospSign')}`
  105. });
  106. }
  107. });
  108. },
  109. onKeyInput(e,key){
  110. // console.log({e,key});
  111. if(key=='password'){
  112. this.password = e.target.value;
  113. }
  114. if(key=='confirmPassword'){
  115. this.confirmPassword = e.target.value;
  116. }
  117. },
  118. goback(){
  119. if(this.ifCompleted){
  120. this.showModal = false;
  121. this.logOut();
  122. }else {
  123. this.showModal = false
  124. }
  125. }
  126. }
  127. }
  128. </script>
  129. <style lang="less">
  130. .form {
  131. position: relative;
  132. padding-top: 15rpx;
  133. height: 100vh;
  134. background: #F5F6FA;
  135. .formContent {
  136. padding: 28rpx;
  137. margin-top: 10rpx;
  138. border-radius: 5rpx;
  139. background-color: #FFFFFF;
  140. .row {
  141. display: flex;
  142. flex-direction: row;
  143. justify-content: flex-start;
  144. align-items: center;
  145. padding: 0 10rpx;
  146. border-radius: 10rpx;
  147. margin-bottom: 20rpx;
  148. border: 0.62rpx solid #DADEE6;
  149. .label {
  150. font-size: 27rpx;
  151. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  152. font-weight: 400;
  153. color: #292C33;
  154. }
  155. .formInput {
  156. height: 80rpx;
  157. font-size: 27rpx;
  158. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  159. font-weight: 400;
  160. color: #292C33;
  161. }
  162. &.noBorder {
  163. border:none;
  164. }
  165. &:first-child {
  166. margin-bottom: 0;
  167. }
  168. }
  169. }
  170. .commitBtn {
  171. position: fixed;
  172. bottom:0rpx;
  173. width: 100%;
  174. height: 75rpx;
  175. line-height: 75rpx;
  176. margin:0 auto;
  177. font-size: 25rpx;
  178. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  179. font-weight: 400;
  180. border-radius: 0;
  181. // margin: 0 20rpx;
  182. }
  183. .modalContent {
  184. display: flex;
  185. justify-content: center;
  186. align-items: center;
  187. width: 100vw;
  188. height: 100vh;
  189. .inner {
  190. // position: relative;
  191. display: flex;
  192. flex-direction: column;
  193. // justify-content: center;
  194. align-items: center;
  195. width: 562.5rpx;
  196. height: 361.25rpx;
  197. margin: 0 auto;
  198. top:50%;
  199. padding-top: 50rpx;
  200. background: #FFFFFF;
  201. border-radius: 15rpx;
  202. .normalTipIcon {
  203. width: 80rpx;
  204. height:80rpx;
  205. margin-bottom: 28.75rpx;
  206. }
  207. .tipText {
  208. display: flex;
  209. justify-content:center;
  210. align-items: center;
  211. width: 427.5rpx;
  212. height: 95rpx;
  213. font-size: 22.5rpx;
  214. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  215. font-weight: 400;
  216. color: #292C33;
  217. line-height: 31.25rpx;
  218. margin-bottom: 39.37rpx;
  219. }
  220. .comfirmBtn {
  221. width: 100%;
  222. height: 75rpx;
  223. line-height: 75rpx;
  224. text-align: center;
  225. font-size: 22.5rpx;
  226. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  227. font-weight: 400;
  228. color: #FFFFFF;
  229. background: #3377FF;
  230. }
  231. }
  232. }
  233. }
  234. </style>