// 订单生成返回数据,弹出是否支付模态
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: '支付失败',
})
},
})
},
})
},

微信小程序 功能函数 支付接口的更多相关文章

  1. 微信小程序 功能函数 openid本地和网络请求

    本地-------------------------------------------------------------------------------------------------- ...

  2. 微信小程序 功能函数 点击传参和页面

    // 商品详情页跳转函数 detailInto: function (e) { // console.log() var change = e.currentTarget.dataset.id; wx ...

  3. 微信小程序 功能函数 定时震动

    ffn: function () { let nnn = this.data.nnn nnn += 1; this.setData({ nnn: nnn }); if (nnn > 10) { ...

  4. 微信小程序 功能函数 客服

    <view> <view class='btn-img'> <image class='image-full' src='../../imgs/index/tab6.pn ...

  5. 微信小程序 功能函数 将对象的键添加到数组 (函数深入)

    // 将对象的键添加到数组 var arr = Object.keys(site); //英文 https://developer.mozilla.org/en-US/docs/Web/JavaScr ...

  6. 微信小程序 功能函数 购物车商品删除

    // 购物车删除 deleteList(e) { const index = e.currentTarget.dataset.index; let carts = this.data.carts; c ...

  7. 微信小程序 功能函数 替换字符串内的指定字符

    var str = 'abcadeacf'; var str1 = str.replace('a', 'o'); alert(str1);    // 打印结果: obcadeacf   var st ...

  8. 微信小程序 功能函数picker-view的弹出模态

    <view class="list"> <form bindsubmit="formSubmit"> <view class=&q ...

  9. 微信小程序 功能函数 获取验证码*

    yanZhengInput: function (e) { var that = this; var yanzheng = e.detail.value; var huozheng = this.da ...

随机推荐

  1. 将windows上.net core 发布的程序部署到linux(ubantu等)上

    首先在linux安装相应的.net core 环境,根据官方的示例安装即可:参考地址:https://dotnet.microsoft.com/learn/dotnet/hello-world-tut ...

  2. CI/CD系列

    一.CI/CD系列 什么是CI/CD(译) Docker与CI/CD(转) Docker和CI/CD实战 二.Git 三.GitLab

  3. JavaScript中的null和undefined

    null :表示无值;undefined : 表示一个未声明的变量,                或已声明但没有赋值的变量,                或一个并不存在的对象属性. ==运算符将两 ...

  4. 换新 IP 地址的时候,ORCL前置准备条件

    1. 开启虚拟机 ORCL 服务 2.   cmd > ipconfig > 3.   cmd > lsnrctl status > 4.  主机改配置文件 IP,succes ...

  5. 【免费培训】腾讯WeTest&TesterHome WorkShop | 一起学压测

    2019年,中国移动软件市场仍呈现快速增长趋势,移动新生态孕育而生.而移动软件质量问题越发受到用户的关注,成为用户体验的关键因素.目前移动软件测试人才稀缺,而性能测试作为一项高门槛.高技术的测试能力, ...

  6. jQuery瀑布流详解(PC及移动端)

    前言 瀑布流布局已成为当今非常普遍的图片展示方式,无论是PC还是手机等移动设备上.这种布局图片的样式大概分为三种:等高等宽.等宽不等高.等高不等宽,接下来我们就最为普遍的等宽不等高形式来作为示例. 我 ...

  7. apache-日志-记录post数据

    apache access.log日志只能打印出相关的头部信息,例如:Referer, User-agent.但是我希望看到body中的data. 目前找到解决方案是使用apache的扩展module ...

  8. Docker创建容器

    容器是镜像的一个运行实例,是基于镜像运行的轻量级环境,是一个或者一组应用. 怎样创建容器?将容器所基于的镜像名称传入即可,Docker会从本地仓库中寻找该镜像,如果本地仓库没有,则会自动从远程仓库中拉 ...

  9. centos7上的postgresql10安装和配置

    安装数据库 安装参考官方文档:https://www.postgresql.org/download/linux/redhat/ 1.Install the repository RPM: yum i ...

  10. C#_Switch语句的内部实现

    Switch的C#内部实现 https://www.cnblogs.com/Interkey/p/3730432.html 在IL汇编语言中的Switch指令 -- 按照标号来进行跳转(和goto语句 ...