login.vue 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. <template>
  2. <view class="login-page">
  3. <image class="bgImage" src="/static/images/shade.png"></image>
  4. <text class="titleOne row" @click="openModal">你好,</text>
  5. <view class="titleTwo row">欢迎使用追踪方法学系统</view>
  6. <view class="inputArea">
  7. <input class="inputTag" type="text" placeholder="请输入账号" placeholder-class="inputTagHolderPlace" v-model="username" />
  8. </view>
  9. <view class="inputArea pwd">
  10. <input class="inputTag" password="true" type="text" placeholder="请输入密码" placeholder-class="inputTagHolderPlace" v-model="password" />
  11. </view>
  12. <button :class="[isInput?'loginBtn on':'loginBtn']" type="default" @click="login" >登录</button>
  13. <tm-modal v-if="showInputModal" @click="clickModalhandle">
  14. <view class="checkItemResultModal">
  15. <view class="modalContent">
  16. <view class="modalBar">开发者模式</view>
  17. <input class="keyInutArea" type="text" v-model="appHospSign" @input='setHospSign' placeholder="请输入hospSign" />
  18. <image @click="openScanner" class="scanBtn" src="../../static/scancodeIcon.png" mode=""></image>
  19. <button class="commitActBtn" @click="updateHospSign(true)" type="default">确定</button>
  20. <!-- <button class="commitActBtn" @click="updateHospSign(false)" type="default">确定</button> -->
  21. </view>
  22. </view>
  23. </tm-modal>
  24. </view>
  25. </template>
  26. <script>
  27. import encryption from "../../utils/crypto.js";
  28. export default {
  29. data() {
  30. return {
  31. index:0,
  32. appHospSign:'tYAoFaa20yCAgaiy',//app端更新hospSign 8CJYqxlGIdLEIwaG
  33. showInputModal:false,
  34. hospSign: '', // 医院标识
  35. username: '', // 用户名
  36. password: '', // 密码
  37. rolList: [
  38. {permission: 1, name: '管理员', pagePath: 'pages/situationsCenter/situationsCenter'}, // targetIndexs:targetList种对应的下标
  39. {permission: 2, name: '查核组长',pagePath: 'pages/situationsCenter/situationsCenter'},
  40. {permission: 3, name: '查核组员', pagePath: 'pages/situationsCenter/situationsCenter'},
  41. {permission: 4, name: '单位负责人', pagePath: 'pages/mission/mission'},
  42. {permission: 5, name: '改善者', pagePath: 'pages/mission/mission'}
  43. ]
  44. }
  45. },
  46. computed:{
  47. isInput:function(){
  48. return (this.username.length>0&&this.password.length>0)?true:false
  49. }
  50. },
  51. onLoad({ hospSign }){
  52. this.hospSign = hospSign;
  53. // #ifdef APP-PLUS
  54. const hospSignFromLocal = uni.getStorageSync('hospSign');
  55. this.appHospSign = hospSignFromLocal;
  56. // #endif
  57. },
  58. mounted(){
  59. console.log(this.username);
  60. },
  61. methods: {
  62. openScanner(){
  63. // 只允许通过相机扫码
  64. uni.scanCode({
  65. onlyFromCamera: true,
  66. success:(res)=>{
  67. console.log('条码类型:' + res.scanType);
  68. console.log('条码内容:' + res.result);
  69. this.appHospSign = res.result;
  70. }
  71. });
  72. },
  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. // #ifdef APP-PLUS
  93. const hospSign = this.appHospSign;
  94. // #endif
  95. // #ifdef H5
  96. const hospSign = this.hospSign;
  97. // #endif
  98. this.$store.dispatch({
  99. type: 'login/commActions',
  100. payload: {
  101. key: 'login',
  102. data: {
  103. username: encryption(this.username),
  104. password: encryption(this.password),
  105. hospSign:hospSign,
  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',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. }
  140. </script>
  141. <style lang="less" scoped>
  142. .login-page {
  143. display: flex;
  144. flex-direction: column;
  145. justify-content: center;
  146. height:100vh;
  147. padding: 0 62.5rpx;
  148. padding-bottom: 100rpx;
  149. background-color: #FFFFFF;
  150. .bgImage {
  151. position: absolute;
  152. right: 0;
  153. top:0;
  154. width: 430rpx;
  155. height: 281.25rpx;
  156. }
  157. .row {
  158. font-size: 45rpx;
  159. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  160. font-weight: bold;
  161. color: #2E2F33;
  162. line-height: 67.5rpx;
  163. }
  164. .titleTwo {
  165. margin-bottom: 75rpx;
  166. }
  167. .inputArea {
  168. height: 80rpx;
  169. margin-bottom: 37.5rpx;
  170. border-bottom: 1.25rpx solid #E6EAF2;
  171. input {
  172. -webkit-box-shadow: 0 0 0 1000px white inset;
  173. }
  174. .inputTag {
  175. height: 100%;
  176. width: 100%;
  177. font-size: 30rpx;
  178. font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  179. font-weight: 500;
  180. color: #292C33;
  181. // &.-internal-autofill-selected {
  182. // background-color:#FFFFFF;
  183. // }
  184. }
  185. // /deep/.inputTag .uni-input-input {
  186. // font-size: 30rpx;
  187. // font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  188. // font-weight: 500;
  189. // color: #292C33;
  190. // box-shadow: 0 0 0 54rpx #fff inset;
  191. // }
  192. .inputTagHolderPlace {
  193. font-size: 30rpx;
  194. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  195. font-weight: 400;
  196. color: #B8BECC;
  197. }
  198. // /deep/.inputTag .uni-input-placeholder {
  199. // font-size: 30rpx;
  200. // }
  201. &.pwd {
  202. margin-bottom: 62.5rpx;
  203. }
  204. }
  205. .loginBtn {
  206. display: block;
  207. width: 100%;
  208. height: 75rpx;
  209. text-align: center;
  210. line-height: 75rpx;
  211. font-size: 30rpx;
  212. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  213. font-weight: 400;
  214. color: #FFFFFF;
  215. background: #A3B1CC;
  216. border-radius: 37.5rpx;
  217. border:none;
  218. background-color: #A3B1CC;
  219. &.on {
  220. background: linear-gradient(90deg, #3377FF 0%, #4D97FF 100%);
  221. }
  222. }
  223. .checkItemResultModal {
  224. display: flex;
  225. height: 100%;
  226. justify-content: center;
  227. align-items: center;
  228. overflow: hidden;
  229. .modalContent {
  230. position: relative;
  231. width: 90%;
  232. height:500rpx;
  233. border-radius: 20rpx;
  234. overflow: hidden;
  235. background-color: #FFFFFF;
  236. .modalBar{
  237. display: flex;
  238. justify-content: center;
  239. align-items: center;
  240. height: 80rpx;
  241. color: #4E78FF;
  242. font-size: 22.5rpx;
  243. border-bottom: 0.1rpx solid #E5E5E5;
  244. }
  245. .keyInutArea {
  246. height: 80rpx;
  247. color: #4E78FF;
  248. font-size: 22.5rpx;
  249. padding: 0 20rpx;
  250. border: 0.1rpx solid #E5E5E5;
  251. }
  252. .scanBtn {
  253. position: absolute;
  254. display: block;
  255. width:25rpx;
  256. height: 25rpx;
  257. top:105rpx;
  258. right:30rpx;
  259. z-index: 10;
  260. }
  261. .commitActBtn {
  262. position: absolute;
  263. width: 100%;
  264. bottom: 0;
  265. border-radius: 0;
  266. }
  267. }
  268. }
  269. }
  270. </style>