index.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. const app = getApp()
  2. const httpUtils = require('../../utils/http.js')
  3. const ui = require('../../utils/ui.js')
  4. Page({
  5. data: {
  6. tab: 1,
  7. money: 100
  8. },
  9. deviceid: '',
  10. onLoad(options) {
  11. this.deviceid = options.deviceid
  12. },
  13. changeTab(e){
  14. console.log(e)
  15. this.setData({
  16. tab: e.target.dataset.info
  17. })
  18. if(e.target.dataset.info == 1){
  19. this.setData({
  20. money: 100
  21. })
  22. }else if(e.target.dataset.info == 2){
  23. this.setData({
  24. money: 200
  25. })
  26. }else if(e.target.dataset.info == 3){
  27. this.setData({
  28. money: 500
  29. })
  30. }
  31. },
  32. toRecharge(){
  33. let obj = {
  34. url: '/api/erp/we/wePhoneCharge',
  35. data: {
  36. deviceId: this.deviceid,
  37. deposit: 100,
  38. token: wx.getStorageSync('token'),
  39. }
  40. }
  41. httpUtils.request(obj).then(res=>{
  42. console.log("pay",res)
  43. let payInfo = res.data.data
  44. // 调取后端接口后微信下单
  45. wx.requestPayment({
  46. timeStamp: payInfo.timeStamp,
  47. nonceStr: payInfo.nonceStr,
  48. package: payInfo.package,
  49. signType: payInfo.signType,
  50. paySign: payInfo.paySign,
  51. success (res1) {
  52. console.log("支付",res1)
  53. },
  54. fail (res1) {
  55. }
  56. })
  57. }).catch(err=>{
  58. console.log('ERROR')
  59. });
  60. }
  61. })