orderDetails.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. let app = getApp();
  2. var status = require('../../utils/index.js');
  3. Page({
  4. mixins: [require('static/orderMixin.js')],
  5. data: {
  6. common_header_backgroundimage: app.globalData.common_header_backgroundimage,
  7. changePrice: 0
  8. },
  9. id: '',
  10. /**
  11. * 生命周期函数--监听页面加载
  12. */
  13. onLoad: function (options) {
  14. let id = options.id || '';
  15. if(!id) {
  16. app.util.message('参数错误', '/lionfish_comshop/moduleB/supply/orderManage', 'error');
  17. return;
  18. }
  19. this.id = id;
  20. status.setGroupInfo().then((groupInfo) => {
  21. this.setData({ groupInfo })
  22. });
  23. this.initFn(id);
  24. },
  25. /**
  26. * 生命周期函数--监听页面显示
  27. */
  28. onShow: function () {
  29. },
  30. initFn: function(){
  31. this.setData({showRaderList: false});
  32. wx.showLoading();
  33. let id = this.id;
  34. let token = wx.getStorageSync('token');
  35. app.util.ProReq('order.order_info', {token, id, is_supply: 1}).then(res=>{
  36. let order = res.data;
  37. let { is_hidden_orderlist_phone, presale_info } = res;
  38. let { real_total, shipping_fare, voucher_credit, fullreduction_money } = order.order_info;
  39. var goodsTotal = parseFloat(real_total) - parseFloat(shipping_fare);
  40. let disAmount = parseFloat(voucher_credit) + parseFloat(fullreduction_money);
  41. disAmount = (disAmount > goodsTotal) ? goodsTotal : disAmount;
  42. let changePrice = 0;
  43. if(order.order_info.is_change_price==1) {
  44. changePrice = Math.abs(order.order_info.admin_change_price);
  45. }
  46. let levelAmount = 0;
  47. let order_goods_list = order.order_goods_list;
  48. if(order_goods_list&&order_goods_list.length) {
  49. order_goods_list.forEach(function(item){
  50. let total = item.total * 1;
  51. let old_total = item.old_total * 1;
  52. if (item.is_level_buy==1 || item.is_vipcard_buy==1) {
  53. levelAmount += old_total - total;
  54. }
  55. })
  56. }
  57. presale_info = Object.keys(presale_info).length ? presale_info : '';
  58. this.setData({
  59. order,
  60. is_hidden_orderlist_phone,
  61. goodsTotal: goodsTotal.toFixed(2),
  62. disAmount: disAmount.toFixed(2),
  63. levelAmount: levelAmount.toFixed(2),
  64. changePrice: changePrice.toFixed(2),
  65. presale_info
  66. })
  67. }).catch(err=>{
  68. app.util.message(err.msg, 'switchTo:/lionfish_comshop/pages/user/me', 'error');
  69. })
  70. },
  71. callTelphone: function (t) {
  72. var e = this;
  73. this.data.isCalling || (this.data.isCalling = true, wx.makePhoneCall({
  74. phoneNumber: t.currentTarget.dataset.phone,
  75. complete: function () {
  76. e.data.isCalling = false;
  77. }
  78. }));
  79. },
  80. goExpress: function(){
  81. let order_id = this.data.order.order_info.order_id;
  82. wx.navigateTo({
  83. url: '/lionfish_comshop/pages/order/goods_express?id=' + order_id,
  84. })
  85. },
  86. hideExpModal: function(){
  87. this.setData({
  88. showExpModal: false
  89. })
  90. }
  91. })