mp.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. // pages/pay/mp.js
  2. const config = require('../../utils/config')
  3. const huoSdk = require('../../libs/huosdk-1.0.0')
  4. const app = getApp()
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. },
  16. /**
  17. * 生命周期函数--监听页面初次渲染完成
  18. */
  19. onReady: function () {
  20. },
  21. /**
  22. * 生命周期函数--监听页面显示
  23. */
  24. onShow: function () {
  25. },
  26. /**
  27. * 生命周期函数--监听页面隐藏
  28. */
  29. onHide: function () {
  30. },
  31. /**
  32. * 生命周期函数--监听页面卸载
  33. */
  34. onUnload: function () {
  35. },
  36. /**
  37. * 页面相关事件处理函数--监听用户下拉动作
  38. */
  39. onPullDownRefresh: function () {
  40. },
  41. /**
  42. * 页面上拉触底事件的处理函数
  43. */
  44. onReachBottom: function () {
  45. },
  46. /**
  47. * 用户点击右上角分享
  48. */
  49. onShareAppMessage: function () {
  50. },
  51. mpPay: function () {
  52. huoSdk.mpPay({
  53. data: {
  54. 'order-currency': 'CNY',
  55. 'order-cp_order_id': '10001',
  56. 'order-product_price': 0.01,
  57. 'order-product_id': '1000000001',
  58. 'order-product_cnt': 1,
  59. 'order-product_name': '金币',
  60. 'order-product_desc': '金币',
  61. 'order-ext': '',
  62. 'role-event': '',
  63. 'role-server_id': '',
  64. 'role-server_name': '',
  65. 'role-role_id': '',
  66. 'role-role_name': '',
  67. 'role-role_level': 0,
  68. 'role-role_vip': 0,
  69. 'token': wx.getStorageSync('userInfo').user_token || '',
  70. 'app_id': config.baseParams.app_id,
  71. 'game-mp_id': config.gameParams['game-mp_id']
  72. }
  73. }).then(res => {
  74. console.log(res)
  75. huoSdk.mpPayQuery({
  76. data: {
  77. 'token': wx.getStorageSync('userInfo').user_token || '',
  78. 'app_id': config.baseParams.app_id,
  79. 'game-mp_id': config.gameParams['game-mp_id']
  80. }
  81. }).then(res => {
  82. console.log(res)
  83. }, err => {
  84. console.log(err)
  85. })
  86. }, err => {
  87. console.log(err)
  88. })
  89. }
  90. })