login.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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. console.log({hospSignFromLocal});
  56. if(hospSignFromLocal != ''){
  57. this.appHospSign = hospSignFromLocal;
  58. }
  59. // #endif
  60. },
  61. mounted(){
  62. console.log(this.username);
  63. },
  64. methods: {
  65. openScanner(){
  66. // 只允许通过相机扫码
  67. uni.scanCode({
  68. onlyFromCamera: true,
  69. success:(res)=>{
  70. console.log('条码类型:' + res.scanType);
  71. console.log('条码内容:' + res.result);
  72. this.appHospSign = res.result;
  73. }
  74. });
  75. },
  76. setHospSign(e){
  77. this.appHospSign = e.target.value
  78. },
  79. openModal(){
  80. // #ifdef APP-PLUS
  81. this.index = this.index + 1;
  82. if(this.index==3)this.showInputModal = true;
  83. // #endif
  84. },
  85. updateHospSign(bool){
  86. if(bool){
  87. this.hospSign = this.appHospSign;
  88. }
  89. this.index=0;
  90. this.showInputModal = false;
  91. },
  92. login() {
  93. if(this.isLogin) return;
  94. const nowPermission = uni.getStorageSync('nowPermission');
  95. // #ifdef APP-PLUS
  96. const hospSign = this.appHospSign;
  97. // #endif
  98. // #ifdef H5
  99. const hospSign = this.hospSign;
  100. // #endif
  101. this.$store.dispatch({
  102. type: 'login/commActions',
  103. payload: {
  104. key: 'login',
  105. data: {
  106. username: encryption(this.username),
  107. password: encryption(this.password),
  108. hospSign:hospSign,
  109. nowPermission:nowPermission
  110. // hospSign:'tYAoFaa20yCAgaiy'
  111. }
  112. }
  113. }).then((data) => {
  114. if (data) {
  115. uni.setStorageSync('hiId', data.hiId);
  116. uni.setStorageSync('permissions', data.permissions);
  117. uni.setStorageSync('token', data.token);
  118. uni.setStorageSync('code', data.code);
  119. uni.setStorageSync('nowPermission', data.nowPermission);
  120. uni.setStorageSync('id', data.id);
  121. uni.setStorageSync('name', data.name);
  122. uni.setStorageSync('hospSign',hospSign);
  123. this.rolToTarget(data.nowPermission)
  124. }
  125. });
  126. },
  127. clickModalhandle(){
  128. },
  129. //角色和对应的跳转页面
  130. rolToTarget(nowPermission) {
  131. if(nowPermission != 0){
  132. let current = this.rolList.find(item => item.permission == nowPermission);
  133. if(current){
  134. // 页面跳转
  135. uni.redirectTo({
  136. url: `/${current.pagePath}`
  137. });
  138. }
  139. }
  140. }
  141. }
  142. }
  143. </script>
  144. <style lang="less" scoped>
  145. .login-page {
  146. display: flex;
  147. flex-direction: column;
  148. justify-content: center;
  149. height:100vh;
  150. padding: 0 62.5rpx;
  151. padding-bottom: 100rpx;
  152. background-color: #FFFFFF;
  153. .bgImage {
  154. position: absolute;
  155. right: 0;
  156. top:0;
  157. width: 430rpx;
  158. height: 281.25rpx;
  159. }
  160. .row {
  161. font-size: 45rpx;
  162. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  163. font-weight: bold;
  164. color: #2E2F33;
  165. line-height: 67.5rpx;
  166. }
  167. .titleTwo {
  168. margin-bottom: 75rpx;
  169. }
  170. .inputArea {
  171. height: 80rpx;
  172. margin-bottom: 37.5rpx;
  173. border-bottom: 1.25rpx solid #E6EAF2;
  174. input {
  175. -webkit-box-shadow: 0 0 0 1000px white inset;
  176. }
  177. .inputTag {
  178. height: 100%;
  179. width: 100%;
  180. font-size: 30rpx;
  181. font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  182. font-weight: 500;
  183. color: #292C33;
  184. // &.-internal-autofill-selected {
  185. // background-color:#FFFFFF;
  186. // }
  187. }
  188. // /deep/.inputTag .uni-input-input {
  189. // font-size: 30rpx;
  190. // font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  191. // font-weight: 500;
  192. // color: #292C33;
  193. // box-shadow: 0 0 0 54rpx #fff inset;
  194. // }
  195. .inputTagHolderPlace {
  196. font-size: 30rpx;
  197. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  198. font-weight: 400;
  199. color: #B8BECC;
  200. }
  201. // /deep/.inputTag .uni-input-placeholder {
  202. // font-size: 30rpx;
  203. // }
  204. &.pwd {
  205. margin-bottom: 62.5rpx;
  206. }
  207. }
  208. .loginBtn {
  209. display: block;
  210. width: 100%;
  211. height: 75rpx;
  212. text-align: center;
  213. line-height: 75rpx;
  214. font-size: 30rpx;
  215. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  216. font-weight: 400;
  217. color: #FFFFFF;
  218. background: #A3B1CC;
  219. border-radius: 37.5rpx;
  220. border:none;
  221. background-color: #A3B1CC;
  222. &.on {
  223. background: linear-gradient(90deg, #3377FF 0%, #4D97FF 100%);
  224. }
  225. }
  226. .checkItemResultModal {
  227. display: flex;
  228. height: 100%;
  229. justify-content: center;
  230. align-items: center;
  231. overflow: hidden;
  232. .modalContent {
  233. position: relative;
  234. width: 90%;
  235. height:500rpx;
  236. border-radius: 20rpx;
  237. overflow: hidden;
  238. background-color: #FFFFFF;
  239. .modalBar{
  240. display: flex;
  241. justify-content: center;
  242. align-items: center;
  243. height: 80rpx;
  244. color: #4E78FF;
  245. font-size: 22.5rpx;
  246. border-bottom: 0.1rpx solid #E5E5E5;
  247. }
  248. .keyInutArea {
  249. height: 80rpx;
  250. color: #4E78FF;
  251. font-size: 22.5rpx;
  252. padding: 0 20rpx;
  253. border: 0.1rpx solid #E5E5E5;
  254. }
  255. .scanBtn {
  256. position: absolute;
  257. display: block;
  258. width:25rpx;
  259. height: 25rpx;
  260. top:105rpx;
  261. right:30rpx;
  262. z-index: 10;
  263. }
  264. .commitActBtn {
  265. position: absolute;
  266. width: 100%;
  267. bottom: 0;
  268. border-radius: 0;
  269. }
  270. }
  271. }
  272. }
  273. </style>