login.vue 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. <template>
  2. <view class="login-page">
  3. <view class="com-model">
  4. <view class="top-box">
  5. <image class="pic" src="/static/images/shade.png"></image>
  6. <text class="title-top" @click="openModal">你好,</text>
  7. <text class="title-buttom">欢迎使用追踪方法学系统</text>
  8. </view>
  9. <view class="main-content">
  10. <input class="uni-input-box"
  11. placeholder="请输入账号"
  12. placeholder-style="color: #A1A7B3"
  13. v-model="username" />
  14. <input class="uni-input-box"
  15. placeholder="请输入密码"
  16. placeholder-style="color: #A1A7B3"
  17. password
  18. v-model="password" />
  19. <com-button class="login-button"
  20. :width="998" :height="120" :fontSize="48" :background="isLogin?'#A3B1CC':''" btnText="登录" @btnClick="login" />
  21. </view>
  22. </view>
  23. <tm-modal v-if="showInputModal" @click="clickModalhandle">
  24. <view class="checkItemResultModal">
  25. <view class="modalContent">
  26. <view class="modalBar">开发者模式</view>
  27. <input class="keyInutArea" type="text" @input='setHospSign' placeholder="请输入hospSign" />
  28. <button class="commitActBtn" @click="updateHospSign(true)" type="default">确定</button>
  29. <button class="commitActBtn" @click="updateHospSign(false)" type="default">确定</button>
  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. index:0,
  41. appHospSign:'tYAoFaa20yCAgaiy',//app端更新hospSign
  42. showInputModal:false,
  43. hospSign: '', // 医院标识
  44. username: '', // 用户名
  45. password: '', // 密码
  46. rolList: [
  47. {permission: 1, name: '管理员', pagePath: 'pages/situationsCenter/situationsCenter'}, // targetIndexs:targetList种对应的下标
  48. {permission: 2, name: '查核组长',pagePath: 'pages/situationsCenter/situationsCenter'},
  49. {permission: 3, name: '查核组员', pagePath: 'pages/situationsCenter/situationsCenter'},
  50. {permission: 4, name: '单位负责人', pagePath: 'pages/mission/mission'},
  51. {permission: 5, name: '改善者', pagePath: 'pages/mission/mission'}
  52. ]
  53. }
  54. },
  55. onLoad({ hospSign }){
  56. this.hospSign = hospSign;
  57. },
  58. mounted(){
  59. // console.log('login mounted');
  60. // try {
  61. // const value = uni.getStorageSync('hospSign');
  62. // if (value) {
  63. // }
  64. // } catch (e) {
  65. // // error
  66. // }
  67. },
  68. methods: {
  69. setHospSign(e){
  70. this.appHospSign = e.target.value
  71. },
  72. openModal(){
  73. // #ifdef APP-PLUS
  74. this.index = this.index + 1;
  75. if(this.index==3)this.showInputModal = true;
  76. // #endif
  77. },
  78. updateHospSign(bool){
  79. if(bool){
  80. this.hospSign = this.appHospSign;
  81. }
  82. this.index=0;
  83. this.showInputModal = false;
  84. },
  85. login() {
  86. if(this.isLogin) return
  87. const nowPermission = uni.getStorageSync('nowPermission');
  88. console.log({nowPermission});
  89. this.$store.dispatch({
  90. type: 'login/commActions',
  91. payload: {
  92. key: 'login',
  93. data: {
  94. username: encryption(this.username),
  95. password: encryption(this.password),
  96. // #ifdef APP-PLUS
  97. hospSign: this.appHospSign,
  98. // #endif
  99. // #ifdef H5
  100. hospSign: this.hospSign,
  101. // #endif
  102. nowPermission:nowPermission
  103. // hospSign:'tYAoFaa20yCAgaiy'
  104. }
  105. }
  106. }).then((data) => {
  107. if (data) {
  108. uni.setStorageSync('hiId', data.hiId);
  109. uni.setStorageSync('permissions', data.permissions);
  110. uni.setStorageSync('token', data.token);
  111. uni.setStorageSync('code', data.code);
  112. uni.setStorageSync('nowPermission', data.nowPermission);
  113. uni.setStorageSync('id', data.id);
  114. uni.setStorageSync('name', data.name);
  115. uni.setStorageSync('hospSign', this.hospSign);
  116. this.rolToTarget(data.nowPermission)
  117. }
  118. });
  119. },
  120. clickModalhandle(){
  121. },
  122. //角色和对应的跳转页面
  123. rolToTarget(nowPermission) {
  124. if(nowPermission != 0){
  125. let current = this.rolList.find(item => item.permission == nowPermission);
  126. if(current){
  127. // 页面跳转
  128. uni.redirectTo({
  129. url: `/${current.pagePath}`
  130. });
  131. }
  132. }
  133. }
  134. },
  135. computed:{
  136. //判断是否输入了用户名和密码
  137. isLogin(){
  138. return !this.username || !this.password;
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="less" scoped>
  144. .login-page {
  145. height:100vh;
  146. background-color: #FFFFFF;
  147. .checkItemResultModal {
  148. display: flex;
  149. height: 100%;
  150. justify-content: center;
  151. align-items: center;
  152. .modalContent {
  153. position: relative;
  154. width: 90%;
  155. height:500rpx;
  156. border-radius: 20rpx;
  157. background-color: #FFFFFF;
  158. .modalBar{
  159. display: flex;
  160. justify-content: center;
  161. align-items: center;
  162. height: 80rpx;
  163. color: #4E78FF;
  164. font-size: 22.5rpx;
  165. border-bottom: 0.1rpx solid #E5E5E5;
  166. }
  167. .keyInutArea {
  168. height: 80rpx;
  169. color: #4E78FF;
  170. font-size: 22.5rpx;
  171. padding: 0 20rpx;
  172. border: 0.1rpx solid #E5E5E5;
  173. }
  174. .commitActBtn {
  175. position: absolute;
  176. width: 100%;
  177. bottom: 0;
  178. border-radius: 0;
  179. }
  180. }
  181. }
  182. .top-box {
  183. display: flex;
  184. flex-direction: column;
  185. padding-left: 62.5rpx;
  186. .pic{
  187. position: absolute;
  188. top: 0;
  189. right: 0;
  190. width: 430rpx;
  191. height: 281.25rpx;
  192. }
  193. .title-top{
  194. height: 45rpx;
  195. font-size: 45rpx;
  196. font-weight: bold;
  197. margin-top: 250rpx;
  198. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  199. color: #2E2F33;
  200. }
  201. .title-buttom{
  202. margin-top: 40rpx;
  203. height: 45rpx;
  204. font-size: 45rpx;
  205. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  206. font-weight: bold;
  207. color: #2E2F33;
  208. }
  209. }
  210. .main-content{
  211. margin-top: 37.5rpx;
  212. float: left;
  213. }
  214. .uni-input-box{
  215. width: 625rpx;
  216. float: left;
  217. margin-left: 62.5rpx;
  218. margin-top: 62.5rpx;
  219. font-size: 30rpx;
  220. padding-bottom: 25rpx;
  221. border-bottom:1.25rpx solid #E6EAF2 ;
  222. }
  223. .login-button{
  224. float: left;
  225. margin-left: 62.5rpx;
  226. margin-top: 62.5rpx;
  227. background-color: #A3B1CC;
  228. }
  229. }
  230. </style>