当前位置:   article > 正文

ASP源代码后台+小程序开发(二)_asp微信小程序源码

asp微信小程序源码

小程序微信支付,ASP源代码。手机同微信:13522116288(全套源代码出售)

小程序前台代码:

  // --------------------------------------------------第1步  获取openID

  getOpenId: function (get_code) {

    var that = this;

    var get_openId = wx.getStorageSync("get_openId")

    that.generateOrder(get_openId)    

  },

  // --------------------------------------------------第2步  获得商户订单编号

  generateOrder: function (openid) {

    var that = this     

    var get_zhangtao = wx.getStorageSync('zhangtao');

    var my_phone = wx.getStorageSync("sisoft_phone2")

    var my_url_ = doMain + "order_get_trade_no.asp" 

    var trail_url = my_url_ + "?p_zhangtao=" + get_zhangtao

    trail_url = trail_url + "&p_phone=" + my_phone

    console.log('trail_url: ', trail_url)

    wx.request({

      url: my_url_,//后台请求地址

      method: 'GET',

      data: {

        p_zhangtao: get_zhangtao , /// 不可以重复 20200416 

        p_phone: my_phone , 

      },

      success: function (res) {

        console.log("结算前计算商户单号:", res)

        that.setData({

            trade_no: res.data[0].trade_no 

        })

        //费用是含送货费的  20200417

        that.pay_sign(that.data.trade_no, that.data.totalPrice_send_fee, that)

       }

     })

   }, 

    // --------------------------------------------------第3步  求签名

    pay_sign: function (get_trade_no, get_fee ,that ) {       

      var get_openId = wx.getStorageSync("get_openId")

      var my_url_pay = doMain + "payfee.asp"

      var trail_url = my_url_pay + "?order_no=" + get_trade_no

      trail_url = trail_url + "&fee=" + get_fee

      trail_url = trail_url + "&gname=" + '平泉'

      trail_url = trail_url + "&openid=" + get_openId

      console.log('trail_url: ', trail_url)

      wx.request({

        url: my_url_pay, 

        method: 'GET',

        data: {

          order_no: get_trade_no ,  

          fee:  get_fee ,

          gname: '平泉邦民',

          openid: get_openId,         

        },

        success: function (res) {

          console.log("后台获取数据成功res", res );          

          var param = { "timeStamp": res.data[0].timeStamp, "package": res.data[0].package, "paySign": res.data[0].paySign, "signType": "MD5", "nonceStr": res.data[0].nonceStr };

          // 发起支付 -------------------

          that.pay(param);

        },

        fail: function (res) {

          console.log("向后台发送数据失败")

        }

      })

   }   ,

  // --------------------------------------------------第3步   支付 wx.requestPayment

  pay: function (param) {

    var that = this;

    var get_zhangtao = wx.getStorageSync('zhangtao');

    var my_phone = wx.getStorageSync("sisoft_phone2")

    console.log("发起支付===========================")

    //console.log(param)

    wx.requestPayment({

      timeStamp: param.timeStamp,

      nonceStr: param.nonceStr,

      package: param.package,

      signType: param.signType,

      paySign: param.paySign,       

      success: function (res) {

        /  等待 点 完成 按钮 。。。。。。

        console.log("支付success,然后处理更新后台数据"); 这个在后台asp通知url里处理20200416        

        ///关闭本页面20200412

        wx.navigateBack({

          delta: 2

        })

      },

      fail: function (res) {

        console.log("fail,没有支付成功!")

        console.log(res);

      },

      complete: function (res) {

        console.log("complete");

        console.log(res)

      }       

    })     

  },

 ASP后台代码payfee.asp:


<!--#include file="WeChatPay.asp"-->

<%
  dim resultdata,result
  dim openid
' session("useropenid")=request.QueryString("openid")
  order_no  =request.QueryString("order_no") 
  fee   =request.QueryString("fee") 
  gname = request.QueryString("gname")  
  openid =request.QueryString("openid")     '  "oG5T-45ff-NmNctRPd_hQRZNXc-I"
  set pay = new WeChatPay
  result = pay.Pay( order_no , gname , gname , fee ,openid)
  response.write result
  
  'resultdata =pay.GetParaValue(result, "prepay_id")
  'response.write resultdata
%>

 

 

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/945710
推荐阅读
相关标签
  

闽ICP备14008679号