123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261 |
- <template>
- <!-- 登录注册 -->
- <view>
- <u-navbar title="" leftIconSize="0" placeholder></u-navbar>
- <view class="card_login">
- <view class="card_head_logo">
- <image class="mine_image" src="../static/logo.png" mode=""></image>
- <view class="welcome_title">欢迎登录宝智达冷链送药</view>
- </view>
- <u--form labelPosition="left" :model="formList" :rules="rules" ref="uForm">
- <u-form-item label="账号" prop="username" labelWidth="50" borderBottom ref="item1">
- <u-input v-model="formList.username" border="none" placeholder="请填写账号"></u-input>
- </u-form-item>
- <u-form-item label="密码" prop="password" labelWidth="50" borderBottom ref="item1">
- <u-input v-show="isText === true" placeholder="请填写密码" border="none" v-model="formList.password"
- class="input_class_pwd" :password="true">
- <template slot="suffix" v-if="formList.password">
- <u-icon name="eye-off" @click="isText = false" size="20"></u-icon>
- </template>
- </u-input>
- <u-input v-show="isText === false" placeholder="请填写密码" border="none" v-model="formList.password"
- class="input_class_pwd" :password="false">
- <template slot="suffix" v-if="formList.password">
- <u-icon name="eye-fill" @click="isText = true" size="20"></u-icon>
- </template>
- </u-input>
- </u-form-item>
- </u--form>
- <!-- <view class="btn_login">
- <view class="title_register" @click="codeLogin">验证码登录</view>
- <view class="title_register" @click="goRegister">去注册</view>
- </view> -->
- <view class="card_hint">
- <view class="card_checkbox">
- <u-checkbox-group @change="checkboxChange">
- <u-checkbox name="asgas" shape="circle"></u-checkbox>
- </u-checkbox-group>
- <span class="message" :style="{display:hintShow ? 'block' : 'none'}">
- 请先阅读并同意协议
- </span>
- </view>
- <view class="agreement_title">我已阅读并同意<span class="protocol_title">《用户协议》</span>、<span
- class="protocol_title">《隐私政策》</span>,
- 并授权宝智达冷链送药使用该宝智达冷链送药账号信息(如昵称、头像、收货地址)进行统一管理
- </view>
- </view>
- <view class="card_btn">
- <u-button type="primary" :disabled="disabled" text="登录" @click="getLogin"></u-button>
- </view>
- </view>
- <!-- <view class="wx_card">
- <view class="card_btn_wx frame">
- <u-icon name="weixin-fill" size="26" color="#07c160"></u-icon>
- </view>
- <span class="title_login_wx">微信登录</span>
- </view> -->
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- formList: {
- username: '',
- password: '',
- },
- rules: {
- username: {
- type: 'string',
- required: true,
- message: '请填写账号',
- trigger: ['blur']
- },
- password: {
- type: 'string',
- required: true,
- message: '请填写密码',
- trigger: ['blur']
- },
- },
- checked: false,
- hintShow: false,
- userInfo: {},
- isText: true,
- }
- },
- computed: {
- disabled() {
- if (this.formList.username == '' || this.formList.password == '') {
- return true;
- } else {
- return false;
- }
- },
- },
- methods: {
- checkboxChange() {
- if (this.checked) {
- this.checked = false
- } else {
- this.checked = true
- this.hintShow = false
- }
- },
- getLogin() {
- if (!this.checked) {
- this.hintShow = true
- } else {
- uni.showLoading({
- title: '登录中...'
- });
- this.$api.post('/api/login', {
- mobile: true,
- type: 1,
- username: this.formList.username,
- password: this.formList.password
- }).then((res) => {
- if (res.code == 200) {
- this.$cache.setToken(res.token)
- // this.getUserInfo()
- uni.redirectTo({
- url: '/pages/indexRouter'
- })
- } else {
- uni.showToast({
- title: res.data.msg,
- icon: 'none'
- });
- }
- uni.hideLoading();
- }).catch(() => {
- uni.hideLoading();
- })
- }
- },
- getUserInfo() {
- this.$api.get('/api/user/profile').then(res => {
- if (res.code == 200) {
- this.userInfo = res.data.user
- this.$cache.setCache('userInfo', this.userInfo)
- uni.redirectTo({
- url: '/pages/indexRouter'
- })
- } else {
- uni.showToast({
- title: '当前用户不存在',
- icon: 'none'
- });
- }
- })
- },
- // 验证码登录
- codeLogin() {
- uni.redirectTo({
- url: '/pages/codeLogin'
- })
- },
- // 注册
- goRegister() {
- this.$refs.uForm.resetFields()
- uni.navigateTo({
- url: '/pages/register'
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #fff !important;
- }
- .welcome_title {
- font-size: 46rpx;
- font-weight: 600;
- margin-bottom: 60rpx;
- margin-top: 10rpx;
- }
- .card_head_logo {
- margin-top: 50rpx;
- display: flex;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- }
- .card_login {
- padding: 20rpx 40rpx;
- }
- .mine_image {
- width: 100rpx;
- height: 100rpx;
- }
- .title_register {
- display: flex;
- justify-content: flex-end;
- font-size: 28rpx;
- color: #494949;
- }
- .card_hint {
- margin-top: 60rpx;
- display: flex;
- align-items: flex-start;
- }
- .agreement_title {
- font-size: 26rpx;
- color: #333;
- }
- .protocol_title {
- color: #1177ff;
- }
- .card_btn {
- margin-top: 20rpx;
- }
- .card_checkbox {
- margin-top: 5rpx;
- position: relative;
- cursor: pointer;
- }
- .message {
- display: none;
- position: absolute;
- padding: 5px 8px;
- border: 1px solid #494949;
- border-radius: 9px;
- top: -36px;
- font-size: 12px;
- width: 110px;
- background: #494949;
- color: #fff;
- left: -6px;
- }
- .message::after {
- content: '';
- position: absolute;
- left: 8px;
- top: 100%;
- border: 8px solid transparent;
- border-top: 6px solid #494949;
- margin-left: -2px;
- }
- .btn_login {
- margin-top: 20rpx;
- display: flex;
- justify-content: space-between;
- }
- </style>
|