123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665 |
- <template>
- <view class="login-wrapper" :style="colorStyle">
- <view class="shading">
- <image :src="logoUrl" />
- </view>
- <view class="whiteBg">
- <view class="list" v-if="current !== 1">
- <form @submit.prevent="submit">
- <view class="item">
- <view class="acea-row row-middle">
- <image src="../static/phone_1.png" style="width: 24rpx; height: 34rpx;"></image>
- <input type="text" :placeholder="$t(`输入手机号码`)" v-model="account" maxlength="11" required />
- </view>
- </view>
- <view class="item">
- <view class="acea-row row-middle">
- <image src="../static/code_1.png" style="width: 28rpx; height: 32rpx;"></image>
- <input type="password" :placeholder="$t(`填写登录密码`)" v-model="password" required />
- </view>
- </view>
- </form>
- <!-- <navigator class="forgetPwd" hover-class="none" url="/pages/users/retrievePassword/index">
- <span class="iconfont icon-wenti"></span>忘记密码
- </navigator> -->
- </view>
- <view class="list" v-if="current !== 0 || appLoginStatus || appleLoginStatus">
- <view class="item">
- <view class="acea-row row-middle">
- <image src="../static/phone_1.png" style="width: 24rpx; height: 34rpx;"></image>
- <input type="text" :placeholder="$t(`输入手机号码`)" v-model="account" :maxlength="11" />
- </view>
- </view>
- <view class="item">
- <view class="acea-row row-middle">
- <image src="../static/code_2.png" style="width: 28rpx; height: 32rpx;"></image>
- <input type="text" :placeholder="$t(`填写邀请码`)" class="codeIput"
- v-model="spread" />
- </view>
- </view>
- <view class="item">
- <view class="acea-row row-middle">
- <image src="../static/code_2.png" style="width: 28rpx; height: 32rpx;"></image>
- <input type="text" :placeholder="$t(`填写验证码`)" :maxlength="6" class="codeIput"
- v-model="captcha" />
- <button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code">
- {{ text }}
- </button>
- </view>
- </view>
- <view class="item" v-if="isShowCode">
- <view class="acea-row row-middle">
- <image src="../static/code_2.png" style="width: 28rpx; height: 32rpx;"></image>
- <input type="text" :placeholder="$t(`填写验证码`)" class="codeIput" v-model="codeVal" />
- <view class="code" @click="again"><img :src="codeUrl" /></view>
- </view>
- </view>
- </view>
- <view class="logon" @click="loginMobile" v-if="current !== 0">{{$t(`注册`)}}</view>
- <view class="logon" @click="submit" v-if="current === 0">{{$t(`登录`)}}</view>
- <view class="tips">
- <!-- <view v-if="current==0" @click="current = 1">{{$t(`快速登录`)}}</view> -->
- <!-- <view v-if="current==1" @click="current = 0">{{$t(`账号登录`)}}</view> -->
- </view>
- <!-- TODO -->
- <view class="choose">
- <!-- <view class="reg" @click="forget">忘记密码</view>
- <view class="xian">|</view> -->
- <view class="zhuce" @click="zhuce">账号登录</view>
- </view>
- <view class="protocol">
- <checkbox-group @change='ChangeIsDefault'>
- <checkbox :class="inAnimation?'trembling':''" @animationend='inAnimation=false'
- :checked="protocol ? true : false" />{{$t(`已阅读并同意`)}} <text class="main-color"
- @click="privacy(4)">{{$t(`《用户协议》`)}}</text>
- {{$t(`与`)}}<text class="main-color" @click="privacy(3)">{{$t(`《隐私协议》`)}}</text>
- </checkbox-group>
- </view>
- </view>
- <!-- <view class="bottom">
- <view class="ver" v-if="copyRight">{{copyRight}}</view>
- <view v-else class="ver">© 2014-2023
- <a href="https://www.crmeb.com">www.crmeb.com</a>
- </view>
- </view> -->
- <Verify @success="success" :captchaType="captchaType" :imgSize="{ width: '330px', height: '155px' }"
- ref="verify"></Verify>
- </view>
- </template>
- <script>
- import dayjs from "@/plugin/dayjs/dayjs.min.js";
- import sendVerifyCode from "@/mixins/SendVerifyCode";
- import {
- loginH5,
- loginMobile,
- registerVerify,
- register,
- getCodeApi,
- getUserInfo,
- appleLogin
- } from "@/api/user";
- import attrs, {
- required,
- alpha_num,
- chs_phone
- } from "@/utils/validate";
- import {
- getLogo
- } from "@/api/public";
- // import cookie from "@/utils/store/cookie";
- import {
- VUE_APP_API_URL
- } from "@/utils";
- // #ifdef APP-PLUS
- import {
- wechatAppAuth
- } from '@/api/api.js'
- // #endif
- const BACK_URL = "login_back_url";
- import colors from '@/mixins/color.js';
- import Verify from '../components/verify/index.vue';
- export default {
- name: "Login",
- components: {
- Verify
- },
- mixins: [sendVerifyCode, colors],
- data: function() {
- return {
- copyRight: '',
- inAnimation: false,
- protocol: false,
- current: 1,
- spread:'',
- account: "",
- password: "",
- captcha: "",
- formItem: 2,
- type: "login",
- logoUrl: "",
- keyCode: "",
- codeUrl: "",
- codeVal: "",
- isShowCode: false,
- appLoginStatus: false, // 微信登录强制绑定手机号码状态
- appUserInfo: null, // 微信登录保存的用户信息
- appleLoginStatus: false, // 苹果登录强制绑定手机号码状态
- appleUserInfo: null,
- appleShow: false, // 苹果登录版本必须要求ios13以上的
- keyLock: true
- };
- },
- watch: {
- formItem: function(nval, oVal) {
- if (nval == 1) {
- this.type = 'login'
- } else {
- this.type = 'register'
- }
- }
- },
- onLoad() {
- let self = this
- if (uni.getStorageSync('copyRight').copyrightContext) {
- this.copyRight = uni.getStorageSync('copyRight').copyrightContext
- }
- self.spread = self.$Cache.get("spread");
- },
- mounted: function() {
- this.getLogoImage();
- },
- methods: {
- ChangeIsDefault(e) {
- this.$set(this, 'protocol', !this.protocol);
- },
- privacy(type) {
- uni.navigateTo({
- url: "/pages/users/privacy/index?type=" + type
- })
- },
- zhuce() {
- uni.navigateTo({
- url: "/pages/users/login/index"
- })
- },
- again() {
- this.codeUrl =
- VUE_APP_API_URL +
- "/sms_captcha?" +
- "key=" +
- this.keyCode +
- Date.parse(new Date());
- },
- success(data) {
- this.$refs.verify.hide()
- getCodeApi()
- .then(res => {
- this.keyCode = res.data.key;
- this.getCode(data);
- })
- .catch(res => {
- this.$util.Tips({
- title: res
- });
- });
- },
- code() {
- let that = this
- if (!that.protocol) {
- this.inAnimation = true
- return that.$util.Tips({
- title: '请先阅读并同意协议'
- });
- }
- if (!that.account) return that.$util.Tips({
- title: that.$t(`请填写手机号码`)
- });
- if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
- title: that.$t(`请输入正确的手机号码`)
- });
- this.$refs.verify.show()
- },
- async getLogoImage() {
- let that = this;
- getLogo(2).then(res => {
- that.logoUrl = res.data.logo_url;
- });
- },
- async loginMobile() {
- let that = this;
- if (!that.protocol) {
- this.inAnimation = true
- return that.$util.Tips({
- title: '请先阅读并同意协议'
- });
- }
- if (!that.account) return that.$util.Tips({
- title: that.$t(`请填写手机号码`)
- });
- if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
- title: that.$t(`请输入正确的手机号码`)
- });
- if (!that.captcha) return that.$util.Tips({
- title: that.$t(`请填写验证码`)
- });
- if (!that.spread) return that.$util.Tips({
- title: that.$t(`请填写邀请码/手机号`)
- });
- if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
- title: that.$t(`请输入正确的验证码`)
- });
- if (this.keyLock) {
- this.keyLock = !this.keyLock
- } else {
- return that.$util.Tips({
- title: that.$t(`请勿重复点击`)
- });
- }
- loginMobile({
- phone: that.account,
- captcha: that.captcha,
- spread: that.spread
- })
- .then(res => {
- let data = res.data;
- that.$store.commit("LOGIN", {
- 'token': data.token,
- 'time': data.expires_time - this.$Cache.time()
- });
- let backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
- that.$Cache.clear(BACK_URL);
- getUserInfo().then(res => {
- this.keyLock = true
- that.$store.commit("SETUID", res.data.uid);
- if (backUrl.indexOf('/pages/users/login/index') !== -1) {
- backUrl = '/pages/index/index';
- }
- uni.reLaunch({
- url: backUrl
- });
- })
- })
- .catch(res => {
- this.keyLock = true
- that.$util.Tips({
- title: res
- });
- });
- },
- async register() {
- let that = this;
- if (!that.protocol) {
- this.inAnimation = true
- return that.$util.Tips({
- title: '请先阅读并同意协议'
- });
- }
- if (!that.account) return that.$util.Tips({
- title: that.$t(`请填写手机号码`)
- });
- if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
- title: that.$t(`请输入正确的手机号码`)
- });
- if (!that.captcha) return that.$util.Tips({
- title: that.$t(`请填写验证码`)
- });
- if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({
- title: that.$t(`请输入正确的验证码`)
- });
- if (!that.password) return that.$util.Tips({
- title: that.$t(`请填写密码`)
- });
- if (/^([0-9]|[a-z]|[A-Z]){0,6}$/i.test(that.password)) return that.$util.Tips({
- title: that.$t(`您输入的密码过于简单`)
- });
- register({
- account: that.account,
- captcha: that.captcha,
- password: that.password,
- spread: that.$Cache.get("spread")
- })
- .then(res => {
- that.$util.Tips({
- title: res
- });
- that.formItem = 1;
- })
- .catch(res => {
- that.$util.Tips({
- title: res
- });
- });
- },
- async getCode(data) {
- let that = this;
- if (!that.protocol) {
- this.inAnimation = true
- return that.$util.Tips({
- title: '请先阅读并同意协议'
- });
- }
- if (!that.account) return that.$util.Tips({
- title: that.$t(`请填写手机号码`)
- });
- if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({
- title: that.$t(`请输入正确的手机号码`)
- });
- if (that.formItem == 2) that.type = "register";
- await registerVerify({
- phone: that.account,
- type: that.type,
- key: that.keyCode,
- captchaType: this.captchaType,
- captchaVerification: data.captchaVerification
- })
- .then(res => {
- this.sendCode()
- that.$util.Tips({
- title: res.msg
- });
- })
- .catch(res => {
- that.$util.Tips({
- title: res
- });
- });
- },
- navTap: function(index) {
- this.current = index;
- },
- async submit() {
- let that = this;
- if (!that.protocol) {
- this.inAnimation = true
- return that.$util.Tips({
- title: '请先阅读并同意协议'
- });
- }
- if (!that.account) return that.$util.Tips({
- title: that.$t(`请填写账号`)
- });
- if (!/^[\w\d]{5,16}$/i.test(that.account)) return that.$util.Tips({
- title: that.$t(`请输入正确的账号`)
- });
- if (!that.password) return that.$util.Tips({
- title: that.$t(`请填写密码`)
- });
- if (this.keyLock) {
- this.keyLock = !this.keyLock
- } else {
- return that.$util.Tips({
- title: that.$t(`请勿重复点击`)
- });
- }
- loginH5({
- account: that.account,
- password: that.password,
- spread: that.$Cache.get("spread")
- })
- .then(({
- data
- }) => {
- that.$store.commit("LOGIN", {
- 'token': data.token,
- 'time': data.expires_time - this.$Cache.time()
- });
- let backUrl = that.$Cache.get(BACK_URL) || "/pages/index/index";
- that.$Cache.clear(BACK_URL);
- getUserInfo().then(res => {
- this.keyLock = true
- that.$store.commit("SETUID", res.data.uid);
- uni.reLaunch({
- url: backUrl
- });
- }).catch(error => {
- this.keyLock = true
- })
- })
- .catch(e => {
- this.keyLock = true
- that.$util.Tips({
- title: e
- });
- });
- }
- }
- };
- </script>
- <style>
- page {
- background: #fff;
- }
- </style>
- <style lang="scss">
- .appLogin {
- margin-top: 60rpx;
- .hds {
- display: flex;
- justify-content: center;
- align-items: center;
- font-size: 24rpx;
- color: #B4B4B4;
- .line {
- width: 68rpx;
- height: 1rpx;
- background: #CCCCCC;
- }
- p {
- margin: 0 20rpx;
- }
- }
- .btn-wrapper {
- display: flex;
- align-items: center;
- justify-content: center;
- margin-top: 30rpx;
- .btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 68rpx;
- height: 68rpx;
- border-radius: 50%;
- }
- .apple-btn {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 68rpx;
- height: 68rpx;
- border-radius: 50%;
- background: #000;
- .icon-s-pingguo {
- color: #fff;
- font-size: 44rpx;
- }
- }
- .iconfont {
- font-size: 40rpx;
- color: #fff;
- }
- .wx {
- margin-right: 30rpx;
- background-color: #61C64F;
- }
- .mima {
- margin-right: 30rpx;
- background-color: #28B3E9;
- }
- .yanzheng {
- margin-right: 30rpx;
- background-color: #F89C23;
- }
- }
- }
- .code img {
- width: 100%;
- height: 100%;
- }
- .acea-row.row-middle {
- input {
- margin-left: 20rpx;
- display: block;
- }
- }
- .login-wrapper {
- padding: 30rpx;
- .shading {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- /* #ifdef APP-VUE */
- margin-top: 50rpx;
- /* #endif */
- /* #ifndef APP-VUE */
- margin-top: 200rpx;
- /* #endif */
- image {
- width: 240rpx;
- height: 240rpx;
- }
- }
- .whiteBg {
- margin-top: 100rpx;
- .list {
- border-radius: 16rpx;
- overflow: hidden;
- .item {
- border-bottom: 1px solid #F0F0F0;
- background: #fff;
- .row-middle {
- position: relative;
- padding: 16rpx 45rpx;
- input {
- flex: 1;
- font-size: 28rpx;
- height: 80rpx;
- }
- .code {
- position: absolute;
- right: 30rpx;
- top: 50%;
- color: var(--view-theme);
- font-size: 26rpx;
- transform: translateY(-50%);
- }
- }
- }
- }
- .logon {
- display: flex;
- align-items: center;
- justify-content: center;
- width: 100%;
- height: 86rpx;
- margin-top: 80rpx;
- background-color: var(--view-theme);
- border-radius: 120rpx;
- color: #FFFFFF;
- font-size: 30rpx;
- }
- .tips {
- margin: 30rpx;
- text-align: center;
- color: #999;
- }
- }
- }
- .protocol {
- margin-top: 40rpx;
- color: #999999;
- font-size: 24rpx;
- text-align: center;
- bottom: 20rpx;
- }
- .bottom {
- position: fixed;
- bottom: 30rpx;
- left: 0;
- display: flex;
- width: 100%;
- justify-content: center;
- color: #999999;
- .ver {
- font-size: 20rpx;
- }
- .ver-msg {
- margin-left: 10rpx;
- }
- a {
- color: #999999;
- margin-left: 10rpx;
- text-decoration: none;
- }
- }
- .trembling {
- animation: shake 0.6s;
- }
- .main-color {
- color: var(--view-theme);
- }
- .choose {
- display: flex;
- justify-content: center;
- .reg {
- font-size: 28rpx;
- font-weight: 500;
- color: #ff8d3a;
- }
- .xian {
- color: #FF4C4C;
- padding-left: 10rpx;
- }
- .zhuce {
- font-size: 28rpx;
- font-weight: 500;
- color: #FF4C4C;
- padding-left: 10rpx;
- }
- }
- </style>
|