| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- <template>
- <view class="normal-login-container">
- <view class="logo-content align-center justify-center flex">
- <image style="width: 100rpx;height: 100rpx;" :src="globalConfig.appInfo.logo" mode="widthFix">
- </image>
- <text class="title">登录</text>
- </view>
- <view class="" style="margin-top: 5%;">
- <uni-row>
- <uni-col :span="20" offset="2">
- <view class="action-btn">
- <button @click="handleWxMiniLogin" class="login-btn cu-btn block bg-blue lg round"
- type="primary" :style="{backgroundColor: themeColor}">一键登录</button>
- </view>
- </uni-col>
- </uni-row>
- </view>
- <view class="xieyi text-center" style="margin-top: 5%;">
- <text class="text-grey1">登录即代表同意</text>
- <text @click="handleUserAgrement" class="text-blue">《用户协议》</text>
- <text @click="handlePrivacy" class="text-blue">《隐私协议》</text>
- </view>
- </view>
- </view>
- </template>
- <script>
- import {
- getCodeImg
- } from '@/api/login'
- export default {
- data() {
- return {
- globalConfig: getApp().globalData.config,
- loginForm: {
- code: "",
- appid: ""
- },
- themeColor:getApp().globalData.config.appInfo.themeColor
- }
- },
- created() {},
- methods: {
- // 隐私协议
- handlePrivacy() {
- let site = this.globalConfig.appInfo.agreements[0]
- this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
- },
- // 用户协议
- handleUserAgrement() {
- let site = this.globalConfig.appInfo.agreements[1]
- this.$tab.navigateTo(`/pages/common/webview/index?title=${site.title}&url=${site.url}`)
- },
- // 登录成功后,处理函数
- loginSuccess(result) {
- // 设置用户信息
- this.$store.dispatch('GetMiniAppUserInfo').then(res => {
- this.$tab.reLaunch('/pages/index')
- })
- this.$tab.reLaunch('/pages/index')
- },
- //一键登录
- handleWxMiniLogin() {
- this.$modal.loading("登录中,请耐心等待...")
- const accountInfo = uni.getAccountInfoSync()
- uni.login({
- provider: 'weixin',
- success: (res) => {
- this.loginForm.code = res.code;
- this.loginForm.appid = accountInfo.miniProgram.appId;
- this.$store.dispatch('WxMiniLogin', this.loginForm).then(() => {
- this.$modal.closeLoading()
- this.loginSuccess()
- }).catch(() => {
- if (this.captchaEnabled) {
- this.getCode()
- }
- })
- }
- })
- }
- }
- }
- </script>
- <style lang="scss">
- page {
- background-color: #ffffff;
- }
- .normal-login-container {
- width: 100%;
- .logo-content {
- width: 100%;
- font-size: 21px;
- text-align: center;
- padding-top: 15%;
- image {
- border-radius: 4px;
- }
- .title {
- margin-left: 10px;
- }
- }
- .login-form-content {
- text-align: center;
- margin: 20px auto;
- margin-top: 15%;
- width: 80%;
- .input-item {
- margin: 20px auto;
- background-color: #f5f6f7;
- height: 45px;
- border-radius: 20px;
- .icon {
- font-size: 38rpx;
- margin-left: 10px;
- color: #999;
- }
- .input {
- width: 100%;
- font-size: 14px;
- line-height: 20px;
- text-align: left;
- padding-left: 15px;
- }
- }
- .login-btn {
- margin-top: 40px;
- height: 45px;
- }
- .reg {
- margin-top: 15px;
- }
- .xieyi {
- color: #333;
- margin-top: 20px;
- }
- .login-code {
- height: 38px;
- float: right;
- .login-code-img {
- height: 38px;
- position: absolute;
- margin-left: 10px;
- width: 200rpx;
- }
- }
- }
- }
- </style>
|