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 @@ +<template> + <div class="login-wrapper" :data-theme="theme"> + <div class="shading"> + <!-- <image :src="logoUrl"/> --> + <image :src="logoUrl"/> + <!-- <image src="/static/images/logo2.png" v-if="!logoUrl" /> --> + </div> + <div class="whiteBg" v-if="formItem === 1"> + <div class="list" v-if="current !== 1"> + <form @submit.prevent="submit"> + <div class="item"> + <div class="acea-row row-middle"> + <image src="/static/images/phone_1.png" style="width: 24rpx; height: 34rpx;"></image> + <input type="number" class="texts" placeholder="输入手机号码" v-model="account" maxlength="11" required/> + </div> + </div> + <div class="item"> + <div class="acea-row row-middle"> + <image src="/static/images/code_2.png" style="width: 28rpx; height: 32rpx;"></image> + <input type="password" class="texts" placeholder="填写登录密码" maxlength="18" v-model="password" required /> + </div> + </div> + </form> + </div> + <div class="list" v-if="current !== 0 || appLoginStatus || appleLoginStatus"> + <div class="item"> + <div class="acea-row row-middle"> + <image src="/static/images/phone_1.png" style="width: 24rpx; height: 34rpx;"></image> + <input type="number" class="texts" placeholder="输入手机号码" v-model="account" maxlength="11"/> + </div> + </div> + <div class="item"> + <div class="acea-row row-middle"> + <image src="/static/images/code_2.png" style="width: 28rpx; height: 32rpx;"></image> + <input type="number" placeholder="填写验证码" class="codeIput" v-model="captcha" maxlength="6" /> + <button class="code main_color" :disabled="disabled" :class="disabled === true ? 'on' : ''" @click="code"> + {{ text }} + </button> + </div> + </div> + <div class="item" v-if="isShowCode"> + <div class="acea-row row-middle"> + <image src="/static/images/code_2.png" style="width: 28rpx; height: 32rpx;"></image> + <input type="number" placeholder="填写验证码" class="codeIput" v-model="codeVal" maxlength="6"/> + <div class="code" @click="again"><img :src="codeUrl" /></div> + </div> + </div> + </div> + <div class="logon bg_color" @click="loginMobile" v-if="current !== 0">登录</div> + <div class="logon bg_color" @click="submit" v-if="current === 0">登录</div> + <!-- #ifndef APP-PLUS --> + <div class="tips"> + <div v-if="current==0" @click="current = 1">快速登录</div> + <!-- <div v-if="current==1" @click="current = 0">账号登录</div> --> + </div> + <!-- #endif --> + <!-- #ifdef APP-PLUS --> + <view class="appLogin" v-if="!appLoginStatus && !appleLoginStatus"> + <view class="hds"> + <span class="line"></span> + <p>其他方式登录</p> + <span class="line"></span> + </view> + <view class="btn-wrapper"> + <view class="btn wx" @click="wxLogin"> + <span class="iconfont icon-s-weixindenglu1"></span> + </view> + <view class="btn mima" v-if="current == 1" @click="current =0"> + <span class="iconfont icon-s-mimadenglu1"></span> + </view> + <view class="btn yanzheng" v-if="current == 0" @click="current =1"> + <span class="iconfont icon-s-yanzhengmadenglu1"></span> + </view> + <view class="btn apple-btn" @click="appleLogin" v-if="appleShow"> + <view class="iconfont icon-s-pingguo"></view> + </view> + </view> + </view> + <!-- #endif --> + </div> + <div class="bottom"></div> + </div> +</template> +<script> + import dayjs from "@/plugin/dayjs/dayjs.min.js"; + import sendVerifyCode from "@/mixins/SendVerifyCode"; + import { + loginH5, + loginMobile, + registerVerify, + register, + // getCodeApi, + getUserInfo + } from "@/api/user"; + let app = getApp(); + import attrs, {required,alpha_num,chs_phone} from "@/utils/validate"; + import {validatorDefaultCatch} from "@/utils/dialog"; + import {getLogo, appAuth, appleLogin} from "@/api/public"; + import {VUE_APP_API_URL} from "@/utils"; + import Routine from '@/libs/routine'; + import {Debounce} from '@/utils/validate.js' + const BACK_URL = "login_back_url"; + + export default { + name: "Login", + mixins: [sendVerifyCode], + data: function() { + return { + navList: ["快速登录", "账号登录"], + current: 1, + account: "", + password: "", + captcha: "", + formItem: 1, + type: "login", + logoUrl: "", + keyCode: "", + codeUrl: "", + codeVal: "", + isShowCode: false, + platform: '', + appLoginStatus: false, // 微信登录强制绑定手机号码状态 + appUserInfo: null, // 微信登录保存的用户信息 + appleLoginStatus: false, // 苹果登录强制绑定手机号码状态 + appleUserInfo: null, + appleShow: false ,// 苹果登录版本必须要求ios13以上的 + theme:app.globalData.theme, + }; + }, + watch:{ + formItem:function(nval,oVal){ + if(nval == 1){ + this.type = 'login' + }else{ + this.type = 'register' + } + } + }, + mounted: function() { + this.getCode(); + this.getLogoImage(); + }, + onLoad() { + let self = this + uni.getSystemInfo({ + success: function(res) { + if (res.platform.toLowerCase() == 'ios' && res.system.split(' ')[1] >= '13') { + self.appleShow = true + } + } + }); + }, + methods: { + // 苹果登录 + appleLogin() { + let self = this + this.account = '' + this.captcha = '' + uni.showLoading({ + title: '登录中' + }) + uni.login({ + provider: 'apple', + timeout: 10000, + success(loginRes) { + uni.getUserInfo({ + provider: 'apple', + success: function(infoRes) { + self.appleUserInfo = infoRes.userInfo + self.appleLoginApi() + }, + fail() { + uni.hideLoading() + uni.showToast({ + title: '获取用户信息失败', + icon: 'none', + duration: 2000 + }) + }, + complete() { + uni.hideLoading() + } + }); + }, + fail(error) { + uni.hideLoading() + console.log(error) + } + }) + }, + // 苹果登录Api + appleLoginApi() { + let self = this + appleLogin({ + openId: self.appleUserInfo.openId, + email: self.appleUserInfo.email == undefined ? '' :self.appleUserInfo.email, + identityToken: self.appleUserInfo.identityToken || '' + }).then((res) => { + this.$store.commit("LOGIN", { + 'token': res.data.token + }); + this.getUserInfo(res.data); + }).catch(error => { + uni.hideLoading(); + uni.showModal({ + title: '提示', + content: `错误信息${error}`, + success: function(res) { + if (res.confirm) { + console.log('用户点击确定'); + } else if (res.cancel) { + console.log('用户点击取消'); + } + } + }); + }) + }, + // App微信登录 + wxLogin:Debounce(function() { + let self = this + this.account = '' + this.captcha = '' + uni.showLoading({ + title: '登录中' + }) + uni.login({ + provider: 'weixin', + success: function(loginRes) { + // 获取用户信息 + uni.getUserInfo({ + provider: 'weixin', + success: function(infoRes) { + uni.hideLoading(); + self.appUserInfo = infoRes.userInfo + self.appUserInfo.type = self.platform === 'ios' ? 'iosWx' : 'androidWx' + self.wxLoginGo(self.appUserInfo) + }, + fail() { + uni.hideLoading(); + uni.showToast({ + title: '获取用户信息失败', + icon: 'none', + duration: 2000 + }) + }, + complete() { + uni.hideLoading() + } + }); + }, + fail() { + uni.hideLoading() + uni.showToast({ + title: '登录失败', + icon: 'none', + duration: 2000 + }) + } + }); + }), + wxLoginGo(userInfo) { + appAuth(userInfo).then(res => { + if (res.data.type === 'register') { + uni.navigateTo({ + url: '/pages/users/app_login/index?authKey='+res.data.key + }) + } + if (res.data.type === 'login') { + this.$store.commit("LOGIN", { + 'token': res.data.token + }); + this.getUserInfo(res.data); + } + }).catch(res => { + this.$util.Tips({ + title: res + }); + }); + }, + again() { + this.codeUrl = + VUE_APP_API_URL + + "/sms_captcha?" + + "key=" + + this.keyCode + + Date.parse(new Date()); + }, + getCode() { + let that = this + }, + async getLogoImage() { + let that = this; + getLogo().then(res => { + that.logoUrl = res.data.logoUrl?res.data.logoUrl:'/static/images/logo2.png'; + }); + }, + //手机号验证码登录 + loginMobile:Debounce(function() { + let that = this; + if (!that.account) return that.$util.Tips({ + title: '请填写手机号码' + }); + if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({ + title: '请输入正确的手机号码' + }); + if (!that.captcha) return that.$util.Tips({ + title: '请填写验证码' + }); + if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({ + title: '请输入正确的验证码' + }); + uni.showLoading({ + title: '登录中' + }) + loginMobile({ + phone: that.account, + captcha: that.captcha, + spread_spid: that.$Cache.get("spread"), + + + }) + .then(res => { + let data = res.data; + let newTime = Math.round(new Date() / 1000); + this.$store.commit("LOGIN", { + 'token': res.data.token + }); + uni.hideLoading(); + that.getUserInfo(data); + }) + .catch(res => { + uni.hideLoading(); + that.$util.Tips({ + title: res + }); + }); + }), + async register() { + let that = this; + if (!that.account) return that.$util.Tips({ + title: '请填写手机号码' + }); + if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({ + title: '请输入正确的手机号码' + }); + if (!that.captcha) return that.$util.Tips({ + title: '请填写验证码' + }); + if (!/^[\w\d]+$/i.test(that.captcha)) return that.$util.Tips({ + title: '请输入正确的验证码' + }); + if (!that.password) return that.$util.Tips({ + title: '请填写密码' + }); + if (!/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$/i.test(that.password)) return that.$util.Tips({ + title: '您输入的密码过于简单' + }); + register({ + account: that.account, + captcha: that.captcha, + password: that.password, + spread_spid: that.$Cache.get("spread"), + + + }) + .then(res => { + that.$util.Tips({ + title: res + }); + that.formItem = 1; + }) + .catch(res => { + that.$util.Tips({ + title: res + }); + }); + }, + async code() { + let that = this; + if (!that.account) return that.$util.Tips({ + title: '请填写手机号码' + }); + if (!/^1(3|4|5|7|8|9|6)\d{9}$/i.test(that.account)) return that.$util.Tips({ + title: '请输入正确的手机号码' + }); + if (that.formItem == 2) that.type = "register"; + uni.showLoading({ + title: '加载中...' + }) + await registerVerify(that.account) + .then(res => { + + that.$util.Tips({title:res.message}); + uni.hideLoading(); + that.sendCode(); + let login = true + uni.setStorageSync('loginstause',login); + }) + .catch(err => { + uni.hideLoading(); + return that.$util.Tips({ + title: err + }); + }); + }, + navTap: function(index) { + this.current = index; + }, + //账号密码登录 + submit:Debounce(function() { + let that = this; + if (!that.account) return that.$util.Tips({ + title: '请填写账号' + }); + if (!/^[\w\d]{5,16}$/i.test(that.account)) return that.$util.Tips({ + title: '请输入正确的账号' + }); + if (!that.password) return that.$util.Tips({ + title: '请填写密码' + }); + uni.showLoading({ + title: '登录中' + }) + loginH5({ + account: that.account, + password: that.password, + spread_spid: that.$Cache.get("spread"), + + + }).then(({data}) => { + this.$store.commit("LOGIN", { + 'token': data.token, + }); + uni.hideLoading(); + that.getUserInfo(data); + let login = true + uni.setStorageSync('loginstause',login); + }) + .catch(e => { + uni.hideLoading(); + that.$util.Tips({ + title: e + }); + }); + }), + getUserInfo(data){ + this.$store.commit("SETUID", data.uid); + getUserInfo().then(res => { + this.$store.commit("UPDATE_USERINFO", res.data); + 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 + }); + }) + }, + } + }; +</script> +<style lang="scss" scoped> + page { + background: #fff; + } + .appLogin { + margin-top: 60rpx; + + .hds { + display: flex; + justify-content: center; + align-items: center; + font-size: 24rpx; + color: #B4B4B4; + + .line { + width: 68rpx; + height: 1rpx; + background: #CCCCCC; + } + + p { + margin: 0 20rpx; + } + } + + .btn-wrapper { + display: flex; + align-items: center; + justify-content: center; + margin-top: 30rpx; + + .btn { + display: flex; + align-items: center; + justify-content: center; + width: 68rpx; + height: 68rpx; + border-radius: 50%; + } + + .apple-btn { + display: flex; + align-items: center; + justify-content: center; + margin-left: 30rpx; + background: #000; + border-radius: 34rpx; + font-size: 40rpx; + + .icon-s-pingguo { + color: #fff; + font-size: 40rpx; + } + } + + .iconfont { + font-size: 40rpx; + color: #fff; + } + + .wx { + margin-right: 30rpx; + background-color: #61C64F; + } + + .mima { + background-color: #28B3E9; + } + + .yanzheng { + background-color: #F89C23; + } + + } + } + + .main_color{ + @include main_color(theme); + } + .bg_color{ + @include main_bg_color(theme); + } + .code img { + width: 100%; + height: 100%; + } + + .acea-row.row-middle { + input { + margin-left: 20rpx; + display: block; + } + } + + .login-wrapper { + padding: 30rpx; + + .shading { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + + /* #ifdef APP-VUE */ + margin-top: 50rpx; + /* #endif */ + /* #ifndef APP-VUE */ + + margin-top: 200rpx; + /* #endif */ + + + image { + width: 180rpx; + height: 180rpx; + } + } + + .whiteBg { + margin-top: 100rpx; + + .list { + border-radius: 16rpx; + overflow: hidden; + + .item { + border-bottom: 1px solid #F0F0F0; + background: #fff; + + .row-middle { + position: relative; + padding: 16rpx 45rpx; + + .texts{ + flex: 1; + font-size: 28rpx; + height: 80rpx; + line-height: 80rpx; + display: flex; + justify-content: center; + align-items: center; + } + + input { + flex: 1; + font-size: 28rpx; + height: 80rpx; + line-height: 80rpx; + display: flex; + justify-content: center; + align-items: center; + } + + .code { + position: absolute; + right: 30rpx; + top: 50%; + color: $theme-color; + font-size: 26rpx; + transform: translateY(-50%); + } + } + } + } + + .logon { + display: flex; + align-items: center; + justify-content: center; + width: 100%; + height: 86rpx; + margin-top: 80rpx; + background-color: $theme-color; + border-radius: 120rpx; + color: #FFFFFF; + font-size: 30rpx; + } + + .tips { + margin: 30rpx; + text-align: center; + color: #999; + } + } + } +</style> 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 @@ </view> <view class="xuhuan"> <text>须还金额:</text><text>¥{{item.repaymentAmount}}</text> - <view class="yuqi"> - {{item.repaymentStatus == 'Pending'? '待还款' : 'Partial' ? '部分还款' : 'Paid' ? '已还款' : '逾期'}}</view> + <view class="yuqi" v-if="item.repaymentStatus=='Pending'"> + 待还款 + </view> + <view class="yuqi" v-if="item.repaymentStatus=='Partial'"> + 部分还款 + </view> + <view class="yuqi" v-if="item.repaymentStatus=='Paid'"> + 已还款 + </view> + <view class="yuqi" v-if="item.repaymentStatus=='Late'"> + 逾期 + </view> <!-- 'Pending'? '待还款' : 'Partial' ? '部分还款' : 'Paid' ? '已还款' : '逾期' --> </view> @@ -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 @@ <!-- #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> <!-- #endif --> <!-- #ifdef APP-PLUS --> <view class="logOut cart-color acea-row row-center-wrapper" @click="outLogin">退出登录</view> @@ -216,6 +218,7 @@ import { login } from '../../../api/public'; uni.reLaunch({ url: '/pages/index/index' }); + uni.clearStorage(); }) .catch(err => { uni.hideLoading();