login.vue 7.8 KB

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