From d8b41fff43a2cee6a8f714ffa807623b15803786 Mon Sep 17 00:00:00 2001 From: quanyawei <401863037@qq.com> Date: Fri, 20 Oct 2023 15:21:35 +0800 Subject: [PATCH] fix:立行立改Uniapp小程序新建项目 --- pages/login/login.vue | 173 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 173 insertions(+), 0 deletions(-) diff --git a/pages/login/login.vue b/pages/login/login.vue new file mode 100644 index 0000000..147529c --- /dev/null +++ b/pages/login/login.vue @@ -0,0 +1,173 @@ +<template> + <view class="page"> + <view class="tit"> + <view class="imageContent"> + <image src="/static/logo.png" style="width: 67.31rpx; height: 100rpx" /> + </view> + <view class=""> + <text>������������������������</text> + </view> + </view> + <view class="formConten"> + <view> + <u-form ref="uForm" label-position="left" :model="form" :labelStyle="labelStyle"> + <u-form-item label="������:" prop="account"> + <u-input v-model="form.account" color='#fff' placeholder="���������������" /> + </u-form-item> + <u-form-item label="������:" prop="password"> + <u-input v-model="form.password" :password-icon="passwordIcon" color='#fff' placeholder="���������������" + type="password" /> + </u-form-item> + </u-form> + </view> + <view class="loginContent"> + <p> + <navigator style="display: inline-block;" url="/pages/login/register/register"> + <text style="text-decoration: underline">������������</text> + </navigator> + </p> + <u-button @click="submit">������</u-button> + </view> + </view> + </view> +</template> +<script> + import { + login, + getUserInfor, + getDic + } from '@/utils/login.js' // ������������ + import { + httpPost, + httpGet + } from '@/utils/http.js' + export default { + data() { + return { + labelStyle: { + color: '#fff' + }, + passwordIcon: false, + form: { + account: '', + password: '', + }, + rules: { + account: [{ + required: true, + message: '���������������', + // ��������������������������������������������������� + trigger: ['change', 'blur'], + }, ], + password: [{ + required: true, + message: '���������������', + trigger: ['change', 'blur'], + }, ], + }, + } + }, + onReady() { + //onReady ���uni-app��������������������������� + this.$refs.uForm.setRules(this.rules) + }, + methods: { + submit() { + this.$refs.uForm.validate().then(res => { + this.getlogin() + }).catch(errors => { + uni.$u.toast('������������') + }) + }, + //������ + getlogin() { + let openId = this.$storage.get('openId') + login({ + ...this.form, + openId + }).then(response => { + this.$storage.set('token', response.data.token) + getDic() + getUserInfor(response.data.token) + uni.hideLoading() + uni.switchTab({ + url: '/pages/actionChange/agencyPage/index', + }) + // this.$storage.setJson("accountInFor", this.form); + // console.log('this.$store', this.$store) + // this.$store.commit('token', token) + }).catch(errors => { + uni.showToast({ + title: errors, + icon: 'none', + }) + }) + }, + }, + } +</script> +<style scoped lang="scss"> + uni-page-body { + height: 100%; + } + + .page { + color: #ffffff; + background: #3875c5; + height: 100%; + } + + .tit { + padding-top: 307.69rpx; + display: flex; + justify-content: center; + align-items: center; + font-size: 53.85rpx; + } + + .formConten { + padding: 0 76.92rpx; + color: #ffffff; + } + + .u-form-item { + color: #ffffff; + font-size: 28.85rpx; + font-weight: 700; + } + + // /deep/.uni-input-wrapper { + // background: #fff; + // border-radius: 5px; + // } + // /deep/.uni-input-placeholder { + // padding-left: 10px; + // } + /deep/.u-form-item__body__left__content__label { + color: #fff; + } + + // /deep/.uni-input-input { + // padding-left: 10px; + // } + .loginContent { + margin-top: 38.46rpx; + + p { + text-align: right; + margin-bottom: 20px; + + a { + color: #fff; + } + } + + .u-btn--default { + width: 80%; + } + } + + uni-navigator { + display: inline-block; + } +</style> \ No newline at end of file -- Gitblit v1.8.0