码迷,mamicode.com
首页 > 微信 > 详细

asp微信小程序获取用户头像和微信名-asp写的服务端

时间:2018-10-26 13:08:42      阅读:526      评论:0      收藏:0      [点我收藏+]

标签:oba   fun   ==   分享图片   ade   storage   sync   获取   stp   

//index.js
//获取应用实例
var app = getApp()
Page({
data: {
paydata: { title: "支付测试", total_fee:1},
userInfo: {}
},
onLoad: function () {
console.log(‘onLoad‘);
//判断是否获取到了详细信息
if (!wx.getStorageSync("userInfo")) {
wx.navigateTo({ url: ‘/pages/login/index‘})
}

 

},

// 监听输入
bindKeyInput: function (e) {
console.log(e.detail.value);
this.setData({
‘paydata.total_fee‘: e.detail.value
})
},

//
payoff: function(e){
var that = this;
//获取openid
app.wxlogin(function (re) {
console.log(re);
//判断有无openid
if (re) {
that.setData({ ‘paydata.openid‘:re })
//下单
that.xiadan();
}
});
},

//下单
xiadan: function (){
var that = this;
wx.request({
url: app.globalData.apiurl+‘c=payorder‘,
method: ‘POST‘,
header: { ‘content-type‘: ‘application/x-www-form-urlencoded‘ },
data: that.data.paydata,
success: function(res) {
console.log(res);
if(res.data.code=="0"){
//发起支付
that.requestPayment(res.data.data);
}else{
wx.showModal({
title: ‘提示‘,
content: ‘支付发起失败‘,
showCancel:false
});
}
}
})
},

//申请支付
requestPayment: function(obj){
console.log(obj);
var that=this;
wx.requestPayment({
‘timeStamp‘: obj.timeStamp,
‘nonceStr‘: obj.nonceStr,
‘package‘: obj.package,
‘signType‘: obj.signType,
‘paySign‘: obj.paySign,
‘success‘:function(res){
wx.showModal({
title: ‘提示‘,
content: ‘成功支付:‘ + that.data.paydata.total_fee+‘分‘,
showCancel: false
});
},
‘fail‘:function(res){
wx.showModal({
title: ‘提示‘,
content: ‘支付失败‘,
showCancel: false
});
}
})
},

 

 

 

 

})

 

=============================================

互相学习电话微信:18611436777(加微信注明事由)

技术分享图片

asp微信小程序获取用户头像和微信名-asp写的服务端

标签:oba   fun   ==   分享图片   ade   storage   sync   获取   stp   

原文地址:https://www.cnblogs.com/lytocnc/p/9855593.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!