代码修改

This commit is contained in:
Sliverber 2024-02-28 11:33:23 +08:00
commit 9274b50e93
10 changed files with 294 additions and 157 deletions

View File

@ -361,9 +361,9 @@ export function getinstallment(data) {
// 到首页查询ip地址
// 首页记录ip
export function logoip() {
return request.get(`login/log`, {}, {
export function getip() {
return request.get('login/log', {
noAuth: true
});
}

View File

@ -19,13 +19,12 @@ export function getWechatConfig() {
* 获取微信sdk配置
* @returns {*}
*/
export function wechatAuth(code, spread,) {
export function wechatAuth(code, spread,channelId) {
var reg=/^[0-9]+.?[0-9]*$/; //判断字符串是否为数字 ,判断正整数用/^[1-9]+[0-9]*]*$/
spread = reg.test(spread) ? spread : 0;
channelId = reg.test(channelId) ? channelId : 0;
return request.get(
"wechat/authorize/login?code=" + code + "&spread_spid=" + spread , {},
"wechat/authorize/login?code=" + code + "&spread_spid=" + spread+"&channelId="+channelId, {},
{ noAuth: true }
);
}

View File

@ -26,6 +26,7 @@ module.exports = {
TIPS_KEY: 'TIPS_KEY',
SPREAD: 'SPREAD',
CHANNELID: 'CHANNELID',
//缓存经度

View File

@ -200,10 +200,10 @@
</button>
<!-- #endif -->
<!-- #ifndef MP -->
<view class="item skeleton-rect" @click="onClickService">
<!-- <view class="item skeleton-rect" @click="onClickService">
<view class="iconfont icon-kefu"></view>
<view>客服</view>
</view>
</view> -->
<!-- #endif -->
<block v-if="type === 'normal'">
<view @click="setCollect" class='item skeleton-rect'>
@ -369,6 +369,7 @@
import cusPreviewImg from '@/components/cus-previewImg/cus-previewImg.vue'
import {
silenceBindingSpread,silenceBindingChannelId
} from "@/utils";
import parser from "@/components/jyf-parser/jyf-parser";
import {
@ -551,7 +552,7 @@
},
onLoad(options) {
// console.log(JSON.stringify(options),"options.spread")
alert("options.spread"+JSON.stringify(options))
// alert("options.spread"+JSON.stringify(options))
//
this.$set(this, 'theme', this.$Cache.get('theme'));
@ -648,6 +649,8 @@
title: that.productInfo.storeName || '',
imageUrl: that.productInfo.image || '',
path: '/pages/goods_details/index?id=' + that.id + '&spread=' + that.uid,
}
},
// #endif
@ -700,6 +703,8 @@
scene: scene,
type: 0,
href: `${HTTP_H5_URL}${curRoute}&spread=${that.uid}`,
title: that.productInfo.storeName,
summary: app.globalData.companyName,
imageUrl: that.productInfo.image,
@ -1318,7 +1323,10 @@
*/
goBuy: Debounce(function(e) {
if (this.isLogin === false) {
toLogin();
// toLogin();
uni.navigateTo({
url:'/pages/user/index'
})
} else {
this.goCat(0);
}
@ -1428,6 +1436,7 @@
}
})
},
getImageBase64: function(images) {
let that = this;
imageBase64({

View File

@ -2,8 +2,12 @@
<view :data-theme="theme">
<skeleton :show="showSkeleton" :isNodes="isNodes" ref="skeleton" loading="chiaroscuro" selector="skeleton"
bgcolor="#FFF"></skeleton>
<!-- <view class="mask" >
</view> -->
<image src="@/static/img/wait.jpg" mode="" style="width: 750rpx;height: 100vh;z-index: 1000;"></image>
<view class="page-index skeleton" :class="{'bgf':navIndex >0}"
:style="{visibility: showSkeleton ? 'hidden' : 'visible'}">
:style="{visibility: showSkeleton ? 'hidden' : 'visible'}" v-if="showwait==false">
<!-- #ifdef H5 -->
<view class="header">
<view class="serch-wrapper flex">
@ -355,7 +359,8 @@
appUpdate: {},
wxText: "点击添加到我的小程序,微信首页下拉即可访问商城。",
cardShow: 1, //1 2 3 4
locationStatus: false
locationStatus: false,
showwait:false
}
},
watch: {
@ -467,6 +472,14 @@
}
if (this.isLogin && parseInt(options.channelId) > 0) {
silenceBindingChannelId()
}
this.getipdz()
// #ifdef H5
var app_type = this.isWeiXin() ? 'weixinh5' : 'h5';
var app_type_name = this.isWeiXin() ? '微信公众号' : 'H5';
// #endif
if(app_type=='weixinh5'){
this.showwait=true
}
},
onShow() {
@ -474,7 +487,7 @@
let self = this;
if (!self.$Cache.getItem('cityList')) getCityList()
// if (!self.$Cache.getItem('cityList')) getCityList()
// #ifdef APP-PLUS
let barHeight = uni.getSystemInfoSync().statusBarHeight;
self.marTop = barHeight + 40; //
@ -492,32 +505,56 @@
let urlParams = new URLSearchParams(currentUrl);
// code
let codeValue = urlParams.get('code');
console.log(codeValue,'codeValuecodeValuecodeValue');
console.log('进入了首页');
const id = uni.getStorageSync('openid');
// let codeValue = urlParams.get('code');
// console.log(codeValue,'codeValuecodeValuecodeValue');
// console.log('');
// const id = uni.getStorageSync('openid');
if(codeValue){
console.log('登陆成功',id);
uni.setStorageSync('openid', codeValue);
let stause= uni.getStorageSync('loginstause');
if(stause){
// if(codeValue){
// console.log('',id);
// uni.setStorageSync('openid', codeValue);
// let stause= uni.getStorageSync('loginstause');
// if(stause){
console.log('进入判断1');
// console.log('1');
}else{
console.log('进入判断2');
uni.switchTab({
url:'/pages/user/index'
})
}
}else{
// }else{
// console.log('2');
// // uni.switchTab({
// // url:'/pages/user/index'
// // })
// }
// }else{
// }
// let self = this;
// if (!self.$Cache.getItem('cityList')) getCityList()
// // #ifdef APP-PLUS
// let barHeight = uni.getSystemInfoSync().statusBarHeight;
// self.marTop = barHeight + 40; //
// setTimeout(() => {
// if (self.appUpdate.openUpgrade == 'true') {
// self.appVersionConfig();
// }
// }, 1000)
// #endif
uni.showTabBar();
}
// ip
// this.getip()
},
methods: {
isWeiXin() {
// #ifndef H5
return false;
// #endif
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
},
// IP
getipdz(){
getip().then(res => {
@ -894,6 +931,15 @@
}
</style>
<style lang="scss" scoped>
.mask {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 9); /* 半透明黑色 */
z-index: 999; /* 使遮罩位于其他元素之上 */
}
.notice {
width: 100%;
height: 70rpx;

View File

@ -15,6 +15,15 @@
<view class="name" v-if="!isLogin" @tap="openAuto" >
请点击登录
</view>
<!-- <view class="name" v-if="userInfo && uid">
{{userInfo && userInfo.nickname && uid ? userInfo.nickname : ''}}
<view class="vip" v-if="userInfo.vip">
<image :src="userInfo.vipIcon" alt="">
<view style="margin-left: 10rpx;" class="vip-txt">
{{userInfo.vipName || ''}}
</view>
</view>
</view> -->
<view class="name" v-if="userInfo && uid">
{{userInfo && userInfo.nickname && uid ? userInfo.nickname : ''}}
<view class="vip" v-if="userInfo.vip">
@ -80,7 +89,7 @@
</view>
</view>
<!-- 待还款 -->
<navigator url="/pages/users/repayment/index" class="repayment">
<navigator url="/pages/users/repayment/index" class="repayment" v-if="isLogin">
<view>待还款</view> <uni-text data-v-137d5072=""
class="iconfont icon-xiangyou"><span></span></uni-text>
</navigator>
@ -297,11 +306,23 @@
});
// #endif
},
// computed: {
// isLogin() {
// return this.$store.getters.isLogin;
// }
// },
onShow: function() {
//
this.getidentityq()
// this.checj()
this.getTokenIsExist();
this.getidentityq()
setTimeout(() => {
}, 1000);
this.copyrightImage();
this.theme = this.$Cache.get('theme')
app.globalData.theme = this.$Cache.get('theme')
@ -314,40 +335,7 @@
that.pageHeight = res.windowHeight + 'px'
}
});
let currentUrl = window.location.href;
// URL
let urlParams = new URLSearchParams(currentUrl);
// code
let codeValue = urlParams.get('code');
console.log(currentUrl,'codeValuecodeValuecodeValue');
if(codeValue){
console.log('进入判断2');
uni.setStorageSync('openid', codeValue);
let stause= uni.getStorageSync('loginstause');
console.log(stause,'stausestause');
if(uni.getStorageSync('loginstause')){
console.log('进入判断3');
}else{
if(uni.getStorageSync('loginopen')){
uni.navigateTo({
url:'/pages/users/logins/index'
})
}else{
this.sendwxcode(codeValue)
}
console.log('进入判断4');
// uni.navigateTo({
// url:'/pages/users/login/index'
// })
}
}else{
}
// id
@ -362,6 +350,44 @@
},
methods: {
checj(){
let currentUrl = window.location.href;
// URL
let urlParams = new URLSearchParams(currentUrl);
// code
let codeValue = urlParams.get('code');
console.log(currentUrl,'codeValuecodeValuecodeValue');
if(codeValue){
console.log('进入判断2');
uni.setStorageSync('openid', codeValue);
if(uni.getStorageSync('loginstause')){
console.log('判断3');
uni.showModal({
content: '进入判断3'
});
}else{
uni.showModal({
content: '进入判断4'
});
this.sendwxcode(codeValue)
console.log('判断4');
}
// if(){
// uni.navigateTo({
// url:'/pages/users/logins/index'
// })
// console.log('4');
// }
}else{
}
},
sendwxcode(code){
let data={
spread_spid: '',
@ -375,8 +401,8 @@
// })
uni.request({
url: 'https://yruibao.com/prod/api/front/login/wxpublic',
// url: 'http://192.168.2.26:20411/api/front/login/wxpublic', //
// url: 'https://yruibao.com/prod/api/front/login/wxpublic',
url: 'http://192.168.2.26:20411/api/front/login/wxpublic', //
data: data,
method:'POST',
@ -390,29 +416,78 @@
url:'/pages/users/logins/index'
})
}else{
console.log(res.data.data.token,'');
let login = true
uni.setStorageSync('loginstause',login);
uni.setStorageSync('loginopen', res.data.data.openid);
this.$store.commit("LOGIN", {
'token': res.data.data.token
});
// this.$store.commit("SET_LOGIN_STATUS", true);
// uni.switchTab({
// url:'/pages/index/index'
// })
let login = true
uni.setStorageSync('loginstause',login);
let data = res.data.data;
let data = res.data.data
this.getUserInfo(data)
}
// this.text = 'request success';
},
fail:(err)=>{
uni.showModal({content: JSON.stringify(err)});
}
});
// let ceshidata ={
// isBandPhone:true,
// nikeName:'55b1d6600c5d',
// phone:'17795402553',
// token:'2118e52ef3a740d59d5bf6814778fbf0',
// uid:20
// }
// if(ceshidata.isBandPhone==false){
// console.log(' aaaaaaaaaa');
// uni.setStorageSync('loginopen', ceshidata.openid);
// uni.navigateTo({
// url:'/pages/users/logins/index'
// })
// }else{
// let login = true
// uni.setStorageSync('loginstause',login);
// uni.setStorageSync('loginopen', ceshidata.openid);
// this.$store.commit("LOGIN", {
// 'token': ceshidata.token
// });
// this.$store.commit("SET_LOGIN_STATUS", true);
// // uni.switchTab({
// // url:'/pages/index/index'
// // })
// let data = ceshidata
// this.getUserInfo(data)
// }
// this.text = 'request success';
},
getUserInfo(data){
console.log(data,'dadadada');
this.$store.commit("SETUID", data.uid);
getUserInfo().then(res => {
this.$store.commit("UPDATE_USERINFO", res.data);
console.log('成功登录了');
this.$forceUpdate()
// console.log(this.$store.getters.isLogin,'this.$store.getters.isLogin;');
// console.log(this.isLogin,'isLoginisLoginisLogin');
// this.$forceUpdate()
// this.isLogin=true
setTimeout(() => {
let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index";
if (backUrl.indexOf('/pages/users/login/index') !== -1) {
backUrl = '/pages/index/index';
@ -420,6 +495,8 @@
uni.reLaunch({
url:backUrl
});
}, 300);
})
},
@ -445,13 +522,17 @@
getTokenIsExist(){
tokenIsExistApi().then(res => {
let tokenIsExist = res.data;
console.log(this.isLogin,'this.isLoginthis.isLoginthis.isLoginthis.isLogin');
if (this.isLogin && tokenIsExist) {
console.log('1111111111111111111111');
this.getMyMenus();
this.getOrderData();
this.$store.dispatch('USERINFO').then(res => {
this.userInfo = res;
});
} else {
this.$store.commit("LOGOUT");
this.$store.commit('UPDATE_LOGIN', '');
this.$store.commit('UPDATE_USERINFO', {});

View File

@ -154,8 +154,9 @@
},
onShow() {
let abb=uni.getStorageSync('channelId')
console.log(abb,'abbabbabbabbabb');
// let abb='4'
// uni.setStorageSync('channelId', abb);
},
methods: {
//
@ -319,14 +320,15 @@
uni.showLoading({
title: '登录中'
})
let channelId=''
let channelId=0
let abb=uni.getStorageSync('channelId')
if(abb!=undefined){
channelId=abb
channelId=parseInt(abb);
}
let openid= uni.getStorageSync('loginstause');
let openid= uni.getStorageSync('openid');
console.log(typeof channelId,'channelIdchannelId');
loginMobiles({
phone: that.account,
captcha: that.captcha,

View File

@ -82,8 +82,8 @@
<!-- #ifdef H5 -->
<view class="logOut cart-color acea-row row-center-wrapper" @click="outLogin"
v-if="!this.$wechat.isWeixin() || (this.$wechat.isWeixin() && publicLoginType ==2)">退出登录</view>
<view class="logOut cart-color acea-row row-center-wrapper" @click="outLogin"
>退出登录</view>
<!-- <view class="logOut cart-color acea-row row-center-wrapper" @click="outLogin"
>退出登录</view> -->
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<view class="logOut cart-color acea-row row-center-wrapper" @click="outLogin">退出登录</view>

View File

@ -144,7 +144,6 @@
//if(!code) location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
if (code && this.options.scope !== 'snsapi_base') {
let spread = app.globalData.spread ? app.globalData.spread : 0;
let channelId = app.globalData.channelId ? app.globalData.channelId : 0;
// wechatAuth(code, Cache.get("spread"), loginType)
wechat.auth(code, spread,channelId).then(res => {

BIN
static/img/wait.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB