Commit 8f224082 authored by 潘永坪's avatar 潘永坪

扫码支付页面登录修改

parent 50584994
...@@ -6,8 +6,9 @@ ...@@ -6,8 +6,9 @@
//4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全 //4.setStorageSync与setStorage的区别:如果后续的操作需要使用更新storage后保存的data,则使用setStorageSync使用异步性能更好,使用同步数据更安全
export default { export default {
onLaunch: function(options) {//初始化完成时触发(全局只触发一次 onLaunch: function(options) {//初始化完成时触发(全局只触发一次
let path=options.path
let openid=uni.getStorageSync("openid") let openid=uni.getStorageSync("openid")
if(!openid){ if(!openid&&path.indexOf("pages/ourPayment/ourPayment")==-1){//扫码支付页面不需要在此登录
setTimeout(()=>{//解决关联普通二维码扫码首次进入时一直显示登录中 setTimeout(()=>{//解决关联普通二维码扫码首次进入时一直显示登录中
uni.navigateTo({ uni.navigateTo({
url: "/pages/login/login" url: "/pages/login/login"
......
...@@ -6,7 +6,6 @@ if(process.env.NODE_ENV === 'development'){//开发环境 ...@@ -6,7 +6,6 @@ if(process.env.NODE_ENV === 'development'){//开发环境
} }
const request = (url = '', data = {}, type = 'POST') => { const request = (url = '', data = {}, type = 'POST') => {
uni.showLoading({title: '加载中',mask:true})
data.reqId = new Date().getTime() //获取时间戳 data.reqId = new Date().getTime() //获取时间戳
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
...@@ -15,11 +14,9 @@ const request = (url = '', data = {}, type = 'POST') => { ...@@ -15,11 +14,9 @@ const request = (url = '', data = {}, type = 'POST') => {
data:data, data:data,
dataType: 'json', dataType: 'json',
}).then((response) => { }).then((response) => {
uni.hideLoading()
let [error, res] = response; let [error, res] = response;
resolve(res.data); resolve(res.data);
}).catch(error => { }).catch(error => {
uni.hideLoading()
let [err, res] = error; let [err, res] = error;
reject(err) reject(err)
}) })
......
...@@ -172,17 +172,66 @@ ...@@ -172,17 +172,66 @@
this.merchantId=option.merchantId this.merchantId=option.merchantId
this.companyId=option.companyId this.companyId=option.companyId
} }
if(uni.getStorageSync("openid")){
this.openid=uni.getStorageSync("openid")
if (this.merchantId) { //大商家的有merchantId if (this.merchantId) { //大商家的有merchantId
this.init() this.init()
} else { //小商家没有merchantId } else { //小商家没有merchantId
this.initTwo() this.initTwo()
} }
//#ifdef MP-WEIXIN //#ifdef MP-WEIXIN
this.initCoupon() this.initCoupon()
//#endif //#endif
}else{
this.login()
}
}, },
methods: { methods: {
login(){//---------------------------------------------------------------------登录
let _this=this
uni.getProvider({
service: 'oauth',
success(proRes){
uni.login({
provider:proRes.provider[0],
success: function (res) {
if(res.code){
let source=""
if(proRes.provider[0]=="weixin"){
source=3
}else if(proRes.provider[0]=="alipay"){
source=4
}
let data={
code:res.code,
source,//微信小程序3,支付宝小程序4
}
_this.$request('wechat/wx/getUserInfoByCode',data).then(res => {
if(res.code=='00'){
_this.openid=res.data.openid
uni.setStorageSync('openid',_this.openid)
if (_this.merchantId) { //大商家的有merchantId
_this.init()
} else { //小商家没有merchantId
_this.initTwo()
}
//#ifdef MP-WEIXIN
_this.initCoupon()
//#endif
}else{
uni.removeStorageSync('openid')
}
}).catch((err)=>{
uni.removeStorageSync('openid')
})
}
}
})
}
})
},
getUrlKey(name){//---------------------------------------------------------------获取url getUrlKey(name){//---------------------------------------------------------------获取url
return(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(decodeURIComponent(this.enterUrl)) || [, ""])[1].replace(/\+/g, '%20') || ""; return(new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(decodeURIComponent(this.enterUrl)) || [, ""])[1].replace(/\+/g, '%20') || "";
}, },
...@@ -223,7 +272,9 @@ ...@@ -223,7 +272,9 @@
"merchantId": this.merchantId, "merchantId": this.merchantId,
"companyId": this.companyId, "companyId": this.companyId,
} }
uni.showLoading({title: '加载中',mask:true})
this.$request("scenic/order/findCodePayInfo",data).then((res) => { this.$request("scenic/order/findCodePayInfo",data).then((res) => {
uni.hideLoading()
if (res.code =="00") { if (res.code =="00") {
this.name = res.data.name this.name = res.data.name
} else { } else {
...@@ -232,13 +283,17 @@ ...@@ -232,13 +283,17 @@
icon:"none" icon:"none"
}) })
} }
}).catch((err)=>{
uni.hideLoading()
}) })
}, },
initTwo() { //--------------------------------------------------------------------------初始化获取商家名称,没有merchantId的小商家 initTwo() { //--------------------------------------------------------------------------初始化获取商家名称,没有merchantId的小商家
let data = { let data = {
"id": this.companyId, "id": this.companyId,
} }
uni.showLoading({title: '加载中',mask:true})
this.$request("user/company/detail", data).then((res) => { this.$request("user/company/detail", data).then((res) => {
uni.hideLoading()
if (res.code=="00"){ if (res.code=="00"){
this.name = res.data.companyVo.companyName this.name = res.data.companyVo.companyName
} else { } else {
...@@ -247,6 +302,8 @@ ...@@ -247,6 +302,8 @@
icon:"none" icon:"none"
}) })
} }
}).catch((err)=>{
uni.hideLoading()
}) })
}, },
initCoupon() { //-------------------------------------------------------------------------加载优惠券 initCoupon() { //-------------------------------------------------------------------------加载优惠券
...@@ -258,7 +315,7 @@ ...@@ -258,7 +315,7 @@
merchantId:this.merchantId, //商户Id merchantId:this.merchantId, //商户Id
companyId:this.companyId,//公司Id companyId:this.companyId,//公司Id
orderSource:this.orderSource,//订单来源 8扫码支付 orderSource:this.orderSource,//订单来源 8扫码支付
openid:uni.getStorageSync("openid") openid:this.openid
} }
this.$request("wechatUser/myPage/usableCouponList",data).then((res) => { this.$request("wechatUser/myPage/usableCouponList",data).then((res) => {
if (res.code == "00") { if (res.code == "00") {
...@@ -315,7 +372,7 @@ ...@@ -315,7 +372,7 @@
let data = { let data = {
companyId: this.companyId, companyId: this.companyId,
merchantId: this.merchantId, merchantId: this.merchantId,
userId:uni.getStorageSync("openid"), userId:this.openid,
orderMoney: parseFloat(this.buyMoney), orderMoney: parseFloat(this.buyMoney),
payType: this.payType, //支付类型, payType: this.payType, //支付类型,
orderSource:this.orderSource,//订单来源 8扫码支付 orderSource:this.orderSource,//订单来源 8扫码支付
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment