123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <template>
- <view>
- <view class="status_bar">
- <!-- 这里是状态栏 -->
- </view>
- <u-image src="../../static/sailun/login_bg.png" mode="widthFix"></u-image>
- <view class="content">
- <u-card padding="50" :head-border-bottom="false" :show-head="false" :show-foot="false" :border="false" box-shadow="0px 1px 10px rgba(0,0,0,0.2)"
- border-radius="20" margin="50rpx">
- <view slot="body">
- <view style="margin-top: 20rpx;">
- <u-field v-model="tel" :placeholder="$t('login.mobile')" label-width="50">
- <u-icon slot="icon" name="account" size="36" color="#666666"></u-icon>
- </u-field>
- </view>
- <view style="margin-top: 30rpx;">
- <u-field v-model="code" :placeholder="$t('login.code')" label-width="50" maxlength="6">
- <u-icon slot="icon" name="lock" size="36" color="#666666"></u-icon>
- <u-button v-if="send=='zh'" size="mini" slot="right" type="primary" @click="getCode" shape="circle" :loading="codeLoading">{{codeText}}</u-button>
- <u-button v-else size="mini" slot="right" type="primary" @click="getCode" shape="circle" :loading="codeLoading">{{codeText}}</u-button>
- </u-field>
- </view>
- <view class="" v-if="send=='zh'">
- <u-verification-code ref="uCode" @change="codeChange"></u-verification-code>
- </view>
- <u-verification-code v-else ref="uCode" @change="codeChange" start-text="Send" change-text="Reacquire in X S"
- end-text="Reacquire"></u-verification-code>
- <view style="margin-top: 80rpx;">
- <u-button type="primary" :ripple="true" ripple-bg-color="#99d4ff" shape="circle" @tap="$u.debounce(submit, 2000,immediate = true)"
- :loading="loading">{{$t("login.login")}}</u-button>
- </view>
- <view style="margin-top: 80rpx;display: flex;justify-content: center;">
- <view class="u-flex" @click="inregister">
- <view style="color: rgba(0,160,234,0.5)">
- {{$t("login.no")}}
- </view>
- <view style="color: #00A0EA">
- {{$t("login.sign")}}
- </view>
- </view>
- </view>
- </view>
- </u-card>
- </view>
- <view class="foot">
- <view class="u-flex u-row-center u-col-center">
- <u-divider color="#0095FF" border-color="#0095FF" bg-color="#F4F4F4" fontSize="30" @click="switchLang">{{$t("login.Lan")}}</u-divider>
- <!-- <u-divider color="#0095FF" border-color="#0095FF" bg-color="#F4F4F4" fontSize="30">赛轮集团</u-divider> -->
- </view>
- </view>
- </view>
- </template>
- <script>
- import permision from "@/js_sdk/wa-permission/permission.js"
- import {
- mapState,
- mapMutations
- } from 'vuex'
- import {
- request
- } from '../../common/request/request'
- require("promise.prototype.finally").shim()
- export default {
- data() {
- return {
- tel: '',
- code: '',
- codeText: "",
- pact: false,
- loading: false,
- codeLoading: false,
- SystemInfo: '',
- networkType: '',
- version: '',
- send: '',
- }
- },
- computed: {
- ...mapState(['hasLogin'])
- },
- created() {
- uni.getSystemInfo({
- success: (res) => {
- this.SystemInfo = res
- }
- });
- uni.getNetworkType({
- success: (res) => {
- this.networkType = res.networkType
- }
- });
- // #ifdef APP-PLUS
- uni.getLocation({
- success: res => {},
- fail: err => {
- if (this.SystemInfo.platform == "ios") {
- this.judgeIosPermission()
- } else {
- this.requestAndroidPermission()
- }
- }
- });
- // #endif
- // #ifdef APP-PLUS
- plus.runtime.getProperty(plus.runtime.appid, (wgtinfo) => {
- this.version = wgtinfo.version
- })
- // #endif
- uni.$on('loginphone', data => {
- this.tel = data
- })
- this.send = this.$i18n.locale
- console.log(this.send)
- },
- methods: {
- switchLang() {
- this.$i18n.locale = this.$i18n.locale == 'en' ? 'zh' : 'en';
- this.send = this.$i18n.locale
- uni.setStorage({
- key: "lang",
- data: this.$i18n.locale
- })
- },
- ...mapMutations(['login']),
- judgeIosPermission() {
- let result = permision.judgeIosPermission('location')
- if (!result) {
- uni.showModal({
- title: this.$t('login.locationtitle'),
- content: this.$t('login.locationcontent'),
- cancelText: this.$t('login.locationcancelText'),
- confirmText: this.$t('login.locationconfirmText'),
- success: res => {
- if (res.confirm) {
- plus.runtime.openURL("app-settings://");
- }
- }
- })
- }
- },
- async requestAndroidPermission() {
- let result = await permision.requestAndroidPermission('android.permission.ACCESS_FINE_LOCATION')
- },
- toUser(provider) {
- this.login(provider);
- if (this.hasLogin) {
- this.$u.route({
- url: 'pages/home/index',
- type: 'switchTab',
- })
- } else {
- uni.navigateBack();
- }
- },
- submit() {
- if (this.$u.test.mobile(this.tel)) {
- this.loading = true
- request({
- url: '/sailun/appLogin/storeLogin',
- method: 'post',
- data: {
- "account": "",
- "loginType": "1",
- "mobileCode": this.code,
- "password": "",
- "phoneNumber": this.tel,
- "osType": this.SystemInfo.platform,
- "osVersion": this.SystemInfo.system,
- "phoneBrand": this.SystemInfo.brand,
- "phoneModel": this.SystemInfo.model,
- "appVersion": this.version,
- "networkType": this.networkType,
- }
- }).then(res => {
- if (res.data.code == 0) {
- this.toUser(res.data.data)
- uni.$emit('login', {
- msg: this.$t('login.suclogin')
- })
- } else {
- this.$u.toast(res.data.msg);
- }
- }).catch(err => {
- this.$u.toast(this.$t('login.errlogin'));
- }).finally(() => {
- this.loading = false
- })
- }
- },
- inregister() {
- this.$u.route({
- url: 'pages/login/register',
- })
- },
- codeChange(text) {
- this.codeText = text;
- },
- getCode() {
- if (this.$u.test.mobile(this.tel)) {
- if (this.$refs.uCode.canGetCode) {
- this.codeLoading = true
- request({
- url: '/sailun/appStoreBasicInfo/sendCode',
- method: 'post',
- data: {
- "phoneNumber": this.tel,
- "opreaType": "1"
- },
- }).then(res => {
- if (res.data.code == 0) {
- this.$refs.uCode.start();
- }
- if (res.data.code == 500) {
- this.$u.toast(res.data.msg);
- }
- }).catch(err => {
- }).finally(() => {
- this.codeLoading = false
- })
- } else {
- this.$u.toast(this.$t('login.repeatcode'));
- }
- } else {
- this.$u.toast(this.$t('login.telcode'));
- }
- },
- }
- };
- </script>
- <style lang="scss" scoped>
- .status_bar {
- height: var(--status-bar-height);
- width: 100%;
- background-color: #0095FF;
- }
- .content {
- position: relative;
- top: -400rpx;
- }
- .foot {
- position: fixed;
- bottom: 10rpx;
- width: 100%;
- padding-bottom: 0;
- padding-bottom: constant(safe-area-inset-bottom);
- padding-bottom: env(safe-area-inset-bottom);
- }
- </style>
|