// 订单生成返回数据,弹出是否支付模态
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. 4821: [Sdoi2017]相关分析

    4821: [Sdoi2017]相关分析 链接 分析: 大力拆式子,化简,然后线段树.注意精度问题与爆longlong问题. 代码: #include<cstdio> #include&l ...

  2. Kafka系列一 基本安装

    一 配置文件(下载.解压.跳过) # Licensed to the Apache Software Foundation (ASF) under one or more # contributor ...

  3. Storm 第三章 Storm编程案例及Stream Grouping详解

    1 功能说明 设计一个topology,来实现对文档里面的单词出现的频率进行统计.整个topology分为三个部分: SentenceSpout:数据源,在已知的英文句子中,随机发送一条句子出去. S ...

  4. html元素可以同时实现两个class的功能

    html元素标签可以放置两个不同的class文件并分别实现效果

  5. 服务器路由配置--Route

    第1章 命令配置 虚拟服务器 网卡配置信息 虚拟网卡名称 虚拟网卡模式 服务器01 eth1 10.0.0.10/24 nat模式 服务器02 eth2 10.0.0.11/24 nat模式 eth3 ...

  6. Spring学习(十四)----- Spring Auto Scanning Components —— 自动扫描组件

    一.      Spring Auto Scanning Components —— 自动扫描组件 1.      Declares Components Manually——手动配置componen ...

  7. 开源项目CIIP(企业信息管理系统框架).2018.0904版更新介绍

    源码: https://github.com/tylike/CIIP https://gitee.com/ciip/CIIP 一,CIIP的目标是什么? 更加简单,快速的建立信息类管理系统.让实施人员 ...

  8. (转载)面试题收集——Java基础部分(一)

    转自:http://www.cnblogs.com/xdp-gacl/p/3641769.html 1.一个".java"源文件中是否可以包括多个类(不是内部类)?有什么限制? 可 ...

  9. [环境配置]Ubuntu16.04下编译安装gcc6.3.0

    上一篇的SVS要用gcc6.3编译,否则结果不正确,本来以为gcc很好装,结果发现用apt-get安装gcc6只能安装6.5版本,代码作者奇特的要求只能用gcc6.3,没办法只能用源码装了,期间碰见了 ...

  10. Kickstart Round G 2018

    第一次打codejam....惨的一比,才A1.5题,感觉自己最近状态渣到姥姥家了,赶紧练练 A 模拟,注意0的问题 #include <iostream> #include <cs ...