login.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574
  1. <template>
  2. <view class="container">
  3. <view class="bg bg-color-base margin-b20"></view>
  4. <u-modal v-model="tipShow" @confirm="pswShow=true" confirm-text="去修改" :show-cancel-button="true" cancel-text="暂不修改" content="检测到您的密码为初始密码,请修改密码后再登录!"></u-modal>
  5. <u-modal @confirm="changeConfirm" title="修改密码" confirm-text="提交" :mask-close-able="true" v-model="pswShow" >
  6. <view class="slot-content" style="margin: 20rpx;">
  7. <u-form label-width="180" ref="uForm">
  8. <u-form-item label="新密码"><u-input v-model="newPsw" type="password"/></u-form-item>
  9. <u-form-item :border-bottom="false" label="确认新密码"><u-input type="password" v-model="confirmPsw" /></u-form-item>
  10. </u-form>
  11. </view>
  12. </u-modal>
  13. <view class="tab vs-row vs-align-center">
  14. <image class="tab-bg"
  15. src="https://6e69-niew6-1302638010.tcb.qcloud.la/denglu/%E7%99%BB%E5%BD%955/banner-icon.png?sign=d63f6b91aed3733b261cc0127d2cf702&t=1604049324"
  16. mode=""></image>
  17. <view class="vs-row vs-align-center">
  18. <view class="vs-column vs-align-center margin-r40" @click="cur = 0">
  19. <text class="font-50 margin-b20" style="color: #000000;">登录</text>
  20. </view>
  21. </view>
  22. </view>
  23. <view class="login margin-b80">
  24. <view class="input vs-row vs-align-center margin-b40">
  25. <image style="color: #88d8bc;width: 42rpx;height: 40rpx;" class="input-icon margin-r20" src="/static/login/a4.png"></image>
  26. <input class="vs-flex-item font-30" v-model="username" type="text" value="" placeholder="请输入您的账号"
  27. placeholder-class="input-placeholder" />
  28. </view>
  29. <view class="input vs-row vs-align-center margin-b40">
  30. <image style="width: 40rpx;height: 40rpx;" class="input-icon margin-r20" src="/static/login/psw2.png"
  31. ></image>
  32. <input class="vs-flex-item font-30" v-model="pwd" type="text" password value="" placeholder="请输入您的密码"
  33. placeholder-class="input-placeholder" />
  34. </view>
  35. <view style="margin-left: 20rpx;">
  36. <u-checkbox active-color="#7dc7ae" @change="checkboxChange" v-model="isSave" >记住密码</u-checkbox>
  37. </view>
  38. </view>
  39. <view @click="login" class="button bg-color-base vs-row vs-align-center vs-space-center margin-b20">
  40. <text class="color-white font-34">立即登录</text>
  41. </view>
  42. <u-modal v-model="show" :content="content"></u-modal>
  43. </view>
  44. </template>
  45. <script>
  46. export default {
  47. data() {
  48. return {
  49. isSave: false,
  50. show: false,
  51. content: "",
  52. username: '', //手机号码
  53. pwd: '' ,//密码
  54. //修改密码
  55. tipShow:false,
  56. pswShow:false,
  57. newPsw:'',//新密码
  58. confirmPsw:''//确认新密码
  59. }
  60. },
  61. onLoad() {
  62. uni.getStorage({
  63. key: 'account',
  64. success: (res)=>{
  65. this.username = res.data.account;
  66. this.pwd = res.data.pwd;
  67. this.isSave = true;
  68. }
  69. });
  70. },
  71. methods:{
  72. checkboxChange(e){
  73. this.isSave=e.value
  74. },
  75. async handelLogin(){
  76. let that=this
  77. // let resp=await this.$api.getCurrentAccount()
  78. // if (resp.data.hadUpdatePwd==1) {
  79. if(this.isSave==true){
  80. uni.setStorageSync('account',{account:that.username,pwd:that.pwd});
  81. }else{
  82. uni.removeStorageSync("account");
  83. }
  84. uni.reLaunch({
  85. url:"../index/index"
  86. })
  87. // }else{
  88. // this.tipShow=true
  89. // }
  90. },
  91. changeConfirm(){
  92. if (this.$isEmpty(this.newPsw)) {
  93. this.$u.toast('新密码不能为空')
  94. this.pswShow=true
  95. return
  96. }
  97. if (this.$isEmpty(this.confirmPsw)) {
  98. this.pswShow=true
  99. this.$u.toast('确认密码不能为空')
  100. return
  101. }
  102. if (this.pwd===this.newPsw) {
  103. this.pswShow=true
  104. this.$u.toast('新密码不能和旧密码一致')
  105. return
  106. }
  107. if (this.newPsw!==this.confirmPsw) {
  108. this.pswShow=true
  109. this.$u.toast('两次输入的密码不一致')
  110. return
  111. }
  112. let params={
  113. oldPwd:this.pwd,
  114. newPwd:this.newPsw,
  115. confirmPwd:this.confirmPsw
  116. }
  117. this.$api.updatePsw(params).then(res=>{
  118. if (res.msg=='success') {
  119. uni.showToast({
  120. title:"修改成功,请重新登录",
  121. icon:"none",
  122. duration:2000
  123. })
  124. this.pwd=""
  125. }
  126. })
  127. },
  128. login() {
  129. var that = this;
  130. if (!that.username) {
  131. that.content="请输入您的账号";
  132. that.show = true;
  133. return;
  134. }
  135. if (!that.pwd) {
  136. that.content="请输入您的密码";
  137. that.show = true;
  138. return;
  139. }
  140. this.$dialog.showLoading('登录中...')
  141. // this.$api.permissions.login({
  142. // loginName: that.phone,
  143. // loginPwd: that.pwd
  144. // },{"Content-Type":"application/x-www-form-urlencoded"}).then(res => {
  145. // if(res.code=="200"){
  146. // uni.setStorageSync('access-token',res.data);
  147. // this.handelLogin()
  148. // }else{
  149. // that.content=res.msg;
  150. // that.show = true;
  151. // }
  152. // uni.hideLoading()
  153. // }).catch(err=>{
  154. // uni.hideLoading()
  155. // });
  156. let params={
  157. tenant_id:"000000",
  158. username:that.username,
  159. password:this.$md5(that.pwd),
  160. grant_type: "password"
  161. }
  162. this.$cache.put('tokenObj',params)
  163. this.$api.getToken(params).then(res => {
  164. console.log(res)
  165. if(res.access_token != undefined){
  166. let token=res.token_type+" "+res.access_token
  167. uni.setStorageSync('token', token)
  168. this.handelLogin()
  169. }else{
  170. that.content = res.msg;
  171. that.show = true;
  172. }
  173. uni.hideLoading()
  174. }).catch(err=>{
  175. uni.hideLoading()
  176. });
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss">
  182. page{
  183. background-color: #FFFFFF;
  184. }
  185. .container {
  186. position: relative;
  187. }
  188. .bg {
  189. position: relative;
  190. width: 750rpx;
  191. height: 380rpx;
  192. }
  193. .tab {
  194. position: absolute;
  195. top: 240rpx;
  196. left: 20rpx;
  197. right: 20rpx;
  198. height: 150rpx;
  199. padding: 0 50rpx;
  200. background-color: #fff;
  201. border-top-left-radius: 20rpx;
  202. border-top-right-radius: 20rpx;
  203. &-bg {
  204. position: absolute;
  205. top: -200rpx;
  206. right: -50rpx;
  207. width: 440rpx;
  208. height: 285rpx;
  209. }
  210. }
  211. .line {
  212. width: 25rpx;
  213. height: 7rpx;
  214. }
  215. .login,
  216. .register {
  217. padding: 0 60rpx;
  218. }
  219. .input {
  220. width: 580rpx;
  221. height: 90rpx;
  222. padding: 0 30rpx;
  223. background-color: rgba(80, 100, 235, 0.1);
  224. border-radius: 100rpx;
  225. &-icon {
  226. width: 30rpx;
  227. height: 38rpx;
  228. }
  229. &-placeholder {
  230. color: #909090;
  231. }
  232. }
  233. .button {
  234. width: 630rpx;
  235. height: 90rpx;
  236. margin-left: 60rpx;
  237. border-radius: 100rpx;
  238. }
  239. .separator {
  240. height: 2rpx;
  241. margin: 0 30rpx;
  242. background-color: #f5f5f5;
  243. }
  244. // 下边距
  245. .margin-b5 {
  246. margin-bottom: 5rpx;
  247. }
  248. .margin-b10 {
  249. margin-bottom: 10rpx;
  250. }
  251. .margin-b15 {
  252. margin-bottom: 15rpx;
  253. }
  254. .margin-b20 {
  255. margin-bottom: 20rpx;
  256. }
  257. .margin-b25 {
  258. margin-bottom: 25rpx;
  259. }
  260. .margin-b30 {
  261. margin-bottom: 30rpx;
  262. }
  263. .margin-b40 {
  264. margin-bottom: 40rpx;
  265. }
  266. .margin-b60 {
  267. margin-bottom: 60rpx;
  268. }
  269. .margin-b80 {
  270. margin-bottom: 80rpx;
  271. }
  272. .margin-b100 {
  273. margin-bottom: 100rpx;
  274. }
  275. // 右边距
  276. .margin-r5 {
  277. margin-right: 5rpx;
  278. }
  279. .margin-r10 {
  280. margin-right: 10rpx;
  281. }
  282. .margin-r15 {
  283. margin-right: 15rpx;
  284. }
  285. .margin-r20 {
  286. margin-right: 20rpx;
  287. }
  288. .margin-r25 {
  289. margin-right: 25rpx;
  290. }
  291. .margin-r30 {
  292. margin-right: 30rpx;
  293. }
  294. .margin-r40 {
  295. margin-right: 40rpx;
  296. }
  297. .margin-r60 {
  298. margin-right: 60rpx;
  299. }
  300. // 字体大小
  301. .font-18 {
  302. font-style: normal;
  303. font-size: 18rpx;
  304. font-family: Droid Sans Fallback;
  305. }
  306. .font-20 {
  307. font-style: normal;
  308. font-size: 20rpx;
  309. font-family: Droid Sans Fallback;
  310. }
  311. .font-22 {
  312. font-style: normal;
  313. font-size: 22rpx;
  314. font-family: Droid Sans Fallback;
  315. }
  316. .font-24 {
  317. font-style: normal;
  318. font-size: 24rpx;
  319. font-family: Droid Sans Fallback;
  320. }
  321. .font-26 {
  322. font-style: normal;
  323. font-size: 26rpx;
  324. font-family: Droid Sans Fallback;
  325. }
  326. .font-28 {
  327. font-style: normal;
  328. font-size: 28rpx;
  329. font-family: Droid Sans Fallback;
  330. }
  331. .font-30 {
  332. font-style: normal;
  333. font-size: 30rpx;
  334. font-family: Droid Sans Fallback;
  335. }
  336. .font-32 {
  337. font-style: normal;
  338. font-size: 32rpx;
  339. font-family: Droid Sans Fallback;
  340. }
  341. .font-34 {
  342. font-style: normal;
  343. font-size: 34rpx;
  344. font-family: Droid Sans Fallback;
  345. }
  346. .font-36 {
  347. font-style: normal;
  348. font-size: 36rpx;
  349. font-family: Droid Sans Fallback;
  350. }
  351. .font-38 {
  352. font-style: normal;
  353. font-size: 38rpx;
  354. font-family: Droid Sans Fallback;
  355. }
  356. .font-40 {
  357. font-style: normal;
  358. font-size: 40rpx;
  359. font-family: Droid Sans Fallback;
  360. }
  361. .font-46 {
  362. font-style: normal;
  363. font-size: 46rpx;
  364. font-family: Droid Sans Fallback;
  365. }
  366. .font-50 {
  367. font-style: normal;
  368. font-size: 50rpx;
  369. font-family: Droid Sans Fallback;
  370. }
  371. .font-60 {
  372. font-style: normal;
  373. font-size: 60rpx;
  374. font-family: Droid Sans Fallback;
  375. }
  376. .font-80 {
  377. font-style: normal;
  378. font-size: 80rpx;
  379. font-family: Droid Sans Fallback;
  380. }
  381. // 字体对齐
  382. .text-left {
  383. text-align: left;
  384. }
  385. .text-center {
  386. text-align: center;
  387. }
  388. .text-right {
  389. text-align: right;
  390. }
  391. // color相关
  392. .color-white {
  393. color: #FFFFFF;
  394. }
  395. .color-red {
  396. color: #dc0000;
  397. }
  398. // 黑色色阶向下
  399. .color-black {
  400. color: #000;
  401. }
  402. .color-black-3 {
  403. color: #333;
  404. }
  405. .color-black-6 {
  406. color: #666;
  407. }
  408. .color-black-9 {
  409. color: #999;
  410. }
  411. // 字体宽度
  412. .font-weight-400 {
  413. font-weight: 400;
  414. }
  415. .font-weight-500 {
  416. font-weight: bold;
  417. }
  418. // 间隔
  419. .spacing-20 {
  420. width: 750rpx;
  421. height: 20rpx;
  422. background-color: #f8f8f8;
  423. }
  424. // 圆角
  425. .radius-10 {
  426. border-radius: 10rpx;
  427. }
  428. .radius-20 {
  429. border-radius: 20rpx;
  430. }
  431. .radius-30 {
  432. border-radius: 30rpx;
  433. }
  434. .radius-circle {
  435. border-radius: 50%;
  436. }
  437. .radius-height {
  438. border-radius: 10000px;
  439. }
  440. // flex相关
  441. .vs-flex-item {
  442. flex: 1;
  443. }
  444. .vs-space-between {
  445. justify-content: space-between;
  446. }
  447. .vs-space-around {
  448. justify-content: space-around;
  449. }
  450. .vs-space-center {
  451. justify-content: center;
  452. }
  453. .vs-space-end {
  454. justify-content: flex-end;
  455. }
  456. .vs-row {
  457. flex-direction: row;
  458. }
  459. .vs-column {
  460. flex-direction: column;
  461. }
  462. .vs-align-end {
  463. align-items: flex-end;
  464. }
  465. .vs-align-center {
  466. display: flex;
  467. align-items: center;
  468. }
  469. .vs-align-start {
  470. align-items: flex-start;
  471. }
  472. .vs-item-hover {
  473. background-color: rgba(0, 0, 0, 0.05);
  474. }
  475. .vs-btn-hover {
  476. opacity: 0.8;
  477. }
  478. .color-base {
  479. color: #7dc7ae;
  480. }
  481. .bg-color-base {
  482. background-color: #7dc7ae;
  483. }
  484. </style>