Bladeren bron

feat: 弹窗添加toast提示。修改提示。

ljc 1 week geleden
bovenliggende
commit
c1b781ce06

+ 5 - 0
components/cwg-file-picker-wrapper.vue

@@ -727,11 +727,16 @@ const imgStyle = computed(() => {
 </script>
 
 <style scoped lang="scss">
+  .file-picker-wrapper{
+
+  }
 /* 布局 */
 .uni-file-picker__container {
   display: flex;
   flex-wrap: wrap;
   //margin: -5px;
+  justify-content: center;
+  align-self: center;
   gap: px2rpx(5);
   width: 100%;
 }

+ 22 - 4
components/cwg-global-popup.vue

@@ -1,31 +1,49 @@
 <template>
-  <cwg-popup v-model:visible="popupState.visible" type="center" :mask-click="false" :show-footers="true" width="400px">
+  <cwg-popup v-model:visible="popupState.visible" type="center" :mask-click="false" :show-footers="showFooters" width="400px">
     <view class="popup-content">
       <view class="confirm-title">{{ popupState.title }}</view>
       <view class="confirm-content">{{ popupState.content }}</view>
     </view>
     <template #footer>
-      <button v-if="popupState.showCancel" @click="close">{{ popupState.cancelText }}</button>
-      <button class="btn btn-secondary btn-shadow waves-effect" @click="handleConfirm">{{ popupState.confirmText }}</button>
+      <button v-if="popupState.showCancel && !popupState.autoClose" @click="close">{{ popupState.cancelText }}</button>
+      <button v-if="!popupState.autoClose" class="btn btn-secondary btn-shadow waves-effect" @click="handleConfirm">{{ popupState.confirmText }}</button>
     </template>
   </cwg-popup>
 </template>
 
 <script setup>
-import { watch, ref } from 'vue'
+import { watch, ref, computed, onUnmounted } from 'vue'
 import { usePopup } from '@/hooks/usePopup'
 
 const { popupState, close, handleConfirm } = usePopup()
 
 const popupRef = ref(null)
+let autoCloseTimer = null
+
+const showFooters = computed(() => !popupState.value.autoClose)
 
 watch(() => popupState.value.visible, (val) => {
     if (val) {
         popupRef.value?.open()
+        if (popupState.value.autoClose) {
+            autoCloseTimer = setTimeout(() => {
+                close()
+            }, popupState.value.autoCloseDelay)
+        }
     } else {
         popupRef.value?.close()
+        if (autoCloseTimer) {
+            clearTimeout(autoCloseTimer)
+            autoCloseTimer = null
+        }
     }
 }, { immediate: true })
+
+onUnmounted(() => {
+    if (autoCloseTimer) {
+        clearTimeout(autoCloseTimer)
+    }
+})
 </script>
 
 <style scoped lang="scss">

+ 1 - 1
hooks/useEmailCountdown.ts

@@ -52,7 +52,7 @@ export function useEmailCountdown(options: UseEmailCountdownOptions) {
     if (timer) {
       clearInterval(timer)
       timer = null
-      time.value = duration
+      // time.value = duration
     }
     ls.set(storageKey, '')
   }

+ 25 - 5
hooks/usePopup.ts

@@ -8,7 +8,8 @@ interface PopupOptions {
   confirmText?: string
   width?: number
   showCancel?: boolean
-  // confirmBtnType?: 'primary' | 'danger'
+  autoClose?: boolean
+  autoCloseDelay?: number
 }
 
 interface PopupState {
@@ -18,7 +19,8 @@ interface PopupState {
   cancelText: string
   confirmText: string
   showCancel: boolean
-  // confirmBtnType: 'primary' | 'danger'
+  autoClose: boolean
+  autoCloseDelay: number
   resolve: ((value: boolean) => void) | null
 }
 
@@ -29,7 +31,8 @@ const popupState = ref<PopupState>({
   cancelText: '',
   confirmText: '',
   showCancel: true,
-  // confirmBtnType: 'primary',
+  autoClose: false,
+  autoCloseDelay: 2000,
   resolve: null
 })
 
@@ -38,7 +41,6 @@ export function usePopup() {
 
   const confirm = (options: PopupOptions = {}): Promise<boolean> => {
     return new Promise((resolve) => {
-      console.log(options,'dia')
       popupState.value = {
         visible: true,
         title: options.title || t('Msg.SystemPrompt'),
@@ -46,7 +48,24 @@ export function usePopup() {
         showCancel: options.showCancel != undefined ? options.showCancel: true,
         cancelText: options.cancelText || t('Btn.Cancel'),
         confirmText: options.confirmText || t('Btn.Confirm'),
-        // confirmBtnType: options.confirmBtnType || 'primary',
+        autoClose: options.autoClose || false,
+        autoCloseDelay: options.autoCloseDelay || 2000,
+        resolve
+      }
+    })
+  }
+  const toast = (options: PopupOptions | string = {}): Promise<boolean> => {
+    const params = typeof options === 'string' ? { content: options } : options
+    return new Promise((resolve) => {
+      popupState.value = {
+        visible: true,
+        title: params.title || t('Msg.SystemPrompt'),
+        content: params.content || '',
+        showCancel: params.showCancel != undefined ? params.showCancel: true,
+        cancelText: params.cancelText || t('Btn.Cancel'),
+        confirmText: params.confirmText || t('Btn.Confirm'),
+        autoClose: true,
+        autoCloseDelay: params.autoCloseDelay || 2000,
         resolve
       }
     })
@@ -71,6 +90,7 @@ export function usePopup() {
   return {
     popupState,
     confirm,
+    toast,
     close,
     handleConfirm
   }

+ 3 - 3
pages/customer/dashboard.vue

@@ -100,7 +100,7 @@
         </uni-row>
       </uni-col>
       <uni-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
-        <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="mobilH mb-3">
+        <uni-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mobilH mb-3">
           <view class="chart-box crm-border-radius">
             <view class="chart-title">
               <uni-row>
@@ -156,7 +156,7 @@
             </view>
           </view>
         </uni-col>
-        <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12" class="mobilH">
+        <uni-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12" class="mobilH">
           <view class="chart-box mh crm-border-radius">
             <view class="bigtitle mb-3">
               {{t('Custom.Index.MyAccount')}}
@@ -680,7 +680,7 @@
   .mobilH{
     height: 100%;
   }
-  @media screen and (max-width: 991px){
+  @media screen and (max-width: 1200px){
     .mobilH{
       height: auto;
     }

+ 17 - 16
pages/login/index.vue

@@ -308,7 +308,7 @@ const tabs = computed(() => [
   { text: t('signin.tabs2'), value: 2, },
 ])
 
-const { confirm } = usePopup()
+const { confirm,toast } = usePopup()
 const activeTab = ref(1)
 
 // ========== 注册表单相关 ==========
@@ -607,10 +607,12 @@ async function sendEmailCode() {
 
 const register = async () => {
   if (countryCode.value == 'MY' || countryCode.value == 'ID') {
-    showToast('Registration not available for this region')
+    toast('Registration not available for this region')
     return
   }
-  regForm.value.validate().then(async (res) => {
+  const res = await regForm.value.validate()
+  if (!res) return
+  try {
     const chinaCountryCodes = ['CN']
     const isChina = chinaCountryCodes.includes(formData.value.country)
     const xSystemValue = isChina ? 'B' : 'A'
@@ -629,19 +631,16 @@ const register = async () => {
         showCancel: false,
         confirmText: t('Btn.Confirm'),
       })
-      // showToast(resData.msg,'error')
     }
-
-  }).catch(err => {
-    console.log('表单错误信息:', err)
-    // confirm({
-    //   title:t('Msg.SystemPrompt'),
-    //   content: '表单错误',
-    //   showCancel: false,
-    //   confirmText: t('Btn.Confirm'),
-    // })
-    return false
-  })
+  }catch (e) {
+    confirm({
+      title: t('Msg.SystemPrompt'),
+      content: e.msg,
+      showCancel: false,
+      confirmText: t('Btn.Confirm'),
+    })
+    console.log(e,'err')
+  }
 }
 
 const registLogin = async () => {
@@ -658,6 +657,7 @@ const registLogin = async () => {
     }
   } catch (error) {
     console.error(error)
+    showToast(error.msg)
   }
 }
 
@@ -752,7 +752,8 @@ async function handleLogin() {
     }
   } catch (error) {
     // console.log(error)
-    uni.showToast({ title: error.msg, icon: 'error' })
+    // uni.showToast({ title: error.msg, icon: 'error' })
+    toast(error.msg)
     //  console.log(error, 19089);
   }
 }

+ 16 - 42
pages/mine/components/BankInfoTab.vue

@@ -385,6 +385,7 @@
   <kyc-auth-dialog ref="kycDialogRef" />
   <!-- 证件认证弹窗 -->
   <card-auth-dialog ref="cardDialogRef" />
+  <cwg-global-popup/>
 </template>
 
 <script setup lang="ts">
@@ -396,9 +397,12 @@
   import AddBankDialog from '@/components/AddBankDialog.vue'
   import config from '@/config'
   import { BankType } from './bank'
+  import {usePopup} from '@/hooks/usePopup'
 
   const { t, locale } = useI18n()
 
+  const {toast} = usePopup()
+
   interface BankListType {
     key: string;
     label: string;
@@ -495,10 +499,7 @@
   const saveBank = async (item) => {
 
     if (selectedBankType.value === 'crypto' && item.approveStatus == 1) {
-      uni.showToast({
-        title: '加密钱包认证审核中',
-        icon: 'none',
-      })
+      toast(t('PersonalManagement.BlockchainWalletReviewing'))
       return
     }
     try {
@@ -525,7 +526,7 @@
     } catch (error) {
       uni.hideLoading()
       uni.showToast({
-        title: error.message || t('Msg.Fail'),
+        title: error.msg || t('Msg.Fail'),
         icon: 'none',
       })
     }
@@ -533,10 +534,7 @@
   // 删除
   const confirmDelete = (item) => {
     if (selectedBankType.value === 'crypto' && item.approveStatus == 1) {
-      uni.showToast({
-        title: '加密钱包认证审核中',
-        icon: 'none',
-      })
+      toast(t('PersonalManagement.BlockchainWalletReviewing'))
       return
     }
     deleteTarget.value = item
@@ -612,18 +610,12 @@
       item => item.authStatus === 0 || item.approveStatus === 1,
     )
     if (hasUnAuth) {
-      uni.showToast({
-        title: '加密钱包未认证',
-        icon: 'none',
-      })
+      toast(t('PersonalManagement.BlockchainWalletNotCertified'))
       return
     }
     // 3️⃣ 是否达到上限
     if (wallets.length >= 2) {
-      uni.showToast({
-        title: t('blockchain.item9'),
-        icon: 'none',
-      })
+      toast(t('blockchain.item9'))
       return
     }
     // 4️⃣ 正常打开
@@ -637,10 +629,7 @@
       return
     }
     if (wallets.length >= 2) {
-      uni.showToast({
-        title: t('Msg.UnionPayCARDS'),
-        icon: 'none',
-      })
+      toast(t('Msg.UnionPayCARDS'))
       return
     }
     addBankDialogRef.value?.open(1)
@@ -653,10 +642,7 @@
       return
     }
     if (wallets.length >= 2) {
-      uni.showToast({
-        title: t('Msg.WireTransfers'),
-        icon: 'none',
-      })
+      toast(t('Msg.WireTransfers'))
       return
     }
     addBankDialogRef.value?.open(2)
@@ -685,17 +671,11 @@
   // kyc认证
   const doReady = (bankId, item) => {
     if (item.approveStatus == 1) {
-      uni.showToast({
-        title: '加密钱包认证审核中',
-        icon: 'none',
-      })
+      toast(t('PersonalManagement.BlockchainWalletReviewing'))
       return
     }
     if (item.authStatus == 1) {
-      uni.showToast({
-        title: '加密钱包已认证',
-        icon: 'none',
-      })
+      toast(t('PersonalManagement.BlockchainWalletNotCertified'))
       return
     }
     openKycDialog(bankId)
@@ -709,17 +689,11 @@
   // 打开证件认证弹窗
   function openCardDialog(e, item) {
     if (item.approveStatus == 1) {
-      uni.showToast({
-        title: '加密钱包认证审核中',
-        icon: 'none',
-      })
+      toast(t('PersonalManagement.BlockchainWalletReviewing'))
       return
     }
     if (item.authStatus == 1) {
-      uni.showToast({
-        title: '加密钱包已认证',
-        icon: 'none',
-      })
+      toast(t('PersonalManagement.BlockchainWalletNotCertified'))
       return
     }
     cardDialogRef.value?.open(e, item)
@@ -783,7 +757,7 @@
       }
     } catch (error) {
       uni.showToast({
-        title: error.message || t('Msg.Fail'),
+        title: error.msg || t('Msg.Fail'),
         icon: 'none',
       })
     }

+ 62 - 37
pages/mine/improveImmediately.vue

@@ -86,7 +86,7 @@
             <uni-col :span="24">
               <view class="crm-title-box">
                 <text class="tit">{{ t('ImproveImmediately.Title.AddressInformation') }}</text>
-                <uni-tooltip placement="top">
+                <uni-tooltip :placement="isMobile?'left':'top'">
                   <text class="icon-tip">ⓘ</text>
                   <template v-slot:content>
                     <view class="address-tip">
@@ -227,7 +227,7 @@
             <uni-col :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
               <view class="crm-title-box">
                 <text class="tit">{{ t('ImproveImmediately.Title.ProofIdentityUpdate') }}</text>
-                <uni-tooltip placement="bottom">
+                <uni-tooltip :placement="isMobile?'left':'bottom'">
                   <text class="icon-tip">ⓘ</text>
                   <template v-slot:content>
                     <view class="address-tip">
@@ -242,7 +242,7 @@
                   :placeholder="t('placeholder.choose')" />
               </uni-forms-item>
               <uni-row class="demo-uni-row uni-row1" :gutter="20">
-                <uni-col :xs="24" :sm="24" :md="10" :lg="10" :xl="10">
+                <uni-col :xs="24" :sm="24" :md="10" :lg="10" :xl="10" class="mb-3">
                   <cwg-file-picker-wrapper v-model="fileListID1.path" :editable="fileListID1.status != 2" :limit="1"
                     :fileMediatype="'all'" uploadUrl="/custom/file/upload/1" :baseUrl="updateUrl" :imageWidth="150"
                     :imageHeight="150" :showPreviewDelete="false" :canDelete="false" :uploadError="false"
@@ -298,7 +298,7 @@
               <uni-col v-if="isPC" :xs="24" :sm="24" :md="12" :lg="12" :xl="12">
                 <view class="crm-title-box">
                   <text class="tit">{{ t('ImproveImmediately.Title.MobileDeviceUpload') }}</text>
-                  <uni-tooltip placement="bottom">
+                  <uni-tooltip :placement="isMobile?'left':'bottom'">
                     <text class="icon-tip">ⓘ</text>
                     <template v-slot:content>
                       <view class="address-tip">
@@ -623,8 +623,14 @@
       <view class="des1">{{ t('ImproveImmediately.Content.Leave1') }}</view>
       <view class="des2">{{ t('ImproveImmediately.Content.Leave2') }}</view>
       <view class="dialog-footer">
-        <u-button @click="closeDia">{{ t('Btn.TemporarilyNot') }}</u-button>
-        <u-button type="primary" @click="save">{{ t('Btn.Save') }}</u-button>
+        <view class="btn-content">
+          <button class="cancel-btn" @click="closeDia">
+            {{ t('Btn.TemporarilyNot') }}
+          </button>
+          <button class="confirm-btn primary"  @click="save">
+            {{ t('Btn.Save') }}
+          </button>
+        </view>
       </view>
     </view>
     <view class="dia-content" v-if="!dialogCheck1">
@@ -634,11 +640,18 @@
       <view class="des1">{{ t('ApplicationDialog.Des1') }}</view>
       <QrCode v-if="text1" :text="text1"></QrCode>
       <view class="dialog-footer">
-        <button @click="closeDia">{{ t('Btn.Cancel') }}</button>
-        <button type="primary" @click="toHome">{{ t('Btn.Home') }}</button>
+        <view class="btn-content">
+          <button class="cancel-btn" @click="closeDia">
+            {{ t('Btn.Cancel') }}
+          </button>
+          <button class="confirm-btn primary"  @click="toHome">
+            {{ t('Btn.Home') }}
+          </button>
+        </view>
       </view>
     </view>
   </uni-popup>
+  <cwg-global-popup/>
 </template>
 
 <script setup lang="ts">
@@ -657,7 +670,9 @@ import icon_doc from '@/static/icons/crm-document.svg'
 import icon_refresh from '@/static/icons/crm-refresh.svg'
 import icon_mobile from '@/static/icons/icon_mobile.svg'
 import icon_arrowR from '@/static/icons/icon_arrowR.svg'
-
+import { useWindowWidth } from '@/composables/useWindowWidth'
+import { usePopup } from '@/hooks/usePopup'
+const { confirm , toast } = usePopup()
 const router = useRouter()
 const { t, locale } = useI18n()
 const currentStep = ref<number>(3)
@@ -667,6 +682,8 @@ const dialogCheck1 = ref(false)
 const text1 = ref('')
 const qrCodeStatus = ref(false)
 const addressTipPopup = ref()
+const windowWidth = useWindowWidth(300)
+const isMobile = computed(() => windowWidth.value <= 991)
 
 // 新增的响应式数据
 const divActiveHelf = ref(false)
@@ -845,18 +862,20 @@ onLoad((options) => {
 
 function goStep(step: number) {
   console.log(step, 'step')
+  if (step == 2){
+    if (!formData.value?.identity){
+      toast(t('vaildate.IDCard.empty'))
+      return
+    }
+  }
   if (step == 4) {
     if (currentUploadCard.value == 1) {
       if (!formData.value.cardType) {
-        uni.showToast({
-          title: t('vaildate.CardType.empty'), icon: 'error'
-        })
+        toast( t('vaildate.CardType.empty'))
         return
       }
       if (!fileListID1.value.path || !fileListID2.value.path) {
-        uni.showToast({
-          title: t('vaildate.IDPhoto.empty'), icon: 'error'
-        })
+        toast( t('vaildate.IDPhoto.empty'))
         return
       }
     }
@@ -1050,27 +1069,24 @@ const showFile = (file) => {
 }
 
 async function fileOtherDelete(id) {
-  uni.showModal({
+  const result = await confirm({
     title: t('Msg.SystemPrompt'),
     content: t('Msg.Delete'),
-    cancelText: t('Btn.Cancel'),
     confirmText: t('Btn.Confirm'),
-    success: async (res) => {
-      if (res.confirm) {
-        // 确认删除
-        let data = await personalApi.customFileDelete({ ids: [id] })
-        if (data.code == 200) {
-          uni.showToast(t('Msg.DeleteSuccess'))
-          getCustomFileList()
-        } else {
-          uni.showToast(res.msg)
-        }
-      }
-    },
-    fail: () => {
-
-    },
+    cancelText: t('Btn.Cancel'),
   })
+  if (result){
+    try {
+      // 确认删除
+      let data = await personalApi.customFileDelete({ ids: [id] })
+      if (data.code == 200) {
+        uni.showToast(t('Msg.DeleteSuccess'))
+        getCustomFileList()
+      }
+    }catch (e) {
+      uni.showToast(e.msg)
+    }
+  }
 }
 
 
@@ -1240,7 +1256,7 @@ async function getCountryList() {
       }
     }
   } catch (error: any) {
-    uni.showToast({ title: error.message, icon: 'none' })
+    uni.showToast({ title: error.msg, icon: 'none' })
   }
 }
 
@@ -1595,6 +1611,7 @@ onUnmounted(() => {
     justify-content: center;
   }
 
+
   .list_upload {
     width: px2rpx(150);
     height: px2rpx(60);
@@ -1621,12 +1638,16 @@ onUnmounted(() => {
     justify-content: center;
     align-content: center;
     align-items: center;
+    @media screen and (max-width: 990px) {
+      flex-direction: column;
+    }
 
     uni-button {
-      min-width: px2rpx(100);
-      max-height: px2rpx(30);
+      min-width: px2rpx(80);
+      max-height: px2rpx(35);
       padding: 0;
-      line-height: px2rpx(30);
+      line-height: px2rpx(35);
+      margin-bottom: px2rpx(5);
 
       span,
       a {
@@ -1762,8 +1783,12 @@ onUnmounted(() => {
 }
 
 .address-tip {
-  width: px2rpx(120);
+  width: px2rpx(140);
+  //height: px2rpx(60);
   font-size: px2rpx(14);
+  word-break:break-all;
+  white-space:wrap;
+  word-wrap:break-word;
 }
 
 .crm-title-box {