Bläddra i källkod

修改部分的接口

lisy 3 veckor sedan
förälder
incheckning
cf6d13d556

+ 1 - 2
.env.development

@@ -4,5 +4,4 @@ VITE_TITLE = 林草平台
 # 开发环境配置
 VITE_APP_ENV = 'development'
 # api请求地址
-VITE_API_BASE_URL = 'https://www.shuziyunyao.com/dm-api'
-VITE_API_OTHER_BASE_URL = 'https://www.shuziyunyao.com/trace-api'
+VITE_API_BASE_URL = 'https://dm.yujin.shuziyunyao.com/api'

+ 1 - 2
.env.production

@@ -4,5 +4,4 @@ VITE_APP_TITLE = 林草平台
 # 开发环境配置
 VITE_APP_ENV = 'production'
 # api请求地址
-VITE_API_BASE_URL = 'https://www.shuziyunyao.com/dm-api'
-VITE_API_OTHER_BASE_URL = 'https://www.shuziyunyao.com/trace-api'
+VITE_API_BASE_URL = 'https://www.shuziyunyao.com/dm-api'

+ 4 - 3
src/App.vue

@@ -2,18 +2,18 @@
 import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
 import { useAuthStore } from '@/store/modules/auth';
 import { autoLogin } from '@/utils/routeGuard';
-
+import { getToken, setToken, removeToken } from '@/utils/auth';
 onLaunch(async () => {
     console.log('App Launch');
 
     // 应用启动时检查登录状态
     try {
-        await autoLogin();
+        // await autoLogin();
     } catch (error) {
         console.error('Auto login check failed:', error);
     }
 });
-
+setToken('eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpblR5cGUiOiJsb2dpbiIsImxvZ2luSWQiOiJhcHBfdXNlcjoxOTQwMjQ1NzU5Mjk2ODY0MjU3Iiwicm5TdHIiOiJiVllYa0QwVnY2T3JLNnc1d1ZOTlpiV0hFUTlhU1J2RyIsImNsaWVudGlkIjoiMjAyNTAyMTQiLCJvcGVuaWQiOiJva0NHMjRrU29nT2VWTGFkc1JVYm8tS2JqR2Y4IiwidXNlcklkIjoxOTQwMjQ1NzU5Mjk2ODY0MjU3fQ.-gNoaCFtXKHYtiGLdd5mpEyhBf9AZ9BTw9udNA_1feM')
 onShow(() => {
     console.log('App Show');
 });
@@ -27,6 +27,7 @@ onHide(() => {
 @import '@/assets/styles/public.scss';
 @import '@/assets/styles/common.scss';
 @import '@/assets/styles/uview-plus.scss';
+
 // 设置背景色
 page {
 	background-color: #f7f7f7;

+ 1 - 3
src/assets/styles/common.scss

@@ -256,9 +256,7 @@
         background-color: #37A954;
     }
 }
-.w-s-no{
-    white-space: nowrap;
-}
+
 // 超出两行省略
 .text-ellipsis-2 {
     display: -webkit-box;

+ 14 - 11
src/assets/styles/public.scss

@@ -1,4 +1,4 @@
-@use "sass:math";
+@use 'sass:math';
 // * {
 // 	box-sizing: border-box;
 // }
@@ -92,7 +92,7 @@ $colors: (
     fa: #fafafa,
     gl: #affec2,
     // 主题色
-    primary: #37A954,
+    primary: #37a954,
     light-black: #4d4d4d,
     // 成功
     success: #67c23a,
@@ -104,7 +104,7 @@ $colors: (
     money-red: #f4403b,
     // 会员绿
     member-green: #41c06d,
-    res-0: #f6881c
+    res-0: #f6881c,
 );
 @each $color, $value in $colors {
     .c-#{$color} {
@@ -117,7 +117,7 @@ $colors: (
     }
 }
 :root {
-    --primary: #37A954;
+    --primary: #37a954;
     // 橙色
     --orange: #ffa500;
 }
@@ -126,16 +126,19 @@ $colors: (
     text-indent: 2em;
 }
 .text-desc {
-	padding: 12rpx;
+    padding: 12rpx;
 
-	// 偶数行背景色
-	&:nth-child(2n) {
-		background-color: #FAFAFA;
-	}
+    // 偶数行背景色
+    &:nth-child(2n) {
+        background-color: #fafafa;
+    }
 }
 .btn-hover {
     background-color: #f5f5f5;
 }
-.tx-ov{
+.tx-ov {
     text-overflow: ellipsis;
-}
+}
+.w-s-no {
+    white-space: nowrap;
+}

+ 1 - 0
src/assets/styles/uview-plus.scss

@@ -34,6 +34,7 @@
 .input-placeholder {
     color: #ccc;
     font-weight: 400;
+    font-size: 14px;
 }
 /* 兼容 H5 与各类小程序的按钮点击态描边移除 */
 button::after,

+ 3 - 3
src/config.ts

@@ -14,9 +14,9 @@ interface ProjectConfig {
 
 const config: ProjectConfig = {
     baseUrl: import.meta.env.VITE_API_BASE_URL || 'http://localhost:3000',
-    clientId: 'your-client-id',
-    tenantId: 'your-tenant-id',
-    appid: 'your-app-id'
+    clientId: '20251229',
+    tenantId: '000000',
+    appid: '1942409637969063940'
 };
 
 export default config;

+ 1 - 1
src/pages/index/index.vue

@@ -104,7 +104,7 @@ const handleLogout = async (): Promise<void> => {
             content: '确定要退出登录吗?',
             success: async (res) => {
                 if (res.confirm) {
-                    await logoutAndRedirect();
+                    // await logoutAndRedirect();
                     uni.showToast({
                         title: '已退出登录',
                         icon: 'success',

+ 1 - 1
src/pages/login/login.vue

@@ -123,7 +123,7 @@ import { useAuthStore } from '@/store/modules/auth';
 import type { LoginForm } from '@/store/modules/auth';
 
 // Store
-const authStore = useAuthStore();
+// const authStore = useAuthStore();
 
 // 响应式数据
 const loginFormRef = ref();

+ 102 - 40
src/pages/plant/index.vue

@@ -1,24 +1,31 @@
 <template>
-    <z-paging ref="paging" v-model="list" @onRefresh="onRefresh" bgColor="#f7f7f7" @scroll="onPageScroll">
+    <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" @scroll="onPageScroll">
         <template #top>
             <up-navbar :fixed="true" :bgColor="navBarBgColor">
                 <template #left>
                     <view class="d-flex a-c pb-5" id="topup-navbar" :style="{ width: `${bubble.left - 30}px` }">
-                        <image class="home_icon mr-20" src="https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/common/home.png" mode="widthFix" />
+                        <image class="home_icon mr-20"
+                            src="https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/common/home.png"
+                            mode="widthFix" />
                         <text class="f-s-40 c-333 f-w-5 w-s-no">中药材种植全链条追溯</text>
                         <view class="flex1"></view>
                     </view>
                 </template>
             </up-navbar>
         </template>
-        <view class="h-500 w-100%" style="background: linear-gradient(to left, #d2f7d5, #eafad8); position: absolute; top: 0; left: 0; z-index: -1"></view>
+        <view class="h-500 w-100%"
+            style="background: linear-gradient(to left, #d2f7d5, #eafad8); position: absolute; top: 0; left: 0; z-index: -1">
+        </view>
         <template>
             <up-navbar :fixed="false" bgColor="transparent">
-                <template #left><view class="pd-10"></view></template>
+                <template #left>
+                    <view class="pd-10"></view>
+                </template>
             </up-navbar>
             <view class="user-page-header pd-10 d-flex a-c mg-14 p-rtv">
                 <view class="user-page-header-avatar mr-20 p-rtv">
-                    <up-avatar size="116rpx" :src="avatar || 'https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/common/avatar.png'"></up-avatar>
+                    <up-avatar size="116rpx"
+                        :src="avatar || 'https://ta.zycpzs.cn/oss-file/smart-trace/szyy/images/common/avatar.png'"></up-avatar>
                 </view>
                 <view class="flex1 ov-hd mr-40">
                     <view class="p-rtv d-flex a-c mb-6">
@@ -27,7 +34,8 @@
                             <text class="c-999 f-s-24">{{ setCipByNum(phone, 3, 4) || '-' }}</text>
                         </view>
                     </view>
-                    <view class="f-s-22 mr-10 b-radius pt-4 pb-4 pl-10 pr-10 c-primary" style="width: max-content; background-color: #b7e8bc">
+                    <view class="f-s-22 mr-10 b-radius pt-4 pb-4 pl-10 pr-10 c-primary"
+                        style="width: max-content; background-color: #b7e8bc">
                         {{ cpyname }}
                     </view>
                 </view>
@@ -36,48 +44,62 @@
         <template>
             <view class="p-rtv">
                 <view class="pd-10 mg-14">
-                    <view class="b-radius pd-6" style="border: 1rpx solid #fff; background: linear-gradient(90deg, #c1f3c5 0%, rgba(193, 243, 197, 0.5) 20%, rgba(255, 255, 255, 0.5) 35%, rgba(255, 255, 255, 0.5) 50%, rgba(232, 255, 234, 0.5) 100%, #e8ffea 100%), linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 30%, rgba(255, 255, 255, 0.3) 80%, transparent 100%)">
+                    <view class="b-radius pd-6"
+                        style="border: 1rpx solid #fff; background: linear-gradient(90deg, #c1f3c5 0%, rgba(193, 243, 197, 0.5) 20%, rgba(255, 255, 255, 0.5) 35%, rgba(255, 255, 255, 0.5) 50%, rgba(232, 255, 234, 0.5) 100%, #e8ffea 100%), linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.3) 30%, rgba(255, 255, 255, 0.3) 80%, transparent 100%)">
                         <view class="b-radius pd-10 p-rtv" style="border: 1rpx solid #baedbf">
-                            <image class="w-200" src="/static/images/plant/typeofBusiness.png" mode="widthFix" style="position: absolute; top: 10rpx; left: 10rpx" />
+                            <image class="w-200" src="/static/images/plant/typeofBusiness.png" mode="widthFix"
+                                style="position: absolute; top: 10rpx; left: 10rpx" />
                             <view v-if="!speciesArray.length" class="pd-20"></view>
                             <view v-if="speciesArray.length" class="d-flex pr-15">
                                 <view class="flex1"></view>
-                                <view class="f-s-22 c-primary" @click="$u.route({ url: '/plant/species/config/index' })">去修改{{ '>' }}</view>
+                                <view class="f-s-22 c-primary"
+                                    @click="$u.route({ url: '/plant/species/config/index' })">去修改{{ '>' }}</view>
                             </view>
                             <view v-if="speciesArray.length" class="c-#333 f-s-24 d-flex pl-40 pr-15 pb-15 pt-15">
-                                <view class="ov-hd tx-ov w-s-no">三七、天麻、徐长卿、白及、徐长卿、白及、三七、天麻、徐长卿、白及、徐长卿、白及</view>
-                                <view class="flex1 w-s-no">等120个品种</view>
+                                <view class="ov-hd tx-ov w-s-no">{{ speciesArray.join('、') }}</view>
+                                <view v-if="speciesArray.length > 4" class="flex1 w-s-no">等{{ speciesArray.length }}个品种
+                                </view>
                             </view>
-                            <view v-if="!speciesArray.length" class="c-primary bg-#E3F6E7 f-s-22 mg-at radius-10 w-250 h-50 d-flex a-c j-c"> 暂未配置品种,去配置{{ '>' }}</view>
+                            <view v-if="!speciesArray.length" @click="$u.route({ url: '/plant/species/config/index' })"
+                                class="c-primary bg-#E3F6E7 f-s-22 mg-at radius-10 w-250 h-50 d-flex a-c j-c">
+                                暂未配置品种,去配置{{ '>' }}</view>
                             <view v-if="!speciesArray.length" class="pd-7"></view>
                         </view>
                     </view>
                 </view>
-                <view class="b-radius pt-0 bg-#f7f7f7" style="border: 1rpx solid #fff; border-bottom-color: transparent; margin-top: -40rpx">
+                <view class="b-radius pt-0 bg-#f7f7f7"
+                    style="border: 1rpx solid #fff; border-bottom-color: transparent; margin-top: -40rpx">
                     <up-sticky :offset-top="stickyTop">
                         <view class="d-flex a-c pd-16 p-rtv">
                             <view class="c-333 f-s-32 f-w-5 z-index-1">基地与地块管理</view>
                             <view class="flex1"></view>
-                            <view @click="$u.route({ url: '/plant/base/gap-base-info/index' })" class="c-primary f-s-22 z-index-1">GAP基地获评信息管理{{ '>' }}</view>
-                            <image src="/static/images/plant/basePlotBG.png" class="w-100%" mode="widthFix" style="position: absolute; top: 0; left: 0; z-index: -1"></image>
+                            <view @click="$u.route({ url: '/plant/base/gap-base-info/index' })"
+                                class="c-primary f-s-22 z-index-1">GAP基地获评信息管理{{ '>' }}</view>
+                            <image src="/static/images/plant/basePlotBG.png" class="w-100%" mode="widthFix"
+                                style="position: absolute; top: 0; left: 0; z-index: -1"></image>
                         </view>
                         <view class="d-flex a-c pt-20 pb-20 pl-16 pr-16 bg-#f7f7f7">
                             <view class="min-w-170 flex1">
-                                <ut-action-sheet v-model="form.type" :tabs="[{ label: '全部', value: '' }]" @change="onRefresh" title="选择原料类型">
+                                <ut-action-sheet v-model="form.type" :tabs="[{ label: '全部', value: '' }]"
+                                    @change="onRefresh" title="选择原料类型">
                                     <view class="d-flex search-select-item a-c">
-                                        <view class="flex1 ov-hd f-s-28 c-333 text-center f-w-5 w-s-no">{{ '全部' }}</view>
-                                        <up-icon size="24rpx" color="#333" name="arrow-down-fill" class="mr-5"></up-icon>
+                                        <view class="flex1 ov-hd f-s-28 c-333 text-center f-w-5 w-s-no">{{ '全部' }}
+                                        </view>
+                                        <up-icon size="24rpx" color="#333" name="arrow-down-fill"
+                                            class="mr-5"></up-icon>
                                     </view>
                                 </ut-action-sheet>
                             </view>
                             <view class="h-86 pl-20 w-100%">
-                                <ut-search ref="searchRef" v-model="form.keywords" @search="changeSeach" margin="0" :border="false" :placeholder="form.placeholder" bgColor="#fff" height="86rpx" borderRadius="10rpx"></ut-search>
+                                <ut-search ref="searchRef" v-model="form.keyword" @search="changeSeach" margin="0"
+                                    :border="false" :placeholder="form.placeholder" bgColor="#fff" height="86rpx"
+                                    borderRadius="10rpx"></ut-search>
                             </view>
                         </view>
                     </up-sticky>
-                    <view class="">
+                    <view class="pd-16">
                         <template>
-                            <view v-for="item in 10" :key="item" class="b-radius bg-#fff pd-20 mb-20">
+                            <view v-for="(item, index) in list" :key="index" class="b-radius bg-#fff pd-20 mb-20">
                                 <view class="c-333 f-s-34 pd-5 f-w-5">德钦县拖顶乡洛沙村各加尼拉基地</view>
                                 <view class="c-ccc f-s-24 pd-5 pt-0">DQTDLSC00156768951001</view>
                                 <view class="d-flex a-c">
@@ -97,34 +119,54 @@
                                 </view>
                                 <view class="c-333 f-s-28 pd-5 d-flex">
                                     <text class="c-#666 w-s-no">当前在地品种:</text>
-                                    <text class="ov-hd tx-ov w-s-no f-w-5">三七、天麻、徐长卿、白及、徐长卿、白及、三七、天麻、徐长卿、白及、徐长卿、白及</text>
+                                    <text
+                                        class="ov-hd tx-ov w-s-no f-w-5">三七、天麻、徐长卿、白及、徐长卿、白及、三七、天麻、徐长卿、白及、徐长卿、白及</text>
                                     <text class="flex1 w-s-no f-w-5">等120个品种</text>
                                 </view>
                                 <view class="pd-10"></view>
                                 <view class="p-rtv">
-                                    <up-image width="100%" src="https://img1.baidu.com/it/u=436536502,2810995452&fm=253&fmt=auto&app=120&f=JPEG?w=820&h=500" mode="widthFix"> </up-image>
-                                    <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20" style="position: absolute; bottom: 140rpx; right: 0; border-radius: 10rpx 0 0 10rpx">李思思负责</view>
-                                    <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20" style="position: absolute; bottom: 80rpx; right: 0; border-radius: 10rpx 0 0 10rpx">公司+合作社</view>
-                                    <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20" style="position: absolute; bottom: 20rpx; right: 0; border-radius: 10rpx 0 0 10rpx">经度:E64.63 纬度:N27.7385</view>
+                                    <up-image width="100%"
+                                        src="https://img1.baidu.com/it/u=436536502,2810995452&fm=253&fmt=auto&app=120&f=JPEG?w=820&h=500"
+                                        mode="widthFix"> </up-image>
+                                    <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20"
+                                        style="position: absolute; bottom: 140rpx; right: 0; border-radius: 10rpx 0 0 10rpx">
+                                        李思思负责</view>
+                                    <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20"
+                                        style="position: absolute; bottom: 80rpx; right: 0; border-radius: 10rpx 0 0 10rpx">
+                                        公司+合作社</view>
+                                    <view class="pl-20 pr-20 pt-10 pb-10 bg-#00000080 c-#ccc f-s-20"
+                                        style="position: absolute; bottom: 20rpx; right: 0; border-radius: 10rpx 0 0 10rpx">
+                                        经度:E64.63 纬度:N27.7385</view>
                                 </view>
                             </view>
                         </template>
-                        <template #empty>
-                            <ut-empty class="mg-at" color="#ccc" size="28rpx" image="/static/images/plant/noEmptyBase.png">尚未添加绘制种养殖基地信息~</ut-empty>
-                            <view class="b-radius c-#fff f-s-36 bg-#37A954 h-78 w-382 d-flex a-c j-c mg-at">
-                                <img class="w-38 h-36 mr-10" src="/static/images/plant/chooseGAP.png" alt="" mode="widthFix" />
-                                <text>去添加基地</text>
-                            </view>
-                        </template>
+
                     </view>
                 </view>
             </view>
         </template>
+        <template #empty>
+            <ut-empty class="mg-at" color="#ccc" size="28rpx" image="/static/images/plant/noEmptyBase.png">尚未添加绘制种养殖基地信息~</ut-empty>
+            <view class="b-radius c-#fff f-s-36 bg-#37A954 h-78 w-382 d-flex a-c j-c mg-at">
+                <img class="w-38 h-36 mr-10" src="/static/images/plant/chooseGAP.png" alt="" mode="widthFix" />
+                <text>去添加基地</text>
+            </view>
+        </template>
     </z-paging>
 </template>
 <script setup lang="ts">
 import { useClientRequest } from '@/utils/request';
 import { setCipByNum } from '@/utils/public';
+interface navbar {
+    bottom: number;
+    height: number;
+    left: number;
+    right: number;
+    top: number;
+    width: number;
+    id: string;
+    dataset?: any
+}
 const instance = getCurrentInstance();
 const list = ref([]);
 const paging = ref();
@@ -133,7 +175,7 @@ const avatar = ref();
 const name = ref('神奇大侠');
 const phone = ref('17708862791');
 const cpyname = ref('智慧溯源有限公司');
-const form = ref({ type: '', placeholder: '搜基地名称、编号、地址、负责人', keywords: '' });
+const form = ref({ type: '', placeholder: '搜基地名称、编号、地址、负责人', keyword: '' });
 const speciesArray = ref([]);
 const navBarBgColor = ref('transparent');
 const stickyTop = ref(0);
@@ -151,18 +193,38 @@ const onPageScroll = (e) => {
         navBarBgColor.value = 'transparent';
     }
 };
+const query = async (pageNum: number, pageSize: number) => {
+    const params = {
+        pageNum,
+        pageSize,
+        ...form.value,
+    };
+    const res = await useClientRequest.get('/plt-api/app/base/pageList', params);
+    console.log(res);
+    const { rows } = res;
+    paging.value.complete(rows);
+};
+// 查询企业的种植品种
+const getSpecies = async () => {
+    const res = await useClientRequest.get('/plt-api/app/cpyVariety/list');
+    if (res.code === 200) {
+        console.log(res);
+        speciesArray.value = res.data.map((item) => item.varietyName)
+    }
+};
+
 onMounted(() => {
-    const query = uni.createSelectorQuery().in(instance.proxy);
-    query
+    const querys = uni.createSelectorQuery().in(instance.proxy);
+    querys
         .select('#topup-navbar')
-        .boundingClientRect((data) => {
+        .boundingClientRect((data: any) => {
             stickyTop.value = data.top + data.height;
-            console.log(data.top + data.height);
-            console.log('得到布局位置信息' + JSON.stringify(data));
-            console.log('节点离页面顶部的距离为' + data.top);
         })
         .exec();
+    getSpecies()
+    query(1, 10)
 });
+
 // setTimeout(() => {
 //     useClientRequest.get('/time');
 // }, 2000);

+ 1 - 1
src/plant/base/gap-base-info/index.vue

@@ -1,5 +1,5 @@
 <template>
-    <z-paging ref="paging" v-model="list" @onRefresh="onRefresh" bgColor="#f7f7f7" @query="query" safe-area-inset-bottom hide-empty-view>
+    <z-paging ref="paging" v-model="list" bgColor="#f7f7f7" @query="query" safe-area-inset-bottom hide-empty-view>
         <template #top>
             <up-navbar title="GAP基地信息" @leftClick="navigateBackOrHome()" :fixed="false"></up-navbar>
             <view class="d-flex a-c pd-25">

+ 66 - 56
src/plant/species/config/index.vue

@@ -1,19 +1,19 @@
 <template>
-    <z-paging ref="paging" v-model="list" @onRefresh="onRefresh" bgColor="#fff" @query="query" :auto="false" safe-area-inset-bottom>
+    <z-paging ref="paging" v-model="list" bgColor="#fff" @query="query" :auto="false" safe-area-inset-bottom>
         <template #top>
             <view class="">
                 <up-navbar :title="title" @leftClick="navigateBackOrHome()" :fixed="false"></up-navbar>
                 <view class="pd-20">
-                    <ut-search ref="searchRef" v-model="form.keywords" @search="changeSeach" @change="changeSeach" margin="0" :border="false" :placeholder="placeholder" bgColor="#f7f7f7" height="86rpx" borderRadius="16rpx"></ut-search>
+                    <ut-search ref="searchRef" v-model="form.medicineName" @search="changeSeach" @change="changeSeach" margin="0" :border="false" :placeholder="placeholder" bgColor="#f7f7f7" height="86rpx" borderRadius="16rpx"></ut-search>
                 </view>
             </view>
         </template>
-        <template v-if="list.length == 0 && !form.keywords.trim()">
+        <template v-if="list.length == 0 && !form.medicineName.trim()">
             <view class="pd-20">
                 <view class="f-s-32 c-333 f-w-5 mb-20">已配置的主营品种</view>
                 <!-- speLable 组件使用示例 -->
                 <view class="d-flex a-c f-w-w">
-                    <spe-lable class="mr-20 mb-20" v-for="(item, index) in speArray" :key="index" :text="item?.name" size="30rpx" :id="item?.id" @close="() => handleLabelClose(item?.id)" />
+                    <spe-lable class="mr-20 mb-20" v-for="(item, index) in speArray" :key="index" :text="item?.varietyName" size="30rpx" :id="item?.id" @close="() => handleLabelClose(item?.id)" />
                 </view>
                 <ut-empty class="mg-at" v-if="speArray.length == 0">
                     <view class="d-flex a-c j-c f-s-28 c-ccc">暂未配置单位主营品种 </view>
@@ -22,14 +22,14 @@
             </view>
         </template>
         <template v-for="(item, index) in list" :key="index">
-            <spe-list :text="item?.name" :searchText="form.keywords" :check="item?.check" @update:check="(value) => handleCheckChange(value, item.id)"> </spe-list>
+            <spe-list :text="item?.medicineName" :searchText="form.medicineName" :check="item?.isChoice" @update:check="(value) => handleCheckChange(value, item.id)"> </spe-list>
         </template>
         <template #empty>
             <ut-empty class="mg-at">
                 <view class="d-flex a-c j-c f-s-28 c-ccc">暂未搜索到该品种</view>
             </ut-empty>
         </template>
-        <template #bottom v-if="form.keywords.trim()">
+        <template #bottom v-if="form.medicineName.trim()">
             <view class="base-bottom-wrap pd-20 pb-0">
                 <up-button type="primary" @click="subMit">确认</up-button>
             </view>
@@ -40,54 +40,67 @@
     </ut-confirm-dialog>
 </template>
 <script setup lang="ts">
+import { useClientRequest } from '@/utils/request';
 import speLable from '../models/speLable.vue';
 import SpeList from '../models/speList.vue';
+
 interface ListItem {
-    id: number;
-    name: string;
-    check: boolean;
+    rows:SpeArrayItem[]
+    code:number;
+    msg: string;
+    total: number;    
 }
 //定义speArray
-interface speArray {
+interface SpeArrayItem {
     id: number;
-    name: string;
+    abbreviation?: string;
+    createdTime: string | null;
+    creator: string | null;
+    delFlag: number;
+    genusLatinName: string;
+    genusName: string;
+    isChoice: string; // 或改为 boolean
+    latinName: string;
+    medicineName: string;
+    modifier: string | null;
+    sourceType: number;
+    updateTime: string | null;
 }
-const list = ref<ListItem[]>([]);
+
+const list = ref<SpeArrayItem[]>([]);
 const paging = ref();
 const title = ref('配置单位主营品种');
 const placeholder = ref('请搜索药材品种名称选择添加');
 const form = ref({
-    keywords: '',
+    medicineName: '',
 });
-const speArray = ref<speArray[]>([]);
+const speArray = ref<any[]>([]);
 // 删除确认相关状态
 const showDeleteDialog = ref(false);
 const currentDeleteId = ref<number | null>(null);
-
-setTimeout(() => {
-    speArray.value = [
-        { id: 1, name: '三七' },
-        { id: 2, name: '天麻' },
-        { id: 3, name: '白及' },
-        { id: 4, name: '重楼' },
-        { id: 5, name: '大麻' },
-        { id: 6, name: '黄精' },
-        { id: 7, name: '地黄' },
-        { id: 8, name: '附子' },
-        { id: 9, name: '紫河车' },
-    ];
-}, 200);
+const getSpecies = async () => {
+    const res = await useClientRequest.get('/plt-api/app/cpyVariety/list');
+    if (res.code === 200) {
+        speArray.value = res.data;
+        speArray.value.forEach((item) => {
+            item.isChoice = '1';
+        });
+    }
+};
 // 处理标签关闭事件
 const handleLabelClose = (id: string | number) => {
     currentDeleteId.value = id as number;
     showDeleteDialog.value = true;
 };
-const handleCheckChange = (newCheckValue: boolean, id: number) => {
+const handleCheckChange = (newCheckValue: string, id: number) => {
     // 根据ID找到对应的列表项并更新
     const item = list.value.find((item) => item.id === id);
     if (item) {
-        item.check = newCheckValue;
+        item.isChoice = newCheckValue;
     }
+    speArray.value = speArray.value.filter((item) => item.varietyId !== id);
+    console.log(speArray.value,'speArray.value');
+    
 };
 const query = async (pageNum: number, pageSize: number) => {
     const params = {
@@ -95,51 +108,45 @@ const query = async (pageNum: number, pageSize: number) => {
         pageSize,
         ...form.value,
     };
-    if (!params.keywords?.trim()) {
+    if (!params.medicineName?.trim()) {
         // 处理空、null、undefined、纯空格的情况
         return;
     }
     // const res = await cpyList(params);
-    let res: ListItem[] = [];
-    //循环push10条数据
-    for (let i = 0; i < 10; i++) {
-        res.push({
-            id: i + 1,
-            name: `${params.keywords}${i + 1}${params.keywords}`,
-            check: false,
-        });
-    }
-    // const { rows } = res;
-    paging.value.complete(res);
+    const res: ListItem = await useClientRequest.get<ListItem>('/plt-api/app/medicine/pageList',params)   
+    const { rows } = res;
+    // 给列表项添加 isChoice 属性
+    paging.value.complete(rows);    
 };
 const changeSeach = () => {
     paging.value.reload();
-    console.log(form.value?.keywords, 'keywords');
 };
 const onRefresh = () => {
     paging.value.reload();
 };
-const subMit = () => {
+const subMit = async() => {
+    // 方法1:使用 Set 避免重复,更高效
+    const existingIds = new Set(speArray.value.map(speItem => speItem.varietyId));
     list.value.forEach((item) => {
-        if (item.check) {
-            console.log(item, 'item');
-            //判断item.id是否不在speArray中
-            if (!speArray.value.find((speItem) => speItem.id === item.id)) {
-                speArray.value.push({
-                    id: item.id,
-                    name: item.name,
-                });
-            }
+        if (item.isChoice === '1' && !existingIds.has(item.id)) {
+            speArray.value.push({varietyId:item.id,varietyName:item?.medicineName, isChoice: '1'});
         }
     });
-    form.value.keywords = '';
+    // 直接使用过滤后的 speArray 中的所有 id
+    await useClientRequest.post('/plt-api/app/cpyVariety/add', {
+        varietyIds: speArray.value.map(item => item.varietyId),
+    });
+    
+    form.value.medicineName = '';
     onRefresh();
+    getSpecies()
 };
 
 // 处理删除确认
-const handleDeleteConfirm = () => {
+const handleDeleteConfirm = async() => {
     if (currentDeleteId.value !== null) {
-        speArray.value = speArray.value.filter((item) => item.id !== currentDeleteId.value);
+       await useClientRequest.get(`/plt-api/app/cpyVariety/delById/${currentDeleteId.value}`);
+       getSpecies()
     }
     showDeleteDialog.value = false;
     currentDeleteId.value = null;
@@ -150,4 +157,7 @@ const handleDeleteCancel = () => {
     showDeleteDialog.value = false;
     currentDeleteId.value = null;
 };
+onMounted(() => {
+    getSpecies()
+})
 </script>

+ 7 - 6
src/plant/species/models/speList.vue

@@ -14,7 +14,7 @@
         </view>
         <!-- 右侧勾选图标(根据check状态显示) -->
         <!-- <up-icon v-if="check" name="checkmark" size="45rpx" color="#37A954" class="check-icon" /> -->
-        <img v-if="check" class="w-30 h-30" src="/static/images/plant/chooseSuccessfully.png" mode="widthFix" alt="" />
+        <img v-if="check === '1'" class="w-30 h-30" src="/static/images/plant/chooseSuccessfully.png" mode="widthFix" alt="" />
     </view>
 </template>
 
@@ -36,16 +36,16 @@ const props = defineProps({
         type: String,
         default: '#37A954',
     },
-    // 是否选中状态
+    // 是否选中状态(字符串格式:0-未选中,1-选中)
     check: {
-        type: Boolean,
-        default: false,
+        type: String,
+        default: '0',
     },
 });
 
 const emit = defineEmits<{
     // 更新check状态的事件
-    'update:check': [check: boolean];
+    'update:check': [check: string];
     // 点击事件
     click: [];
 }>();
@@ -77,7 +77,8 @@ const textParts = computed(() => {
 
 // 处理点击事件
 const handleClick = () => {
-    emit('update:check', !props.check);
+    const newValue = props.check === '1' ? '0' : '1';
+    emit('update:check', newValue);
     emit('click');
 };
 </script>

+ 2 - 0
src/store/modules/auth.ts

@@ -74,6 +74,8 @@ export const useAuthStore = defineStore('auth', () => {
      */
     const logout = async (): Promise<void> => {
         try {
+            console.log('>>>>>>>');
+            
             // 调用登出接口
             await useClientRequest.post('/auth/logout');
         } catch (error) {

+ 1 - 1
src/utils/auth.ts

@@ -10,7 +10,7 @@ import { envWx, EnvType } from '@/config';
 type TokenKeyMap = Record<EnvType, string>;
 
 const mapTokenKey: TokenKeyMap = {
-    develop: 'develop-token',
+    develop: 'token',
     trial: 'develop-token',
     release: 'App-Token',
 };

+ 2 - 0
src/utils/loginHelper.ts

@@ -43,6 +43,8 @@ export const silentLogin = async (): Promise<boolean> => {
  * 安全登出
  */
 export const secureLogout = async (): Promise<void> => {
+  console.log('安全登出');
+  
   const authStore = useAuthStore();
   const userStore = useUserStore();
   

+ 14 - 9
src/utils/request.ts

@@ -1,3 +1,5 @@
+import config from '@/config';
+const { clientId, appid } = config;
 // uniapp封装的请求方法
 let timeout = 60 * 1000;
 
@@ -5,10 +7,13 @@ let timeout = 60 * 1000;
 const getHeader = () => {
     let header = {
         'Content-Type': 'application/json',
-        Authorization: uni.getStorageSync('token') || '',
+        Authorization: 'Bearer ' + uni.getStorageSync('token') || '',
+        'xid':config?.appid || '',
+        'clientId':config?.clientId || '',
     };
     return header;
 };
+
 // 获取host地址
 export const request = ({ url, method = 'GET', data = {}, header = null }: any) => {
     const baseUrl = import.meta.env.VITE_API_BASE_URL || 'http://localhost:3000';
@@ -29,32 +34,32 @@ export const request = ({ url, method = 'GET', data = {}, header = null }: any)
     });
 };
 export const useClientRequest = {
-    post: (url: string, data?: any) => {
+    post: <T = any>(url: string, data?: any): Promise<T> => {
         return request({
             url,
             method: 'POST',
             data,
-        });
+        }) as Promise<T>;
     },
-    get: (url: string, data?: any) => {
+    get: <T = any>(url: string, data?: any): Promise<T> => {
         return request({
             url,
             method: 'GET',
             data,
-        });
+        }) as Promise<T>;
     },
-    put: (url: string, data?: any) => {
+    put: <T = any>(url: string, data?: any): Promise<T> => {
         return request({
             url,
             method: 'PUT',
             data,
-        });
+        }) as Promise<T>;
     },
-    delete: (url: string, data?: any) => {
+    delete: <T = any>(url: string, data?: any): Promise<T> => {
         return request({
             url,
             method: 'DELETE',
             data,
-        });
+        }) as Promise<T>;
     },
 };

+ 4 - 1
src/utils/routeGuard.ts

@@ -16,6 +16,7 @@ export const checkAuth = async (options: RouteGuardOptions = {}): Promise<boolea
   }
 
   const authStore = useAuthStore();
+  console.log(authStore,"authStore");
   
   // 如果没有token,直接跳转到登录页
   if (!authStore.token) {
@@ -49,6 +50,7 @@ export const checkAuth = async (options: RouteGuardOptions = {}): Promise<boolea
  */
 export const routeGuard = async (url: string, options: RouteGuardOptions = {}): Promise<void> => {
   const isAuthenticated = await checkAuth(options);
+  console.log(isAuthenticated,'isAuthenticated');
   
   if (isAuthenticated) {
     uni.navigateTo({
@@ -69,7 +71,7 @@ export const navigateWithAuth = (url: string, options: RouteGuardOptions = {}):
  */
 export const autoLogin = async (): Promise<boolean> => {
   const authStore = useAuthStore();
-  
+  console.log(authStore,'自动登录检查');
   if (!authStore.token) {
     return false;
   }
@@ -89,6 +91,7 @@ export const autoLogin = async (): Promise<boolean> => {
 export const logoutAndRedirect = async (redirectUrl: string = '/pages/login/login'): Promise<void> => {
   const authStore = useAuthStore();
   await authStore.logout();
+  console.log('登出并跳转到登录页');
   
   uni.reLaunch({
     url: redirectUrl

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 0 - 1
stats.html


Vissa filer visades inte eftersom för många filer har ändrats