123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <template>
- <view class="content">
- <view class="head">
- <text>登录</text>
- </view>
- <view class="login-wrap">
- <view class="username item">
- <text>账号:</text>
- <uni-easyinput :inputBorder="false" class="login_input" type="text" v-model="username" placeholder="请输入账号" />
- </view>
- <view class="password item">
- <text>密码:</text>
- <uni-easyinput :inputBorder="false" class="login_input" type="password" v-model="password" placeholder="请输入密码">
- </uni-easyinput>
- </view>
- <!-- <getPhone showByPlatform /> -->
- <button type="primary" @click="loginSubmit" class="submit-BT">登录</button>
- </view>
- </view>
- </template>
- <script>
- import { login} from '@/api/user';
- import { setToken } from '@/libs/auth';
- import getPhone from '@/components/getPhone.vue'
- export default {
- data() {
- return {
- username: "",
- password: "",
- }
- },
- onLoad({username,password}) {
- if(username){
- this.username=username;
- this.password=password;
- }
- },
- methods: {
- loginSubmit() {
- let username = (this.username).trim();
- let password = (this.password).trim();
- if (username.length < 1) {
- uni.showToast({
- title: '请填写账号',
- icon: "error"
- })
- return;
- }
- login({
- accountName:username,
- pwd:password
- }).then((res) => {
- let token = res.data.token;
- uni.setStorageSync('phone',username)
- uni.setStorageSync('accountId',res.data.id)
- setToken(token);
- uni.switchTab({
- url: '/pages/index/index'
- })
- }).catch((res)=>{
- console.log(res)
- })
- }
- }
- }
- </script>
- <style lang="scss" scoped>
- .content {
- .head {
- font-size: 50upx;
- text-align: center;
- padding: 40upx 0;
- letter-spacing: 2upx;
- }
- .login-wrap {
- width: 90%;
- margin: 50upx auto 0;
- box-sizing: border-box;
- padding: 20upx;
- border-radius: 8upx;
- .item {
- display: flex;
- justify-content: flex-start;
- align-items: center;
- height: 100upx;
- font-size: 32upx;
- line-height: 100upx;
- input {
- font-size: 32upx;
- height: 100upx;
- border: 0;
- }
- }
- .tip {
- text-align: right;
- padding: 18upx 0;
- font-size: 28upx;
- }
- .submit-BT {
- border-radius: 16upx;
- margin-top: 50upx;
- background-color: #409eff;
- border-color: #409eff;
- }
- }
- }
- </style>
|