• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

微信小程序 功能函数 支付接口

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
// 订单生成返回数据,弹出是否支付模态
wx.showModal({
title: \'微信支付\',
content: \'确定支付吗?\',
success: function (res) {
if (res.confirm) {
self.pay(bianhao);
} else if (res.cancel) {
setTimeout(function () {
wx.redirectTo({
url: "/pages/user/dingdan?id=2&&status=1"
})
}, 1500)
}
}
})
 
 
 

// 支付
pay: function (a) {
 
var that=this;
var allAdd = that.data.allAdd
console.log(allAdd)
var gongprice = parseInt(this.data.gongprice);
// console.log(gongprice)
var user = wx.getStorageSync(\'user\');
 
var openid = user.openid;
var phone = user.userphone;
var member = user.member;
//----------------------------------------------------------
var gongpriceChe=that.data.gongpriceChe

//----------------------------------------------------------
// 微信支付请求
self = this;
wx.showToast({
title: \'请求中.....\',
icon: \'loading\',
duration: 1000
})
wx.request({
url: \'https://www.didu86.com/Clothes-manager-web/payMoney\',
data: {
openid: openid,
wx_total_fee: gongprice,
wx_body: \'时装圈子\',
wx_out_trade_no: a
},
header: {
\'content-type\': \'application/json\'
},
success: function (res) {
// console.log(res)
var dateTime = new Date();
var timestamp1 = Date.parse(new Date());
var json = res.data.result;
// console.log(json)
// console.log(json.appid)
var pk = \'prepay_id=\' + json.prepay_id;
// console.log(pk)
wx.requestPayment({
\'appId\': json.appid,
\'timeStamp\': json.timeStamp,
\'nonceStr\': json.noncestr,
\'package\': pk,
\'signType\': \'MD5\',
\'paySign\': json.paySign,
\'success\': function (res) {
// 修改状态
var myDate = new Date();
var myN = myDate.getFullYear();
var myY = myDate.getMonth();
var myR = myDate.getDate();
var myh = myDate.getHours();
var mym = myDate.getMinutes();
var mys = myDate.getSeconds();
if (myDate.getHours() < 10) {
myh = \'0\' + myDate.getHours(); //补齐
}
if (myDate.getMinutes() < 10) {
mym = \'0\' + myDate.getMinutes(); //补齐
}
if (myDate.getSeconds() < 10) {
mys = \'0\' + myDate.getSeconds(); //补齐
}
if (myDate.getDate() < 10) {
myR = \'0\' + myDate.getDate(); //补齐
}
var successTime = \'\' + myN + \'-\' + (myY + 1) + \'-\' + myR + \' \' + myh + \':\' + mym + \':\' + mys;

//------------------
// 余额支付
if (that.data.switChange) {
// 余额支付请求
wx.request({
url: \'https://www.didu86.com/Clothes-manager-web/updateOrdersBalance\',
data: {
balance: that.data.discountsDelete,
serial: that.data.seriarlChe
},
success: function (res) {
console.log(res.data + "余额花费")
}
});

}
//------------------
var linallChe = parseFloat(gongpriceChe * that.data.allAdd);
if (member==\'1\'){
linallChe = linallChe
}else{
linallChe=0
}
var allFan = parseFloat(that.data.discounts) + linallChe;
console.log(allFan)
// 微信
wx.request({
url: \'https://www.didu86.com/Clothes-manager-web/updateTotalSpend\',
data: {
id: user.id,
openid:user.openid,
userphone: user.userphone,
balance: allFan,
totalspend: gongpriceChe
},
success: function (res) {
console.log(res.data + "余额加总消费")
}
});
//------------------
// 销量
wx.request({
url: \'https://www.didu86.com/Clothes-manager-web/updateVolume\',
data: {
serial: that.data.seriarlChe,
},
success: function (res) {
console.log(res.data+"销量更改")
}
});
//------------------
// 修改状态
// time: successTime,
wx.request({
url: \'https://www.didu86.com/Clothes-manager-web/updateOrders\',
data: {
serial: that.data.seriarlChe,
status:"2",
btime: successTime
},
success: function (res) {
console.log(res.data + "状态修改")
}
});
wx.showToast({
title: \'支付成功\',
})

setTimeout(function () {
wx.switchTab({
url: "/pages/user/user"
})
}, 1500)
 

},
\'fail\': function (res) {
// console.log(res)
wx.showToast({
title: \'支付失败\',
})

},
})
},
})

},

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap