resetInfo.vue 5.7 KB

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