groupDetail.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. // lionfish_comshop/pages/groupCenter/groupDetail.js
  2. var app = getApp();
  3. var util = require('../../utils/util.js');
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. order: {}
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. this.setData({
  16. orderId: options.groupOrderId
  17. });
  18. if (util.check_login()) {
  19. this.setData({ needAuth: false })
  20. } else {
  21. this.setData({ needAuth: true });
  22. }
  23. wx.showLoading({
  24. title: "加载中...",
  25. mask: true
  26. });
  27. this.getData();
  28. },
  29. authSuccess: function () {
  30. let that = this;
  31. this.setData({
  32. needAuth: false
  33. }, ()=>{
  34. that.getData();
  35. })
  36. },
  37. /**
  38. * 生命周期函数--监听页面显示
  39. */
  40. onShow: function () {
  41. },
  42. /**
  43. * 获取数据
  44. */
  45. getData: function(){
  46. var that = this;
  47. var token = wx.getStorageSync('token');
  48. if (this.data.orderId){
  49. app.util.request({
  50. 'url': 'entry/wxapp/index',
  51. 'data': {
  52. controller: 'order.order_head_info',
  53. token: token,
  54. id: this.data.orderId
  55. },
  56. dataType: 'json',
  57. success: function (res) {
  58. wx.hideLoading();
  59. if (res.data.code == 0) {
  60. let order = res.data.data;
  61. let commision = 0;
  62. order && order.order_goods_list && order.order_goods_list.forEach(function (item) {
  63. commision += parseFloat(item.commision);
  64. })
  65. that.setData({
  66. order: res.data.data,
  67. commision: commision.toFixed(2)
  68. });
  69. }
  70. }
  71. })
  72. } else {
  73. wx.showModal({
  74. title: '提示',
  75. content: '订单不存在',
  76. showCancel: false,
  77. success(res) {
  78. if (res.confirm) {
  79. wx.redirectTo({
  80. url: '/lionfish_comshop/pages/groupCenter/groupList',
  81. })
  82. }
  83. }
  84. })
  85. }
  86. },
  87. /**
  88. * 状态判断
  89. */
  90. swithState: function (e) {
  91. switch (e) {
  92. case "-1":
  93. break;
  94. case "0":
  95. this.setData({
  96. orderStatusName: "待成团"
  97. });
  98. break;
  99. case "1":
  100. this.setData({
  101. orderStatusName: "待配送"
  102. });
  103. break;
  104. case "2":
  105. this.setData({
  106. orderStatusName: "待收货"
  107. });
  108. break;
  109. case "3":
  110. this.setData({
  111. orderStatusName: "待提货"
  112. });
  113. break;
  114. case "4":
  115. this.setData({
  116. orderStatusName: "已完成"
  117. });
  118. break;
  119. case "6":
  120. this.setData({
  121. orderStatusName: "待采购"
  122. });
  123. }
  124. }
  125. })