btnAction.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. export default {
  2. data() {
  3. return {
  4. actionList: [],
  5. showReportSheet: false,
  6. order: {},
  7. };
  8. },
  9. onShow() {
  10. let selectEditAddr = uni.getStorageSync("selectEditAddr");
  11. if (selectEditAddr.id) {
  12. this.handleAddressSubmit(selectEditAddr.id);
  13. }
  14. },
  15. methods: {
  16. //操作成功之后的回调
  17. successFeedback() {
  18. uni.$emit("btnActionSuccess");
  19. },
  20. //修改地址
  21. handleAddressSubmit(addressId) {
  22. const params = {
  23. orderId: this.order.orderId,
  24. addressId,
  25. };
  26. uni.$u.http
  27. .post("/token/order/modifyAddress", params)
  28. .then((res) => {
  29. if (res.code === 200) {
  30. uni.showToast({
  31. title: "地址修改成功",
  32. icon: "none",
  33. });
  34. this.$emit("success");
  35. this.successFeedback();
  36. uni.removeStorageSync("selectEditAddr");
  37. } else {
  38. uni.showToast({
  39. title: res.msg,
  40. icon: "none",
  41. });
  42. }
  43. })
  44. .finally(() => {
  45. uni.removeStorageSync("selectEditAddr");
  46. uni.hideLoading();
  47. });
  48. },
  49. //根据code获取字典 /token/common/getDictOptions
  50. getDict(code) {
  51. return uni.$u.http.get("/token/common/getDictOptions?type=" + code);
  52. },
  53. //获取一键上报的选项 code user_report_options
  54. getReportOptions() {
  55. this.getDict("user_report_options").then((res) => {
  56. if (res.code === 200) {
  57. this.actionList = res.data.map((item) => ({
  58. text: item.dictLabel,
  59. value: item.dictValue,
  60. }));
  61. }
  62. });
  63. },
  64. //一键上报相关操作
  65. handleReportSelect(index) {
  66. this.showReportSheet = false;
  67. let reason = this.actionList[index].value;
  68. if (this.actionList[index]?.isCancel) {
  69. this.submitCancel(reason);
  70. } else {
  71. this.submitReport(reason);
  72. }
  73. },
  74. submitReport(reason) {
  75. const params = {
  76. orderId: this.order.orderId,
  77. reason: reason,
  78. };
  79. uni.$u.http.post("/token/order/userReport", params).then((res) => {
  80. if (res.code === 200) {
  81. uni.showToast({
  82. title: "一键上报已上报给管理员",
  83. icon: "none",
  84. });
  85. this.$emit("success");
  86. this.successFeedback();
  87. }
  88. });
  89. },
  90. //订单取消字典 order_cancel_reason_user
  91. getCancelReason() {
  92. this.getDict("order_cancel_reason_user").then((res) => {
  93. if (res.code === 200) {
  94. this.actionList = res.data.map((item) => ({
  95. text: item.dictLabel,
  96. value: item.dictValue,
  97. isCancel: true,
  98. }));
  99. }
  100. });
  101. },
  102. // 订单操作方法
  103. handleAction({ type, order }) {
  104. console.log("handleAction", type, order);
  105. this.order = order;
  106. switch (type) {
  107. case "submit":
  108. uni.navigateTo({
  109. url: "/pages-home/pages/book-order",
  110. });
  111. uni.setStorageSync("orderId", this.order.orderId);
  112. break;
  113. case "editAddress":
  114. uni.navigateTo({
  115. url: `/pages-mine/pages/address/list?id=${this.order.addressId}&isSelect=1&editAddress=1`,
  116. });
  117. break;
  118. case "cancel":
  119. uni.showModal({
  120. title: "提示",
  121. content: "确定取消订单吗?",
  122. success: (res) => {
  123. if (res.confirm) {
  124. this.showReportSheet = true;
  125. this.getCancelReason();
  126. }
  127. },
  128. });
  129. break;
  130. case "report":
  131. this.showReportSheet = true;
  132. this.getReportOptions();
  133. break;
  134. case "remindAudit":
  135. this.submitRemindAudit();
  136. break;
  137. case "complaint":
  138. uni.navigateTo({
  139. url: `/pages-mine/pages/complaint?orderId=${this.order.orderId}`,
  140. });
  141. break;
  142. case "compensation":
  143. this.$emit("compensation", this.order);
  144. break;
  145. }
  146. },
  147. submitCancel(reason) {
  148. const params = {
  149. orderId: this.order.orderId,
  150. reason: reason,
  151. };
  152. uni.$u.http.post("/token/order/userCancel", params).then((res) => {
  153. if (res.code === 200) {
  154. uni.showToast({
  155. title: "您的订单已取消",
  156. icon: "none",
  157. });
  158. this.$emit("success");
  159. this.successFeedback();
  160. }
  161. });
  162. },
  163. //提醒审核
  164. submitRemindAudit() {
  165. uni.$u.http
  166. .post("/api/token/order/urgeOrder", {
  167. orderId: this.order.orderId,
  168. })
  169. .then((res) => {
  170. if (res.code === 200) {
  171. uni.showToast({
  172. title: "已提醒给管理员进行加急审核",
  173. icon: "none",
  174. });
  175. } else {
  176. uni.showToast({
  177. title: res.msg,
  178. icon: "none",
  179. });
  180. }
  181. });
  182. },
  183. },
  184. };