// 订单生成返回数据,弹出是否支付模态
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. 【HNOI2014】抄卡组

    题面 题解 如果所有的字符串都有通配符,那么只要比较不含通配符的前缀和后缀就可以了. 否则一定有一个串没有通配符.找出这个字符串,然后将所有串与这个串匹配,通配符将\(B\)分成一段一段在\(A\)上 ...

  2. 【CJOJ2433】陌上花开 CDQ分治

    [CJOJ2433]陌上花开 CDQ呲嘚秋分治 WA果然呲嘚秋分治跑得比树套树还快!!!(md理论复杂度不是一样的吗) 但树套树不知道比呲嘚秋高到哪里去辣装X用 Orz hzwer 第一维sort,第 ...

  3. java基础解析系列(三)---HashMap

    java基础解析系列(三)---HashMap java基础解析系列 java基础解析系列(一)---String.StringBuffer.StringBuilder java基础解析系列(二)-- ...

  4. 用xpo实现dc技术的关键点-XPO是如何处理接口类型与真实类型的对应关系的

    https://www.devexpress.com/Support/Center/Question/Details/Q487000/xpodatamodel-and-model-interfaces ...

  5. 第四节:Windows系统安装时BIOS设置及注意

    BIOS系统 BIOS是英文"Basic Input Output System"的缩略词,直译过来后中文名称就是"基本输入输出系统".在IBM PC兼容系统上 ...

  6. 【日常训练】Hockey(CodeForces-96C)

    题意与分析 对于这题题意的理解比较重要,因为这是一条傻逼题: 大小写保持不变 原串中出现的非法字符串里的每一个字符都要替换 Lucky Letter越多越好 这样一种情况下,算法其实特别简单.我傻逼在 ...

  7. AndroidStudio下使用 RecyclerView xml文件不显示预览条目并报错类似:NoClassDefFoundError 问题解决

    在项目中使用RecyclerView是很普遍的,最近工作中遇到了这种情况: RecyclerView可以正常使用 不会报错 但是在layout中的xml文件中不显示并且报错,如下图:(报的错忘了截了, ...

  8. 内置函数——eval、exec、compile

    内置函数——eval.exec.compile eval() 将字符串类型的代码执行并返回结果 print(eval('1+2+3+4')) exec()将自字符串类型的代码执行 print(exec ...

  9. SVN For Mac: Cornerstone.app破解版免费下载

    Cornerstone.app下载地址 链接:https://pan.baidu.com/s/1kwQ65SBgfWXQur8Zdzkyyw  密码:rqe7 Cornerstone303 MAS.a ...

  10. Hyperledger Fabric 中channel配置相关数据结构

    channel Configuration Transaction Hyperledger Fabric区块链网络中的配置存储在一个configuration-transaction的集合中,每个ch ...