login.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  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. // uni.getSystemInfo({
  60. // success: function (res) {
  61. // // console.log('res.model',res.model);
  62. // // console.log('res.pixelRatio',res.pixelRatio);
  63. // // console.log('res.windowWidth',res.windowWidth);
  64. // // console.log('res.windowHeight',res.windowHeight);
  65. // // console.log('res.language',res.language);
  66. // // console.log('res.version',res.version);
  67. // // console.log('res.platform',res.platform);
  68. // // uni.showModal({
  69. // // title: '测试',
  70. // // content:res.windowWidth,
  71. // // showCancel: true
  72. // // });
  73. // }
  74. // });
  75. },
  76. methods: {
  77. setHospSign(e){
  78. this.appHospSign = e.target.value
  79. },
  80. openModal(){
  81. // #ifdef APP-PLUS
  82. this.index = this.index + 1;
  83. if(this.index==3)this.showInputModal = true;
  84. // #endif
  85. },
  86. updateHospSign(bool){
  87. if(bool){
  88. this.hospSign = this.appHospSign;
  89. }
  90. this.index=0;
  91. this.showInputModal = false;
  92. },
  93. login() {
  94. if(this.isLogin) return
  95. this.$store.dispatch({
  96. type: 'login/commActions',
  97. payload: {
  98. key: 'login',
  99. data: {
  100. username: encryption(this.username),
  101. password: encryption(this.password),
  102. // #ifdef APP-PLUS
  103. hospSign: this.appHospSign,
  104. // #endif
  105. // #ifdef H5
  106. hospSign: this.hospSign,
  107. // #endif
  108. // hospSign:'tYAoFaa20yCAgaiy'
  109. }
  110. }
  111. }).then((data) => {
  112. if (data) {
  113. uni.setStorageSync('hiId', data.hiId);
  114. uni.setStorageSync('permissions', data.permissions);
  115. uni.setStorageSync('token', data.token);
  116. uni.setStorageSync('code', data.code);
  117. uni.setStorageSync('nowPermission', data.nowPermission);
  118. uni.setStorageSync('id', data.id);
  119. uni.setStorageSync('name', data.name);
  120. uni.setStorageSync('hospSign', this.hospSign);
  121. this.rolToTarget(data.nowPermission)
  122. }
  123. });
  124. },
  125. clickModalhandle(){
  126. },
  127. //角色和对应的跳转页面
  128. rolToTarget(nowPermission) {
  129. if(nowPermission != 0){
  130. let current = this.rolList.find(item => item.permission == nowPermission);
  131. if(current){
  132. // 页面跳转
  133. uni.redirectTo({
  134. url: `/${current.pagePath}`
  135. });
  136. }
  137. }
  138. }
  139. },
  140. computed:{
  141. //判断是否输入了用户名和密码
  142. isLogin(){
  143. return !this.username || !this.password;
  144. }
  145. }
  146. }
  147. </script>
  148. <style lang="less" scoped>
  149. .login-page {
  150. height:100vh;
  151. background-color: #FFFFFF;
  152. .checkItemResultModal {
  153. display: flex;
  154. height: 100%;
  155. justify-content: center;
  156. align-items: center;
  157. .modalContent {
  158. position: relative;
  159. width: 90%;
  160. height:500rpx;
  161. border-radius: 20rpx;
  162. background-color: #FFFFFF;
  163. .modalBar{
  164. display: flex;
  165. justify-content: center;
  166. align-items: center;
  167. height: 80rpx;
  168. color: #4E78FF;
  169. font-size: 22.5rpx;
  170. border-bottom: 0.1rpx solid #E5E5E5;
  171. }
  172. .keyInutArea {
  173. height: 80rpx;
  174. color: #4E78FF;
  175. font-size: 22.5rpx;
  176. padding: 0 20rpx;
  177. border: 0.1rpx solid #E5E5E5;
  178. }
  179. .commitActBtn {
  180. position: absolute;
  181. width: 100%;
  182. bottom: 0;
  183. border-radius: 0;
  184. }
  185. }
  186. }
  187. .top-box {
  188. display: flex;
  189. flex-direction: column;
  190. padding-left: 62.5rpx;
  191. .pic{
  192. position: absolute;
  193. top: 0;
  194. right: 0;
  195. width: 430rpx;
  196. height: 281.25rpx;
  197. }
  198. .title-top{
  199. height: 45rpx;
  200. font-size: 45rpx;
  201. font-weight: bold;
  202. margin-top: 250rpx;
  203. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  204. color: #2E2F33;
  205. }
  206. .title-buttom{
  207. margin-top: 40rpx;
  208. height: 45rpx;
  209. font-size: 45rpx;
  210. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  211. font-weight: bold;
  212. color: #2E2F33;
  213. }
  214. }
  215. .main-content{
  216. margin-top: 37.5rpx;
  217. float: left;
  218. }
  219. .uni-input-box{
  220. width: 625rpx;
  221. float: left;
  222. margin-left: 62.5rpx;
  223. margin-top: 62.5rpx;
  224. font-size: 30rpx;
  225. padding-bottom: 25rpx;
  226. border-bottom:1.25rpx solid #E6EAF2 ;
  227. }
  228. .login-button{
  229. float: left;
  230. margin-left: 62.5rpx;
  231. margin-top: 62.5rpx;
  232. background-color: #A3B1CC;
  233. }
  234. }
  235. </style>