123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- <template>
- <view class="container">
- <view class="container_text">
- <image class="banner-img" src="/static/img/shouye1.png" mode="scaleToFill"></image>
- </view>
- <view class="loginTitle"><text>{{$t('login.a0')}}</text></view>
- <view class="login_text">
- <view class="login_input flex">
- <view class="login_img">
- <image src="/static/icon/ze.png"></image>
- </view>
- <view class="login_name">
- <input class="uni-input" v-model="account" focus :placeholder="$t('login.a1')" />
- </view>
- </view>
- <view class="login_input flex">
- <view class="login_img">
- <image src="/static/icon/ze2.png"></image>
- </view>
- <view class="login_name"><input class="uni-input" type="password" v-model="passward" focus
- :placeholder="$t('login.a3')" /></view>
- </view>
- <view><button type="green" class="uni-button uni-button-green" @click="toLogin">{{$t('login.a4')}}</button>
- </view>
- <view><button type="green" class="uni-button uni-button-green uni-button-green-plain" plain="true"
- hover-class="none" @click="register">{{$t('login.a7')}}</button></view>
- <navigator url="./forget">
- <view class="forget">{{$t('login.b2')}}</view>
- </navigator>
- <!-- #ifdef H5 -->
- <view class="flex">
- <button class="uni-button loadapp" @click="domApp('apk')">APK下载</button>
- <button class="uni-button loadapp" @click="domApp('ios')">IOS下载</button>
- </view>
- <!-- #endif -->
- </view>
- </view>
- </template>
- <script>
- import {
- mapMutations
- } from 'vuex';
- import {
- login
- } from '@/api/login.js';
- import {
- getUserInfo
- } from '@/api/user.js';
- // #ifdef APP-PLUS
- // applelogin接口需要开发编写,基础项目中可能没有
- import {
- applelogin
- } from '@/api/set.js';
- // loginWx接口需要开发编写,基础项目中可能没有
- import {
- loginWx
- } from '@/api/login.js';
- // #endif
- // #ifdef H5
- import {
- loginWinxin
- } from '@/utils/wxAuthorized';
- import {
- getAppVersion
- } from '@/api/index.js'
- // #endif
- export default {
- data() {
- return {
- // account: '13245678911' ,// 账号
- // passward: '132456', //密码
- account: '',
- passward: '',
- // #ifdef APP-PLUS
- is_ios: false, //判断是否为ios手机
- is_apple_login: false, //是否有ios授权登录功能
- // #endif
- };
- },
- onLoad() {
- let obj = this;
- // #ifdef APP-PLUS
- let system = uni.getStorageSync('platform');
- // 判断是否为ios
- if (system == 'ios') {
- obj.is_ios = true;
- }
- uni.getSystemInfo({
- success(e) {
- if (+e.system.split('.')[0] >= 13) {
- obj.is_apple_login = true;
- }
- }
- })
- // #endif
- },
- methods: {
- ...mapMutations('user', ['setUserInfo', 'login']),
- // #ifdef H5
- domApp(type) {
- console.log('111');
- const bool = navigator.userAgent.toLowerCase().match(/MicroMessenger/i) == 'micromessenger';
- if (bool) {
- uni.showModal({
- // title: '提示',
- title: this.$t("enter.a7"),
- // content: '无法在微信中下载,请用浏览器打开下载',
- content: this.$t("login.c2"),
- showCancel: false,
- });
- } else {
- if (type == 'apk') {
- getAppVersion().then((res) => {
- console.log(res, 'res');
- window.open(res.data.apk);
- }).catch((err) => {
- console.log(err, 'err');
- })
- return
- }
- if (type == "ios") {
- window.open("/index/dom/iosdom.mobileconfig");
- }
- }
- },
- // #endif
- // 微信登录
- wecahtLogin(type) {
- let obj = this;
- // #ifdef H5
- let weichatBrowser = uni.getStorageSync('weichatBrowser');
- if (weichatBrowser) {
- loginWinxin();
- }
- // #endif
- // #ifdef APP-PLUS
- uni.login({
- provider: type,
- success(e) {
- uni.getUserInfo({
- provider: type,
- success(es) {
- if (type === 'weixin') {
- loginWx(es.userInfo)
- .then(e => {
- uni.setStorageSync('token', e.data.token);
- getUserInfo({}).then(e => {
- obj.login();
- // 保存返回用户数据
- obj.setUserInfo(e.data);
- //成功跳转首页
- uni.switchTab({
- url: '/pages/index/index'
- });
- });
- })
- .catch(e => {
- console.log(e);
- uni.showModal({
- content: JSON.stringify(e),
- success() {},
- fail() {}
- });
- });
- }
- if (type === 'apple') {
- console.log(es.userInfo);
- applelogin({
- account: es.userInfo.openId,
- })
- .then(function(e) {
- console.log(e, 'token')
- uni.setStorageSync('token', e.data.token);
- getUserInfo({}).then(e => {
- obj.login();
- // 保存返回用户数据
- obj.setUserInfo(e.data);
- //成功跳转首页
- uni.switchTab({
- url: '/pages/index/index'
- });
- });
- })
- .catch(function(e) {
- console.log(e);
- });
- }
- },
- fail(es) {
- uni.showModal({
- content: JSON.stringify(es),
- success() {
- // obj.login();
- // // 保存返回用户数据
- // obj.setUserInfo(e.data);
- // //成功跳转首页
- // uni.switchTab({
- // url: '/pages/index/index'
- // });
- }
- });
- }
- });
- },
- fail(e) {
- uni.showModal({
- title: '提示',
- content: JSON.stringify(e),
- showCancel: false
- });
- }
- });
- // #endif
- },
- //登录
- async toLogin() {
- let obj = this;
- obj.logining = true;
- if (obj.account == '') {
- obj.$api.msg(obj.$t("login.a1"));
- // obj.$api.msg('132456789');
- return;
- }
- if (obj.passward == '') {
- obj.$api.msg(obj.$t("login.a3"));
- // obj.$api.msg('132456');
- return;
- }
- login({
- account: obj.account,
- password: obj.passward
- })
- .then(function(e) {
- uni.setStorageSync('token', e.data.token);
- getUserInfo({}).then(e => {
- obj.login();
- // 保存返回用户数据
- obj.setUserInfo(e.data);
- let ur = '';
- let url = uni.getStorageSync('present') || '';
- if (url != '/pages/public/login' && url) {
- ur = uni.getStorageSync('present')
- } else {
- ur = '/pages/index/index';
- }
- //成功跳转首页
- uni.switchTab({
- url: ur,
- fail(e) {
- uni.navigateTo({
- url: ur,
- fail(e) {
- uni.switchTab({
- url: '/pages/index/index',
- });
- }
- });
- }
- });
- });
- })
- .catch(function(e) {
- console.log(e);
- });
- },
- //跳转注册页
- register() {
- uni.navigateTo({
- url: `/pages/public/register`
- });
- },
- // 后退
- navBack() {
- uni.navigateBack();
- }
- }
- };
- </script>
- <style lang="scss">
- /* #ifdef APP-PLUS */
- .ios_login {
- width: 260rpx;
- border-radius: 12rpx;
- justify-content: center;
- border: 1px solid #212121;
- margin: 24rpx auto;
- padding: 10rpx;
- background-color: #212121;
- color: #ffffff;
- .loginIcon {
- width: 50rpx;
- height: 50rpx;
- }
- .weixin_text {
- line-height: 1;
- margin-left: 20rpx;
- color: #ffffff !important;
- }
- }
- /* #endif */
- .ios_login {
- width: 350rpx;
- border-radius: 12rpx;
- justify-content: center;
- border: 1px solid #212121;
- margin: 24rpx auto;
- padding: 15rpx;
- background-color: #212121;
- color: #ffffff;
- font-size: 32rpx;
- .loginIcon {
- font-size: 35rpx;
- width: 35rpx;
- height: 35rpx;
- }
- .weixin_text {
- line-height: 1;
- margin-left: 20rpx;
- color: #ffffff !important;
- }
- }
- page {
- height: 100%;
- }
- .container {
- width: 100%;
- height: 100%;
- background-size: 100%;
- background-color: #000000;
- }
- .container_text {
- width: 100%;
- height: 500rpx;
- top: 0rpx;
- .banner-img {
- width: 144rpx;
- height: 144rpx;
- margin-top: 100rpx;
- margin-left: 302rpx;
- }
- }
- .login_text {
- margin: auto 10rpx;
- position: relative;
- padding: 100rpx 102rpx;
- background-color: #000000;
- margin-top: -180rpx;
- border-radius: 20rpx;
- .login_input {
- border-bottom: 1px solid #f0f0f0;
- margin-bottom: 65rpx;
- .login_img image {
- height: 35rpx;
- width: 29rpx;
- }
- .uni-input {
- text-align: left;
- width: 100%;
- font-size: 28rpx !important;
- }
- .login_name {
- margin-left: 20rpx;
- flex-grow: 1;
- color: #fff;
- }
- }
- .other {
- margin-top: 60rpx;
- .fenge {
- width: 30%;
- height: 2rpx;
- background-color: #eeeeee;
- }
- .qita {
- font-size: 28rpx;
- color: #999999;
- }
- }
- .weixin {
- width: 75rpx;
- height: 75rpx;
- margin: 25rpx auto;
- }
- .weixin image {
- width: 100%;
- height: 100%;
- }
- .weixin_text {
- text-align: center;
- font-size: 28rpx;
- color: #999999;
- }
- .forget {
- font-size: 28rpx;
- width: 100%;
- text-align: right;
- color: #999999;
- }
- .uni-button-green {
- color: #ffffff;
- background-color: #feb041;
- margin: 40rpx 10rpx;
- border-radius: 50rpx;
- }
- .uni-button-green-plain {
- border: 1px solid #feb041;
- margin: 40rpx 10rpx;
- border-radius: 50rpx;
- color: #feb041;
- background-color: #000000;
- }
- .uni-button {
- height: 85rpx;
- line-height: 85rpx;
- }
- }
- .loginTitle {
- position: absolute;
- top: 250rpx;
- width: 100%;
- text-align: center;
- color: #cbb174;
- font-size: 40rpx;
- }
- /* #ifdef H5 */
- .loadapp {
- margin-top: 20rpx;
- border: 1px solid #feb041;
- background-color: transparent;
- color: #feb041;
- width: 45%;
- }
- /* #endif */
- </style>
|