|
@@ -4,24 +4,22 @@ let api = "http://192.168.1.200/mobile/index.php";
|
|
|
// let api = "https://www.xyzshops.cn/mobile/index.php";
|
|
|
// let api = "http://www.xyzshops.cn/mobile/index.php";
|
|
|
|
|
|
-
|
|
|
-function getReq(app,data, callback, method)
|
|
|
-{
|
|
|
- let options = {
|
|
|
+function getReq(app, data, callback, method) {
|
|
|
+ let options = {
|
|
|
client_type: 'mini'
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
data = Object.assign({}, options, data);
|
|
|
let session_id = wx.getStorageSync('session_id');
|
|
|
if (!app.globalData.fMinistart && data['op'] != 'ministart') {
|
|
|
setTimeout(() => {
|
|
|
- getReq(app,data, callback, method)
|
|
|
+ getReq(app, data, callback, method)
|
|
|
}, 0);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
let act = data['act'];
|
|
|
- if(act.indexOf('member_') == 0)
|
|
|
- {
|
|
|
+ if (act.indexOf('member_') == 0) {
|
|
|
if (app != null && !app.globalData.userInfo) {
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/auth/auth',
|
|
@@ -29,7 +27,7 @@ function getReq(app,data, callback, method)
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
console.log('act=' + act + '&' + 'op=' + data['op']);
|
|
|
let header = {
|
|
|
'content-type': 'application/json', // 默认值
|
|
@@ -42,31 +40,28 @@ function getReq(app,data, callback, method)
|
|
|
'Cookie': 'MPHPSESSID=' + session_id
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
return wx.request({
|
|
|
url: api,
|
|
|
data,
|
|
|
method: method || 'GET',
|
|
|
header,
|
|
|
- success(res)
|
|
|
- {
|
|
|
+ success(res) {
|
|
|
console.log('header:', res.header["Set-Cookie"])
|
|
|
var cookies = res.header["Set-Cookie"];
|
|
|
if (cookies) {
|
|
|
var cookie = getCookieValue(cookies, 'MPHPSESSID');
|
|
|
- if(cookie) wx.setStorageSync('session_id', cookie);
|
|
|
+ if (cookie) wx.setStorageSync('session_id', cookie);
|
|
|
}
|
|
|
if (res.data.code == 10014) { //ErrUnLogin = 10014;
|
|
|
wx.navigateTo({
|
|
|
url: '/pages/auth/auth',
|
|
|
})
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
callback(res.data)
|
|
|
}
|
|
|
},
|
|
|
- fail()
|
|
|
- {
|
|
|
+ fail() {
|
|
|
wx.showModal({
|
|
|
confirmText: '重试',
|
|
|
content: '网络错误',
|
|
@@ -75,8 +70,7 @@ function getReq(app,data, callback, method)
|
|
|
wx.reLaunch({
|
|
|
url: "/pages/index/index"
|
|
|
})
|
|
|
- }
|
|
|
- else if (res.cancel) {
|
|
|
+ } else if (res.cancel) {
|
|
|
console.log('用户点击取消')
|
|
|
}
|
|
|
}
|
|
@@ -85,8 +79,8 @@ function getReq(app,data, callback, method)
|
|
|
})
|
|
|
}
|
|
|
|
|
|
-function getCookieValue(cookies,name) {
|
|
|
- var cookie_pos = cookies.indexOf(name,0);
|
|
|
+function getCookieValue(cookies, name) {
|
|
|
+ var cookie_pos = cookies.indexOf(name, 0);
|
|
|
if (cookie_pos != -1) {
|
|
|
cookie_pos += name.length + 1;
|
|
|
var cookie_end = cookies.indexOf(";", cookie_pos);
|
|
@@ -100,16 +94,15 @@ function getCookieValue(cookies,name) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function buyVGoods(app,goods_id,goods_num, other, successCallback, failCallback)
|
|
|
-{
|
|
|
- let ifcart = 0 ;
|
|
|
+function buyVGoods(app, goods_id, goods_num, other, successCallback, failCallback) {
|
|
|
+ let ifcart = 0;
|
|
|
let cartids = goods_id + '|' + goods_num;
|
|
|
let params = {
|
|
|
act: 'member_buy',
|
|
|
op: 'step_vsecond',
|
|
|
payment: 'minipay',
|
|
|
usebonus: 0,
|
|
|
- ifcart : 0,
|
|
|
+ ifcart: 0,
|
|
|
cart_id: cartids,
|
|
|
invoice_id: 0,
|
|
|
...other
|
|
@@ -120,20 +113,32 @@ function buyVGoods(app,goods_id,goods_num, other, successCallback, failCallback)
|
|
|
mask: true
|
|
|
});
|
|
|
params = Object.assign({}, params);
|
|
|
- getReq(app,params, function (res) {
|
|
|
+ getReq(app, params, function (res) {
|
|
|
wx.hideLoading()
|
|
|
if (res.code == 200) {
|
|
|
let param = res.datas.param.data
|
|
|
let pay_sn = res.datas.pay_sn
|
|
|
wx.requestPayment({
|
|
|
timeStamp: param.timeStamp, //时间戳,自1970年以来的秒数
|
|
|
- nonceStr: param.nonceStr, //随机串
|
|
|
+ nonceStr: param.nonceStr, //随机串
|
|
|
package: param.package,
|
|
|
signType: param.signType, //微信签名方式:
|
|
|
- paySign: param.paySign, //微信签名
|
|
|
+ paySign: param.paySign, //微信签名
|
|
|
success: function (res) {
|
|
|
wx.hideLoading()
|
|
|
successCallback && successCallback(res)
|
|
|
+ wx.aldPushSubscribeMessage({
|
|
|
+ eventId: '5f38ac6790fcd68beee4d510',
|
|
|
+ success(res) {
|
|
|
+ // 成功后的回调函数
|
|
|
+ console.log(res)
|
|
|
+ },
|
|
|
+ fail(res, e) {
|
|
|
+ // 失败后的回调函数
|
|
|
+ console.log(res)
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ });
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
wx.showToast({
|
|
@@ -144,8 +149,7 @@ function buyVGoods(app,goods_id,goods_num, other, successCallback, failCallback)
|
|
|
failCallback && failCallback(res)
|
|
|
}
|
|
|
});
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
wx.showToast({
|
|
|
icon: 'none',
|
|
|
title: '支付未完成,订单将在10分钟后取消...',
|
|
@@ -167,14 +171,27 @@ function payOrder(app, pay_sn) {
|
|
|
let param = res.datas.param.data;
|
|
|
wx.requestPayment({
|
|
|
timeStamp: param.timeStamp, //时间戳,自1970年以来的秒数
|
|
|
- nonceStr: param.nonceStr, //随机串
|
|
|
+ nonceStr: param.nonceStr, //随机串
|
|
|
package: param.package,
|
|
|
- signType: param.signType, //微信签名方式:
|
|
|
- paySign: param.paySign, //微信签名
|
|
|
+ signType: param.signType, //微信签名方式:
|
|
|
+ paySign: param.paySign, //微信签名
|
|
|
success: function (res) {
|
|
|
wx.redirectTo({
|
|
|
url: "/pages/order_tabs/orderTabs?state_type=state_pay"
|
|
|
})
|
|
|
+
|
|
|
+ wx.aldPushSubscribeMessage({
|
|
|
+ eventId: '5f38ac6790fcd68beee4d510',
|
|
|
+ success(res) {
|
|
|
+ // 成功后的回调函数
|
|
|
+ console.log(res)
|
|
|
+ },
|
|
|
+ fail(res, e) {
|
|
|
+ // 失败后的回调函数
|
|
|
+ console.log(res)
|
|
|
+ console.log(e)
|
|
|
+ }
|
|
|
+ });
|
|
|
console.log("支付成功:", res);
|
|
|
},
|
|
|
fail: function (res) {
|