Переглянути джерело

feat: 回收功能开发对接

liangan 1 місяць тому
батько
коміт
648e49c11e

+ 4 - 4
env/.env.development

@@ -7,8 +7,8 @@ VITE_SHOW_SOURCEMAP = true
 
 VITE_UNI_APPID = '__UNI__F0919F6'
 
-VITE_SERVER_BASEURL = 'http://124.222.152.234:8101' # mall
-VITE_API_SECONDARY_URL = 'http://124.222.152.234:8101' # cif
-VITE_API_THIRD_URL = 'http://124.222.152.234:8101' # operating
-VITE_UPLOAD_BASEURL = 'http://124.222.152.234:8101/operating/file/upload'
+VITE_SERVER_BASEURL = 'http://192.168.0.110:8110' # mall
+VITE_API_SECONDARY_URL = 'http://192.168.0.110:8110' # cif
+VITE_API_THIRD_URL = 'http://192.168.0.110:8110' # operating
+VITE_UPLOAD_BASEURL = 'http://192.168.0.110:8110/operating/file/upload'
 

+ 17 - 0
src/api/order.ts

@@ -91,3 +91,20 @@ export function bindingAddress(data: any) {
 export function pendingRedDots() {
   return http.get<any>(`${pre}/app/order/pendingRedDots`)
 }
+
+/**
+ * 可回收订单数
+ * @returns
+ */
+export function userCanRecycleNum() {
+  return http.get<any>(`${pre}/app/order/app/userCanRecycleNum`)
+}
+
+/**
+ * 回收订单
+ * @param data { orderNos: string[] }
+ * @returns
+ */
+export function recycleOrder(data: { orderNos: string[] }) {
+  return http.post<any>(`${pre}/app/order/app/recycleOrder`, data)
+}

+ 1 - 1
src/locale/bn.json

@@ -44,7 +44,7 @@
   "myOrders.dialog.title": "অর্ডার বিক্রয় করুন",
   "myOrders.dialog.notesTitle": "নোট:",
   "myOrders.dialog.note1": "① আপনি BandhuBuy কে গ্রুপ অর্ডারের আইটেমগুলি বিক্রয় করতে বেছে নিতে পারেন।",
-  "myOrders.dialog.note2": "② বিক্রয় মূল্য পণ্যের 100%।",
+  "myOrders.dialog.note2": "② বিক্রয় মূল্য পণ্যের {0}%।",
   "myOrders.dialog.note3": "③ পুনরুদ্ধার করা পরিমাণ আপনার আয় অ্যাকাউন্টে বিতরণ করা হবে।",
   "myOrders.dialog.priceLabel": "বিক্রয় মূল্য",
   "myOrders.dialog.confirm": "নিশ্চিত করুন",

+ 1 - 1
src/locale/en.json

@@ -44,7 +44,7 @@
   "myOrders.dialog.title": "Sell Back Order",
   "myOrders.dialog.notesTitle": "Notes:",
   "myOrders.dialog.note1": "① You can choose to have BandhuBuy sell back the items in the group order.",
-  "myOrders.dialog.note2": "② The sell back price is 100% of the product.",
+  "myOrders.dialog.note2": "② The sell back price is {0}% of the product.",
   "myOrders.dialog.note3": "③ The recovered amount will be distributed to your earnings account.",
   "myOrders.dialog.priceLabel": "Sell Back Price",
   "myOrders.dialog.confirm": "Confirm",

+ 1 - 1
src/locale/zh-Hans.json

@@ -44,7 +44,7 @@
   "myOrders.dialog.title": "回售订单",
   "myOrders.dialog.notesTitle": "注意事项:",
   "myOrders.dialog.note1": "① 您可以选择让 BandhuBuy 回售团购订单中的商品。",
-  "myOrders.dialog.note2": "② 回售价格为商品价格的 100%。",
+  "myOrders.dialog.note2": "② 回收价格为商品价格的 {0}%。",
   "myOrders.dialog.note3": "③ 回收金额将分配到您的收益账户。",
   "myOrders.dialog.priceLabel": "回售价格",
   "myOrders.dialog.confirm": "确认",

+ 6 - 2
src/manifest.json

@@ -1,6 +1,6 @@
 {
   "name": "BandhuBuy",
-  "appid": "__UNI__C639CFC",
+  "appid": "__UNI__F0919F6",
   "description": "",
   "versionName": "1.0.0",
   "versionCode": "100",
@@ -41,7 +41,11 @@
         ],
         "minSdkVersion": 30,
         "targetSdkVersion": 35,
-        "abiFilters": ["armeabi-v7a", "arm64-v8a", "x86"]
+        "abiFilters": [
+          "armeabi-v7a",
+          "arm64-v8a",
+          "x86"
+        ]
       },
       "ios": {
         "idfa": false

+ 66 - 23
src/pages/myOrders/myOrders.vue

@@ -13,7 +13,8 @@
 // eslint-disable-next-line unused-imports/no-unused-imports
 import { onPageScroll, onReachBottom } from '@dcloudio/uni-app'
 import useZPaging from 'z-paging/components/z-paging/js/hooks/useZPaging.js'
-import { orderList, orderStatusEnum } from '@/api/order'
+import { getConfigByCode } from '@/api/common'
+import { orderList, orderStatusEnum, recycleOrder, userCanRecycleNum } from '@/api/order'
 import { DialogBox } from '@/components/DialogBox'
 import { t } from '@/locale'
 import { formatNumber } from '@/utils'
@@ -53,6 +54,41 @@ const tabList = ref<any>([
     value: 4,
   },
 ])
+
+// 搜索结果
+const dataList = ref<any[]>([])
+
+const maxSelectCount = ref<number>(0) // 最大可选订单数量
+const selectedOrders = ref<string[]>([]) // 已选中的订单ID列表
+
+const recycleProportion = ref<string>('')
+const recycleRate = ref<number>(0)
+
+async function getRecycleProportion() {
+  try {
+    const res = await getConfigByCode({ code: 'recycle_proportion' })
+    if (res.code === '200' && res.data?.valueInfo) {
+      let rate = Number(res.data.valueInfo) || 0
+      if (rate > 1)
+        rate = rate / 100
+      recycleRate.value = rate
+      recycleProportion.value = String(rate * 100)
+    }
+  }
+  catch {
+  }
+}
+
+async function getUserCanRecycleNum() {
+  try {
+    const res = await userCanRecycleNum()
+    if (res.code === '200') {
+      maxSelectCount.value = Number(res.data) || 0
+    }
+  }
+  catch {
+  }
+}
 const orderStatusEnumData = ref<any>([])
 async function getOrderStatus() {
   try {
@@ -66,13 +102,6 @@ async function getOrderStatus() {
   }
 }
 
-// 搜索结果
-const dataList = ref<any[]>([])
-
-// TODO: 后期从接口获取最大可选订单数量
-const maxSelectCount = ref<number>(5) // 最大可选订单数量
-const selectedOrders = ref<string[]>([]) // 已选中的订单ID列表
-
 // 判断订单是否已选中
 function isOrderSelected(orderId: string) {
   return selectedOrders.value.includes(orderId)
@@ -99,6 +128,7 @@ function toggleOrderSelection(orderId: string) {
 // 切换tab时清空选中状态
 function handleTabChange() {
   selectedOrders.value = []
+  getUserCanRecycleNum()
   queryList(1, 20)
 }
 
@@ -115,6 +145,10 @@ const totalAmount = computed(() => {
     }, 0)
 })
 
+const recycleAmount = computed(() => {
+  return totalAmount.value * recycleRate.value
+})
+
 // 弹框状态
 const showRecycleDialog = ref(false)
 
@@ -126,28 +160,32 @@ function handleRecycleOrder() {
 // 确认回收订单
 async function confirmRecycle() {
   try {
-    // TODO: 后续调用回收订单的接口
-    console.log('选中的订单ID:', selectedOrders.value)
-    console.log('总金额:', totalAmount.value)
+    if (selectedOrders.value.length === 0) {
+      toast.info(t('myOrders.selectTip', [maxSelectCount.value]))
+      return
+    }
 
-    // 模拟接口调用
-    // const res = await recycleOrderApi({ orderIds: selectedOrders.value })
-    // if (res.code === '200') {
-    //   toast.success(t('myOrders.recycleSuccess'))
-    //   selectedOrders.value = []
-    //   queryList(1, 20) // 刷新列表
-    // }
+    uni.showLoading({
+      title: t('common.loading'),
+      mask: true,
+    })
 
-    // 临时模拟成功
-    toast.success(t('myOrders.recycleSuccess'))
+    const res = await recycleOrder({ orderNos: selectedOrders.value })
+    if (res.code === '200') {
+      toast.success(t('myOrders.recycleSuccess'))
+    }
     selectedOrders.value = []
     // 刷新列表
     paging.value?.reload()
+    getUserCanRecycleNum()
   }
   catch (error) {
     console.error('回收订单失败:', error)
     toast.error(t('myOrders.recycleFailed'))
   }
+  finally {
+    uni.hideLoading()
+  }
 }
 async function queryList(pageNo: number, pageSize: number) {
   // 此处请求仅为演示,请替换为自己项目中的请求
@@ -163,6 +201,9 @@ async function queryList(pageNo: number, pageSize: number) {
       type: tab.value, // 根据tab的值来查询不同状态的订单
     })
     paging.value.complete(res.data.list)
+    if (pageNo === 1) {
+      getUserCanRecycleNum()
+    }
   }
   catch {
     paging.value.complete(false)
@@ -176,6 +217,8 @@ async function queryList(pageNo: number, pageSize: number) {
 }
 onLoad((options) => {
   getOrderStatus()
+  getUserCanRecycleNum()
+  getRecycleProportion()
 
   // 处理页面参数,如果有type参数则切换到对应的tab
   if (options) {
@@ -300,7 +343,7 @@ onLoad((options) => {
             {{ $t('myOrders.total') }}:
           </text>
           <text class="text-[var(--wot-color-theme)]">
-            ৳{{ formatNumber(totalAmount) }}
+            ৳{{ formatNumber(recycleAmount) }}
           </text>
         </view>
         <wd-button
@@ -330,14 +373,14 @@ onLoad((options) => {
       <view class="pb-32rpx text-24rpx text-#666">
         <view class="space-y-16rpx">
           <view>{{ $t('myOrders.dialog.note1') }}</view>
-          <view>{{ $t('myOrders.dialog.note2') }}</view>
+          <view>{{ $t('myOrders.dialog.note2', [recycleProportion]) }}</view>
           <view>{{ $t('myOrders.dialog.note3') }}</view>
         </view>
       </view>
       <view class="mb-44rpx text-center">
         <text>{{ $t('myOrders.dialog.priceLabel') }}: </text>
         <text class="text-[var(--wot-color-theme)]">
-          ৳{{ formatNumber(totalAmount) }}
+          ৳{{ formatNumber(recycleAmount) }}
         </text>
       </view>
     </view>