Browse Source

修改问题

tangning 2 years ago
parent
commit
7734f855ee
1 changed files with 6 additions and 10 deletions
  1. 6 10
      src/views/home/submit.vue

+ 6 - 10
src/views/home/submit.vue

@@ -135,14 +135,14 @@
       />
     </van-cell-group>
     <div style="margin: 16px; background-color: #f5f5f5">
-      <van-button block color="#00B3EC" type="primary" native-type="submit"> 提交 </van-button>
+      <van-button :loading="loading" loading-text="上传中..." block color="#00B3EC" type="primary" native-type="submit"> 提交 </van-button>
     </div>
   </van-form>
 </template>
   
 <script lang="ts" setup name="HomeSubmit">
 import { showLoadingToast, closeToast } from 'vant';
-import { computed, reactive, unref } from 'vue';
+import { computed, reactive, unref, ref } from 'vue';
 import { useUserStore } from '/@/store/modules/user';
 import { showToast, showSuccessToast } from 'vant';
 import axios from 'axios';
@@ -154,6 +154,7 @@ import { cameraRepair } from '/@/api';
 const emit = defineEmits(['setActive']);
 // const { locale } = useI18n();
 const userStore = useUserStore();
+const loading = ref(false)
 const wxOpenId = computed(() => {
   return userStore.getWxOpenId;
 });
@@ -210,16 +211,11 @@ function clzpAfterRead(file) {
   // 上传状态提示开启
   file.status = 'uploading';
   file.message = '上传中...';
+  loading.value = true
   // 创建一个空对象实例
   let formData = new FormData();
   // 调用append()方法添加数据
   formData.append('file', file.file);
-  showLoadingToast({
-      message: '上传中...',
-      forbidClick: true,
-      duration: 0,
-      iconSize: 35,
-    });
   axios({
     url: '/service/sale/upload/file',
     method: 'POST',
@@ -228,8 +224,8 @@ function clzpAfterRead(file) {
       'Content-Type': 'multipart/form-data',
     },
   }).then((res) => {
+    loading.value = false
     let { data } = res;
-    closeToast()
     if (data.code == 200) {
       // 上传状态提示关闭
       file.url = data.data;
@@ -237,7 +233,7 @@ function clzpAfterRead(file) {
       showToast('上传成功!');
     }
   }).catch(() =>{
-    closeToast()
+    loading.value = false
   });
 }
 </script>