orderPaySn.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. const getReq = require('./../../config.js').getReq
  2. let appInstance = getApp()
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. order_info: {},
  9. defaultAddress: null
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. let pay_sn = options.pay_sn;
  16. this.getDatas(pay_sn);
  17. },
  18. getDatas(pay_sn) {
  19. let self = this;
  20. wx.showLoading({
  21. title: '加载中',
  22. })
  23. getReq({
  24. act: 'member_order',
  25. op: 'pay_info',
  26. pay_sn: pay_sn
  27. }, function (res) {
  28. wx.hideLoading();
  29. if (res.code == 200) {
  30. console.log(res);
  31. self.setData({
  32. defaultAddress: {
  33. mob_phone: res.datas.order.reciver_info.mob_phone,
  34. true_name: res.datas.order.reciver_info.reciver_name,
  35. area_info: res.datas.order.reciver_info.area,
  36. address: res.datas.order.reciver_info.street
  37. },
  38. order_info: res.datas.order.order_info
  39. });
  40. }
  41. else {
  42. wx.showToast({
  43. icon: 'none',
  44. title: res.message,
  45. duration: 2000
  46. })
  47. }
  48. })
  49. },
  50. getGoodsList(summary, goods_list) {
  51. let newGoodsList = []
  52. goods_list.map((item, index) => {
  53. summary.find((list, key) => {
  54. if (item.goods_id == list.goods_id) {
  55. let goods_item = list
  56. goods_item.goods_num = item.goods_num
  57. newGoodsList.push(goods_item)
  58. return true
  59. }
  60. })
  61. })
  62. return newGoodsList
  63. },
  64. toPay() {
  65. let params = {
  66. act: 'member_order',
  67. op: 'pay',
  68. pay_sn: this.data['order_info']['pay_sn'],
  69. payment: 'minipay'
  70. }
  71. getReq(params, function (res) {
  72. if (res.code == 200) {
  73. let param = res.datas.param.data;
  74. wx.requestPayment({
  75. timeStamp: param.timeStamp, //时间戳,自1970年以来的秒数
  76. nonceStr: param.nonceStr, //随机串
  77. package: param.package,
  78. signType: param.signType, //微信签名方式:
  79. paySign: param.paySign, //微信签名
  80. success: function (res) {
  81. // wx.showToast({
  82. // icon: 'none',
  83. // title: res,
  84. // duration: 2000
  85. // })
  86. wx.reLaunch({
  87. url: "/pages/index/index"
  88. })
  89. console.log("成功:" + res);
  90. console.log('支付成功')
  91. },
  92. fail: function (res) {
  93. wx.showToast({
  94. icon: 'none',
  95. title: res,
  96. duration: 2000
  97. })
  98. console.log("失败:" + res);
  99. }
  100. });
  101. }
  102. })
  103. },
  104. /**
  105. * 生命周期函数--监听页面初次渲染完成
  106. */
  107. onReady: function () {
  108. },
  109. /**
  110. * 生命周期函数--监听页面显示
  111. */
  112. onShow: function () {
  113. if (!this.data.firstLoad) {
  114. let defaultAddress = appInstance.globalData.defaultAddress
  115. this.setData({
  116. defaultAddress
  117. })
  118. }
  119. },
  120. /**
  121. * 生命周期函数--监听页面隐藏
  122. */
  123. onHide: function () {
  124. },
  125. /**
  126. * 生命周期函数--监听页面卸载
  127. */
  128. onUnload: function () {
  129. },
  130. /**
  131. * 页面相关事件处理函数--监听用户下拉动作
  132. */
  133. onPullDownRefresh: function () {
  134. },
  135. /**
  136. * 页面上拉触底事件的处理函数
  137. */
  138. onReachBottom: function () {
  139. }
  140. })