login.vue 6.5 KB

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