daily_rent.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. var app = getApp();
  2. const util = require('../../utils/utils.js')
  3. Page({
  4. data: {
  5. show:false,
  6. date:[],
  7. code:''
  8. },
  9. onLoad: function (options) {
  10. this.setData({date:wx.getStorageSync('setting'),code:options.code})
  11. },
  12. btn: util.throttle(function(){
  13. this.setData({show:true})
  14. },1000),
  15. over:util.throttle(function(){
  16. this.setData({ show: false })
  17. },1000),
  18. pay: util.throttle(function () {
  19. var that = this;
  20. wx.getLocation({
  21. success: function (res) {
  22. console.log(res)
  23. if (app.globalData.req) {
  24. var data = {
  25. 'type': 'D',
  26. 'bike_no': that.data.code,
  27. 'area_id': wx.getStorageSync('home').id,
  28. 'lat': res.latitude,
  29. 'lng': res.longitude
  30. }
  31. app.request('/rent/store-order', data, 'POST', app.globalData.req).then(res => {
  32. console.log(res)
  33. if (res.statusCode == 200) {
  34. if (res.data.nonceStr == undefined) {
  35. wx.reLaunch({
  36. url: '/pages/daily_riding/daily_riding?order=' + res.data.no,
  37. })
  38. } else {
  39. wx.requestPayment({
  40. timeStamp: res.data.timeStamp.toString(),
  41. nonceStr: res.data.nonceStr,
  42. package: res.data.package,
  43. signType: res.data.signType,
  44. paySign: res.data.paySign,
  45. success(resp) {
  46. console.log(resp)
  47. wx.reLaunch({
  48. url: '/pages/daily_riding/daily_riding?order=' + res.data.no,
  49. })
  50. },
  51. fail(err) {
  52. console.log(err)
  53. wx.showToast({
  54. title: '支付失败',
  55. icon: 'none'
  56. })
  57. }
  58. })
  59. }
  60. }
  61. })
  62. } else {
  63. wx.showToast({
  64. title: '您的操作过于频繁,请稍后再试~',
  65. icon: 'none'
  66. })
  67. }
  68. },
  69. })
  70. }, 1000),
  71. onReady: function () {
  72. },
  73. onShow: function () {
  74. },
  75. onHide: function () {
  76. },
  77. onUnload: function () {
  78. },
  79. onPullDownRefresh: function () {
  80. },
  81. onReachBottom: function () {
  82. },
  83. onShareAppMessage: function () {
  84. }
  85. })