123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181 |
- <template>
- <view class="content">
- <view class="one">
- {{basicInfo.name}}
- </view>
- <view class="two">
- <uni-forms ref="form" :model="form" :rules="rules" label-width="auto">
- <uni-forms-item name="account">
- <uni-easyinput type="text" v-model="form.account" placeholder="请输入登录账号" />
- </uni-forms-item>
- <uni-forms-item name="password">
- <uni-easyinput type="password" v-model="form.password" placeholder="请输入登录密码" />
- </uni-forms-item>
- </uni-forms>
- <view class="agree">
- <checkbox-group @change="changeAgree">
- <label>
- <checkbox :checked="agree" />
- <text @tap.stop="toAgree()">我已阅读并同意“用户协议”和“隐私政策”</text>
- </label>
- </checkbox-group>
- </view>
- <view class="btn">
- <button size="mini" @tap="toSubmit('form')">提交登录</button>
- </view>
- </view>
- <view class="thr">
- <button size="mini" @tap="toRegister()">账号注册</button>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- // 基本信息
- basicInfo: {},
- form: {},
- rules: {
- account: {
- rules: [ //
- {
- required: true,
- errorMessage: '请输入登录账号',
- }
- ]
- },
- password: {
- rules: [ //
- {
- required: true,
- errorMessage: '请输入登录密码',
- }
- ]
- }
- },
- // 用戶协议
- agree: true,
- };
- },
- onLoad() {},
- onShow() {
- const that = this;
- that.searchBasic();
- },
- methods: {
- searchBasic() {
- const that = this;
- uni.getStorage({
- key: 'basicInfo',
- success: (res) => {
- let data = res.data
- that.$set(that, `basicInfo`, data);
- }
- })
- },
- // 提交登录
- toSubmit(ref) {
- const that = this;
- let agree = that.agree;
- that.$refs[ref].validate().then(async parmas => {
- if (agree) {
- let res = await that.$api('user/login', 'POST', parmas)
- if (res.errcode == '0') {
- uni.showToast({
- title: '账号登录成功',
- icon: 'none'
- })
- uni.setStorage({
- key: 'token',
- data: res.data,
- success: function() {
- uni.navigateBack()
- }
- });
- } else {
- uni.showToast({
- title: res.errmsg,
- icon: 'none'
- })
- }
- } else {
- uni.showToast({
- title: '请阅读并同意用户协议和隐私政策',
- icon: 'none'
- })
- }
- }).catch(err => {
- console.log('err', err);
- })
- },
- toRegister() {
- uni.navigateTo({
- url: '/pagesAccount/register/index'
- })
- },
- // 同意隐私协议
- changeAgree() {
- const that = this;
- let agree = true;
- if (that.agree) agree = false;
- that.$set(that, `agree`, agree);
- },
- // 查看隐私协议
- toAgree() {
- const that = this;
- uni.navigateTo({
- url: `/pagesAccount/other/agree`
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .content {
- background-color: var(--rgb000);
- padding: 0 2vw;
- .one {
- text-align: center;
- font-size: 30px;
- font-family: monospace;
- color: var(--rgbfff);
- padding: 10vw 0 10vw 0;
- }
- .two {
- margin: 0 0 4vw 0;
- .btn {
- padding: 2vw 0 0 0;
- text-align: center;
- button {
- width: 80%;
- background-color: var(--rgbfa4);
- color: var(--rgbfff);
- padding: 1vw 0;
- }
- }
- }
- .thr {
- text-align: center;
- button {
- background-color: var(--rgbfa4);
- color: var(--rgbfff);
- }
- }
- }
- .agree {
- text-align: center;
- font-size: 12px;
- margin: 0 0 2vw 0;
- color: var(--rgbfff);
- }
- </style>
|