Browse Source

feat(auto-imports): 添加微信小程序检测函数的全局类型声明

添加 isWxMiniProgram 函数到全局类型声明中,同时移除已废弃的 navCommonMiniProgram 函数

BREAKING CHANGE: 移除 navCommonMiniProgram 函数,使用 isWxMiniProgram 替代

fix(config): 恢复开发环境配置的默认设置

将开发环境的默认配置从 HTTPS 地址改为本地 IP 地址,便于本地开发调试

refactor(addressList): 替换设备检测逻辑为微信小程序检测

使用统一的 isWxMiniProgram 函数替换原有的 handleGetDeviceInfo 函数,
简化地址添加和编辑功能的设备检测逻辑

fix(afterSales): 修复提交状态重置问题

在提交售后申请后正确重置 isSubmit 状态,防止重复提交

refactor(order): 优化订单模块类型定义和空值处理

为订单组件添加正确的类型定义,并在方法调用前添加可选链操作符,
避免空值访问错误

feat(utils): 新增微信小程序环境检测工具函数

创建 isWxMiniProgram 函数用于检测当前是否为微信小程序环境,
并在非手机环境下提示用户使用手机操作
zhangtao 5 days ago
parent
commit
dd7f0fb4a5

+ 2 - 1
src/auto-imports.d.ts

@@ -63,6 +63,7 @@ declare global {
   const isReactive: typeof import('vue')['isReactive']
   const isReadonly: typeof import('vue')['isReadonly']
   const isRef: typeof import('vue')['isRef']
+  const isWxMiniProgram: typeof import('./utils/index')['isWxMiniProgram']
   const makeDestructurable: typeof import('@vueuse/core')['makeDestructurable']
   const mapActions: typeof import('pinia')['mapActions']
   const mapGetters: typeof import('pinia')['mapGetters']
@@ -432,6 +433,7 @@ declare module 'vue' {
     readonly isReactive: UnwrapRef<typeof import('vue')['isReactive']>
     readonly isReadonly: UnwrapRef<typeof import('vue')['isReadonly']>
     readonly isRef: UnwrapRef<typeof import('vue')['isRef']>
+    readonly isWxMiniProgram: UnwrapRef<typeof import('./utils/index')['isWxMiniProgram']>
     readonly makeDestructurable: UnwrapRef<typeof import('@vueuse/core')['makeDestructurable']>
     readonly mapActions: UnwrapRef<typeof import('pinia')['mapActions']>
     readonly mapGetters: UnwrapRef<typeof import('pinia')['mapGetters']>
@@ -440,7 +442,6 @@ declare module 'vue' {
     readonly mapWritableState: UnwrapRef<typeof import('pinia')['mapWritableState']>
     readonly markRaw: UnwrapRef<typeof import('vue')['markRaw']>
     readonly mountApis: UnwrapRef<typeof import('./api/createApis')['mountApis']>
-    readonly navCommonMiniProgram: UnwrapRef<typeof import('./utils/index')['navCommonMiniProgram']>
     readonly nextTick: UnwrapRef<typeof import('vue')['nextTick']>
     readonly onActivated: UnwrapRef<typeof import('vue')['onActivated']>
     readonly onAddToFavorites: UnwrapRef<typeof import('@dcloudio/uni-app')['onAddToFavorites']>

+ 2 - 2
src/config/index.ts

@@ -2,13 +2,13 @@ const mapEnvVersion = {
   /**
    * 开发版
    */
-  // develop: 'http://192.168.1.166:8080', // 张
+  develop: 'http://192.168.1.166:8080', // 张
   // develop: 'http://192.168.1.101:8080',
   // develop: 'http://192.168.0.157:8080',
   // develop: 'http://192.168.1.253:8080',
   // develop: 'http://192.168.1.89:8080', // 田
   // develop: 'http://47.109.84.152:8081',
-  develop: 'https://smqjh.api.zswlgz.com',
+  // develop: 'https://smqjh.api.zswlgz.com',
   /**
    * 体验版
    */

+ 2 - 12
src/subPack-common/addressList/index.vue

@@ -38,22 +38,12 @@ function handleSelectAddress(item: Api.addressList) {
   router.back()
 }
 async function handleAddAddress() {
-  await handleGetDeviceInfo()
+  await isWxMiniProgram()
   router.push({ name: 'common-editAddress', params: { type: '1' } })
 }
 
-function handleGetDeviceInfo() {
-  return new Promise((resolve, reject) => {
-    const apltInfo = uni.getDeviceInfo()
-    if (apltInfo.platform === 'windows') {
-      useGlobalToast().show('不支持电脑操作地址,请使用手机打开')
-      reject(new Error('不支持电脑操作地址,请使用手机打开'))
-    }
-    resolve(1)
-  })
-}
 async function handleEditAddress(item: Api.addressList) {
-  await handleGetDeviceInfo()
+  await isWxMiniProgram()
   router.push({ name: 'common-editAddress', params: { type: '2', id: `${item.id}` } })
 }
 </script>

+ 1 - 0
src/subPack-common/afterSales/index.vue

@@ -51,6 +51,7 @@ async function handleSubmit() {
   isSubmit.value = true
   try {
     await cathcApplRefund()
+    isSubmit.value = false
   }
   catch (e) {
     isSubmit.value = false

+ 8 - 8
src/subPack-smqjh/order/index.vue

@@ -11,8 +11,8 @@ definePage({
     navigationBarTitleText: '订单列表',
   },
 })
-const subPackOrder = ref()
-const subPackComfirm = ref()
+const subPackOrder = ref<typeof import('@/subPack-xsb/utils/order-data')>()
+const subPackComfirm = ref<typeof import('@/subPack-xsb/utils/confirm-order')>()
 
 const navActiveTab = ref(0)
 const scrollViewId = ref()
@@ -63,24 +63,24 @@ onReachBottom(() => {
   }
 })
 async function handleCancel(order: Api.xsbOrderList) {
-  await subPackOrder.value.handleCommonCancelOrder(order)
+  await subPackOrder.value?.handleCommonCancelOrder(order)
   reload()
 }
 async function handlePay(orderNumber: string) {
-  const res = await subPackComfirm.value.handleCommonPayMent(orderNumber)
-  if (res.payType !== 1) {
-    await subPackComfirm.value.getWxCommonPayment(res)
+  const res = await subPackComfirm.value?.handleCommonPayMent(orderNumber)
+  if (res?.payType !== 1 && res) {
+    await subPackComfirm.value?.getWxCommonPayment(res)
   }
   else {
     reload()
   }
 }
 async function handleSubmitOrder(order: Api.xsbOrderList) {
-  await subPackOrder.value.handleCommonOrderReceive(order)
+  await subPackOrder.value?.handleCommonOrderReceive(order)
   reload()
 }
 async function handleDel(order: Api.xsbOrderList) {
-  await subPackOrder.value.handleCommonDeleteOrder(order)
+  await subPackOrder.value?.handleCommonDeleteOrder(order)
   reload()
 }
 function handleAfterSale(item: Api.xsbOrderList) {

+ 11 - 6
src/utils/index.ts

@@ -9,12 +9,17 @@ export function getCurrentPath() {
 }
 
 /**
- * 统一跳转小程序方法
- * @param appid
- *
+ * 检测当前环境是否为微信小程序
  */
-export function navCommonMiniProgram(appid: string) {
-  uni.navigateToMiniProgram({
-    appId: appid,
+export function isWxMiniProgram() {
+  return new Promise((resolve, reject) => {
+    const apltInfo = uni.getDeviceInfo()
+    console.log(apltInfo, '当前环境=======================')
+
+    if (apltInfo.platform === 'windows') {
+      useGlobalToast().show('不支持电脑操作地址,请使用手机打开')
+      reject(new Error('不支持电脑操作地址,请使用手机打开'))
+    }
+    resolve(1)
   })
 }