Commit 654db285 by 李嘉林

登录兼容

parent 512c8211
import {requestPOST,requestGET} from "@/utils/request.js";
import { requestPOST, requestGET } from "@/utils/request.js";
console.log(process.env,'-----------------config------')
// wx
export default {
console.log(process.env, "-----------------config------");
// wx
export default {
//登录
miniLogin(options){
return requestGET(`${process.env.OLSHOP_URL}/wx/mini_login`,options)
miniLogin(options, env) {
return requestGET(
`${process.env.OLSHOP_URL}/${env ? env : "wx"}/mini_login`,
options
);
},
bindUser(options, env) {
//绑定
bindUser(options){
return requestPOST(`${process.env.OLSHOP_URL}/wx/mini_bind_user`,options)
return requestPOST(
`${process.env.OLSHOP_URL}/${env ? env : "wx"}/mini_bind_user`,
options
);
},
checkUnionid(options, env) {
//check unionid
checkUnionid(options){
return requestGET(`${process.env.OLSHOP_URL}/wx/mini_check_union_id`,options)
}
return requestGET(
`${process.env.OLSHOP_URL}/${env ? env : "wx"}/mini_check_${
env && env == "tt" ? "open" : "union"
}_id`,
options
);
}
\ No newline at end of file
};
<template>
<div>
<web-view :src="link+page+params" @message="getMessage" @error="handleError" @load="handleLoad"></web-view>
<web-view :src="webLink" @message="getMessage" @error="handleError" @load="handleLoad"></web-view>
</div>
</template>
......@@ -46,6 +46,11 @@ export default {
] //分享白名单
};
},
computed:{
webLink(){
return this.link+this.page+this.params;
}
},
onLoad(options) {
Object.assign(this.$data, this.$options.data());
console.log(
......@@ -226,6 +231,7 @@ export default {
},
methods: {
init() {
console.log(wx,'---------------------------229')
// 获取小程序开启的订阅消息配置
shop.getWxMiniSubscribeMessageConfig().then(res => {
if (res.data.code == 200) {
......@@ -349,6 +355,10 @@ export default {
console.log("卸载----------------", this.options);
},
onShareAppMessage(res) {
// 抖音展示拍视频功能
if(MINI_ENV=='tt'){
}
console.log(res)
console.log(
this.shareShopName,
......
......@@ -4,7 +4,7 @@
<image class="img" mode="aspectFit" :src="logoUrl" />
<p class="shopName" v-if="shopName">{{shopName}}</p>
<div class="btn_info">
<button class="btn" lang="zh_CN" open-type="getUserInfo" @getuserinfo="getUserInfo">微信一键登录</button>
<button class="btn" lang="zh_CN" open-type="getUserInfo" @getuserinfo="getUserInfo" @click="clickLogin">一键登录</button>
</div>
<!-- <div>{{testd}}</div>
......@@ -74,9 +74,11 @@ export default {
wx.login({
success: res => {
this.code = res.code;
console.log(this.code,'-------------------------77')
},
fail: err => {
reject(err);
console.log(err,'------------------------80--err')
// reject(err);
}
}) //重新登录
},
......@@ -87,7 +89,8 @@ export default {
this.code = res.code;
},
fail: err => {
reject(err);
console.log(err,'------------------------91--err')
// reject(err);
}
}) //重新登录
}
......@@ -107,6 +110,24 @@ export default {
this.getshop();
},
methods: {
clickLogin(){
let _this=this;
console.log(wx,'--------------wx')
console.log(MINI_ENV,'---------------------------115')
if(MINI_ENV=='tt'){
wx.getUserInfo({
withCredentials:true,
success(res) {
console.log(`getUserInfo 调用成功`,res);
_this.getUserInfo(res)
},
fail(res) {
console.log(`getUserInfo 调用失败`);
},
});
}
console.log("-------------点击登录")
},
getshop() {
this.shopName = wx.getStorageSync("shopName");
this.logoUrl = wx.getStorageSync("logoUrl");
......@@ -135,7 +156,7 @@ export default {
spokesmanRelId : this.$store.state.spokesmanRelId,
spokesmanGroupId : this.$store.state.spokesmanGroupId,
spokesmanShopId : this.$store.state.spokesmanShopId
})
},MINI_ENV)
.then(res => {
if (res.data.code == 200) {
resolve(res);
......@@ -149,11 +170,18 @@ export default {
});
},
getUserInfo: function(e) {
console.log(e.errMsg,"---------------152")
this.backParams=this.defalutBackParams
wx.showLoading({
title: "加载中"
});
if (e.target.errMsg == "getUserInfo:ok") {
let errMsg="";
if(MINI_ENV=='tt'){
errMsg=e.errMsg;
}else if(MINI_ENV=='wx'){
errMsg=e.target.errMsg
}
if (errMsg == "getUserInfo:ok") {
this.init()
.then(res => {
console.log("promise", res);
......@@ -183,6 +211,7 @@ export default {
this.session_key = res.data.data.session_key;
this.openid = res.data.data.openid;
this.isShow = true;
console.log(res.data.data,'--------------------------214')
//checkLogin
this.checkLogin(e);
......@@ -199,6 +228,18 @@ export default {
},
checkLogin(e) {
console.log(this.isHaveUnion,e)
if(MINI_ENV=='tt'){
e.mp={
detail:{
encryptedData:e.encryptedData,
iv:e.iv,
}
};
e.target={
rawData:e.rawData
};
}
console.log(e,e.mp,e.target.rawData,'-----------------------229')
if (this.isHaveUnion) {
wx.hideLoading();
//是会员 直接登录
......@@ -233,7 +274,7 @@ export default {
if (this.unionId) {
login
.checkUnionid({ unionId: this.unionId, openId: this.openid })
.checkUnionid({ unionId: this.unionId, openId: this.openid },MINI_ENV)
.then(res => {
wx.hideLoading();
if (res.data.code == 200) {
......@@ -277,7 +318,7 @@ export default {
delta: 1
});
}else{
wx.reLaunch({
wx.redirectTo({
url: `../index/main?from=login&backpath=${
this.backPath
}&params=${encodeURIComponent(this.backParams)}`
......@@ -285,10 +326,27 @@ export default {
}
},
getPhoneNumber(e) {
console.log(e,'---------getPhoneNumber')
return;
wx.checkSession({
success: () => {
//session_key 未过期,并且在本生命周期一直有效
if (e.target.errMsg == "getPhoneNumber:ok") {
let errMsg="";
if(MINI_ENV=='tt'){
errMsg=e.errMsg;
// e.mp={
// detail:{
// encryptedData:e.encryptedData,
// iv:e.iv,
// }
// };
// e.target={
// rawData:e.rawData
// };
}else if(MINI_ENV=='wx'){
errMsg=e.target.errMsg
}
if (errMsg == "getPhoneNumber:ok") {
// this.isShowPhone = false;
this.phoneNumber = wx_decode(
this.appid,
......@@ -300,7 +358,8 @@ export default {
this.bindUser();
}
},
fail: () => {
fail: (err) => {
console.log(err,'-------------------err---359')
// session_key 已经失效,需要重新执行登录流程
// wx.login() //重新登录
}
......@@ -327,7 +386,7 @@ export default {
console.log(query, "query");
login
.bindUser(query)
.bindUser(query,MINI_ENV)
.then(res => {
//绑定成功
if (res.data.code == 200) {
......@@ -378,9 +437,11 @@ export default {
province: this.userInfo.province,
city: this.userInfo.city
};
console.log(query,'--------------440')
// return;
//绑定手机号
wx.navigateTo({
url: `../index/main?from=login&backpath=/login/wxRegister&params=${encodeURIComponent(
url: `/pages/index/main?from=login&backpath=/login/wxRegister&params=${encodeURIComponent(
serialize(query)
)}`
});
......
......@@ -40,11 +40,16 @@ export default {
that.options.openId = res.data;
that.options.tradeType = "Mini";
console.log("支付开始", that.options);
if(MINI_ENV=='tt'){
that.toTtPay();
}else{
that.toPay();
}
}
});
},
methods: {
// 微信小程序支付
toPay() {
wxPay
.to_wx_pay(this.options)
......@@ -135,6 +140,60 @@ export default {
wx.showToast({ title: res.data.msg, icon: "none" });
});
},
// 头条支付
toTtPay(){
console.log("-----------------145头条支付")
tt.pay({
orderInfo: {
app_id: "800000040005",
sign_type: "MD5",
out_order_no: "MicroApp7075638135",
merchant_id: "1300000004",
timestamp: "1566720681",
product_code: "pay",
payment_type: "direct",
total_amount: 1,
trade_type: "H5",
uid: "800000040005",
version: "2.0",
currency: "CNY",
subject: "microapp test",
body: "microapp test",
trade_time: "1566720681",
valid_time: "300",
notify_url: "https://wx.tenpay.com/paycallback",
wx_url: "https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=xxx&package=yyy",
wx_type: "MWEB",
alipay_url:
"alipay_sdk=alipay-sdk-java-3.4.27.ALL&app_id=2018061460417275&biz_content=%7B%22body%22%3A%22%E6%B5%8B%E8%AF%95%E8%AE%A2%E5%8D%95%22%2C%22extend_params%22%3A%7B%7D%2C%22out_trade_no%22%3A%2211908250000028453790%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22seller_id%22%3A%222088721387102560%22%2C%22subject%22%3A%22%E6%B5%8B%E8%AF%95%E8%AE%A2%E5%8D%95%22%2C%22timeout_express%22%3A%22599m%22%2C%22total_amount%22%3A%220.01%22%7D&charset=utf-8&format=json&method=alipay.trade.app.pay&notify_url=http%3A%2F%2Fapi-test-pcs.snssdk.com%2Fgateway%2Fpayment%2Fcallback%2Falipay%2Fnotify%2Fpay&sign=D2A6ua51os2aIzIH907ppK7Bd9Q2Kk5h7AtKPdudP%2Be%2BNTtAkp0Lfojtgl4BMOIQ3Z7cWyYMx6nk4qbntSx7aZnBhWAcImLbVVr1cmaYAedmrmJG%2B3f8G5TfAZu53ESzUgk02%2FhU1XV0iXRyE8TdEJ97ufmxwsUEc7K0EvwEFDIBCJg73meQtyCRFgCqYRWvmxetQgL7pwfKXpFXjAYsvFrRBas2YGYt689XpBS321g%2BZ8SZ0JOtLPWqhROzEs3dnAtWBW15y3NzRiSNi5rPzah4cWd4SgT0LZHmNf3eDQEHEcPmofoWfnA4ao75JmP95aLUxerMumzo9OwqhiYOUw%3D%3D&sign_type=RSA2&timestamp=2019-08-25+16%3A11%3A22&version=1.0",
sign: "15aa99cd80878661a4d442b7540bdf96",
risk_info: '{"ip":"127.0.0.1"}',
},
service: 3,
payChannel: {
default_pay_channel: "wx", // wx || alipay
},
getOrderStatus(res) {
let { out_order_no } = res;
return new Promise(function (resolve, reject) {
// 商户前端根据 out_order_no 请求商户后端查询微信支付订单状态
});
},
success(res) {
console.log(res,'--------------ttpay')
if (res.code == 0) {
console.log("支付成功处理逻辑,只有res.code=0时,才表示支付成功")
// 支付成功处理逻辑,只有res.code=0时,才表示支付成功
// 但是最终状态要以商户后端结果为准
}
},
fail(res) {
console.log(res,'-----------------------201--res')
// 调起收银台失败处理逻辑
},
});
},
toPage() {
let query = {
orderSn: this.options.orderSn,
......
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