order.js 4.3 KB

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