// 订单生成返回数据,弹出是否支付模态
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. [WC2011]最大XOR和路径 线性基

    [WC2011]最大XOR和路径 LG传送门 需要充分发掘经过路径的性质:首先注意不一定是简单路径,但由于统计的是异或值,重复走是不会被统计到的,考虑对于任意一条从\(1\)到\(n\)的路径的有效部 ...

  2. PCA人脸识别的python实现

    这几天看了看PCA及其人脸识别的流程,并在网络上搜相应的python代码,有,但代码质量不好,于是自己就重新写了下,对于att_faces数据集的识别率能达到92.5%~98.0%(40种类型,每种随 ...

  3. Flutter - Error: 'xxx' is imported from both package...

    Compiler message: lib/main.dart:77:32: Error: 'Toast' is imported from both 'package:easy_alert/src/ ...

  4. springmvc框架开发中解决产生的乱码情况

    一:解决post请求方式产生的乱码情况 示例代码如下: <!-- 解决post乱码 --> <filter> <filter-name>CharacterEncod ...

  5. 安装vs2017后,RDLC 报表定义具有无法升级的无效目标命名空间

    原先的RDLC报表定义用的命名空间是2008,用vs2017报表设计器重新保存后,会自动升级成2016,导致无法使用. 不想升级控件,太麻烦,所以就手动修改RDLC文件吧. 1.修改http://sc ...

  6. 使用vs2015编译、部署ssd-caffe(weiliu89版,CPU模式)

    前因项目所需,须训练一个快速模型以实现目标物体的实时检测.历经多次实践,发现MobileNetSSD网络符合要求,故在本人工作PC上部署weiliu89版本的ssd-caffe以期用之训练项目要求之模 ...

  7. Unity中使用C#实现UDP广播

    没有系统的学习过网络,想做联机游戏还真是费劲,想做在局域网内实现自动搜索服务器的功能,然后就想到了使用UDP进行广播,把服务器的信息广播给每一个玩家. Socket udpSocket = new S ...

  8. Table 组件构建过程中遇到的问题与解决思路

    在 GearCase 开源项目构建 Table 组件的过程中.遇到了各式各样的问题,最后尝试了各种方法去解决这些问题. 遇到的部分问题 checkbox 的全选和半选问题 table 组件的排序请求方 ...

  9. 【Docker】第四篇 Docker仓库管理

    一.仓库概述 仓库(Repository):Docker仓库主要用于镜像的存储,它是镜像分发.部署的关键.仓库分为公共仓库和私有仓库. 注册服务器(Registry)和仓库区别:注册服务器上往往存放着 ...

  10. pytorch 如何使用tensorboard实时查看曲线---- tensorboardX简介

    用惯了tensorflow的小伙伴肯定都用过tensorboard工具吧.虽然Facebook也推出了visdom,但是在一次不小心误触clear之后,我放弃了这个工具(页面的一个clear按钮我本来 ...