123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219 |
- <template>
- <view class="content">
- <!-- <view> -->
- <view>
- <view class="logo-cont">
- <u-image src="/static/login_icon_logo.png" width="160" height="160" class="logo"></u-image>
- <!-- <u-image src="/static/login_slogan.png" mode="aspectFit" width="286" height="36" class="logo_text"></u-image> -->
- </view>
- <view class="login-btns">
- <u-button shape="circle" :custom-style="wxButton" class="login-btn" type="success" :hair-line="false" open-type="getPhoneNumber" @getphonenumber="getPhoneNumber">
- 微信授权登录
- </u-button>
- </view>
- </view>
- <view class="nologin">
- <u-button shape="circle" size="mini" plain lass="login-btn" @click="cansel" type="info">
- 暂不登录
- </u-button>
- </view>
- <!-- </view> -->
- <view @click="toYs" class="yszc">首次登录会自动创建账号且即代表同意<text class="yszc-text">《乐色超人服务协议》</text>及<text class="yszc-text">《隐私保护政策》</text></view>
- </view>
- </template>
- <script>
- import {login} from "@/api/login"
- export default {
- components: {},
- data() {
- return {
- path: '/pages/index/index',
- lanuch: false,
- code: '',
- wxButton: {
- background: '#0DC55F'
- },
- popupBox:{
- padding:'20'
- },
- cancelBtn:{
- background:'#eee',
- color:"#07C160",
- width:'100px',
- height:'35px',
- border:0
- },
- submitBtn:{
- width:'100px',
- height:'35px'
- }
- }
- },
- onLoad(option) {
- // 开启分享
- uni.showShareMenu({
- withShareTicket: true,
- menus: ['shareAppMessage', 'shareTimeline']
- })
- // 为解决首次登录异常问题 进入页面先调微信登录获取code
- this.wxLogin()
- const {
- path,
- lanuch
- } = option;
- this.lanuch = (lanuch + '') === 'true';
- if (path) {
- this.path = decodeURIComponent(path);
- }
- },
- methods: {
- cansel(){
- this.$store.state.vuex_noLogin = true
- uni.reLaunch({
- url: '/pages/index/index'
- })
- },
- toYs(){
- uni.navigateTo({
- url: '/pages/agreement/agreement'
- })
- },
- getPhoneNumber(e) {
- let _this = this
- uni.showLoading({
- mask: true,
- title: '加载中'
- });
- if (!this.code) {
- this.wxLogin()
- }
- console.log(this.code, e)
- if (e.target.errMsg === 'getPhoneNumber:ok') {
- setTimeout(()=>{
- const params={
- code: _this.code,
- encryptedData: e.target.encryptedData,
- iv: e.target.iv,
- }
- login(params).then(res => {
- uni.hideLoading();
- _this.code = ''
- console.log(res,_this.path, 'login data')
- if (res.status == '200') {
- getApp().globalData.token = res.data
- _this.$u.vuex('vuex_token',res.data)
- console.log(getApp().globalData.token,'---------getApp().globalData.token','------登录token')
- uni.$emit("getUserInfo")
- if (_this.path === '/pages/index/index' || _this.lanuch) {
- uni.reLaunch({
- url: _this.path
- });
- } else {
- uni.redirectTo({
- url: _this.path
- });
- }
- } else {
- uni.showToast({
- title: res.message,
- icon: 'none',
- duration: 2500
- });
- }
- });
- },300)
- } else {
- uni.showToast({
- title: '授权失败',
- icon: 'none',
- duration: 2500
- });
- }
- },
- // 调微信登录 获取code
- wxLogin () {
- let _this = this
- uni.login({
- provider: 'weixin',
- success(res) {
- console.log(res.code)
- _this.code = res.code
- }
- })
- },
- }
- }
- </script>
- <style lang="scss">
- .content{
- width: 100%;
- height: 100vh;
- padding:0 130upx;
- margin: 0 auto;
- .logo-cont{
- display: flex;
- flex-direction: column;
- align-items: center;
- }
- .logo{
- display: inline-block;
- margin:240upx 256upx 120upx;
- }
- .logo_text{
- display: inline-block;
- margin-bottom: 200upx;
- }
- .login-btn{
- display: block;
- // width: 670upx;
- height: 80upx;
- }
- .phoneBtn:active{
- background: #fff ;
- outline: none;
- }
- .nologin{
- text-align: center;
- margin: 70upx 0 350upx 0;
- }
- .yszc{
- font-size: 24upx;
- text-align: center;
- .yszc-text{
- color:#4F88F7;
- }
-
- }
- .popup-title{
- display: flex;
- align-items: center;
- padding: 30rpx 40rpx;
- h4{
- margin-left:20rpx ;
- }
- }
- .popup-usePhone{
- padding:20rpx 40rpx ;
- }
- .popup-bindPhone{
- display: flex;
- padding:20rpx 40rpx ;
- text{
- display: inline-block;
- margin-left: 20rpx;
- color:#999
- }
- }
- .popup-useOtherPhone{
- padding:20rpx 40rpx ;
- color:#576B95
- }
- .popup-btn{
- display: flex;
- justify-content: space-around;
- padding:20rpx 40rpx 40rpx;
- }
- }
- </style>
|