| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- export default {
- data() {
- return {
- actionList: [],
- showReportSheet: false,
- order: {},
- };
- },
- onShow() {
- let selectEditAddr = uni.getStorageSync("selectEditAddr");
- if (selectEditAddr.id) {
- this.handleAddressSubmit(selectEditAddr.id);
- }
- },
- methods: {
- //操作成功之后的回调
- successFeedback() {
- uni.$emit("btnActionSuccess");
- },
- //修改地址
- handleAddressSubmit(addressId) {
- const params = {
- orderId: this.order.orderId,
- addressId,
- };
- uni.$u.http
- .post("/token/order/modifyAddress", params)
- .then((res) => {
- if (res.code === 200) {
- uni.showToast({
- title: "地址修改成功",
- icon: "none",
- });
- this.$emit("success");
- this.successFeedback();
- uni.removeStorageSync("selectEditAddr");
- } else {
- uni.showToast({
- title: res.msg,
- icon: "none",
- });
- }
- })
- .finally(() => {
- uni.removeStorageSync("selectEditAddr");
- uni.hideLoading();
- });
- },
- //根据code获取字典 /token/common/getDictOptions
- getDict(code) {
- return uni.$u.http.get("/token/common/getDictOptions?type=" + code);
- },
- //获取一键上报的选项 code user_report_options
- getReportOptions() {
- this.getDict("user_report_options").then((res) => {
- if (res.code === 200) {
- this.actionList = res.data.map((item) => ({
- text: item.dictLabel,
- value: item.dictValue,
- }));
- }
- });
- },
- //一键上报相关操作
- handleReportSelect(index) {
- this.showReportSheet = false;
- let reason = this.actionList[index].value;
- if (this.actionList[index]?.isCancel) {
- this.submitCancel(reason);
- } else {
- this.submitReport(reason);
- }
- },
- submitReport(reason) {
- const params = {
- orderId: this.order.orderId,
- reason: reason,
- };
- uni.$u.http.post("/token/order/userReport", params).then((res) => {
- if (res.code === 200) {
- uni.showToast({
- title: "一键上报已上报给管理员",
- icon: "none",
- });
- this.$emit("success");
- this.successFeedback();
- }
- });
- },
- //订单取消字典 order_cancel_reason_user
- getCancelReason() {
- this.getDict("order_cancel_reason_user").then((res) => {
- if (res.code === 200) {
- this.actionList = res.data.map((item) => ({
- text: item.dictLabel,
- value: item.dictValue,
- isCancel: true,
- }));
- }
- });
- },
- // 订单操作方法
- handleAction({ type, order }) {
- console.log("handleAction", type, order);
- this.order = order;
- switch (type) {
- case "submit":
- uni.navigateTo({
- url: "/pages-home/pages/book-order",
- });
- uni.setStorageSync("orderId", this.order.orderId);
- break;
- case "editAddress":
- uni.navigateTo({
- url: `/pages-mine/pages/address/list?id=${this.order.addressId}&isSelect=1&editAddress=1`,
- });
- break;
- case "cancel":
- uni.showModal({
- title: "提示",
- content: "确定取消订单吗?",
- success: (res) => {
- if (res.confirm) {
- this.showReportSheet = true;
- this.getCancelReason();
- }
- },
- });
- break;
- case "report":
- this.showReportSheet = true;
- this.getReportOptions();
- break;
- case "remindAudit":
- this.submitRemindAudit();
- break;
- case "complaint":
- uni.navigateTo({
- url: `/pages-mine/pages/complaint?orderId=${this.order.orderId}`,
- });
- break;
- case "compensation":
- this.$emit("compensation", this.order);
- break;
- case "review":
- this.$refs.reviewDialog.openPopup();
- break;
- case "reviewImage":
- uni.navigateTo({
- url: `/pages-mine/pages/review-image?orderId=${this.order.orderId}`,
- });
- break;
- }
- },
- submitCancel(reason) {
- const params = {
- orderId: this.order.orderId,
- reason: reason,
- };
- uni.$u.http.post("/token/order/userCancel", params).then((res) => {
- if (res.code === 200) {
- uni.showToast({
- title: "您的订单已取消",
- icon: "none",
- });
- this.$emit("success");
- this.successFeedback();
- }
- });
- },
- //提醒审核
- submitRemindAudit() {
- uni.$u.http
- .post("/api/token/order/urgeOrder", {
- orderId: this.order.orderId,
- })
- .then((res) => {
- if (res.code === 200) {
- uni.showToast({
- title: "已提醒给管理员进行加急审核",
- icon: "none",
- });
- } else {
- uni.showToast({
- title: res.msg,
- icon: "none",
- });
- }
- });
- },
- },
- };
|