1. 程式人生 > >asp寫的微信小程序支付demo-服務器端是asp+mdb的

asp寫的微信小程序支付demo-服務器端是asp+mdb的

input image glob orm iad inf 服務器端 .data mage

這個微信小程序支付demo代碼是我用asp寫的,微信小程序端加上服務器端用的asp和mdb數據庫,下面是代碼分享:

<view class="container">


<view class=‘view‘>訂單說明:{{paydata.title}}</view>
<view class=‘view inputview‘>
支付金額:<input bindinput="bindKeyInput" type="number" class="input" placeholder="支付金額" value=‘{{paydata.total_fee}}‘ />分
</view>
<view class=‘view‘>
<button bindtap="payoff" class=‘btn‘ >支付</button>
</view>

</view>

-----------------------

//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寫的微信小程序支付demo-服務器端是asp+mdb的