// 订单生成返回数据,弹出是否支付模态
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. 基于socketserver实现并发

    基于tcp的套接字,关键就是两个循环,一个链接循环,一个通信循环 socketserver模块中分两大类:server类(解决链接问题)和request类(解决通信问题) 一.分析socketserv ...

  2. java多线程系列(一)---多线程技能

    java多线程技能 前言:本系列将从零开始讲解java多线程相关的技术,内容参考于<java多线程核心技术>与<java并发编程实战>等相关资料,希望站在巨人的肩膀上,再通过我 ...

  3. leetcode_11. Container With Most Water

    leetcode_11. Container With Most Water 一,问题: Given n non-negative integers a1, a2, ..., an, where ea ...

  4. linux分区满了,如何进行扩容

    转自:https://blog.csdn.net/valage/article/details/73332147 图片中可以看到挂载点“/”的利用率移到100%,空间不够,所以要对其进行分区. 1.  ...

  5. Python之pexpect详解

    一.引子 Pexpect程序主要用于人机对话的模拟,就是那种系统提问,人来回答yes/no,或者账号登陆输入用户名和密码等等的情况.因为这种情况特别多而且繁琐,所以很多语言都有各种自己的实现.最初的第 ...

  6. mysql以zip安装,解决the service already exists(转载)

    喵喵亲测可用: 转自:https://www.cnblogs.com/dichters/p/5929209.html mysql以zip安装, mysqld -install 报错:​The serv ...

  7. MPVUE多环境定义后台URL

    小程序选定了mpvue作为开发框架,搭建开发环境和构建环境.自从用了Travis和Jenkins之后,再也回不到手工构建的时代了. 目的-自动构建 web项目中,自从前后台分离的结构形成,就形成了一个 ...

  8. openstack horizon开发第一天

    horizon插件构造 创建一个dashboardmkdir opesntack_dashboard/dashboards/mydashboardpython manage.py startdash ...

  9. Oz 创建Ubuntu镜像

    参考链接: http://blog.csdn.net/gcogle/article/details/52767135http://tlinux.blog.51cto.com/7288656/17497 ...

  10. 比较语义分割的几种结构:FCN,UNET,SegNet,PSPNet和Deeplab

    简介 语义分割:给图像的每个像素点标注类别.通常认为这个类别与邻近像素类别有关,同时也和这个像素点归属的整体类别有关.利用图像分类的网络结构,可以利用不同层次的特征向量来满足判定需求.现有算法的主要区 ...