login.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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="phone" 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. phone: '', //手机号码
  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.phone = 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.phone,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.phone) {
  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. }
  157. }
  158. }
  159. </script>
  160. <style lang="scss">
  161. page{
  162. background-color: #FFFFFF;
  163. }
  164. .container {
  165. position: relative;
  166. }
  167. .bg {
  168. position: relative;
  169. width: 750rpx;
  170. height: 380rpx;
  171. }
  172. .tab {
  173. position: absolute;
  174. top: 240rpx;
  175. left: 20rpx;
  176. right: 20rpx;
  177. height: 150rpx;
  178. padding: 0 50rpx;
  179. background-color: #fff;
  180. border-top-left-radius: 20rpx;
  181. border-top-right-radius: 20rpx;
  182. &-bg {
  183. position: absolute;
  184. top: -200rpx;
  185. right: -50rpx;
  186. width: 440rpx;
  187. height: 285rpx;
  188. }
  189. }
  190. .line {
  191. width: 25rpx;
  192. height: 7rpx;
  193. }
  194. .login,
  195. .register {
  196. padding: 0 60rpx;
  197. }
  198. .input {
  199. width: 580rpx;
  200. height: 90rpx;
  201. padding: 0 30rpx;
  202. background-color: rgba(80, 100, 235, 0.1);
  203. border-radius: 100rpx;
  204. &-icon {
  205. width: 30rpx;
  206. height: 38rpx;
  207. }
  208. &-placeholder {
  209. color: #909090;
  210. }
  211. }
  212. .button {
  213. width: 630rpx;
  214. height: 90rpx;
  215. margin-left: 60rpx;
  216. border-radius: 100rpx;
  217. }
  218. .separator {
  219. height: 2rpx;
  220. margin: 0 30rpx;
  221. background-color: #f5f5f5;
  222. }
  223. // 下边距
  224. .margin-b5 {
  225. margin-bottom: 5rpx;
  226. }
  227. .margin-b10 {
  228. margin-bottom: 10rpx;
  229. }
  230. .margin-b15 {
  231. margin-bottom: 15rpx;
  232. }
  233. .margin-b20 {
  234. margin-bottom: 20rpx;
  235. }
  236. .margin-b25 {
  237. margin-bottom: 25rpx;
  238. }
  239. .margin-b30 {
  240. margin-bottom: 30rpx;
  241. }
  242. .margin-b40 {
  243. margin-bottom: 40rpx;
  244. }
  245. .margin-b60 {
  246. margin-bottom: 60rpx;
  247. }
  248. .margin-b80 {
  249. margin-bottom: 80rpx;
  250. }
  251. .margin-b100 {
  252. margin-bottom: 100rpx;
  253. }
  254. // 右边距
  255. .margin-r5 {
  256. margin-right: 5rpx;
  257. }
  258. .margin-r10 {
  259. margin-right: 10rpx;
  260. }
  261. .margin-r15 {
  262. margin-right: 15rpx;
  263. }
  264. .margin-r20 {
  265. margin-right: 20rpx;
  266. }
  267. .margin-r25 {
  268. margin-right: 25rpx;
  269. }
  270. .margin-r30 {
  271. margin-right: 30rpx;
  272. }
  273. .margin-r40 {
  274. margin-right: 40rpx;
  275. }
  276. .margin-r60 {
  277. margin-right: 60rpx;
  278. }
  279. // 字体大小
  280. .font-18 {
  281. font-style: normal;
  282. font-size: 18rpx;
  283. font-family: Droid Sans Fallback;
  284. }
  285. .font-20 {
  286. font-style: normal;
  287. font-size: 20rpx;
  288. font-family: Droid Sans Fallback;
  289. }
  290. .font-22 {
  291. font-style: normal;
  292. font-size: 22rpx;
  293. font-family: Droid Sans Fallback;
  294. }
  295. .font-24 {
  296. font-style: normal;
  297. font-size: 24rpx;
  298. font-family: Droid Sans Fallback;
  299. }
  300. .font-26 {
  301. font-style: normal;
  302. font-size: 26rpx;
  303. font-family: Droid Sans Fallback;
  304. }
  305. .font-28 {
  306. font-style: normal;
  307. font-size: 28rpx;
  308. font-family: Droid Sans Fallback;
  309. }
  310. .font-30 {
  311. font-style: normal;
  312. font-size: 30rpx;
  313. font-family: Droid Sans Fallback;
  314. }
  315. .font-32 {
  316. font-style: normal;
  317. font-size: 32rpx;
  318. font-family: Droid Sans Fallback;
  319. }
  320. .font-34 {
  321. font-style: normal;
  322. font-size: 34rpx;
  323. font-family: Droid Sans Fallback;
  324. }
  325. .font-36 {
  326. font-style: normal;
  327. font-size: 36rpx;
  328. font-family: Droid Sans Fallback;
  329. }
  330. .font-38 {
  331. font-style: normal;
  332. font-size: 38rpx;
  333. font-family: Droid Sans Fallback;
  334. }
  335. .font-40 {
  336. font-style: normal;
  337. font-size: 40rpx;
  338. font-family: Droid Sans Fallback;
  339. }
  340. .font-46 {
  341. font-style: normal;
  342. font-size: 46rpx;
  343. font-family: Droid Sans Fallback;
  344. }
  345. .font-50 {
  346. font-style: normal;
  347. font-size: 50rpx;
  348. font-family: Droid Sans Fallback;
  349. }
  350. .font-60 {
  351. font-style: normal;
  352. font-size: 60rpx;
  353. font-family: Droid Sans Fallback;
  354. }
  355. .font-80 {
  356. font-style: normal;
  357. font-size: 80rpx;
  358. font-family: Droid Sans Fallback;
  359. }
  360. // 字体对齐
  361. .text-left {
  362. text-align: left;
  363. }
  364. .text-center {
  365. text-align: center;
  366. }
  367. .text-right {
  368. text-align: right;
  369. }
  370. // color相关
  371. .color-white {
  372. color: #FFFFFF;
  373. }
  374. .color-red {
  375. color: #dc0000;
  376. }
  377. // 黑色色阶向下
  378. .color-black {
  379. color: #000;
  380. }
  381. .color-black-3 {
  382. color: #333;
  383. }
  384. .color-black-6 {
  385. color: #666;
  386. }
  387. .color-black-9 {
  388. color: #999;
  389. }
  390. // 字体宽度
  391. .font-weight-400 {
  392. font-weight: 400;
  393. }
  394. .font-weight-500 {
  395. font-weight: bold;
  396. }
  397. // 间隔
  398. .spacing-20 {
  399. width: 750rpx;
  400. height: 20rpx;
  401. background-color: #f8f8f8;
  402. }
  403. // 圆角
  404. .radius-10 {
  405. border-radius: 10rpx;
  406. }
  407. .radius-20 {
  408. border-radius: 20rpx;
  409. }
  410. .radius-30 {
  411. border-radius: 30rpx;
  412. }
  413. .radius-circle {
  414. border-radius: 50%;
  415. }
  416. .radius-height {
  417. border-radius: 10000px;
  418. }
  419. // flex相关
  420. .vs-flex-item {
  421. flex: 1;
  422. }
  423. .vs-space-between {
  424. justify-content: space-between;
  425. }
  426. .vs-space-around {
  427. justify-content: space-around;
  428. }
  429. .vs-space-center {
  430. justify-content: center;
  431. }
  432. .vs-space-end {
  433. justify-content: flex-end;
  434. }
  435. .vs-row {
  436. flex-direction: row;
  437. }
  438. .vs-column {
  439. flex-direction: column;
  440. }
  441. .vs-align-end {
  442. align-items: flex-end;
  443. }
  444. .vs-align-center {
  445. display: flex;
  446. align-items: center;
  447. }
  448. .vs-align-start {
  449. align-items: flex-start;
  450. }
  451. .vs-item-hover {
  452. background-color: rgba(0, 0, 0, 0.05);
  453. }
  454. .vs-btn-hover {
  455. opacity: 0.8;
  456. }
  457. .color-base {
  458. color: #7dc7ae;
  459. }
  460. .bg-color-base {
  461. background-color: #7dc7ae;
  462. }
  463. </style>