Commit 522b4ae7 authored by 王建威's avatar 王建威

小程序登录 支付

parent 3eaa2429
......@@ -81,44 +81,6 @@
$draggable.on('staticClick', function( event, pointer ) {
$('#qidian_dom').click();
})
const { origin } = window.location;
let url = '';
// 测试环境
if(origin.indexOf('local') > -1 || origin.indexOf('test') > -1){
if(origin.indexOf('test') > -1){
url = `${origin}/mobile/index.php?`;
}else{
url = 'https://test.pet-dbc.cn/mobile/index.php?';
}
}else if(origin.indexOf('jingxiang') > -1){
url = 'https://jingxiang.pet-dbc.cn/mobile/index.php?';
}else{
url = 'https://shop.pet-dbc.cn/mobile/index.php?';
}
var search = window.location.href.split('?');
if(search[1]) {
var arr = search[1].split('&');
arr.every((item, index) => {
var kv = item.split('=');
if(kv[0] === 'openId') {
localStorage.openId = kv[1];
$.ajax({
url: url + 'app=weixin&act=autoLogin',
type: 'get',
data: {
openid: kv[1]
},
dataType: 'json',
success: function(res) {
alert(JSON.stringify(res))
}
})
}
if(kv[0] === 'inionid') {
localStorage.unionid = kv[1];
}
});
}
</script>
<!-- built files will be auto injected -->
</body>
......
......@@ -20,6 +20,49 @@ Vue.prototype.$wechat = wechat;
// #endif
Vue.config.productionTip = false;
const {
origin
} = window.location;
let url = '';
// 测试环境
if (origin.indexOf('local') > -1 || origin.indexOf('test') > -1) {
if (origin.indexOf('test') > -1) {
url = origin + '/mobile/index.php?';
} else {
url = 'https://test.pet-dbc.cn/mobile/index.php?';
}
} else if (origin.indexOf('jingxiang') > -1) {
url = 'https://jingxiang.pet-dbc.cn/mobile/index.php?';
} else {
url = 'https://shop.pet-dbc.cn/mobile/index.php?';
}
var search = window.location.href.split('?');
if (search[1]) {
var arr = search[1].split('&');
arr.every((item, index) => {
var kv = item.split('=');
if (kv[0] === 'openId') {
localStorage.openId = kv[1];
var exp = new Date();
exp.setTime(exp.getTime() + 3650*24*60*60*1000);
document.cookie = 'openId='+kv[1]+';expires='+exp.toGMTString();
$.ajax({
url: url + 'app=weixin&act=autoLogin',
type: 'get',
data: {
openid: kv[1]
},
dataType: 'json',
success: function(res) {
alert(JSON.stringify(res))
}
})
}
if (kv[0] === 'inionid') {
localStorage.unionid = kv[1];
}
});
}
// 加入购物车
function addCart(spec_id, quantity, isLogin) {
......@@ -82,10 +125,10 @@ function backup() {
// 跳转外部链接,使用webview
function jump(url, type) {
// #ifdef H5
if(type === 1){
if (type === 1) {
// 重定向到指定地址,防止回退
window.location.replace(url);
} else if (type === 2){
} else if (type === 2) {
uni.navigateTo({
url: url
})
......
......@@ -78,10 +78,10 @@
},2000);
return;
}
wx.miniProgram.getEnv(function (res) {
if(res.miniprogram){
jWeixin.miniProgram.getEnv(function (result) {
if(result.miniprogram){
var path = '/pages/pay/index?payParam='+encodeURIComponent(JSON.stringify(res))+'&type=uni';
wx.miniProgram.navigateTo({url: path});
jWeixin.miniProgram.navigateTo({url: path});
} else {
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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