Bläddra i källkod

feat:"添加远程退币功能"

soobin 11 månader sedan
förälder
incheckning
251d417b89

BIN
src/assets/device/operIcon/coin.png


+ 13 - 0
src/assets/language/en.json

@@ -550,6 +550,19 @@
     "viewPositioning": "View positioning",
     "restartAndroid": "Restart touch screen",
     "alramClean": "Machine clean",
+    "returnCoin": "Coin return",
+    "returnCoinPage": {
+      "amount": "Amount",
+      "returnCoinRecord": "Return record",
+      "returnCoinBtn": "Coin return",
+      "tipsContent": "Confirm the refund?",
+      "applyTime": "Application time",
+      "status":"Return status",
+      "returnCoinSuccess": "Successful",
+      "returnCoinFailed": "Failed",
+      "waiting": "Wait for machine response",
+      "reason": "Cause of failure"
+    },
     "refrigeration": "Refrigeration mode",
     "keepFresh": "Fresh-keeping mode",
     "stir": "Stirring mode",

+ 13 - 0
src/assets/language/ja.json

@@ -567,6 +567,19 @@
         "viewPositioning": "位置情報を見る",
         "restartAndroid": "画面を再起動",
         "alramClean": "機器洗浄",
+        "returnCoin": "硬貨を払い戻す",
+        "returnCoinPage": {
+            "amount": "数です",
+            "returnCoinRecord": "申請記録です",
+            "returnCoinBtn": "硬貨を払い戻す",
+            "tipsContent": "払い戻しコインの確認です?",
+            "applyTime": "申し込み期間です",
+            "status": "コイン返却状態です",
+            "returnCoinSuccess": "成功です",
+            "returnCoinFailed": "失敗です",
+            "waiting": "機械の応答を待ちます",
+            "reason": "失敗の原因です"
+        },
         "refrigeration": "冷却モードです",
         "keepFresh": "鮮度保持モードです",
         "stir": "撹拌モードです",

+ 13 - 0
src/assets/language/zh.json

@@ -573,6 +573,19 @@
     "viewPositioning": "查看定位",
     "restartAndroid": "重启触摸屏",
     "alramClean": "设备清洗",
+    "returnCoin": "远程退币",
+    "returnCoinPage": {
+      "amount": "退币数量",
+      "returnCoinRecord": "退币记录",
+      "returnCoinBtn": "申请退币",
+      "tipsContent": "确认退币?",
+      "applyTime": "申请时间",
+      "status": "退币状态",
+      "returnCoinSuccess": "成功",
+      "returnCoinFailed": "失败",
+      "waiting": "等待机器响应",
+      "reason": "失败原因"
+    },
     "refrigeration": "制冷模式",
     "keepFresh": "保鲜模式",
     "stir": "搅拌模式",

+ 7 - 0
src/router/index.js

@@ -498,6 +498,13 @@ const router = createRouter({
       component: () => import("@/views/device/alramClean/index"),
       meta: { index: 1 },
     },
+    // 远程退币
+    {
+      path: "/returnCoin",
+      name: "returnCoin",
+      component: () => import("@/views/device/returnCoin/index"),
+      meta: { index: 1 },
+    },
     // 修改机器密码
     {
       path: "/devicePassword",

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

@@ -255,4 +255,14 @@ export function changeCleanFunction(params) {
 // 获取机器开关机状态
 export function getOnOffStatus(params) {
     return axios.post(`/SZWL-SERVER/tEquipment/onOffStatus?${stringToUrl(params)}`, params)
+}
+
+// 获取当天远程退币申请记录
+export function getReturnCoinList(params) {
+    return axios.get(`/SZWL-SERVER/returnCoinRecord/list`, { params })
+}
+
+// 提交远程退币申请
+export function applyReturnCoin(params) {
+    return axios.post(`/SZWL-SERVER/returnCoinRecord/apply`, params)
 }

+ 17 - 2
src/views/device/deviceOper.vue

@@ -221,6 +221,12 @@
         </div>
         <div class="operText">{{ $t("device.alramClean") }}</div>
       </div>
+      <div class="operItem" v-if="(device.machineType === '0' || device.machineType === null) && (user.ifForeign == 1 || user.type == 0)" @click="returnCoinClk()">
+        <div class="operIcon">
+          <img class="operImg" src="../../assets/device/operIcon/coin.png" />
+        </div>
+        <div class="operText">{{ $t("device.returnCoin") }}</div>
+      </div>
 
     </div>
   </van-dialog>
@@ -285,7 +291,7 @@ export default {
     const diyFlowerClk = () => {
       router.push({
         path: "diyFlower",
-        query: { deviceId: device.value.id, name: device.value.name, diyFlowerStatus: device.value.diyFlowerStatus, flower: device.value.flowers , clientId: device.value.clientId},
+        query: { deviceId: device.value.id, name: device.value.name, diyFlowerStatus: device.value.diyFlowerStatus, flower: device.value.flowers, clientId: device.value.clientId },
       });
     };
 
@@ -296,6 +302,14 @@ export default {
         query: { deviceId: device.value.id, name: device.value.name, clientId: device.value.clientId, cleanFunction: device.value.cleanFunction },
       });
     };
+
+    // 点击远程退币
+    const returnCoinClk = () => {
+      router.push({
+        path: "returnCoin",
+        query: { deviceId: device.value.id, name: device.value.name, clientId: device.value.clientId },
+      });
+    };
     const { t } = useI18n();
     const user = getLoginUser();
     const router = useRouter();
@@ -600,7 +614,7 @@ export default {
       if (operType.value === 10) {
         const { data } = await changeWorkingMode({
           equipmentId: device.value.id,
-          workingMode : workMode.value,
+          workingMode: workMode.value,
         });
         if (data.code === '00000') {
           showSuccessToast(t("device.Succeed"));
@@ -652,6 +666,7 @@ export default {
       lockDevice,
       restartAndroid,
       alramCleanClk,
+      returnCoinClk,
       // viewPosiClk,
       changePasswordClk,
       sleepIcon,

+ 7 - 7
src/views/device/index.vue

@@ -82,7 +82,7 @@
                   }}
                 </span>
                 <!-- 温湿度 -->
-                <span v-if="(item.machineType == '0' || item.machineType == null) && item.equimentType != 'P30'"
+                <span v-if="item.machineType == '0' || item.machineType == null"
                   class="txt1 o-mt-10" :style="{
         color: item.furnaceTm <= 100 && item.eqeStatus == 1 ? '#ff0033' : '',
         fontSize: item.furnaceTm <= 100 && item.eqeStatus == 1 ? '0.5rem' : ''
@@ -91,31 +91,31 @@
         $t("device.degree")
                   }}
                 </span>
-                <span v-if="(item.machineType == '0' || item.machineType == null) && item.equimentType != 'P30'"
+                <span v-if="item.machineType == '0' || item.machineType == null"
                   class="txt1 o-mt-10">
                   {{ $t("device.temperatureInCabinet") + ':' + (item.cabinetTm ? item.cabinetTm : '0')
         + $t("device.degree") }}
                 </span>
-                <span v-if="(item.machineType == '0' || item.machineType == null) && item.equimentType != 'P30'"
+                <span v-if="item.machineType == '0' || item.machineType == null"
                   class="txt1 o-mt-10">
                   {{ $t("device.humidityInCabinet") + ':' + (item.cabinetHd ? item.cabinetHd : '0')
         + $t("device.humidity") }}
                 </span>
-                <span v-if="item.machineType == '1' && item.equimentType == 'P30'" class="txt1 o-mt-10">
+                <span v-if="item.machineType == '1'" class="txt1 o-mt-10">
                   {{ $t("device.cornGeneratorTemperature") + ':' + (item.cabinetTm ? item.cabinetTm : '0') +
                     $t("device.degree")
                   }}
                 </span>
-                <span v-if="item.machineType == '1' && item.equimentType == 'P30'" class="txt1 o-mt-10">
+                <span v-if="item.machineType == '1'" class="txt1 o-mt-10">
                   {{ $t("device.stirringTemperature") + ':' + (item.cabinetHd ? item.cabinetHd : '0') +
                     $t("device.degree") }}
                 </span>
                 <span
-                  v-if="item.machineType == '1' && item.equimentType == 'P30' && (item.furnaceTm && item.furnaceTm != '-1')"
+                  v-if="item.machineType == '1' && (item.furnaceTm && item.furnaceTm != '-1')"
                   class="txt1 o-mt-10">
                   {{ $t("device.cupQuantity") + ':' + item.furnaceTm }}
                 </span>
-                <span v-if="item.machineType == '1' && item.equimentType == 'P30' && item.furnaceSp"
+                <span v-if="item.machineType == '1' && item.furnaceSp"
                   class="txt1 o-mt-10">
                   {{ $t("device.bucketWeight") + ':' + item.furnaceSp + $t("device.weight") }}
                 </span>

+ 150 - 0
src/views/device/returnCoin/index.vue

@@ -0,0 +1,150 @@
+<template>
+    <div class="showGoodsIdx">
+        <s-header :name="$t('device.returnCoin')" :noback="false"></s-header>
+        <div class="headerCon kBordBott o-plr-10 o-ptb-16 l-flex-RC">
+            <div class="line o-mr-6"></div>
+            <div>
+                <span class="c-color c-text-14">{{ $t('device.showGoodsPage.equipmentName') }}:</span>
+                <span class="c-text-color c-text-14">{{ equipmentName }}</span>
+            </div>
+
+        </div>
+        <div class="">
+            <van-field name="stepper" :label="$t('device.returnCoinPage.amount')" class="l-flex-RC">
+                <template #input>
+                    <van-stepper v-model="amount" max="50"/>
+                </template>
+                <template #button>
+                    <van-button size="small" type="primary" @click="applyReturnCoinClk()">{{ $t('device.returnCoinPage.returnCoinBtn')
+                        }}</van-button>
+                </template>
+            </van-field>
+        </div>
+        <van-cell :title="$t('device.returnCoinPage.returnCoinRecord')" icon="points"/>
+        <div class="outer2 flex-col" v-for="item in recordList" :key="item.id">
+            <div class="word">{{ $t('device.returnCoinPage.applyTime') }}:{{ showTime(item.createDate) }}</div>
+            <div class="word">{{ $t('device.returnCoinPage.amount') }}:{{ item.amount }}</div>
+            <div class="word">{{ $t('device.returnCoinPage.status') }}:{{ item.status == 1 ? $t('device.returnCoinPage.returnCoinSuccess') : (item.status == 2 ? $t('device.returnCoinPage.returnCoinFailed') : $t('device.returnCoinPage.waiting')) }}</div>
+            <div class="word" v-if="item.status == 2">{{ $t('device.returnCoinPage.reason') }}:{{ item.reason}}</div>
+        </div>
+
+    </div>
+</template>
+
+<script>
+// 导入接口
+import { applyReturnCoin, getReturnCoinList } from '@/service/device/index';
+import sHeader from "@/components/SimpleHeader";
+import { ref } from "@vue/reactivity";
+import { onMounted } from '@vue/runtime-core';
+import { useRoute, useRouter } from 'vue-router';
+import { showConfirmDialog, showFailToast, showToast } from 'vant';
+import { useI18n } from "vue-i18n";
+import { getLoginUser, styleUrl } from '../../../common/js/utils';
+import dateUtil from "../../../utils/dateUtil";
+export default {
+    components: {
+        sHeader
+    },
+    setup() {
+        // 引入语言
+        const { t } = useI18n();
+        // 路由
+        const route = useRoute();
+        const router = useRouter();
+        const amount = ref(1);
+        const user = getLoginUser();
+        const equipmentId = ref('');
+        const equipmentName = ref('');
+        const clientId = ref('');
+        const activeNames = ref(['1']);
+        const recordList = ref([]);
+        // 刚进页面
+        onMounted(() => {
+            // 加载样式
+            styleUrl('showGoods');
+            equipmentId.value = route.query.deviceId || "";
+            const name = route.query.name || "";
+            clientId.value = route.query.clientId || "";
+            if (equipmentId) {
+                equipmentName.value = name;
+            }
+            getList(clientId.value);
+
+        });
+
+        // 获取退币记录
+        const getList = async () => { // 声明为异步函数
+            try {
+                const { data } = await getReturnCoinList({equipmentId: equipmentId.value}); // 使用await等待异步函数执行完毕并返回结果
+                // 处理获取到的data
+                recordList.value = data.data;
+            } catch (error) {
+                console.error('Error fetching data:', error);
+            }
+        }
+
+        // 格式化时间
+        const showTime = (time) => {
+            return dateUtil.timeZoneDate(new Date(dateUtil.formateDate(new Date(time), "yyyy/MM/dd hh:mm:ss")));
+        }
+
+
+        // 退币申请
+        const applyReturnCoinClk = () => {
+            const params = {
+                equipmentId: equipmentId.value,
+                amount: amount.value,
+                adminId: user.id
+            };
+            showConfirmDialog({
+                title: t('alramClean.tips'),
+                message: t('device.returnCoinPage.tipsContent'),
+            }).then(async () => {
+                const { data } = await applyReturnCoin(params);
+                console.log("data>>>", data);
+                if (data.code) {
+                    showToast(t('alramClean.successfully'));
+                    setTimeout(() => {
+                        router.go(-1);
+                    }, 1500);
+                } else {
+                    showFailToast(data.message);
+                }
+            }).catch((error) => {
+                console.log(error);
+            });
+        }
+
+        return {
+            equipmentName,
+            applyReturnCoinClk,
+            amount,
+            activeNames,
+            recordList,
+            showTime
+        };
+    },
+};
+</script>
+
+<style lang="less" scoped>
+
+.van-cell {
+    font-size: 20px !important;
+}
+.outer2 {
+    box-shadow: 1px 2px 5px 3px rgba(70, 95, 198, 0.14);
+    background-color: rgba(255, 255, 255, 1);
+    border-radius: 4px;
+    margin: 20px 30px;
+    margin-bottom: 20px;
+    padding: 10px 20px;
+
+    .word {
+        font-size: 14px;
+        padding: 3px 0;
+        line-height: 20px;
+    }
+}
+</style>