1
0

loginDoctor.vue 4.1 KB

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