Browse Source

feat:"增加MQTT推送APP,优化短信退款提醒功能"

soobin 1 month ago
parent
commit
628e740b25
3 changed files with 168 additions and 31 deletions
  1. 5 0
      src/service/device/index.js
  2. 51 12
      src/views/device/deviceSet.vue
  3. 112 19
      src/views/orderCenter/index.vue

+ 5 - 0
src/service/device/index.js

@@ -249,6 +249,11 @@ export function Api_getTApkInfo_updateApk(params) {
   return axios.get(`/SZWL-SERVER/tApkInfo/updateApk`, { params });
 }
 
+// MQTT远程推送更新
+export function pushAppUpdate(params) {
+  return axios.post(`/SZWL-SERVER/tEquipment/pushAppUpdate`,  params);
+}
+
 // 修改优惠码开关状态
 export function Api_getDiscCodeStatus(params) {
   return axios.get(`/SZWL-SERVER/tEquipment/updateCouponStatus`, { params });

+ 51 - 12
src/views/device/deviceSet.vue

@@ -194,6 +194,8 @@
         <van-field
           v-model="deviceDetal.url"
           center
+          autosize
+          type="textarea"
           clearable
           class="form-item"
           :label="$t('device.url')"
@@ -205,6 +207,23 @@
             }}</van-button>
           </template>
         </van-field>
+
+        <van-field
+          v-model="mqttUrl"
+          center
+          autosize
+          type="textarea"
+          clearable
+          class="form-item"
+          label="MQTT URL"
+          :placeholder="$t('device.urlPlace')"
+        >
+          <template #button>
+            <van-button size="small" type="primary" @click="mqttUrlClk">{{
+              $t("device.update")
+            }}</van-button>
+          </template>
+        </van-field>
       </div>
 
       <!-- 操作按钮 -->
@@ -263,15 +282,22 @@ import { Api_getGetEquipmentToLabel } from "@/service/labelMan";
 import kCascader from "@/components/commom/kCascader/index.vue";
 import { computed, onMounted, reactive, ref } from "vue";
 import sHeader from "@/components/SimpleHeader";
-import { useRoute, useRouter, onBeforeRouteLeave } from "vue-router";
+import { useRoute, useRouter } from "vue-router";
 import {
   getDeviceDetal,
   updateDevice,
   Api_getTApkInfo_updateApk,
   Api_getDiscCodeStatus,
   getGoodsNumber,
+  pushAppUpdate,
 } from "@/service/device/index";
-import { showFailToast, showSuccessToast, showToast, closeToast } from "vant";
+import {
+  showFailToast,
+  showSuccessToast,
+  showToast,
+  closeToast,
+  showConfirmDialog,
+} from "vant";
 import { useI18n } from "vue-i18n";
 import dateUtil from "@/utils/dateUtil";
 
@@ -307,13 +333,6 @@ export default {
     let tagsList = reactive({
       arr: [],
     });
-    onBeforeRouteLeave((to, from, next) => {
-      if (isUpdate.value) {
-        // console.log("to.meta.keepAlive>>>", to.meta.keepAlive);
-        // to.meta.keepAlive = false;
-      }
-      next();
-    });
     // 过滤时间
     const filterDate = (date) => {
       if (date) {
@@ -351,9 +370,6 @@ export default {
     onMounted(async () => {
       // 加载样式
       // 从标签设置回来
-      // let tagList = sessionStorage.getItem("tagList") || "[]";
-      // tagsList.arr = JSON.parse(tagList);
-      // sessionStorage.removeItem("tagList");
       getDeviceDetalFun();
       getLabelDetail();
       // 如果user.type<2那么则是公司人员
@@ -520,6 +536,27 @@ export default {
       }
       kDialogRef.value.openDialog();
     };
+    const mqttUrl = ref("");
+    // 点击MQTT的推送app
+    const mqttUrlClk = () => {
+      showConfirmDialog({
+        title: "提醒",
+        message: "是否推送app更新?",
+      }).then(async () => {
+        const { data } = await pushAppUpdate({
+          id: deviceDetal.value.id,
+          url: mqttUrl.value,
+        });
+        if (data.code === "00000") {
+          showSuccessToast("推送成功");
+          setTimeout(() => {
+            router.go(-1);
+          }, 1500);
+        } else {
+          showFailToast(data.message);
+        }
+      });
+    };
     // 点击更新弹窗的确定
     const confirmClk = () => {
       Api_getTApkInfo_updateApk({
@@ -602,6 +639,8 @@ export default {
       getAreaName,
       isAdmind,
       updateUrlClk,
+      mqttUrl,
+      mqttUrlClk,
       confirmClk,
       kDialogRef,
       couponStatusChg,

+ 112 - 19
src/views/orderCenter/index.vue

@@ -323,7 +323,7 @@
             >更新</van-button
           >
         </div>
-        <van-field
+        <!-- <van-field
           v-if="
             refundObject.status === 1 &&
             user.ifForeign === '0' &&
@@ -335,7 +335,7 @@
           label="联系方式"
           placeholder="消费者联系方式,没有则不填"
         >
-        </van-field>
+        </van-field> -->
         <!-- 发起退款 -->
         <!-- 非已付款订单,线下订单要隐藏按钮 -->
         <div
@@ -373,7 +373,7 @@
               user.type < 2 &&
               orderType != '3'
             "
-            @click="sentRefundMessage(refundObject)"
+            @click="showSendDialog = true"
             round
             type="primary"
             style="padding: 15px 15px; margin-top: 20px"
@@ -401,6 +401,45 @@
           >
             {{ $t("orderCenter.initiateRefund") }}
           </van-button>
+
+          <!-- 短信发送确认弹窗 -->
+          <van-dialog
+            v-model:show="showSendDialog"
+            title="提醒"
+            :showCancelButton="true"
+            class="complaint-dialog"
+            @confirm="sentRefundMessage(refundObject)"
+          >
+            <div class="dialog-content">
+              <!-- 消费者号码输入 -->
+              <div class="input-group">
+                <label class="input-label">消费者号码</label>
+                <van-field
+                  v-model="customerPhone"
+                  class="input-field"
+                  type="tel"
+                  placeholder="没有不填"
+                  clearable
+                />
+              </div>
+
+              <!-- 投诉原因输入 -->
+              <div class="input-group">
+                <label class="input-label required">投诉原因</label>
+                <van-field
+                  v-model="reason"
+                  class="input-field"
+                  rows="3"
+                  type="textarea"
+                  autosize
+                  maxlength="20"
+                  show-word-limit
+                  placeholder="请输入投诉原因"
+                  :border="false"
+                />
+              </div>
+            </div>
+          </van-dialog>
         </div>
       </div>
     </van-popup>
@@ -584,6 +623,8 @@ export default {
     const sendListshow = ref(false);
     // 提醒记录
     const sendList = ref([]);
+    // 短信确认弹窗
+    const showSendDialog = ref(false);
     const router = useRouter();
     // 更新是否开发票
     const updateInvoice = async (id) => {
@@ -606,8 +647,6 @@ export default {
           return;
         });
     };
-    // 加载状态
-    // const isLoading = ref(false);
     // 监控退款选择框状态
     const checkGood = (index) => {
       if (isChecked.value[index]) {
@@ -737,27 +776,25 @@ export default {
         });
     };
     const customerPhone = ref(""); // 消费者号码
+    const reason = ref(""); // 投诉原因
     // 发送退款提醒短信
     const sentRefundMessage = async (row) => {
+      if (reason.value === "" || reason.value === null) {
+        showToast("请填写投诉原因");
+        return;
+      }
       const params = {
         id: row.id,
         customerPhone: customerPhone.value,
         adminId: user.id,
+        reason: reason.value,
       };
-      showConfirmDialog({
-        message: "是否确认发送短信?",
-      })
-        .then(async () => {
-          const { data } = await sentMessage(params);
-          if (data.code === "00000") {
-            showSuccessToast("发送成功");
-          } else {
-            showFailToast(data.message);
-          }
-        })
-        .catch(() => {
-          return;
-        });
+      const { data } = await sentMessage(params);
+      if (data.code === "00000") {
+        showSuccessToast("发送成功");
+      } else {
+        showFailToast(data.message);
+      }
     };
     // 退款操作
     const refundAjax = async () => {
@@ -1370,6 +1407,8 @@ export default {
       getStatusType,
       pushPageList,
       statusClass,
+      showSendDialog,
+      reason,
     };
   },
 };
@@ -1855,4 +1894,58 @@ export default {
     }
   }
 }
+
+.complaint-dialog {
+  :deep(.van-dialog__header) {
+    padding: 20px 20px 10px;
+    font-size: 18px;
+    font-weight: 600;
+    // color: --;
+  }
+
+  :deep(.van-dialog__content) {
+    padding: 0;
+  }
+}
+
+.dialog-content {
+  padding: 0 20px 20px;
+}
+
+.input-group {
+  margin-bottom: 20px;
+
+  &:last-child {
+    margin-bottom: 25px;
+  }
+}
+
+.input-label {
+  display: block;
+  margin-bottom: 8px;
+  font-size: 14px;
+  color: var(--text-primary);
+  font-weight: 500;
+}
+
+.input-field {
+  background-color: #f9fbfe;
+  border-radius: 8px;
+  padding: 10px 15px;
+
+  :deep(.van-field__control) {
+    font-size: 14px;
+    color: var(--text-secondary);
+  }
+}
+
+@media (max-width: 480px) {
+  .dialog-content {
+    padding: 0 15px 15px;
+  }
+
+  .input-group {
+    margin-bottom: 15px;
+  }
+}
 </style>