|
@@ -1,9 +1,9 @@
|
|
<template>
|
|
<template>
|
|
<view class="content">
|
|
<view class="content">
|
|
<!-- #ifndef H5 -->
|
|
<!-- #ifndef H5 -->
|
|
- <image class="bg-img" src="/static/img/img09.png" mode=" scaleToFill"></image>
|
|
|
|
|
|
+ <!-- <image class="bg-img" :src="baseURL+urlFile+'/img/img09.png'" mode=" scaleToFill"></image> -->
|
|
<view class="logo-img-box">
|
|
<view class="logo-img-box">
|
|
- <image class="logo-img" src="/static/img/img10.png" mode=" aspectFit"></image>
|
|
|
|
|
|
+ <!-- <image class="logo-img" src="https://zhxc2030.com/img/logo.jpg" mode=" aspectFit"></image> -->
|
|
<button class="userInfo" type="warn" open-type="getUserInfo" @getuserinfo='userInfoData'>
|
|
<button class="userInfo" type="warn" open-type="getUserInfo" @getuserinfo='userInfoData'>
|
|
<text class="iconfont iconweixin"></text>
|
|
<text class="iconfont iconweixin"></text>
|
|
<text>
|
|
<text>
|
|
@@ -16,13 +16,15 @@
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
|
|
+ import { getUserInfo } from '@/api/login.js';
|
|
// #ifdef H5
|
|
// #ifdef H5
|
|
import { loginWinxin } from '@/utils/wxAuthorized';
|
|
import { loginWinxin } from '@/utils/wxAuthorized';
|
|
// #endif
|
|
// #endif
|
|
// #ifdef MP-WEIXIN
|
|
// #ifdef MP-WEIXIN
|
|
import { loginWinxinMp } from '@/utils/wxMinProgram';
|
|
import { loginWinxinMp } from '@/utils/wxMinProgram';
|
|
|
|
+import { wechatMpAuth } from '@/api/wx';
|
|
// #endif
|
|
// #endif
|
|
-import { mapMutations } from 'vuex';
|
|
|
|
|
|
+import { mapMutations,mapState } from 'vuex';
|
|
export default {
|
|
export default {
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
@@ -33,25 +35,92 @@ export default {
|
|
onLoad(option) {
|
|
onLoad(option) {
|
|
this.loadData();
|
|
this.loadData();
|
|
},
|
|
},
|
|
|
|
+ computed: {
|
|
|
|
+ ...mapState(['baseURL','urlFile'])
|
|
|
|
+ },
|
|
methods: {
|
|
methods: {
|
|
|
|
+ ...mapMutations('user',['login', 'setUserInfo']),
|
|
loadData() {
|
|
loadData() {
|
|
|
|
+ let obj = this;
|
|
// #ifdef H5
|
|
// #ifdef H5
|
|
loginWinxin();
|
|
loginWinxin();
|
|
// #endif
|
|
// #endif
|
|
// #ifdef MP-WEIXIN
|
|
// #ifdef MP-WEIXIN
|
|
- loginWinxinMp().then((e) => {
|
|
|
|
- this.code = e.code;
|
|
|
|
|
|
+ loginWinxinMp().then(() => {
|
|
|
|
+ wx.login({
|
|
|
|
+ success(e) {
|
|
|
|
+ console.log(e);
|
|
|
|
+ obj.code = e.code;
|
|
|
|
+ },
|
|
|
|
+ fill:function (e) {
|
|
|
|
+ console.log(e)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
});
|
|
});
|
|
// #endif
|
|
// #endif
|
|
},
|
|
},
|
|
// 用户确认授权
|
|
// 用户确认授权
|
|
userInfoData(e){
|
|
userInfoData(e){
|
|
this.userInfo = e;
|
|
this.userInfo = e;
|
|
- uni.navigateTo({
|
|
|
|
- url:'/pages/redirect/redirect?code='+this.code
|
|
|
|
- })
|
|
|
|
|
|
+ console.log(e)
|
|
|
|
+ this.loadMp()
|
|
|
|
+ },
|
|
|
|
+ // #ifdef MP-WEIXIN
|
|
|
|
+ loadMp() {
|
|
|
|
+ let obj = this;
|
|
|
|
+ // 获取登录授权页数据
|
|
|
|
+ let user = obj.userInfo;
|
|
|
|
+ console.log(user)
|
|
|
|
+ // 获取推广人id
|
|
|
|
+ let spread_spid = uni.getStorageSync('spread') || '';
|
|
|
|
+ // #ifdef MP
|
|
|
|
+ let spread_code = uni.getStorageSync('spread_code') || '';
|
|
|
|
+ // #endif
|
|
|
|
+ wechatMpAuth({
|
|
|
|
+ code: obj.code,
|
|
|
|
+ iv: user.target.iv,
|
|
|
|
+ encryptedData: user.target.encryptedData,
|
|
|
|
+ spread_spid: spread_spid,
|
|
|
|
+ // #ifdef MP
|
|
|
|
+ spread_code: spread_code,
|
|
|
|
+ // #endif
|
|
|
|
+ }).then(({ data }) => {
|
|
|
|
+ obj.wchatAuth(data);
|
|
|
|
+ console.log(data)
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ // #endif
|
|
|
|
+ wchatAuth(data) {
|
|
|
|
+ let obj = this;
|
|
|
|
+ // 保存token
|
|
|
|
+ uni.setStorageSync('token', data.token);
|
|
|
|
+ // 获取用户基础信息
|
|
|
|
+ getUserInfo({}).then(e => {
|
|
|
|
+ obj.login();
|
|
|
|
+ // 保存返回用户数据
|
|
|
|
+ obj.setUserInfo(e.data);
|
|
|
|
+ console.log(uni.getStorageSync('present'),'地址')
|
|
|
|
+ let ur = uni.getStorageSync('present') || '/pages/index/index';
|
|
|
|
+ console.log(ur,'缓存的地址')
|
|
|
|
+ // 用于处理缓存bug
|
|
|
|
+ if (ur=='pages/shop/product') {
|
|
|
|
+ ur = '/pages/index/index'
|
|
|
|
+ }
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url: ur,
|
|
|
|
+ fail(e) {
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url: ur,
|
|
|
|
+ fail(e) {
|
|
|
|
+ uni.navigateTo({
|
|
|
|
+ url: '/pages/index/index',
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ });
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
};
|
|
};
|
|
</script>
|
|
</script>
|
|
@@ -80,6 +149,6 @@ page,
|
|
margin-top: 50rpx;
|
|
margin-top: 50rpx;
|
|
color: #FFFFFF;
|
|
color: #FFFFFF;
|
|
border-radius: 99rpx;
|
|
border-radius: 99rpx;
|
|
- background-color: $base-color;
|
|
|
|
|
|
+ background-color: $base-color !important;
|
|
}
|
|
}
|
|
</style>
|
|
</style>
|