From f1bcc817fa0b5e3256b386542679c2e9f0b8ee3e Mon Sep 17 00:00:00 2001 From: Sliverber <2622874537@qq.com> Date: Tue, 27 Feb 2024 09:45:51 +0800 Subject: [PATCH] 11 --- App.vue | 1 + api/order.js | 11 +- api/user.js | 18 + components/login_mobile/index.vue | 1 + components/payments/index.vue | 162 ++++++-- libs/wechat.js | 46 +-- pages/index/index.vue | 64 ++- pages/user/index.vue | 67 +++- pages/users/app_login/index.vue | 1 + pages/users/login/index.vue | 4 + pages/users/logins/index.vue | 647 ++++++++++++++++++++++++++++++ pages/users/order_list/index.vue | 5 +- pages/users/repayment/index.vue | 21 +- pages/users/signin/index.vue | 20 +- pages/users/user_info/index.vue | 3 + 15 files changed, 985 insertions(+), 86 deletions(-) create mode 100644 pages/users/logins/index.vue diff --git a/App.vue b/App.vue index 3bcb583..092fe1d 100644 --- a/App.vue +++ b/App.vue @@ -154,6 +154,7 @@ state, scope } = option.query; + console.log(option.query,'option.queryoption.queryoption.query'); if (code && code != uni.getStorageSync('snsapiCode') && location.pathname.indexOf( '/pages/users/wechat_login/index') === -1) { // 存储静默授权code diff --git a/api/order.js b/api/order.js index 703f1e9..23ec45b 100644 --- a/api/order.js +++ b/api/order.js @@ -27,7 +27,7 @@ export function changeCartNum(cartId, number) { return request.post("cart/num", { id: cartId, number: number - }, {}, 1); + }, ); } /** * 清除购物车 @@ -40,7 +40,10 @@ export function cartDel(ids) { ids: ids }, {}, 1); } - +export function sendwxcodes(data) { + console.log(data,'datadatadatadata'); + return request.post('user/wxcode', data); +} /** * 购物车重选提交 * @@ -148,8 +151,8 @@ export function orderTake(uni) { * */ // 立即签约请求 -export function getnowqy(uni) { - return request.post('order/signContract/' + uni, { +export function getnowqy(uni,type) { + return request.post('order/signContract/' + uni+'/'+type, { // id:uni }); } diff --git a/api/user.js b/api/user.js index 3fbb5ef..601a956 100644 --- a/api/user.js +++ b/api/user.js @@ -381,6 +381,24 @@ export function spread(puid) { return request.get("user/bindSpread?spreadPid="+ puid); } +export function sendwxcodes(code) +{ + console.log(code,'codecode'); + return request.get("user/wxcode?code="+ code); +} +// export function sendwxcodes(code,channel,spread) { +// console.log(code,'codecodecodecode'); +// return request.post("login/wxpublic", { +// spread_spid: spread, +// code: code, +// channel_id:channel +// }, ); + +// } +// export function sendwxcodes(data) { +// console.log(data,'datadatadatadata'); +// return request.post('user/wxcode', data); +// } /** // * 静默绑定推广人 // * @param {Object} channelId diff --git a/components/login_mobile/index.vue b/components/login_mobile/index.vue index d23b44f..f08f385 100644 --- a/components/login_mobile/index.vue +++ b/components/login_mobile/index.vue @@ -173,6 +173,7 @@ }) }) } else { + console.log('调用了'); getUserPhone({ captcha: that.codeNum, phone: that.account, diff --git a/components/payments/index.vue b/components/payments/index.vue index dcdcba1..d7432ea 100644 --- a/components/payments/index.vue +++ b/components/payments/index.vue @@ -52,29 +52,30 @@ }, data() { return { + payType:'', formContent: '', payChannel: '', openId: '', checkid: '', - intervalId: null, // 用于存储定时器的ID + intervalId: null, // 用于存储定时器的ID //支付方式 payMode: [ - { - "name": "微信支付", - "icon": "icon-weixin2", - value: 'weixin', - title: '微信快捷支付', - payStatus: 1, - }, - // { - // "name": "余额支付", - // "icon": "icon-yuezhifu", - // value: 'yue', - // title: '可用余额:', - // payStatus: 1, - // number: 0 - // }, - // // #ifndef MP + // { + // "name": "微信支付", + // "icon": "icon-weixin2", + // value: 'weixin', + // title: '微信快捷支付', + // payStatus: 1, + // }, + // // { + // // "name": "余额支付", + // // "icon": "icon-yuezhifu", + // // value: 'yue', + // // title: '可用余额:', + // // payStatus: 1, + // // number: 0 + // // }, + // // #ifndef MP-ALIPAY // { // "name": "支付宝支付", // "icon": "icon-zhifubao", @@ -88,14 +89,80 @@ }, computed: mapGetters(['systemPlatform', 'userInfo', 'productType']), created() { + + // #ifdef H5 + var app_type = this.isWeiXin() ? 'weixinh5' : 'h5'; + var app_type_name = this.isWeiXin() ? '微信公众号' : 'H5'; + // #endif + + // #ifdef MP-WEIXIN + var app_type = 'weixin'; + var app_type_name = '微信小程序'; + + // #endif + + // #ifdef MP-ALIPAY + var app_type = 'aliapp'; + var app_type_name = '支付宝小程序'; + // #endif + + // #ifdef MP-BAIDU + var app_type = 'baiduapp'; + var app_type_name = '百度小程序'; + // #endif + + // #ifdef MP-TOUTIAO + var app_type = 'MP-TOUTIAO'; + var app_type_name = '头条小程序'; + // #endif + + // #ifdef MP-QQ + var app_type = 'MP-QQ'; + var app_type_name = 'QQ小程序'; + // #endif + this.payType=app_type + console.log('app_type_name',app_type_name); + if (app_type_name == '微信公众号') { + this.payMode = [{ + "name": "微信支付", + "icon": "icon-weixin2", + value: 'weixin', + title: '微信快捷支付', + payStatus: 1, + }, ] + } else if(app_type_name == 'H5') { + this.payMode = [ { + "name": "支付宝支付", + "icon": "icon-zhifubao", + value: 'alipay', + title: '支付宝快捷支付', + payStatus: 1, + }] + } // this.alipayQueryPay() this.payConfig(); // this.payMode[1].number = this.userInfo.nowMoney; this.importAliPayScript(); // 导入支付宝脚本 this.listenMessageFromMiniProgram(); // 监听来自小程序的消息 + + + }, + onShow() { + }, methods: { + isWeiXin() { + // #ifndef H5 + return false; + // #endif + var ua = navigator.userAgent.toLowerCase(); + if (ua.match(/MicroMessenger/i) == "micromessenger") { + return true; + } else { + return false; + } + }, // 导入 my 对象所需的脚本 importAliPayScript() { if (navigator.userAgent.indexOf('AliApp') > -1) { @@ -120,30 +187,30 @@ }; }, alipayQueryPay() { - + let id = this.checkid alipayQueryPayResult(id).then(res => { - if(res.data==true){ - + if (res.data == true) { + uni.navigateTo({ - url: '/pages/users/alipay_returns/alipay_return?id='+id + url: '/pages/users/alipay_returns/alipay_return?id=' + id }) - }else{ + } else { setTimeout(() => { - this.alipayQueryPay() - }, 1000); + this.alipayQueryPay() + }, 1000); } - if(res.data==null){ + if (res.data == null) { setTimeout(() => { - this.alipayQueryPay() - }, 1000); + this.alipayQueryPay() + }, 1000); } }).catch(err => { - + }) }, // startPolling() { - + // // 开始轮询,设置定时器每隔一段时间执行一次alipayQueryPay方法 // this.intervalId = my.setInterval(() => { // this.alipayQueryPay(); @@ -159,7 +226,7 @@ console.log('支付宝小程序支付'); let that = this console.log(that.order_id, 'idididiid'); - + my.tradePay({ tradeNO: that.order_id, success: (res) => { @@ -235,6 +302,23 @@ that.payChannel = that.systemPlatform === 'ios' ? 'weixinAppIos' : 'weixinAppAndroid'; } // #endif + const storedSystemInfo = uni.getStorageSync('systemInfo'); + console.log('存储的系统信息:', storedSystemInfo); + + // if (storedSystemInfo == 'web') { + // paytype = 'weixinh5' + // } + console.log(paytype, 'payTypepayTypepayType'); + let id = uni.getStorageSync('openids'); + + // 判断id是否存在 + if (id) { + // 如果存在,将其赋值给that.openid + + that.openId=id + + } + // that.openId='omtaz6jkDPjbYdR8FNiEf6VEqSHI' orderPays({ id: that.order_id, openid: that.openId, @@ -245,7 +329,8 @@ // // #ifndef MP // payChannel:that.payChannel, // // #endif - payType: paytype, + payType: that.payType, + // scene: that.productType === 'normal' ? 0 : 1177 //下单时小程序的场景值 }).then(res => { let jsConfig = res.data.jsConfig; @@ -269,8 +354,9 @@ break; case 'weixinh5': uni.hideLoading(); - location.replace(jsConfig.mwebUrl + '&redirect_url=' + window.location.protocol + - '//' + window.location.host + goPages + '&status=1'); + that.weixinPay(jsConfig); + // location.replace(jsConfig.mwebUrl + '&redirect_url=' + window.location.protocol + + // '//' + window.location.host + goPages + '&status=1'); return that.$util.Tips({ title: "支付中", icon: 'success' @@ -281,9 +367,9 @@ }); break; case 'alipay': - // + // // uni.hideLoading(); - if(that.openId==''){ + if (that.openId == '') { if (this.$wechat.isWeixin()) { //微信公众号内支付 } else { @@ -299,15 +385,15 @@ document.forms['punchout_form'].submit(); }) } - }else{ + } else { this.aliPay(that.order_id) } //#ifdef H5 - + //#endif //#ifdef MP-ALIPAY - + //#endif // #ifdef APP-PLUS let alipayRequest = res.data.alipayRequest; diff --git a/libs/wechat.js b/libs/wechat.js index c4a9e74..6054cdc 100644 --- a/libs/wechat.js +++ b/libs/wechat.js @@ -175,36 +175,36 @@ class AuthWechat { * 自动去授权 */ oAuth(snsapiBase, url) { - if (uni.getStorageSync(WX_AUTH) && store.state.app.token && snsapiBase == 'snsapi_base') return; - const { - code - } = parseQuery(); - if (!code || code == uni.getStorageSync('snsapiCode')) { - return this.toAuth(snsapiBase, url); - } else { - if (Cache.has('snsapiKey')) - return this.auth(code).catch(error => { - uni.showToast({ - title: error, - icon: 'none' - }) - }) - } - // if (uni.getStorageSync(WX_AUTH) && store.state.app.token) return; + // if (uni.getStorageSync(WX_AUTH) && store.state.app.token && snsapiBase == 'snsapi_base') return; // const { // code // } = parseQuery(); - // if (!code){ - // return this.toAuth(snsapiBase,url); - // }else{ - // if(Cache.has('snsapiKey')) - // return this.auth(code).catch(error=>{ + // if (!code || code == uni.getStorageSync('snsapiCode')) { + // return this.toAuth(snsapiBase, url); + // } else { + // if (Cache.has('snsapiKey')) + // return this.auth(code).catch(error => { // uni.showToast({ - // title:error, - // icon:'none' + // title: error, + // icon: 'none' // }) // }) // } + if (uni.getStorageSync(WX_AUTH) && store.state.app.token) return; + const { + code + } = parseQuery(); + if (!code){ + return this.toAuth(snsapiBase,url); + }else{ + if(Cache.has('snsapiKey')) + return this.auth(code).catch(error=>{ + uni.showToast({ + title:error, + icon:'none' + }) + }) + } } clearAuthStatus() { diff --git a/pages/index/index.vue b/pages/index/index.vue index 9372a9b..0dcfcba 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -172,12 +172,14 @@ getAppVersion, } from '@/api/api.js'; import { - spread + spread, + } from "@/api/user"; // #ifdef MP-WEIXIN || APP-PLUS import { getTemlIds, - logoip + logoip, + } from '@/api/api.js'; // #endif // #ifdef H5 @@ -370,6 +372,31 @@ this.setTabList() }, onLoad(options) { + + // const env = uni.getEnv(); + + // 获取系统信息 + const systemInfo = uni.getSystemInfoSync(); + console.log(systemInfo,'systemInfosystemInfo'); + // 判断当前环境 + uni.setStorageSync('systemInfo', systemInfo.uniPlatform); + // const storedSystemInfo = uni.getStorageSync('systemInfo'); + + // console.log('存储的系统信息:', storedSystemInfo); + // if (systemInfo.uniPlatform === 'android' || systemInfo.uniPlatform === 'ios') { + // console.log('当前环境是 App'); + // } else if (systemInfo.uniPlatform === 'mp-weixin') { + // console.log('当前环境是微信小程序'); + // } else if (systemInfo.uniPlatform === 'h5') { + // console.log('当前环境是 H5'); + // } else if (systemInfo.uniPlatform === 'mp-alipay') { + // console.log('当前环境是支付宝小程序'); + // } else if (systemInfo.uniPlatform === 'mp-toutiao') { + // console.log('当前环境是字节跳动小程序'); + // } else { + // console.log('未知环境'); + // } + if (app.globalData.isIframe) { setTimeout(() => { let active; @@ -438,9 +465,37 @@ // 调用记录ip - this.getip() + // this.getip() }, onShow() { + let currentUrl = window.location.href; + + // 解析URL,提取参数 + let urlParams = new URLSearchParams(currentUrl); + + // 获取名为code的参数的值 + 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){ + + console.log('进入判断1'); + + }else{ + console.log('进入判断2'); + uni.switchTab({ + url:'/pages/user/index' + }) + } + }else{ + + } let self = this; if (!self.$Cache.getItem('cityList')) getCityList() // #ifdef APP-PLUS @@ -458,10 +513,11 @@ // this.getip() }, methods: { + // 首页记录ip getip(){ logoip().then(res => { - console.log(res,'记录ip') + }) }, diff --git a/pages/user/index.vue b/pages/user/index.vue index 635daaa..f66117a 100644 --- a/pages/user/index.vue +++ b/pages/user/index.vue @@ -151,10 +151,12 @@ } from '@/config/cache'; import { getMenuList, - copyrightApi + copyrightApi, + } from '@/api/user.js'; import { - orderData + orderData, + sendwxcodes } from '@/api/order.js'; import { getCity, @@ -297,6 +299,7 @@ }, onShow: function() { // 调用查询是否实名 + this.getidentityq() this.getTokenIsExist(); this.copyrightImage(); @@ -311,14 +314,72 @@ 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{ + + console.log('进入判断4'); + this.sendwxcode(codeValue) + // uni.navigateTo({ + // url:'/pages/users/login/index' + // }) + } + }else{ + + } + + + // 判断id是否存在 + + // 打印code的值 + // #endif // #ifdef MP let query = uni.createSelectorQuery(); let dom = query.select('.new-users'); // #endif + }, methods: { - + sendwxcode(code){ + let data={ + spread_spid: '', + code: code, + channel_id:'' + } + console.log(code,'wxcodewxcodewxcodewxcode'); + // sendwxcodes(code).then(res => { + // console.log('wxcodewxcodewxcodewxcode'); + // // uni.setStorageSync('openids', res.data.openId); + + // }) + uni.request({ + // url: 'https://yruibao.com/prod/api/front/login/wxpublic', + url: 'http://192.168.2.26:20411/api/front/login/wxpublic', //仅为示例,并非真实接口地址。 + data: data, + method:'POST', + + success: (res) => { + console.log(res.data); + // this.text = 'request success'; + } + }); + }, // 查询是否进行过身份保存 getidentityq:function(){ let data = { diff --git a/pages/users/app_login/index.vue b/pages/users/app_login/index.vue index 9bb948a..9059a7c 100644 --- a/pages/users/app_login/index.vue +++ b/pages/users/app_login/index.vue @@ -85,6 +85,7 @@ } = options; that.options = options if (options.authKey) that.authKey = options.authKey + console.log(options.authKey,'options.authKeyoptions.authKeyoptions.authKey'); if (options.appleShow) that.appleShow = options.appleShow if (options.code) that.wxCode = options.code }, diff --git a/pages/users/login/index.vue b/pages/users/login/index.vue index 85917f3..3bbbd8f 100644 --- a/pages/users/login/index.vue +++ b/pages/users/login/index.vue @@ -393,6 +393,8 @@ that.$util.Tips({title:res.message}); uni.hideLoading(); that.sendCode(); + let login = true + uni.setStorageSync('loginstause',login); }) .catch(err => { uni.hideLoading(); @@ -431,6 +433,8 @@ }); uni.hideLoading(); that.getUserInfo(data); + let login = true + uni.setStorageSync('loginstause',login); }) .catch(e => { uni.hideLoading(); diff --git a/pages/users/logins/index.vue b/pages/users/logins/index.vue new file mode 100644 index 0000000..4837514 --- /dev/null +++ b/pages/users/logins/index.vue @@ -0,0 +1,647 @@ + + + diff --git a/pages/users/order_list/index.vue b/pages/users/order_list/index.vue index b84754a..0691d4f 100644 --- a/pages/users/order_list/index.vue +++ b/pages/users/order_list/index.vue @@ -233,7 +233,10 @@ this.$Cache.set('qyids', id) // 跳转到签署页面 this.logoflag = true //logo显示 - getnowqy(id).then(res => { + const storedSystemInfo = uni.getStorageSync('systemInfo'); + + console.log('存储的系统信息:', storedSystemInfo,id); + getnowqy(id,storedSystemInfo).then(res => { this.logoflag = false //logo隐藏 this.https = res.data.url console.log(res.data.url,2222) diff --git a/pages/users/repayment/index.vue b/pages/users/repayment/index.vue index 7dc98d8..3fb97b8 100644 --- a/pages/users/repayment/index.vue +++ b/pages/users/repayment/index.vue @@ -17,8 +17,18 @@ 须还金额:¥{{item.repaymentAmount}} - - {{item.repaymentStatus == 'Pending'? '待还款' : 'Partial' ? '部分还款' : 'Paid' ? '已还款' : '逾期'}} + + 待还款 + + + 部分还款 + + + 已还款 + + + 逾期 + @@ -54,7 +64,7 @@ }, onLoad() { - this.getData() + uni.webView.postMessage({ data: { action: 'authorize' @@ -71,6 +81,11 @@ // step 4. 接受小程序发过来的用户信息 }, + onShow() { + + + this.getData() + }, methods: { toreturn(){ console.log('点击了'); diff --git a/pages/users/signin/index.vue b/pages/users/signin/index.vue index dbc6df9..5d7626d 100644 --- a/pages/users/signin/index.vue +++ b/pages/users/signin/index.vue @@ -52,17 +52,17 @@ } }, onLoad(option) { - // this.orderNo = this.$Cache.get('qyids') - // console.log(this.id) - this.orderNo = option.orderId - let token =option.token - console.log(token,'tokentokentokentokentoken'); - this.$store.commit("LOGIN", { - 'token': token - }); + this.orderNo = this.$Cache.get('qyids') + console.log(this.id) + // this.orderNo = option.orderId + // let token =option.token + // console.log(token,'tokentokentokentokentoken'); + // this.$store.commit("LOGIN", { + // 'token': token + // }); // this.shopobj = JSON.parse(option.shopobj) - // this.getnews() - // this.logoflag = true + this.getnews() + this.logoflag = true this.timer = setInterval(() => { this.getnews() diff --git a/pages/users/user_info/index.vue b/pages/users/user_info/index.vue index 68a9a99..6e316de 100644 --- a/pages/users/user_info/index.vue +++ b/pages/users/user_info/index.vue @@ -82,6 +82,8 @@ 退出登录 + 退出登录 退出登录 @@ -216,6 +218,7 @@ import { login } from '../../../api/public'; uni.reLaunch({ url: '/pages/index/index' }); + uni.clearStorage(); }) .catch(err => { uni.hideLoading();