daily_rent.js 2.4 KB

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