Commit d1ecdebd authored by zhengxiuming's avatar zhengxiuming

Merge commit '522b4ae7' into develop

parents 232c89d7 522b4ae7
...@@ -6,13 +6,13 @@ import { ...@@ -6,13 +6,13 @@ import {
go go
} from '@/common/host.js'; } from '@/common/host.js';
import { import {
getNavigationBarTitle, getNavigationBarTitle,
getCache getCache
} from './common/util.js'; } from './common/util.js';
// 微信分享公共接口 // 微信分享公共接口
// #ifdef H5 // #ifdef H5
import wechat from './common/wechat.js'; import wechat from './common/wechat.js';
Vue.prototype.$wechat = wechat; Vue.prototype.$wechat = wechat;
// if (wechat.isWechat() || wechat.isMini()) { // if (wechat.isWechat() || wechat.isMini()) {
// Vue.prototype.$wechat = wechat; // Vue.prototype.$wechat = wechat;
...@@ -20,6 +20,49 @@ Vue.prototype.$wechat = wechat; ...@@ -20,6 +20,49 @@ Vue.prototype.$wechat = wechat;
// #endif // #endif
Vue.config.productionTip = false; 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) { function addCart(spec_id, quantity, isLogin) {
...@@ -62,16 +105,16 @@ function __reloadResource(_this) { ...@@ -62,16 +105,16 @@ function __reloadResource(_this) {
_this._source.default_image = _this._source.default_image =
'https://dbc-static.oss-cn-beijing.aliyuncs.com/credit_shop/20190605/goods/5cf78b96601be.png?x-oss-process=image/resize,m_lfit,w_300,h_300/auto-orient,0/quality,Q_85/format,jpg'; 'https://dbc-static.oss-cn-beijing.aliyuncs.com/credit_shop/20190605/goods/5cf78b96601be.png?x-oss-process=image/resize,m_lfit,w_300,h_300/auto-orient,0/quality,Q_85/format,jpg';
} }
// 毫秒数转时间 // 毫秒数转时间
// 跳转商品详情页,只传一个商品ID,方便以后全局修改 // 跳转商品详情页,只传一个商品ID,方便以后全局修改
function jumpGoodDetail(goods_id) { function jumpGoodDetail(goods_id) {
window.location.href = `${php}app=goods&id=${goods_id}`; window.location.href = `${php}app=goods&id=${goods_id}`;
} }
function jumpOrderDetail(order_id) { function jumpOrderDetail(order_id) {
window.location.href = `${php}app=buyer_order&act=view&order_id=${order_id}`; window.location.href = `${php}app=buyer_order&act=view&order_id=${order_id}`;
} }
function backup() { function backup() {
...@@ -86,15 +129,15 @@ function backup() { ...@@ -86,15 +129,15 @@ function backup() {
// 跳转外部链接,使用webview // 跳转外部链接,使用webview
function jump(url, type) { function jump(url, type) {
// #ifdef H5 // #ifdef H5
if(type === 1){ if (type === 1) {
// 重定向到指定地址,防止回退 // 重定向到指定地址,防止回退
window.location.replace(url); window.location.replace(url);
} else if (type === 2){ } else if (type === 2) {
uni.navigateTo({ uni.navigateTo({
url: url url: url
}) })
} else { } else {
window.location.href = url; window.location.href = url;
} }
// #endif // #endif
...@@ -108,8 +151,8 @@ function jump(url, type) { ...@@ -108,8 +151,8 @@ function jump(url, type) {
} }
Vue.prototype.$jumpGoodDetail = jumpGoodDetail; Vue.prototype.$jumpGoodDetail = jumpGoodDetail;
Vue.prototype.$jump = jump; Vue.prototype.$jump = jump;
Vue.prototype.$jumpOrderDetail = jumpOrderDetail; Vue.prototype.$jumpOrderDetail = jumpOrderDetail;
Vue.prototype.$getCache = getCache; Vue.prototype.$getCache = getCache;
Vue.prototype.$addCart = addCart; Vue.prototype.$addCart = addCart;
Vue.prototype.$backup = backup; Vue.prototype.$backup = backup;
......
...@@ -86,66 +86,73 @@ ...@@ -86,66 +86,73 @@
},2000); },2000);
return; return;
} }
WeixinJSBridge.invoke( jWeixin.miniProgram.getEnv(function (result) {
'getBrandWCPayRequest', { if(result.miniprogram){
"appId": res.app_id, //公众号名称,由商户传入 var path = '/pages/pay/index?payParam='+encodeURIComponent(JSON.stringify(res))+'&type=uni';
"timeStamp": res.timeStamp, //时间戳,自1970年以来的秒数 jWeixin.miniProgram.navigateTo({url: path});
"nonceStr": res.nonce_str, //随机串 } else {
"package": res.package, WeixinJSBridge.invoke(
"signType": res.sign_type, //微信签名方式: 'getBrandWCPayRequest', {
"paySign": res.pay_sign //微信签名 "appId": res.app_id, //公众号名称,由商户传入
}, "timeStamp": res.timeStamp, //时间戳,自1970年以来的秒数
function (res) { "nonceStr": res.nonce_str, //随机串
WeixinJSBridge.log(res.err_msg); "package": res.package,
const url = window.location.origin; "signType": res.sign_type, //微信签名方式:
if (res.err_msg === "get_brand_wcpay_request:ok") { "paySign": res.pay_sign //微信签名
uni.removeStorageSync('monthly'); },
uni.navigateTo({ function (res) {
url: '/pages/payresult/payresult' WeixinJSBridge.log(res.err_msg);
}) const url = window.location.origin;
} else if (res.err_msg === "get_brand_wcpay_request:cancel") { if (res.err_msg === "get_brand_wcpay_request:ok") {
uni.showToast({ uni.removeStorageSync('monthly');
title: '已取消支付,请重新支付', uni.navigateTo({
duration: 2000, url: '/pages/payresult/payresult'
icon: 'none' })
}); } else if (res.err_msg === "get_brand_wcpay_request:cancel") {
setTimeout(() => { uni.showToast({
history.back(); title: '已取消支付,请重新支付',
},2000); duration: 2000,
} else if (res.err_msg === "get_brand_wcpay_request:fail") { icon: 'none'
// Toast.fail('支付失败', 3); });
uni.showToast({ setTimeout(() => {
title: '支付失败,请重新支付', history.back();
duration: 2000, },2000);
icon: 'none' } else if (res.err_msg === "get_brand_wcpay_request:fail") {
}); // Toast.fail('支付失败', 3);
// 回退上一页重新支付 uni.showToast({
setTimeout(() => { title: '支付失败,请重新支付',
history.back(); duration: 2000,
},2000); icon: 'none'
// 提示支付失败,关闭当前页面 });
// setTimeout(function() { // 回退上一页重新支付
//这个可以关闭安卓系统的手机 setTimeout(() => {
// document.addEventListener( history.back();
// "WeixinJSBridgeReady", },2000);
// function() { // 提示支付失败,关闭当前页面
// WeixinJSBridge.call("closeWindow"); // setTimeout(function() {
// }, //这个可以关闭安卓系统的手机
// false // document.addEventListener(
// ); // "WeixinJSBridgeReady",
// //这个可以关闭ios系统的手机 // function() {
// WeixinJSBridge.call("closeWindow"); // WeixinJSBridge.call("closeWindow");
// this.$jump(`${url}?app=member`); // },
// }, 300); // false
} else { // );
uni.showToast({ // //这个可以关闭ios系统的手机
title: '未知错误,刷新重试', // WeixinJSBridge.call("closeWindow");
duration: 2000, // this.$jump(`${url}?app=member`);
icon: 'none' // }, 300);
}); } else {
} uni.showToast({
title: '未知错误,刷新重试',
duration: 2000,
icon: 'none'
});
}
}
);
} }
); })
}, },
goBack(){ goBack(){
this.$backup(); this.$backup();
......
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