소스 검색

feat(api): 修改用户授权错误处理逻辑

- 移除对token的直接赋值操作,改为使用useUserStore().$reset()重置用户状态
- 在响应和错误处理中统一使用$reset方法来清除用户信息

config: 更新开发环境API配置

- 将默认开发环境从内网地址切换到线上地址
- 注释掉多个内网开发地址配置
- 启用线上开发环境配置

feat(order): 添加订单删除和售后申请功能

- 新增handleDel方法用于删除订单
- 新增handleAfterSale方法用于申请售后
- 在订单列表中添加删除订单按钮
- 在订单列表和详情页中添加申请售后按钮

fix(classify): 修复分类组件点击无子分类项的问题

- 在handleTopNavChange方法中添加children存在性检查
- 避免点击没有子分类的项时出现错误
- 优化组件挂载时的初始化逻辑

style(category): 优化分类图标显示样式

- 使用view容器包装image组件,改善布局
- 为没有子分类的项添加"敬请期待"遮罩层
- 调整图片尺寸和边框样式

fix(commonTab): 修复组件初始化错误

- 在handleCommonClass方法中添加children存在性检查
- 避免访问未定义的children属性

feat(permission): 添加门店权限控制功能

- 在store中添加allShopHasPermission状态
- 实现门店权限检查逻辑
- 添加权限不足时的提示弹窗
- 在选择地址页面显示门店权限状态

feat(afterSales): 在订单详情页添加售后申请功能

- 新增handleAfterSale方法处理售后申请
- 根据订单状态控制售后按钮显示
- 添加商品异常检查逻辑
zhangtao 5 일 전
부모
커밋
14b8c5f9bd

+ 4 - 4
src/api/core/handlers.ts

@@ -32,10 +32,10 @@ export async function handleAlovaResponse(
   const { statusCode, data } = response as UniNamespace.RequestSuccessCallbackResult
   // 处理401/403错误(如果不是在handleAlovaResponse中处理的)
   if ((statusCode === 401 || statusCode === 403)) {
-    const { redirectName, token } = storeToRefs(useUserStore())
+    const { redirectName } = storeToRefs(useUserStore())
     useSmqjhCartStore().$reset()
     // 如果是未授权错误,清除用户信息并跳转到登录页
-    token.value = ''
+    useUserStore().$reset()
     redirectName.value = getCurrentPath()
     // useGlobalMessage().confirm({
     //   title: '提示',
@@ -80,10 +80,10 @@ export function handleAlovaError(error: any, method: Method) {
   // 处理401/403错误(如果不是在handleAlovaResponse中处理的)
   if (error instanceof ApiError && (error.code === 401 || error.code === 403)) {
     // 如果是未授权错误,清除用户信息并跳转到登录页
-    const { redirectName, token } = storeToRefs(useUserStore())
+    const { redirectName } = storeToRefs(useUserStore())
     useSmqjhCartStore().$reset()
     // 如果是未授权错误,清除用户信息并跳转到登录页
-    token.value = ''
+    useUserStore().$reset()
     redirectName.value = getCurrentPath()
     // useGlobalMessage().confirm({
     //   title: '提示',

+ 3 - 2
src/config/index.ts

@@ -2,19 +2,20 @@ 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',
   /**
    * 体验版
    */
   // trial: "http://192.168.1.166:8080/jeecg-boot",
   // trial: 'http://192.168.0.157:8080',
   // trial: 'http://47.109.84.152:8081',
+  // trial: 'http://192.168.1.166:8080',
   trial: 'https://smqjh.api.zswlgz.com',
   /**
    * 正式版

+ 30 - 0
src/subPack-smqjh/order/index.vue

@@ -79,6 +79,17 @@ async function handleSubmitOrder(order: Api.xsbOrderList) {
   await subPackOrder.value.handleCommonOrderReceive(order)
   reload()
 }
+async function handleDel(order: Api.xsbOrderList) {
+  await subPackOrder.value.handleCommonDeleteOrder(order)
+  reload()
+}
+function handleAfterSale(item: Api.xsbOrderList) {
+  if (!item.orderItemList) {
+    useGlobalToast().show('商品异常!')
+    return
+  }
+  router.push({ name: 'common-afterSales', params: { order: JSON.stringify(item.orderItemList) } })
+}
 </script>
 
 <template>
@@ -186,6 +197,18 @@ async function handleSubmitOrder(order: Api.xsbOrderList) {
               </wd-button>
             </view>
           </template>
+          <template v-if="[subPackOrder?.OrderStatus.OrderCancel, subPackOrder?.OrderStatus.OrderCompleted].includes(item.hbOrderStatus) ">
+            <view class="mr20rpx">
+              <wd-button size="small" plain type="info" @click.stop="handleDel(item)">
+                删除订单
+              </wd-button>
+            </view>
+            <!-- <view class="ml20rpx">
+              <wd-button size="small" plain type="error" >
+                再次购买
+              </wd-button>
+            </view> -->
+          </template>
           <template v-if="item.hbOrderStatus === subPackOrder?.OrderStatus.OrderArrived">
             <view>
               <wd-button size="small" plain type="info" @click.stop="handleSubmitOrder(item)">
@@ -193,6 +216,13 @@ async function handleSubmitOrder(order: Api.xsbOrderList) {
               </wd-button>
             </view>
           </template>
+          <template v-if="[subPackOrder?.OrderStatus.OrderCompleted, subPackOrder?.OrderStatus.OrderWaitDelivery, subPackOrder?.OrderStatus.OrderAccepted].includes(item.hbOrderStatus) ">
+            <view>
+              <wd-button size="small" plain type="info" @click.stop="handleAfterSale(item)">
+                申请售后
+              </wd-button>
+            </view>
+          </template>
         </view>
       </view>
       <wd-status-tip v-if="!orderList.length" image="content" tip="暂无内容" />

+ 18 - 8
src/subPack-xsb/commonTab/components/classfiy.vue

@@ -52,8 +52,10 @@ const navHeight = computed(() => {
 })
 const totalProduct = ref<Api.shoppingCartOrderConfirm>()
 function handleTopNavChange(item: Api.xsbCategoriesChildren) {
-  goodsLoading.value = 'loading'
   topNavActive.value = item.code
+  if (!item.children)
+    return
+  goodsLoading.value = 'loading'
   leftActive.value = item.children[0].code
   show.value = false
   topScrollView.value = null
@@ -206,8 +208,8 @@ async function handleSubCart(event: WechatMiniprogram.TouchEvent, item: Api.xsbC
 
 onMounted(async () => {
   if (!topNavActive.value || !leftActive.value) {
-    topNavActive.value = props.categoryList[0].code || ''
-    leftActive.value = props.categoryList[0].children[0].code || ''
+    topNavActive.value = props.categoryList && props.categoryList[0].code
+    leftActive.value = props.categoryList[0].children && props.categoryList[0].children[0].code
   }
 
   if (leftActive.value) {
@@ -385,10 +387,18 @@ function handlePay() {
             v-for="item in classfiylist" :id="`id${item.code}`" :key="item.code"
             class="mr24rpx flex flex-col items-center justify-center" @click="handleTopNavChange(item)"
           >
-            <image
-              :src="item.icon"
-              :class="[topNavActive == item.code ? 'overflow-hidden border-solid border-[var(--them-color)] border-2rpx rounded-26rpx h84rpx w-84rpx' : 'h72rpx w-72rpx']"
-            />
+            <view class="relative">
+              <view class="box-border" :class="[topNavActive == item.code ? 'overflow-hidden border-solid border-[var(--them-color)] border-2rpx rounded-26rpx h84rpx w-84rpx' : 'h72rpx w-72rpx']">
+                <image
+                  :src="item.icon"
+                  class="h-full w-full"
+                />
+              </view>
+              <view v-if="!item.children" class="absolute left-0 top-0 h-full w-full flex items-center justify-center rounded-26rpx bg-[rgba(0,0,0,0.6)] text-16rpx text-white">
+                敬请期待
+              </view>
+            </view>
+
             <view
               class="mt16rpx text-22rpx"
               :class="[topNavActive == item.code ? 'bg-[var(--them-color)] rounded-18rpx px-8rpx py2rpx text-white text-24rpx' : '']"
@@ -644,7 +654,7 @@ function handlePay() {
       <template #footer>
         <view class="box-border w-full flex items-center justify-between py20rpx">
           <view class="w-48%">
-            <wd-button hairline plain block @click="selectGoods = false">
+            <wd-button plain hairline block @click="selectGoods = false">
               取消
             </wd-button>
           </view>

+ 1 - 1
src/subPack-xsb/commonTab/components/index.vue

@@ -40,7 +40,7 @@ function handleCommonClass(item: Api.xsbCategories) {
   console.log(item, '===================')
 
   topNavActive.value = item.code
-  leftActive.value = item.children[0].code
+  leftActive.value = item.children && item.children[0].code
   emit('changeNav')
 }
 function handleSwiperClick(e: { index: number, item: Api.xsbCategories }) {

+ 17 - 1
src/subPack-xsb/commonTab/index.vue

@@ -22,7 +22,7 @@ definePage({
     disableScroll: true,
   },
 })
-const { opcity, backTop, SelectShopInfo } = storeToRefs(useSysXsbStore())
+const { opcity, backTop, SelectShopInfo, allShopHasPermission, xsbShopList } = storeToRefs(useSysXsbStore())
 const { userInfo } = storeToRefs(useUserStore())
 const commonCategoryData = ref<Api.xsbCategories[]>([])
 const { data: goodsList, isLastPage, page, error, reload, refresh } = usePagination((pageNum, pageSize) =>
@@ -174,6 +174,22 @@ function beforeleave() {
         </template>
       </wd-tabbar-item>
     </wd-tabbar>
+    <wd-popup v-model="allShopHasPermission" custom-style="border-radius:32rpx;" :close-on-click-modal="false" :z-index="99999">
+      <view class="p28rpx">
+        <view class="text-center text-24rpx text-#AAAAAA">
+          你没有该门店的商品数据查看权限,请切
+          换其他门店
+        </view>
+        <view class="mt30rpx w420rpx">
+          <view v-for="item in xsbShopList" :key="item.shopId" class="mb20rpx flex items-center text-28rpx" :class="[item.isPermiss ? 'text-[var(--them-color)] font-semibold' : 'text-#AAAAAA ']">
+            {{ item.shopName }}
+            <view v-if="!item.isPermiss" class="ml20rpx rounded-22rpx bg-#aaa px16rpx text-24rpx text-white">
+              无权限
+            </view>
+          </view>
+        </view>
+      </view>
+    </wd-popup>
   </view>
 </template>
 

+ 9 - 3
src/subPack-xsb/orderDetaile/index.vue

@@ -59,6 +59,13 @@ function handleCopy() {
     showToast: true,
   })
 }
+function handleAfterSale() {
+  if (!orderInfo.value?.orderItemList) {
+    useGlobalToast().show('商品异常!')
+    return
+  }
+  router.push({ name: 'common-afterSales', params: { order: JSON.stringify(orderInfo.value?.orderItemList) } })
+}
 </script>
 
 <template>
@@ -155,8 +162,7 @@ function handleCopy() {
             </view>
           </button>
         </view>
-
-        <!-- <view class="flex  flex-col items-center " @click="router.push({ name: 'common-afterSales' })">
+        <view v-if="[OrderStatus.OrderCompleted, OrderStatus.OrderWaitDelivery, OrderStatus.OrderAccepted].includes(orderInfo.hbOrderStatus) " class="flex flex-col items-center" @click="handleAfterSale">
           <image
             :src="`${StaticUrl}/orderDetaile-shou.png`"
             class="h40rpx w40rpx"
@@ -164,7 +170,7 @@ function handleCopy() {
           <view class="mt40rpx">
             申请售后
           </view>
-        </view> -->
+        </view>
         <!-- <view class="flex  flex-col items-center " @click="router.push({ name: 'common-revalue' })">
           <image
             :src="`${StaticUrl}/orderDetaile-pj.png`"

+ 12 - 5
src/subPack-xsb/selectAddress/index.vue

@@ -77,20 +77,27 @@ async function handelChange(e: { value: number }) {
           </wd-radio-group>
         </view>
       </view>
-      <view v-if="SelectShopInfo" class="mt20rpx rounded-16rpx bg-white px24rpx py28rpx" @click="handleClick(SelectShopInfo)">
+      <view v-if="SelectShopInfo.shopId" class="mt20rpx rounded-16rpx bg-white px24rpx py28rpx" @click="SelectShopInfo.isPermiss && handleClick(SelectShopInfo)">
         <view class="text-24rpx text-#AAAAAA">
           附近的门店
         </view>
-        <view class="mt24rpx text-28rpx font-semibold">
-          {{ SelectShopInfo?.shopName }}
+        <view class="mt24rpx flex items-center text-28rpx font-semibold">
+          {{ SelectShopInfo?.shopName }} <view v-if="!SelectShopInfo.isPermiss" class="ml20rpx rounded-22rpx bg-#aaa px16rpx text-24rpx text-white">
+            无权限
+          </view>
         </view>
         <view class="mt16rpx text-24rpx text-#AAAAAA">
           以为您选择距离最近的可配送店
         </view>
       </view>
       <view v-if="allShopList" class="mt20rpx rounded-16rpx bg-white px24rpx py28rpx">
-        <view v-for="item, idx in allShopList" :key="item.shopId" class="text-28rpx font-semibold" @click="handleClick(item)">
-          {{ item.shopName }}
+        <view v-for="item, idx in allShopList" :key="item.shopId" :class="[item.isPermiss ? '' : 'text-#AAAAAA']" class="text-28rpx font-semibold" @click="item.isPermiss && handleClick(item)">
+          <view class="flex items-center">
+            {{ item.shopName }}
+            <view v-if="!item.isPermiss" class="ml20rpx rounded-22rpx bg-#aaa px16rpx text-24rpx text-white">
+              无权限
+            </view>
+          </view>
           <view v-if="idx < allShopList.length - 1" class="mb24rpx mt20rpx h2rpx w-full bg-#F0F0F0" />
         </view>
       </view>

+ 18 - 4
src/subPack-xsb/store-xsb/sys.ts

@@ -29,6 +29,10 @@ interface SysState {
    * 用户选中我的地址id
    */
   selectAddressId: number | undefined
+  /**
+   * 是否所有门店都有权限
+   */
+  allShopHasPermission: boolean
 
 }
 export const useSysXsbStore = defineStore('system-xsb', {
@@ -40,8 +44,8 @@ export const useSysXsbStore = defineStore('system-xsb', {
     SelectShopInfo: { shopId: 0 },
     xsbShopList: [],
     opcity: 0,
-
     selectAddressId: undefined,
+    allShopHasPermission: false,
   }),
   actions: {
     getTabbarItemValue(name: string) {
@@ -54,9 +58,19 @@ export const useSysXsbStore = defineStore('system-xsb', {
       return new Promise((resolve, reject) => {
         Apis.xsb.shopList({}).then(async (res) => {
           this.xsbShopList = res.data
-          const { Location } = storeToRefs(useAddressStore())
-          await this.getnNearestShop(Location.value.latitude || 26.648327, Location.value.longitude || 106.620256)
-          resolve(res)
+          const hasPermission = res.data.every(it => !it.isPermiss)
+          if (hasPermission) {
+            // 所有门店都没有权限
+            this.allShopHasPermission = true
+            this.SelectShopInfo = { shopId: 0 }
+            reject(res)
+          }
+          else {
+            this.allShopHasPermission = false
+            const { Location } = storeToRefs(useAddressStore())
+            await this.getnNearestShop(Location.value.latitude || 26.648327, Location.value.longitude || 106.620256)
+            resolve(res)
+          }
         }).catch((err) => { reject(err) })
       })
     },