login.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  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. <view>{{deviceInfo}}</view>
  20. <button class="commitActBtn" @click="updateHospSign(true)" type="default">确定</button>
  21. <!-- <button class="commitActBtn" @click="updateHospSign(false)" type="default">确定</button> -->
  22. </view>
  23. </view>
  24. </tm-modal>
  25. </view>
  26. </template>
  27. <script>
  28. import encryption from "../../utils/crypto.js";
  29. export default {
  30. data() {
  31. return {
  32. index:0,
  33. appHospSign:'8CJYqxlGIdLEIwaG',//app端更新hospSign
  34. showInputModal:false,
  35. hospSign: '', // 医院标识
  36. username: '', // 用户名
  37. password: '', // 密码
  38. rolList: [
  39. {permission: 1, name: '管理员', pagePath: 'pages/situationsCenter/situationsCenter'}, // targetIndexs:targetList种对应的下标
  40. {permission: 2, name: '查核组长',pagePath: 'pages/situationsCenter/situationsCenter'},
  41. {permission: 3, name: '查核组员', pagePath: 'pages/situationsCenter/situationsCenter'},
  42. {permission: 4, name: '单位负责人', pagePath: 'pages/mission/mission'},
  43. {permission: 5, name: '改善者', pagePath: 'pages/mission/mission'}
  44. ],
  45. deviceInfo:{}
  46. }
  47. },
  48. computed:{
  49. isInput:function(){
  50. return (this.username.length>0&&this.password.length>0)?true:false
  51. }
  52. },
  53. onLoad({ hospSign }){
  54. this.hospSign = hospSign;
  55. // #ifdef APP-PLUS
  56. const hospSignFromLocal = uni.getStorageSync('hospSign');
  57. if(hospSignFromLocal != ''){
  58. this.appHospSign = hospSignFromLocal;
  59. }
  60. this.deviceInfo = uni.getSystemInfoSync();
  61. // #endif
  62. },
  63. methods: {
  64. openScanner(){
  65. // 只允许通过相机扫码
  66. uni.scanCode({
  67. onlyFromCamera: true,
  68. success:(res)=>{
  69. console.log('条码类型:' + res.scanType);
  70. console.log('条码内容:' + res.result);
  71. this.appHospSign = res.result;
  72. }
  73. });
  74. },
  75. setHospSign(e){
  76. this.appHospSign = e.target.value
  77. },
  78. openModal(){
  79. // #ifdef APP-PLUS
  80. this.index = this.index + 1;
  81. if(this.index==3)this.showInputModal = true;
  82. // #endif
  83. },
  84. updateHospSign(bool){
  85. if(bool){
  86. this.hospSign = this.appHospSign;
  87. }
  88. this.index=0;
  89. this.showInputModal = false;
  90. },
  91. login() {
  92. if(this.isLogin) return;
  93. const nowPermission = uni.getStorageSync('nowPermission');
  94. // #ifdef APP-PLUS
  95. const hospSign = this.appHospSign;
  96. // #endif
  97. // #ifdef H5
  98. const hospSign = this.hospSign;
  99. // #endif
  100. this.$store.dispatch({
  101. type: 'login/commActions',
  102. payload: {
  103. key: 'login',
  104. data: {
  105. username: encryption(this.username),
  106. password: encryption(this.password),
  107. hospSign:hospSign,
  108. nowPermission:nowPermission
  109. // hospSign:'tYAoFaa20yCAgaiy'
  110. }
  111. }
  112. }).then((data) => {
  113. console.log('loginResData',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. position: relative;
  162. z-index: 100;
  163. font-size: 45rpx;
  164. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  165. font-weight: bold;
  166. color: #2E2F33;
  167. line-height: 67.5rpx;
  168. }
  169. .titleTwo {
  170. margin-bottom: 75rpx;
  171. }
  172. .inputArea {
  173. height: 80rpx;
  174. margin-bottom: 37.5rpx;
  175. border-bottom: 1.25rpx solid #E6EAF2;
  176. input {
  177. -webkit-box-shadow: 0 0 0 1000px white inset;
  178. }
  179. .inputTag {
  180. height: 100%;
  181. width: 100%;
  182. font-size: 30rpx;
  183. font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  184. font-weight: 500;
  185. color: #292C33;
  186. // &.-internal-autofill-selected {
  187. // background-color:#FFFFFF;
  188. // }
  189. }
  190. // /deep/.inputTag .uni-input-input {
  191. // font-size: 30rpx;
  192. // font-family: SourceHanSansCN-Medium, SourceHanSansCN;
  193. // font-weight: 500;
  194. // color: #292C33;
  195. // box-shadow: 0 0 0 54rpx #fff inset;
  196. // }
  197. .inputTagHolderPlace {
  198. font-size: 30rpx;
  199. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  200. font-weight: 400;
  201. color: #B8BECC;
  202. }
  203. // /deep/.inputTag .uni-input-placeholder {
  204. // font-size: 30rpx;
  205. // }
  206. &.pwd {
  207. margin-bottom: 62.5rpx;
  208. }
  209. }
  210. .loginBtn {
  211. display: block;
  212. width: 100%;
  213. height: 75rpx;
  214. text-align: center;
  215. line-height: 75rpx;
  216. font-size: 30rpx;
  217. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  218. font-weight: 400;
  219. color: #FFFFFF;
  220. background: #A3B1CC;
  221. border-radius: 37.5rpx;
  222. border:none;
  223. background-color: #A3B1CC;
  224. &.on {
  225. background: linear-gradient(90deg, #3377FF 0%, #4D97FF 100%);
  226. }
  227. }
  228. .checkItemResultModal {
  229. display: flex;
  230. height: 100%;
  231. justify-content: center;
  232. align-items: center;
  233. overflow: hidden;
  234. .modalContent {
  235. position: relative;
  236. width: 90%;
  237. height:500rpx;
  238. border-radius: 20rpx;
  239. overflow: hidden;
  240. background-color: #FFFFFF;
  241. .modalBar{
  242. display: flex;
  243. justify-content: center;
  244. align-items: center;
  245. height: 80rpx;
  246. color: #4E78FF;
  247. font-size: 22.5rpx;
  248. border-bottom: 0.1rpx solid #E5E5E5;
  249. }
  250. .keyInutArea {
  251. height: 80rpx;
  252. color: #4E78FF;
  253. font-size: 22.5rpx;
  254. padding: 0 20rpx;
  255. border: 0.1rpx solid #E5E5E5;
  256. }
  257. .scanBtn {
  258. position: absolute;
  259. display: block;
  260. width:25rpx;
  261. height: 25rpx;
  262. top:105rpx;
  263. right:30rpx;
  264. z-index: 10;
  265. }
  266. .commitActBtn {
  267. position: absolute;
  268. width: 100%;
  269. bottom: 0;
  270. border-radius: 0;
  271. }
  272. }
  273. }
  274. }
  275. </style>