login.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332
  1. <template>
  2. <view class="page">
  3. <view class="top-background-raduis">
  4. <image class="header-image" src="/static/TFT-Logo.png"></image>
  5. <text class="system-name">关键件追溯管理系统PDA</text>
  6. </view>
  7. <view class="login-box">
  8. <view class="login-card-title">
  9. <view class="login-card-title-content"> 账号密码登录 </view>
  10. </view>
  11. <view class="login-card-input">
  12. <!-- 输入框头部图标 -->
  13. <uni-easyinput
  14. class="hj-input"
  15. v-model="userNo"
  16. maxlength="30"
  17. :trim="true"
  18. @focus="UserNamePassWrodFocusBorderStyle"
  19. :styles="inputColorConfigToUserName"
  20. @blur="UserNamePassWrodBlurBorderStyle"
  21. placeholder="请输入账号"
  22. ></uni-easyinput>
  23. <!-- 输入框头部图标 -->
  24. <uni-easyinput
  25. class="hj-input"
  26. v-model="pswVal"
  27. type="password"
  28. @focus="PassWordFocusBorderStyle"
  29. @blur="PassWordBlurBorderStyle"
  30. :styles="inputColorConfigToPassWord"
  31. placeholder="请输入密码"
  32. ></uni-easyinput>
  33. </view>
  34. <view class="uni-flex uni-row">
  35. <view class="flex-item login-bottom-info" style="-webkit-flex: 1;flex: 1;text-decoration: underline;" @click="ChangeApiAddress">
  36. 修改后台API接口地址
  37. </view>
  38. <view style="font-size: 0.92em;color: #5555ff;-webkit-flex: 1;flex: 1;-webkit-justify-content: center;justify-content: center;-webkit-align-items: center;align-items: center;">
  39. <checkbox-group @change="selfChanged">
  40. <checkbox class="flex-item" style="transform:scale(0.75);" :checked="saveUserPswFlag" />记住用户和密码
  41. </checkbox-group>
  42. </view>
  43. </view>
  44. <!-- <view class="login-bottom-info" @click="ChangeApiAddress">
  45. 修改后台API接口地址
  46. </view> -->
  47. <view class="login-card-loginIn">
  48. <view class="login-card-loginIn-btn" @click="BtnLoginClick">
  49. 登 录
  50. </view>
  51. <view class="login-card-loginIn-btn" @click="BtnExitClick">
  52. 退 出
  53. </view>
  54. </view>
  55. </view>
  56. <view class="bottom-message">
  57. Copyright ©2023 NAURA 北京七星华创集成电路装备有限公司
  58. </view>
  59. <view>
  60. <!-- 提示信息弹窗 -->
  61. <uni-popup ref="message" type="message">
  62. <uni-popup-message :type="msgType" :message="messageText" :duration="2000"></uni-popup-message>
  63. </uni-popup>
  64. </view>
  65. <view>
  66. <!-- 输入框示例 -->
  67. <uni-popup ref="inputDialog" type="dialog">
  68. <uni-popup-dialog ref="inputClose" mode="input" title="修改后台API接口地址" :value="baseUrl" placeholder="请输入内容" @confirm="dialogInputConfirm"></uni-popup-dialog>
  69. </uni-popup>
  70. </view>
  71. </view>
  72. </template>
  73. <script>
  74. import store from "@/store/index.js"
  75. export default {
  76. data() {
  77. return {
  78. // 输入框边框颜色默认值
  79. colorDefault:'#b4b4b4',
  80. // 输入框边框聚焦值
  81. colorFocusColor:'#3cb79a',
  82. // 输入框颜色配置
  83. inputColorConfigToUserName: {
  84. color: "#000000",
  85. disableColor: "#eee",
  86. borderColor: "#b4b4b4",
  87. },
  88. // 输入框颜色配置
  89. inputColorConfigToPassWord: {
  90. color: "#000000",
  91. disableColor: "#eee",
  92. borderColor: "#b4b4b4",
  93. },
  94. userNo: getApp().globalData.userName,
  95. pswVal: getApp().globalData.password,
  96. msgType: 'success',
  97. messageText: '这是一条成功提示',
  98. baseUrl: '',
  99. saveUserPswFlag: true
  100. };
  101. },
  102. onLoad() {
  103. this.baseUrl = uni.getStorageSync('BasrUrl');
  104. this.userNo = uni.getStorageSync('UserNo');
  105. this.pswVal = uni.getStorageSync('PswVal');
  106. },
  107. // onBackPress() {
  108. // //console.log("111")
  109. // return true
  110. // },
  111. methods: {
  112. // 输入框聚焦变换边框样式
  113. UserNamePassWrodFocusBorderStyle(){
  114. this.inputColorConfigToUserName.borderColor
  115. = this.colorFocusColor;
  116. },
  117. PassWordFocusBorderStyle(){
  118. this.inputColorConfigToPassWord.borderColor
  119. = this.colorFocusColor;
  120. },
  121. // 输入框失去焦点变换边框样式
  122. UserNamePassWrodBlurBorderStyle(){
  123. this.inputColorConfigToUserName.borderColor
  124. = this.colorDefault;
  125. },
  126. PassWordBlurBorderStyle(){
  127. this.inputColorConfigToPassWord.borderColor
  128. = this.colorDefault;
  129. },
  130. async BtnLoginClick() {
  131. uni.showLoading({
  132. title: "正在登录中......",
  133. mask: true,
  134. })
  135. let parm = {
  136. url : '/login',
  137. data: {
  138. username: this.userNo,
  139. password: this.pswVal
  140. },
  141. method: 'POST',
  142. isHaveToken : false
  143. }
  144. let that = this;
  145. await getApp().RequestData(parm).then(
  146. value => {
  147. let retData = value
  148. if(retData.isSuccess) {
  149. if(retData.data.code == 200) {
  150. uni.hideLoading()
  151. if(that.saveUserPswFlag) {
  152. uni.setStorage({
  153. key: 'UserNo',
  154. data: that.userNo,
  155. })
  156. uni.setStorage({
  157. key: 'PswVal',
  158. data: that.pswVal,
  159. })
  160. }
  161. else {
  162. uni.removeStorage({
  163. key: 'UserNo'
  164. })
  165. uni.removeStorage({
  166. key: 'PswVal'
  167. })
  168. }
  169. uni.setStorage({
  170. key: 'userInfo',
  171. data: {username : that.userNo, tokenStr : retData.data.data},
  172. })
  173. uni.switchTab({
  174. url:"/pages/tabBar/inspect/inspect",
  175. })
  176. }
  177. else {
  178. uni.hideLoading()
  179. let type = "登录失败!" + retData.data.msg + "!"
  180. this.msgType = 'error'
  181. this.messageText = `${type}`
  182. this.$refs.message.open()
  183. }
  184. }
  185. else {
  186. uni.hideLoading()
  187. let type = "登录失败!" + retData.retMsg + "!"
  188. this.msgType = 'error'
  189. this.messageText = `${type}`
  190. this.$refs.message.open()
  191. }
  192. },
  193. err => {
  194. let retData = err
  195. uni.hideLoading()
  196. let type = "登录失败!" + retData.retMsg + "!"
  197. this.msgType = 'error'
  198. this.messageText = `${type}`
  199. this.$refs.message.open()
  200. }
  201. );
  202. },
  203. BtnExitClick() {
  204. let app = getApp()
  205. app.AppExit()
  206. },
  207. ChangeApiAddress() {
  208. this.$refs.inputDialog.open()
  209. },
  210. dialogInputConfirm(e) {
  211. uni.setStorage({
  212. key: 'BasrUrl',
  213. data: e
  214. });
  215. getApp().globalData.baseUrl = e
  216. this.baseUrl = e
  217. },
  218. selfChanged(e) {
  219. this.saveUserPswFlag = !this.saveUserPswFlag;
  220. }
  221. }
  222. };
  223. </script>
  224. <style lang="scss" scoped>
  225. * {
  226. box-sizing: border-box;
  227. }
  228. .header-image {
  229. width: 177px;
  230. height: 80px;
  231. margin-top: 45px;
  232. margin-left: 93px;
  233. }
  234. .system-name {
  235. margin-top: 30px;
  236. font-size: 1.9em;
  237. color: #595556;
  238. }
  239. .page {
  240. position: relative;
  241. height: 100vh;
  242. }
  243. .top-background-raduis {
  244. height: 45%;
  245. background-color: #d8d8d8;
  246. border-bottom-left-radius: 50%;
  247. border-bottom-right-radius: 50%;
  248. flex-direction: column;
  249. display: flex;
  250. text-align: center;
  251. }
  252. // /deep/ .is-input-border{
  253. // border-radius: 7px !important;
  254. // }
  255. // /deep/ .uni-easyinput__content{
  256. // min-height: 39px !important;
  257. // }
  258. .hj-input {
  259. margin-top: 15rpx;
  260. }
  261. .hj-input:nth-child(2) {
  262. margin-top: 35rpx;
  263. }
  264. .login-box {
  265. top: 35%;
  266. position: absolute;
  267. width: 80%;
  268. left: 10%;
  269. right: 10%;
  270. height: 550rpx;
  271. padding: 30rpx;
  272. background-color: white;
  273. border-radius: 40rpx;
  274. box-shadow: 9px 9px 6px #e3e3e3;
  275. .login-card-input {
  276. // background-color: violet;
  277. height: 50%;
  278. padding: 1rpx;
  279. }
  280. .login-card-title {
  281. height: 20%;
  282. // background-color: black;
  283. padding: 10rpx;
  284. display: flex;
  285. justify-content: center;
  286. .login-card-title-content {
  287. font-size: 1.2em;
  288. color: #007aff;
  289. border-bottom: 3px solid #007aff;
  290. }
  291. }
  292. .login-card-loginIn{
  293. height: 25%;
  294. display: flex;
  295. justify-content: center;
  296. padding: 10rpx;
  297. align-items: center;
  298. .login-card-loginIn-btn{
  299. display: flex;
  300. align-items: center;
  301. justify-content: center;
  302. background-color: #007aff;
  303. width: 100%;
  304. font-size: 1.3em;
  305. height: 80%;
  306. border-radius: 40rpx;
  307. color: white;
  308. }
  309. }
  310. .login-bottom-info{
  311. // height: 5%;
  312. // display: flex;
  313. font-size: 0.9em;
  314. color: #aa00ff;
  315. // justify-content: center;
  316. }
  317. }
  318. .bottom-message{
  319. position: absolute;
  320. height: 70rpx;
  321. display: flex;
  322. width: 100%;
  323. justify-content: center;
  324. align-items: center;
  325. font-size: 0.9em;
  326. overflow: hidden;
  327. color: #969898;
  328. bottom: 10rpx;
  329. }
  330. </style>