order.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. // +----------------------------------------------------------------------
  2. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  3. // +----------------------------------------------------------------------
  4. // | Copyright (c) 2016~2025 https://www.crmeb.com All rights reserved.
  5. // +----------------------------------------------------------------------
  6. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  7. // +----------------------------------------------------------------------
  8. // | Author: CRMEB Team <admin@crmeb.com>
  9. // +----------------------------------------------------------------------
  10. import {
  11. preOrderApi,refundOrderRevokeApi
  12. } from '@/api/order.js';
  13. import util from '@/utils/util'
  14. import animationType from '@/utils/animationType.js'
  15. import { ProductMarketingTypeEnum, ProductTypeEnum } from "@/enums/productEnums";
  16. /**
  17. * 去订单详情
  18. */
  19. export function goOrderDetail(orderNo) {
  20. return new Promise(resolve => {
  21. if (!orderNo) return that.$util.Tips({
  22. title: '缺少订单号无法查看订单详情'
  23. });
  24. // #ifdef MP
  25. uni.navigateTo({
  26. url: '/pages/goods/order_details/index?orderNo=' + orderNo
  27. })
  28. // #endif
  29. // #ifndef MP
  30. uni.navigateTo({
  31. animationType: animationType.type,
  32. animationDuration: animationType.duration,
  33. url: '/pages/goods/order_details/index?orderNo=' + orderNo
  34. })
  35. // #endif
  36. });
  37. }
  38. /**
  39. * 去商品详情
  40. */
  41. export function goProductDetail(id, marketingType, params) {
  42. return new Promise(resolve => {
  43. // #ifdef MP
  44. uni.navigateTo({
  45. url: `/pages/goods/goods_details/index?id=${id}&mt=${marketingType}${params}`
  46. })
  47. // #endif
  48. // #ifndef MP
  49. uni.navigateTo({
  50. animationType: animationType.type,
  51. animationDuration: animationType.duration,
  52. url: `/pages/goods/goods_details/index?id=${id}&mt=${marketingType}${params}`
  53. })
  54. // #endif
  55. });
  56. }
  57. /**
  58. * 活动商品、普通商品、购物车、再次购买预下单
  59. */
  60. export function onGetPreOrder(preOrderType, orderDetails) {
  61. return new Promise((resolve, reject) => {
  62. preOrderApi({
  63. "preOrderType": preOrderType,
  64. "orderDetails": orderDetails
  65. }).then(res => {
  66. uni.navigateTo({
  67. url: '/pages/goods/order_confirm/index?orderNo=' + res.data.orderNo
  68. });
  69. }).catch(err => {
  70. return util.Tips({
  71. title: err
  72. });
  73. })
  74. });
  75. }
  76. /**
  77. * 售后,撤销售后申请
  78. */
  79. export function onRevokeRefund(refundOrderNo) {
  80. return new Promise((resolve, reject) => {
  81. uni.showModal({
  82. title: '提示',
  83. content: '确定要撤销本次退款申请吗?',
  84. success: function(res) {
  85. if (res.confirm) {
  86. refundOrderRevokeApi(refundOrderNo).then(res => {
  87. resolve()
  88. }).catch(err => {
  89. return util.Tips({
  90. title: err
  91. });
  92. })
  93. } else if (res.cancel) {
  94. console.log('用户点击取消');
  95. }
  96. }
  97. });
  98. });
  99. }
  100. /**
  101. * 去协议详情
  102. */
  103. export function goToAgreement(from) {
  104. return new Promise(resolve => {
  105. // #ifdef MP
  106. uni.navigateTo({
  107. url: `/pages/goods/agreement_info/index?from=${from}`
  108. })
  109. // #endif
  110. // #ifndef MP
  111. uni.navigateTo({
  112. animationType: animationType.type,
  113. animationDuration: animationType.duration,
  114. url: `/pages/goods/agreement_info/index?from=${from}`
  115. })
  116. // #endif
  117. });
  118. }
  119. // 普通商品、虚拟(开启可申请退款开关)、视频号可申请退款
  120. export function isRefund(orderInfo) {
  121. return (
  122. orderInfo.type === ProductMarketingTypeEnum.Normal &&
  123. (orderInfo.secondType === ProductTypeEnum.Normal ||
  124. orderInfo.secondType === ProductTypeEnum.Fictitious ||
  125. orderInfo.secondType === ProductTypeEnum.Video)
  126. )
  127. }