orderDetail.js 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. var util = require('../../../utils/util.js');
  2. var api = require('../../../config/api.js');
  3. Page({
  4. data: {
  5. orderId: 0,
  6. orderInfo: {},
  7. orderGoods: [],
  8. handleOption: {}
  9. },
  10. onLoad: function (options) {
  11. // 页面初始化 options为页面跳转所带来的参数
  12. this.setData({
  13. orderId: options.id
  14. });
  15. this.getOrderDetail();
  16. },
  17. getOrderDetail() {
  18. let that = this;
  19. util.request(api.OrderDetail, {
  20. orderId: that.data.orderId
  21. }).then(function (res) {
  22. if (res.errno === 0) {
  23. console.log(res.data);
  24. that.setData({
  25. orderInfo: res.data.orderInfo,
  26. orderGoods: res.data.orderGoods,
  27. handleOption: res.data.handleOption
  28. });
  29. //that.payTimer();
  30. }
  31. });
  32. },
  33. payTimer() {
  34. let that = this;
  35. let orderInfo = that.data.orderInfo;
  36. setInterval(() => {
  37. console.log(orderInfo);
  38. orderInfo.add_time -= 1;
  39. that.setData({
  40. orderInfo: orderInfo,
  41. });
  42. }, 1000);
  43. },
  44. payOrder() {
  45. let that = this;
  46. util.request(api.PayPrepayId, {
  47. orderId: that.data.orderId || 15
  48. }).then(function (res) {
  49. if (res.errno === 0) {
  50. const payParam = res.data;
  51. wx.requestPayment({
  52. 'timeStamp': payParam.timeStamp,
  53. 'nonceStr': payParam.nonceStr,
  54. 'package': payParam.package,
  55. 'signType': payParam.signType,
  56. 'paySign': payParam.paySign,
  57. 'success': function (res) {
  58. console.log(res)
  59. },
  60. 'fail': function (res) {
  61. console.log(res)
  62. }
  63. });
  64. }
  65. });
  66. },
  67. onReady: function () {
  68. // 页面渲染完成
  69. },
  70. onShow: function () {
  71. // 页面显示
  72. },
  73. onHide: function () {
  74. // 页面隐藏
  75. },
  76. onUnload: function () {
  77. // 页面关闭
  78. }
  79. })