代码修改

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地址
// 首页记录ip
export function logoip() { export function getip() {
return request.get(`login/log`, {}, { return request.get('login/log', {
noAuth: true noAuth: true
}); });
} }

View File

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

View File

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

View File

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

View File

@ -2,8 +2,12 @@
<view :data-theme="theme"> <view :data-theme="theme">
<skeleton :show="showSkeleton" :isNodes="isNodes" ref="skeleton" loading="chiaroscuro" selector="skeleton" <skeleton :show="showSkeleton" :isNodes="isNodes" ref="skeleton" loading="chiaroscuro" selector="skeleton"
bgcolor="#FFF"></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}" <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 --> <!-- #ifdef H5 -->
<view class="header"> <view class="header">
<view class="serch-wrapper flex"> <view class="serch-wrapper flex">
@ -355,7 +359,8 @@
appUpdate: {}, appUpdate: {},
wxText: "点击添加到我的小程序,微信首页下拉即可访问商城。", wxText: "点击添加到我的小程序,微信首页下拉即可访问商城。",
cardShow: 1, //1 2 3 4 cardShow: 1, //1 2 3 4
locationStatus: false locationStatus: false,
showwait:false
} }
}, },
watch: { watch: {
@ -468,13 +473,21 @@
if (this.isLogin && parseInt(options.channelId) > 0) { if (this.isLogin && parseInt(options.channelId) > 0) {
silenceBindingChannelId() 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() { onShow() {
let self = this; let self = this;
if (!self.$Cache.getItem('cityList')) getCityList() // if (!self.$Cache.getItem('cityList')) getCityList()
// #ifdef APP-PLUS // #ifdef APP-PLUS
let barHeight = uni.getSystemInfoSync().statusBarHeight; let barHeight = uni.getSystemInfoSync().statusBarHeight;
self.marTop = barHeight + 40; // self.marTop = barHeight + 40; //
@ -492,32 +505,56 @@
let urlParams = new URLSearchParams(currentUrl); let urlParams = new URLSearchParams(currentUrl);
// code // code
let codeValue = urlParams.get('code'); // let codeValue = urlParams.get('code');
console.log(codeValue,'codeValuecodeValuecodeValue'); // console.log(codeValue,'codeValuecodeValuecodeValue');
console.log('进入了首页'); // console.log('');
const id = uni.getStorageSync('openid'); // const id = uni.getStorageSync('openid');
if(codeValue){ // if(codeValue){
console.log('登陆成功',id); // console.log('',id);
uni.setStorageSync('openid', codeValue); // uni.setStorageSync('openid', codeValue);
let stause= uni.getStorageSync('loginstause'); // let stause= uni.getStorageSync('loginstause');
if(stause){ // if(stause){
console.log('进入判断1'); // console.log('1');
}else{ // }else{
console.log('进入判断2'); // console.log('2');
uni.switchTab({ // // uni.switchTab({
url:'/pages/user/index' // // url:'/pages/user/index'
}) // // })
} // }
}else{ // }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 // ip
// this.getip() // this.getip()
}, },
methods: { methods: {
isWeiXin() {
// #ifndef H5
return false;
// #endif
var ua = navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == "micromessenger") {
return true;
} else {
return false;
}
},
// IP // IP
getipdz(){ getipdz(){
getip().then(res => { getip().then(res => {
@ -894,6 +931,15 @@
} }
</style> </style>
<style lang="scss" scoped> <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 { .notice {
width: 100%; width: 100%;
height: 70rpx; height: 70rpx;

View File

@ -12,9 +12,18 @@
<image v-else class="avatar" src="/static/images/f.png" mode="" @click="goEdit()"> <image v-else class="avatar" src="/static/images/f.png" mode="" @click="goEdit()">
</image> </image>
<view class="info"> <view class="info">
<view class="name" v-if="!isLogin" @tap="openAuto"> <view class="name" v-if="!isLogin" @tap="openAuto" >
请点击登录 请点击登录
</view> </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"> <view class="name" v-if="userInfo && uid">
{{userInfo && userInfo.nickname && uid ? userInfo.nickname : ''}} {{userInfo && userInfo.nickname && uid ? userInfo.nickname : ''}}
<view class="vip" v-if="userInfo.vip"> <view class="vip" v-if="userInfo.vip">
@ -80,7 +89,7 @@
</view> </view>
</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="" <view>待还款</view> <uni-text data-v-137d5072=""
class="iconfont icon-xiangyou"><span></span></uni-text> class="iconfont icon-xiangyou"><span></span></uni-text>
</navigator> </navigator>
@ -297,11 +306,23 @@
}); });
// #endif // #endif
}, },
// computed: {
// isLogin() {
// return this.$store.getters.isLogin;
// }
// },
onShow: function() { onShow: function() {
// //
this.getidentityq()
this.getTokenIsExist();
// this.checj()
this.getTokenIsExist();
this.getidentityq()
setTimeout(() => {
}, 1000);
this.copyrightImage(); this.copyrightImage();
this.theme = this.$Cache.get('theme') this.theme = this.$Cache.get('theme')
app.globalData.theme = this.$Cache.get('theme') app.globalData.theme = this.$Cache.get('theme')
@ -314,40 +335,7 @@
that.pageHeight = res.windowHeight + 'px' 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 // id
@ -362,7 +350,45 @@
}, },
methods: { methods: {
sendwxcode(code){ 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={ let data={
spread_spid: '', spread_spid: '',
code: code, code: code,
@ -375,8 +401,8 @@
// }) // })
uni.request({ uni.request({
url: 'https://yruibao.com/prod/api/front/login/wxpublic', // url: 'https://yruibao.com/prod/api/front/login/wxpublic',
// url: 'http://192.168.2.26:20411/api/front/login/wxpublic', // url: 'http://192.168.2.26:20411/api/front/login/wxpublic', //
data: data, data: data,
method:'POST', method:'POST',
@ -384,42 +410,93 @@
console.log(res.data); console.log(res.data);
if(res.data.data.isBandPhone==false){ if(res.data.data.isBandPhone==false){
console.log('调换 aaaaaaaaaa'); console.log('调换 aaaaaaaaaa');
uni.setStorageSync('loginopen', res.data.data.openid); uni.setStorageSync('loginopen', res.data.data.openid);
uni.navigateTo({ uni.navigateTo({
url:'/pages/users/logins/index' url:'/pages/users/logins/index'
}) })
}else{ }else{
console.log(res.data.data.token,''); let login = true
this.$store.commit("LOGIN", { uni.setStorageSync('loginstause',login);
'token': res.data.data.token uni.setStorageSync('loginopen', res.data.data.openid);
}); this.$store.commit("LOGIN", {
// uni.switchTab({ 'token': res.data.data.token
// url:'/pages/index/index' });
// }) // this.$store.commit("SET_LOGIN_STATUS", true);
let login = true
uni.setStorageSync('loginstause',login); // uni.switchTab({
let data = res.data.data; // url:'/pages/index/index'
this.getUserInfo(data) // })
}
let data = res.data.data
this.getUserInfo(data)
}
// this.text = 'request success'; // 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){ getUserInfo(data){
console.log(data,'dadadada'); console.log(data,'dadadada');
this.$store.commit("SETUID", data.uid); this.$store.commit("SETUID", data.uid);
getUserInfo().then(res => { getUserInfo().then(res => {
this.$store.commit("UPDATE_USERINFO", res.data); this.$store.commit("UPDATE_USERINFO", res.data);
console.log('成功登录了');
this.$forceUpdate()
let backUrl = this.$Cache.get(BACK_URL) || "/pages/index/index";
if (backUrl.indexOf('/pages/users/login/index') !== -1) { // console.log(this.$store.getters.isLogin,'this.$store.getters.isLogin;');
backUrl = '/pages/index/index'; // console.log(this.isLogin,'isLoginisLoginisLogin');
} // this.$forceUpdate()
uni.reLaunch({
url: backUrl
}); // 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';
}
uni.reLaunch({
url:backUrl
});
}, 300);
}) })
}, },
@ -445,13 +522,17 @@
getTokenIsExist(){ getTokenIsExist(){
tokenIsExistApi().then(res => { tokenIsExistApi().then(res => {
let tokenIsExist = res.data; let tokenIsExist = res.data;
console.log(this.isLogin,'this.isLoginthis.isLoginthis.isLoginthis.isLogin');
if (this.isLogin && tokenIsExist) { if (this.isLogin && tokenIsExist) {
console.log('1111111111111111111111');
this.getMyMenus(); this.getMyMenus();
this.getOrderData(); this.getOrderData();
this.$store.dispatch('USERINFO').then(res => { this.$store.dispatch('USERINFO').then(res => {
this.userInfo = res; this.userInfo = res;
}); });
} else { } else {
this.$store.commit("LOGOUT"); this.$store.commit("LOGOUT");
this.$store.commit('UPDATE_LOGIN', ''); this.$store.commit('UPDATE_LOGIN', '');
this.$store.commit('UPDATE_USERINFO', {}); this.$store.commit('UPDATE_USERINFO', {});

View File

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

View File

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

View File

@ -144,8 +144,7 @@
//if(!code) location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url))); //if(!code) location.replace(decodeURIComponent(decodeURIComponent(option.query.back_url)));
if (code && this.options.scope !== 'snsapi_base') { if (code && this.options.scope !== 'snsapi_base') {
let spread = app.globalData.spread ? app.globalData.spread : 0; let spread = app.globalData.spread ? app.globalData.spread : 0;
let channelId = app.globalData.channelId ? app.globalData.channelId : 0;
let channelId = app.globalData.channelId ? app.globalData.channelId : 0;
// wechatAuth(code, Cache.get("spread"), loginType) // wechatAuth(code, Cache.get("spread"), loginType)
wechat.auth(code, spread,channelId).then(res => { wechat.auth(code, spread,channelId).then(res => {
if (res.type === 'register') { if (res.type === 'register') {
@ -252,7 +251,7 @@
let userInfo = {}; let userInfo = {};
userInfo.code = code; userInfo.code = code;
userInfo.spread_spid = app.globalData.spread; //广ID userInfo.spread_spid = app.globalData.spread; //广ID
userInfo.channelId = app.globalData.channelId; //ID userInfo.channelId = app.globalData.channelId; //ID
userInfo.avatar = ''; userInfo.avatar = '';
userInfo.nickName = '微信用户'; userInfo.nickName = '微信用户';
userInfo.type = 'routine' userInfo.type = 'routine'
@ -268,7 +267,7 @@
let userInfo = res.userInfo; let userInfo = res.userInfo;
userInfo.code = code; userInfo.code = code;
userInfo.spread_spid = app.globalData.spread; //广ID userInfo.spread_spid = app.globalData.spread; //广ID
userInfo.channelId = app.globalData.channelId; //ID userInfo.channelId = app.globalData.channelId; //ID
userInfo.avatar = userInfo.userInfo.avatarUrl; userInfo.avatar = userInfo.userInfo.avatarUrl;
userInfo.city = userInfo.userInfo.city; userInfo.city = userInfo.userInfo.city;
userInfo.country = userInfo.userInfo.country; userInfo.country = userInfo.userInfo.country;

BIN
static/img/wait.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB