浏览代码

[云端支付修改][修改]:云端支付修改

tags/富茂链客_2.2.6
meo 6 年前
父节点
当前提交
396122fb83
共有 4 个文件被更改,包括 58 次插入87 次删除
  1. +3
    -3
      config/config.js
  2. +31
    -34
      pages/coupon/detail/index.js
  3. +23
    -49
      pages/order/detail/index.js
  4. +1
    -1
      project.config.json

+ 3
- 3
config/config.js 查看文件

@@ -1,8 +1,8 @@
var config = { var config = {
// url: "http://10.11.205.51:7000/C/api", // url: "http://10.11.205.51:7000/C/api",
// url: "https://ciformall.youlane.cn/C/api", // url: "https://ciformall.youlane.cn/C/api",
url:"https://c.malls.iformall.com/C/api",
// url: "http://31adc9ce.ngrok.io/C/api",
// url:"https://c.malls.iformall.com/C/api",
url: "http://81be62f2.ngrok.io/C/api",
api: { api: {
/** /**
* 接口用途:login * 接口用途:login
@@ -161,7 +161,7 @@ var config = {
}, },


weapp: { weapp: {
AppId: "wx026ee7f6290aa336"
AppId: "wx649b3be73c1afe47"
}, },
ErrorCode: { ErrorCode: {
NICK_NOT_AUTH: 11004, NICK_NOT_AUTH: 11004,


+ 31
- 34
pages/coupon/detail/index.js 查看文件

@@ -24,7 +24,6 @@ Page({


phone: function () { phone: function () {
let that = this; let that = this;
console.log(that.data);
if (that.data.data.merchantLinkPhone) { if (that.data.data.merchantLinkPhone) {
wx.makePhoneCall({ wx.makePhoneCall({
phoneNumber: that.data.data.merchantLinkPhone phoneNumber: that.data.data.merchantLinkPhone
@@ -99,7 +98,6 @@ Page({
} }
}; };
Http.get(parmer).then(res => { Http.get(parmer).then(res => {
console.log(res.data);
if (res.data.endTime){ if (res.data.endTime){
that.countdown(res.data.endTime); that.countdown(res.data.endTime);
//当前时间与优惠券下架时间做计算 //当前时间与优惠券下架时间做计算
@@ -121,8 +119,8 @@ Page({
}); });
if (res.data.validType == 1) { if (res.data.validType == 1) {
that.setData({ that.setData({
validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dddd"),
validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dddd"),
validStartDate: util.formatTime(res.data.validStartDate, "yyyy-MM-dd"),
validEndDate: util.formatTime(res.data.validEndDate, "yyyy-MM-dd"),
}); });
} else { } else {
that.setData({ that.setData({
@@ -134,7 +132,8 @@ Page({
/** /**
* 支付订单更新 * 支付订单更新
*/ */
payOrderUpdate: (orderId, payOrderId, status, reason) => {
payOrderUpdate: (orderId, payOrderId, status, reason,type) => {
let that=this;
// 支付成功 // 支付成功
Http.post({ Http.post({
url: config.api.payOrderUpdate, url: config.api.payOrderUpdate,
@@ -145,12 +144,22 @@ Page({
reason: reason reason: reason
} }
}) })
.then(res => {
console.log("payOrderUpdate then", res);
})
.catch(err => {
console.log("payOrderUpdate catch", err);
});
.then(res => {
console.log(that.payOrderUpdate());
console.log("成功");
if(!type){
setTimeout(() => {
wx.navigateTo({
url: `/pages/order/detail/index?orderId=${
orderId
}`
});
}, 1000)
}
})
.catch(err => {

});
}, },
/** /**
* 发起支付 * 发起支付
@@ -166,7 +175,6 @@ Page({
data: {} data: {}
}) })
.then(res => { .then(res => {
console.log(res);
var data = { var data = {
couponChannelId: "" + that.data.couponChannelId, couponChannelId: "" + that.data.couponChannelId,
couponId: "" + that.data.couponId couponId: "" + that.data.couponId
@@ -185,7 +193,6 @@ Page({
}); });
}) })
.catch(err => { .catch(err => {
console.log(err);
if (err.code == "2011") { if (err.code == "2011") {
wx.showToast({ wx.showToast({
title: "商户信息没找到", title: "商户信息没找到",
@@ -272,10 +279,7 @@ Page({
} }
}) })
.then(res => { .then(res => {
console.log(res);
console.log("点击领取卡券一直在loading");
if (typeof (res) != "undefined") { if (typeof (res) != "undefined") {
console.log("", res);
let orderId = "" + res.data.id; let orderId = "" + res.data.id;
that.setData({ that.setData({
orderId: orderId orderId: orderId
@@ -291,7 +295,6 @@ Page({
orderId: orderId orderId: orderId
} }
}).then(res => { }).then(res => {
console.log(res);
/// Begin payment ---- /// Begin payment ----
var payOrderId = "" + res.data.payOrderId; var payOrderId = "" + res.data.payOrderId;
wx.hideLoading(); wx.hideLoading();
@@ -302,19 +305,20 @@ Page({
signType: (res.data.signType) ? res.data.signType : "MD5", signType: (res.data.signType) ? res.data.signType : "MD5",
paySign: res.data.paySign, paySign: res.data.paySign,
success: res => { success: res => {
that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功
console.log(res);

var timesRun = 0;
var interval = setInterval(function () {
timesRun += 1;
if (timesRun === 3) {
clearInterval(interval);
}
that.payOrderUpdate(that.data.orderId, payOrderId, 1, );
}, 2000);
if (res.errMsg == "requestPayment:ok") { if (res.errMsg == "requestPayment:ok") {
setTimeout(function () { setTimeout(function () {
wx.hideLoading(); wx.hideLoading();
}, 2000); }, 2000);
setTimeout(() => {
wx.navigateTo({
url: `/pages/order/detail/index?orderId=${
that.data.orderId
}`
});
}, 1000)
/** /**
* 用户支付成功以后跳转到券包列表 * 用户支付成功以后跳转到券包列表
*/ */
@@ -336,8 +340,7 @@ Page({
}, },


fail: res => { fail: res => {
that.payOrderUpdate(that.data.orderId, payOrderId, 2); // 支付失败
console.log(res);
that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail'); // 支付失败
return; return;
}, },
complete: res => { complete: res => {
@@ -364,8 +367,6 @@ Page({
}` }`
}); });
}, 1000) }, 1000)
//////////////////////////停车券
console.log(that.data.data.type)
if (that.data.data.type == 5) { if (that.data.data.type == 5) {
setTimeout(() => { setTimeout(() => {
wx.switchTab({ wx.switchTab({
@@ -388,20 +389,16 @@ Page({
path: '/pages/index/index', path: '/pages/index/index',
success: function (res) { success: function (res) {
if (res.errMsg == 'shareAppMessage:ok') { if (res.errMsg == 'shareAppMessage:ok') {
console.log(res)
} }
}, },
fail: function (error) { fail: function (error) {
if (res.errMsg == 'shareAppMessage:fail cancel') { if (res.errMsg == 'shareAppMessage:fail cancel') {
console.log(error)
} else if (res.errMsg == 'shareAppMessage:fail') { } else if (res.errMsg == 'shareAppMessage:fail') {
console.log(error)
} }
} }
}; };
// 来自页面内的按钮的转发 // 来自页面内的按钮的转发
if (options.from == 'button') { if (options.from == 'button') {
console.log(options)
var eData = options.target.dataset.id; var eData = options.target.dataset.id;
var couponId = options.target.dataset.couponid; var couponId = options.target.dataset.couponid;
// shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${couponId}`; // shareObj.path = `/pages/index/index?couponChannelId=${eData}&couponId=${couponId}`;


+ 23
- 49
pages/order/detail/index.js 查看文件

@@ -119,54 +119,12 @@ Page({
console.log(res); console.log(res);
that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功 that.payOrderUpdate(that.data.orderId, payOrderId, 1); // 支付成功
console.log(res); console.log(res);
if (res.errMsg == "requestPayment:ok") {
wx.showToast({
title: "购买成功",
duration: 2000,
image: "./../../../assets/img/success.png",
mask: false,
success: function () {
wx.showLoading({
title: "加载中..."
});

setTimeout(function () {
wx.hideLoading();
}, 1600);
setTimeout(() => {
wx.navigateTo({
url: `/pages/order/detail/index?orderId=${
that.data.orderId
}`
});
}, 1600);
}
});
}
}, },
fail: res => { fail: res => {
that.payOrderUpdate(that.data.orderId, payOrderId, 2);
that.payOrderUpdate(that.data.orderId, payOrderId, 2,'','fail');
console.log(res); console.log(res);
// wx.showToast({
// title: "支付失败",
// image: "./../../../assets/img/fail.png",
// duration: 2000,
// mask: false
// });
return; return;
}, },
// complete: res => {
// console.log(res);
// if (res.errMsg == "requestPayment:ok") {} else {
// wx.showToast({
// title: "支付失败",
// image: "./../../../assets/img/fail.png",
// duration: 2000,
// mask: false
// });
// }
// return;
// }
}); });
/// End payment -------- /// End payment --------
}); });
@@ -183,7 +141,7 @@ Page({
/** /**
* 支付订单更新 * 支付订单更新
*/ */
payOrderUpdate: (orderId, payOrderId, status, reason) => {
payOrderUpdate: (orderId, payOrderId, status, reason,type) => {
// 支付成功 // 支付成功
Http.post({ Http.post({
url: config.api.payOrderUpdate, url: config.api.payOrderUpdate,
@@ -195,11 +153,27 @@ Page({
} }
}) })
.then(res => { .then(res => {
console.log("payOrderUpdate then", res);
// wx.showToast({
// title: "购买成功",
// duration: 2500
// });
if (!type) {
wx.showToast({
title: "购买成功",
duration: 2000,
image: "./../../../assets/img/success.png",
mask: false,
success: function () {
wx.showLoading({
title: "加载中..."
});
setTimeout(function () {
wx.hideLoading();
}, 1600);
setTimeout(() => {
wx.navigateTo({
url: `/pages/order/detail/index?orderId=${orderId}`
});
}, 1600);
}
});
}
}) })
.catch(err => { .catch(err => {
console.log("payOrderUpdate catch", err); console.log("payOrderUpdate catch", err);


+ 1
- 1
project.config.json 查看文件

@@ -12,7 +12,7 @@
}, },
"compileType": "miniprogram", "compileType": "miniprogram",
"libVersion": "2.0.9", "libVersion": "2.0.9",
"appid": "wx026ee7f6290aa336",
"appid": "wx649b3be73c1afe47",
"projectname": "C", "projectname": "C",
"isGameTourist": false, "isGameTourist": false,
"condition": { "condition": {


正在加载...
取消
保存