login.vue 6.3 KB

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