order.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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 {
  14. preSecondHandOrderApi
  15. } from '@/api/secondHand.js';
  16. import util from '@/utils/util'
  17. import animationType from '@/utils/animationType.js'
  18. import { ProductMarketingTypeEnum, ProductTypeEnum } from "@/enums/productEnums";
  19. /**
  20. * 去订单详情
  21. */
  22. export function goOrderDetail(orderNo) {
  23. return new Promise(resolve => {
  24. if (!orderNo) return that.$util.Tips({
  25. title: '缺少订单号无法查看订单详情'
  26. });
  27. // #ifdef MP
  28. uni.navigateTo({
  29. url: '/pages/goods/order_details/index?orderNo=' + orderNo
  30. })
  31. // #endif
  32. // #ifndef MP
  33. uni.navigateTo({
  34. animationType: animationType.type,
  35. animationDuration: animationType.duration,
  36. url: '/pages/goods/order_details/index?orderNo=' + orderNo
  37. })
  38. // #endif
  39. });
  40. }
  41. /**
  42. * 去商品详情
  43. */
  44. export function goProductDetail(id, marketingType, params, data, isManage) {
  45. return new Promise(resolve => {
  46. // #ifdef MP
  47. uni.navigateTo({
  48. url: `/pages/goods/goods_details/index?id=${id}&mt=${marketingType}${params}&dataItem=${data||''}&isManage=${isManage}`
  49. })
  50. // #endif
  51. // #ifndef MP
  52. uni.navigateTo({
  53. animationType: animationType.type,
  54. animationDuration: animationType.duration,
  55. url: `/pages/goods/goods_details/index?id=${id}&mt=${marketingType}${params}&dataItem=${data||''}&isManage=${isManage}`
  56. })
  57. // #endif
  58. });
  59. }
  60. /**
  61. * 活动商品、普通商品、购物车、再次购买预下单
  62. */
  63. export function onGetPreOrder(preOrderType, orderDetails) {
  64. return new Promise((resolve, reject) => {
  65. preOrderApi({
  66. "preOrderType": preOrderType,
  67. "orderDetails": orderDetails
  68. }).then(res => {
  69. uni.navigateTo({
  70. url: '/pages/goods/order_confirm/index?orderNo=' + res.data.orderNo
  71. });
  72. }).catch(err => {
  73. return util.Tips({
  74. title: err
  75. });
  76. })
  77. });
  78. }
  79. /**
  80. * 二手交易预下单
  81. */
  82. export function onGetPreSecondHandOrder(orderDetails) {
  83. return new Promise((resolve, reject) => {
  84. preSecondHandOrderApi({
  85. "orderDetails": orderDetails
  86. }).then(res => {
  87. uni.navigateTo({
  88. url: '/pages/goods/order_confirm/index?orderNo=' + res.data.orderNo + '&orderType=secondHand'
  89. });
  90. }).catch(err => {
  91. return util.Tips({
  92. title: err
  93. });
  94. })
  95. });
  96. }
  97. /**
  98. * 售后,撤销售后申请
  99. */
  100. export function onRevokeRefund(refundOrderNo) {
  101. return new Promise((resolve, reject) => {
  102. uni.showModal({
  103. title: '提示',
  104. content: '确定要撤销本次退款申请吗?',
  105. success: function(res) {
  106. if (res.confirm) {
  107. refundOrderRevokeApi(refundOrderNo).then(res => {
  108. resolve()
  109. }).catch(err => {
  110. return util.Tips({
  111. title: err
  112. });
  113. })
  114. } else if (res.cancel) {
  115. console.log('用户点击取消');
  116. }
  117. }
  118. });
  119. });
  120. }
  121. /**
  122. * 去协议详情
  123. */
  124. export function goToAgreement(from) {
  125. return new Promise(resolve => {
  126. // #ifdef MP
  127. uni.navigateTo({
  128. url: `/pages/goods/agreement_info/index?from=${from}`
  129. })
  130. // #endif
  131. // #ifndef MP
  132. uni.navigateTo({
  133. animationType: animationType.type,
  134. animationDuration: animationType.duration,
  135. url: `/pages/goods/agreement_info/index?from=${from}`
  136. })
  137. // #endif
  138. });
  139. }
  140. // 普通商品、虚拟(开启可申请退款开关)、视频号可申请退款
  141. export function isRefund(orderInfo) {
  142. return (
  143. orderInfo.type === ProductMarketingTypeEnum.Normal &&
  144. (orderInfo.secondType === ProductTypeEnum.Normal ||
  145. orderInfo.secondType === ProductTypeEnum.Fictitious ||
  146. orderInfo.secondType === ProductTypeEnum.Video)
  147. )
  148. }