loginDoctor.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. <template>
  2. <view>
  3. <back></back>
  4. <view class="app_top">
  5. <image src="../../static/my2.png" mode="widthFix" class="img"></image>
  6. </view>
  7. <view class="dk">
  8. <view class="tx">
  9. <image src="../../static/favicon.png" mode="aspectFill"></image>
  10. </view>
  11. <view class="unit">医生登录</view>
  12. <view class="bg">
  13. <text class="icon">&#xe616;</text>
  14. <input v-model="item.username" placeholder="请输入账号" class="input" />
  15. </view>
  16. <view class="bg">
  17. <text class="icon">&#xe62a;</text>
  18. <input :password="show" v-model="item.password" placeholder="请输入密码" class="input" />
  19. <view class="label"><view class="icon" :class="{ active: !show }" @click="show = !show">&#xe6ef;</view></view>
  20. </view>
  21. <view class="bg">
  22. <text class="icon">&#xe613;</text>
  23. <input type="number" v-model="item.code" placeholder="请输入验证码" class="input" />
  24. <view class="label" @click="getCaptcha()"><image :src="img" mode="widthFix" class="captcha"></image></view>
  25. </view>
  26. <button class="btn" @click="login()">立即登录</button>
  27. <view class="fg" @click="forget()">忘记密码?</view>
  28. </view>
  29. </view>
  30. </template>
  31. <script>
  32. export default {
  33. data() {
  34. return {
  35. img: '',
  36. item: { username: '', password: '' },
  37. show: true
  38. };
  39. },
  40. onLoad(e) {
  41. this.getCaptcha();
  42. if (this.hasLogin()) {
  43. uni.redirectTo({
  44. url: '/pages/index/index'
  45. });
  46. }
  47. },
  48. methods: {
  49. back() {
  50. uni.navigateBack();
  51. },
  52. //图形验证码
  53. getCaptcha() {
  54. this.http.request({
  55. url: '/app/common/captcha',
  56. success: (res) => {
  57. this.img = res.data.data.img;
  58. this.item.uuid = res.data.data.uuid;
  59. }
  60. });
  61. },
  62. //登录
  63. login() {
  64. let rule = [
  65. { name: 'username', checkType: 'notnull', errorMsg: '请输入账号' },
  66. { name: 'password', checkType: 'notnull', errorMsg: '请输入密码' }
  67. ];
  68. if (!this.verify.check(this.item, rule)) {
  69. uni.showModal({ content: this.verify.error, showCancel: false });
  70. return false;
  71. }
  72. this.http.request({
  73. url: '/login',
  74. data: this.item,
  75. method: 'POST',
  76. success: (res) => {
  77. //提醒用户修改初始密码
  78. if (this.item.password == '123456') {
  79. uni.setStorageSync('easy', true);
  80. }
  81. let user = res.data.user.user;
  82. user.doctor = true;
  83. user.token = res.data.token;
  84. uni.setStorageSync('user', user);
  85. uni.showToast({ title: '登录成功' });
  86. setTimeout(() => {
  87. uni.navigateBack({
  88. delta: 2
  89. });
  90. }, 1000);
  91. },
  92. fail: (res) => {
  93. this.getCaptcha();
  94. }
  95. });
  96. },
  97. forget() {
  98. uni.showModal({ title: '提示', content: '如忘记密码,请联系管理员重置密码', showCancel: false });
  99. }
  100. }
  101. };
  102. </script>
  103. <style lang="scss">
  104. .app_top {
  105. display: block;
  106. position: relative;
  107. .img {
  108. width: 100%;
  109. }
  110. }
  111. .dk {
  112. position: relative;
  113. margin: 0 auto;
  114. padding: 20px;
  115. width: 75%;
  116. background-color: white;
  117. border-radius: 10px;
  118. margin-top: -80px;
  119. box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
  120. .tx {
  121. text-align: center;
  122. position: relative;
  123. margin-top: -70px;
  124. image {
  125. width: 80px;
  126. height: 80px;
  127. border-radius: 50%;
  128. border: 2px solid white;
  129. }
  130. }
  131. .unit {
  132. text-align: center;
  133. margin-bottom: 20px;
  134. font-size: 20px;
  135. color: #545555;
  136. margin-top: 10px;
  137. font-weight: bold;
  138. }
  139. .bg {
  140. overflow: hidden;
  141. margin-bottom: 15px;
  142. border-radius: 5px;
  143. border: 1px solid #cdcdcd;
  144. .icon {
  145. float: left;
  146. padding-left: 10px;
  147. margin-top: 12px;
  148. font-size: 18px;
  149. color: $font-c;
  150. }
  151. .input {
  152. height: 45px;
  153. text-align: left;
  154. padding-left: 15px;
  155. font-size: 14px;
  156. color: $font-c;
  157. width: 60%;
  158. }
  159. .label {
  160. float: right;
  161. margin-top: -31px;
  162. padding-right: 15px;
  163. font-size: 14px;
  164. color: $main-color;
  165. cursor: pointer;
  166. .icon {
  167. color: darkgray;
  168. font-size: 22px;
  169. margin-top: -4px;
  170. &.active {
  171. color: $main-color;
  172. }
  173. }
  174. .captcha {
  175. width: 90px;
  176. height: 34px;
  177. margin-top: -8px;
  178. border-radius: 3px;
  179. }
  180. }
  181. }
  182. .fg {
  183. text-align: center;
  184. margin-top: 30px;
  185. color: #989898;
  186. font-size: 14px;
  187. }
  188. }
  189. </style>