Commit 654db285 by 李嘉林

登录兼容

parent 512c8211
import {requestPOST,requestGET} from "@/utils/request.js"; import { requestPOST, requestGET } from "@/utils/request.js";
console.log(process.env, "-----------------config------");
console.log(process.env,'-----------------config------') // wx
// wx export default {
export default { //登录
//登录 miniLogin(options, env) {
miniLogin(options){ return requestGET(
return requestGET(`${process.env.OLSHOP_URL}/wx/mini_login`,options) `${process.env.OLSHOP_URL}/${env ? env : "wx"}/mini_login`,
}, options
);
},
bindUser(options, env) {
//绑定 //绑定
bindUser(options){ return requestPOST(
return requestPOST(`${process.env.OLSHOP_URL}/wx/mini_bind_user`,options) `${process.env.OLSHOP_URL}/${env ? env : "wx"}/mini_bind_user`,
}, options
);
},
checkUnionid(options, env) {
//check unionid //check unionid
checkUnionid(options){ return requestGET(
return requestGET(`${process.env.OLSHOP_URL}/wx/mini_check_union_id`,options) `${process.env.OLSHOP_URL}/${env ? env : "wx"}/mini_check_${
} env && env == "tt" ? "open" : "union"
} }_id`,
options
\ No newline at end of file );
}
};
<template> <template>
<div> <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> </div>
</template> </template>
...@@ -46,6 +46,11 @@ export default { ...@@ -46,6 +46,11 @@ export default {
] //分享白名单 ] //分享白名单
}; };
}, },
computed:{
webLink(){
return this.link+this.page+this.params;
}
},
onLoad(options) { onLoad(options) {
Object.assign(this.$data, this.$options.data()); Object.assign(this.$data, this.$options.data());
console.log( console.log(
...@@ -226,6 +231,7 @@ export default { ...@@ -226,6 +231,7 @@ export default {
}, },
methods: { methods: {
init() { init() {
console.log(wx,'---------------------------229')
// 获取小程序开启的订阅消息配置 // 获取小程序开启的订阅消息配置
shop.getWxMiniSubscribeMessageConfig().then(res => { shop.getWxMiniSubscribeMessageConfig().then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
...@@ -349,6 +355,10 @@ export default { ...@@ -349,6 +355,10 @@ export default {
console.log("卸载----------------", this.options); console.log("卸载----------------", this.options);
}, },
onShareAppMessage(res) { onShareAppMessage(res) {
// 抖音展示拍视频功能
if(MINI_ENV=='tt'){
}
console.log(res) console.log(res)
console.log( console.log(
this.shareShopName, this.shareShopName,
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<image class="img" mode="aspectFit" :src="logoUrl" /> <image class="img" mode="aspectFit" :src="logoUrl" />
<p class="shopName" v-if="shopName">{{shopName}}</p> <p class="shopName" v-if="shopName">{{shopName}}</p>
<div class="btn_info"> <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>
<!-- <div>{{testd}}</div> <!-- <div>{{testd}}</div>
...@@ -74,9 +74,11 @@ export default { ...@@ -74,9 +74,11 @@ export default {
wx.login({ wx.login({
success: res => { success: res => {
this.code = res.code; this.code = res.code;
console.log(this.code,'-------------------------77')
}, },
fail: err => { fail: err => {
reject(err); console.log(err,'------------------------80--err')
// reject(err);
} }
}) //重新登录 }) //重新登录
}, },
...@@ -87,7 +89,8 @@ export default { ...@@ -87,7 +89,8 @@ export default {
this.code = res.code; this.code = res.code;
}, },
fail: err => { fail: err => {
reject(err); console.log(err,'------------------------91--err')
// reject(err);
} }
}) //重新登录 }) //重新登录
} }
...@@ -107,6 +110,24 @@ export default { ...@@ -107,6 +110,24 @@ export default {
this.getshop(); this.getshop();
}, },
methods: { 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() { getshop() {
this.shopName = wx.getStorageSync("shopName"); this.shopName = wx.getStorageSync("shopName");
this.logoUrl = wx.getStorageSync("logoUrl"); this.logoUrl = wx.getStorageSync("logoUrl");
...@@ -135,7 +156,7 @@ export default { ...@@ -135,7 +156,7 @@ export default {
spokesmanRelId : this.$store.state.spokesmanRelId, spokesmanRelId : this.$store.state.spokesmanRelId,
spokesmanGroupId : this.$store.state.spokesmanGroupId, spokesmanGroupId : this.$store.state.spokesmanGroupId,
spokesmanShopId : this.$store.state.spokesmanShopId spokesmanShopId : this.$store.state.spokesmanShopId
}) },MINI_ENV)
.then(res => { .then(res => {
if (res.data.code == 200) { if (res.data.code == 200) {
resolve(res); resolve(res);
...@@ -149,11 +170,18 @@ export default { ...@@ -149,11 +170,18 @@ export default {
}); });
}, },
getUserInfo: function(e) { getUserInfo: function(e) {
console.log(e.errMsg,"---------------152")
this.backParams=this.defalutBackParams this.backParams=this.defalutBackParams
wx.showLoading({ wx.showLoading({
title: "加载中" 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() this.init()
.then(res => { .then(res => {
console.log("promise", res); console.log("promise", res);
...@@ -183,6 +211,7 @@ export default { ...@@ -183,6 +211,7 @@ export default {
this.session_key = res.data.data.session_key; this.session_key = res.data.data.session_key;
this.openid = res.data.data.openid; this.openid = res.data.data.openid;
this.isShow = true; this.isShow = true;
console.log(res.data.data,'--------------------------214')
//checkLogin //checkLogin
this.checkLogin(e); this.checkLogin(e);
...@@ -199,6 +228,18 @@ export default { ...@@ -199,6 +228,18 @@ export default {
}, },
checkLogin(e) { checkLogin(e) {
console.log(this.isHaveUnion,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) { if (this.isHaveUnion) {
wx.hideLoading(); wx.hideLoading();
//是会员 直接登录 //是会员 直接登录
...@@ -233,7 +274,7 @@ export default { ...@@ -233,7 +274,7 @@ export default {
if (this.unionId) { if (this.unionId) {
login login
.checkUnionid({ unionId: this.unionId, openId: this.openid }) .checkUnionid({ unionId: this.unionId, openId: this.openid },MINI_ENV)
.then(res => { .then(res => {
wx.hideLoading(); wx.hideLoading();
if (res.data.code == 200) { if (res.data.code == 200) {
...@@ -277,7 +318,7 @@ export default { ...@@ -277,7 +318,7 @@ export default {
delta: 1 delta: 1
}); });
}else{ }else{
wx.reLaunch({ wx.redirectTo({
url: `../index/main?from=login&backpath=${ url: `../index/main?from=login&backpath=${
this.backPath this.backPath
}&params=${encodeURIComponent(this.backParams)}` }&params=${encodeURIComponent(this.backParams)}`
...@@ -285,10 +326,27 @@ export default { ...@@ -285,10 +326,27 @@ export default {
} }
}, },
getPhoneNumber(e) { getPhoneNumber(e) {
console.log(e,'---------getPhoneNumber')
return;
wx.checkSession({ wx.checkSession({
success: () => { success: () => {
//session_key 未过期,并且在本生命周期一直有效 //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.isShowPhone = false;
this.phoneNumber = wx_decode( this.phoneNumber = wx_decode(
this.appid, this.appid,
...@@ -300,7 +358,8 @@ export default { ...@@ -300,7 +358,8 @@ export default {
this.bindUser(); this.bindUser();
} }
}, },
fail: () => { fail: (err) => {
console.log(err,'-------------------err---359')
// session_key 已经失效,需要重新执行登录流程 // session_key 已经失效,需要重新执行登录流程
// wx.login() //重新登录 // wx.login() //重新登录
} }
...@@ -327,7 +386,7 @@ export default { ...@@ -327,7 +386,7 @@ export default {
console.log(query, "query"); console.log(query, "query");
login login
.bindUser(query) .bindUser(query,MINI_ENV)
.then(res => { .then(res => {
//绑定成功 //绑定成功
if (res.data.code == 200) { if (res.data.code == 200) {
...@@ -378,9 +437,11 @@ export default { ...@@ -378,9 +437,11 @@ export default {
province: this.userInfo.province, province: this.userInfo.province,
city: this.userInfo.city city: this.userInfo.city
}; };
console.log(query,'--------------440')
// return;
//绑定手机号 //绑定手机号
wx.navigateTo({ 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) serialize(query)
)}` )}`
}); });
......
...@@ -40,11 +40,16 @@ export default { ...@@ -40,11 +40,16 @@ export default {
that.options.openId = res.data; that.options.openId = res.data;
that.options.tradeType = "Mini"; that.options.tradeType = "Mini";
console.log("支付开始", that.options); console.log("支付开始", that.options);
that.toPay(); if(MINI_ENV=='tt'){
that.toTtPay();
}else{
that.toPay();
}
} }
}); });
}, },
methods: { methods: {
// 微信小程序支付
toPay() { toPay() {
wxPay wxPay
.to_wx_pay(this.options) .to_wx_pay(this.options)
...@@ -135,6 +140,60 @@ export default { ...@@ -135,6 +140,60 @@ export default {
wx.showToast({ title: res.data.msg, icon: "none" }); 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() { toPage() {
let query = { let query = {
orderSn: this.options.orderSn, 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