Bladeren bron

接口调试,修改baseUrl减少字符拼接

LuChongMei 2 jaren geleden
bovenliggende
commit
5e383d5d82

+ 4 - 4
src/api/placeActivity/placeActivityServer.js

@@ -1,9 +1,9 @@
 import request from '@/utils/request'
 export default class placeActivityServer {
     list(params) {
-        return request.get({
-            url: '/reporting/reportingActivities/list',
-            params: params
-        })
+        return request.get(
+            `/reporting/reportingActivities/list`,
+            params
+        )
     }
 }

+ 15 - 8
src/api/sys/tools.js

@@ -1,12 +1,19 @@
+import request from '@/utils/request'
 export default class Tools {
     treeData() {
-            return request.get('/tools/area_yc/treeData');
-        }
-        // 获取人员信息
-    list(params) {
-        return request({
-            url: '/user/usermanagement/userManagement/list',
-            params: params
-        })
+        return request.get(`/tools/area_yc/treeData`);
+    };
+    // 获取人员信息
+    personList(params) {
+        return request.get(
+            `/user/usermanagement/userManagement/list`,
+            params
+        )
+    };
+    placeList(params) {
+        return request.get(
+            `/religioussites/siteinfo/religiousSitesInfo/list`,
+            params
+        )
     }
 }

+ 30 - 31
src/utils/request.js

@@ -1,12 +1,12 @@
-import axios from "axios";          //引入axios
-import sysConfig from '@/config'    //引入配置文件
+import axios from "axios"; //引入axios
+import sysConfig from '@/config' //引入配置文件
 import store from "../store/index"
 import qs from "qs"
 
 // console.log(process.env.NODE_ENV)
 
-axios.defaults.baseURL = sysConfig.baseURL   //设置请求时间
-axios.defaults.timeout = sysConfig.timeout   //设置请求超时时间
+axios.defaults.baseURL = sysConfig.baseUrl //设置请求时间
+axios.defaults.timeout = sysConfig.timeout //设置请求超时时间
 const ContentType = sysConfig.ContentType
 
 //axios.defaults.headers["Content-Type"] = "application/json";
@@ -19,7 +19,7 @@ axios.defaults.headers["Content-Type"] = "application/x-www-form-urlencoded";
 /** 请求发送前拦截,用于配置求情内容,如headers参数等 */
 axios.interceptors.request.use(
     (config) => {
-        config.headers.token=window.localStorage.getItem('MZ_TOKEN');
+        config.headers.token = window.localStorage.getItem('MZ_TOKEN');
         return config
     },
     (error) => {
@@ -27,34 +27,34 @@ axios.interceptors.request.use(
     }
 )
 
-function error1(res){
-	if (res.status == 408 || res.status == 401) {// 需要重新登录
-        store.commit('setPcToken',"");
-		console.log(res.data);
+function error1(res) {
+    if (res.status == 408 || res.status == 401) { // 需要重新登录
+        store.commit('setPcToken', "");
+        console.log(res.data);
         // window.xm.showToast({
         //     message:res.data
         // })
-	}else if(res.status === 404){
-        console.log("404,路径找不到:"+res.data.path);
+    } else if (res.status === 404) {
+        console.log("404,路径找不到:" + res.data.path);
         // window.xm.showToast({
         //     message:"404,路径找不到:"+res.data.path
         // })
-	}else if(res.status === 503){
+    } else if (res.status === 503) {
         console.log("服务不可用");
         // window.xm.showToast({
         //     message:"服务不可用"
         // })
-	}else if(res.status === 504){
+    } else if (res.status === 504) {
         console.log("网络连接错误");
         // window.xm.showToast({
         //     message:"网络连接错误"
         // })
-	}else{
+    } else {
         console.log(res.data);
         // window.xm.showToast({
         //     message:res.data
         // })
-	}
+    }
 }
 
 /** 请求发送后返回拦截,用于处理数据格式等 */
@@ -63,11 +63,11 @@ axios.interceptors.response.use(
         return response
     },
     (error) => {
-		if(error.request){
-			error1(error.request);
-		} else if(error.response){
+        if (error.request) {
+            error1(error.request);
+        } else if (error.response) {
 
-		}
+        }
         return error
     }
 )
@@ -84,13 +84,13 @@ var http = {
      * @param {*} config    请求的config相关配置
      * @returns
      */
-    get: function (url, params = {}, config = {}) {
+    get: function(url, params = {}, config = {}) {
         return new Promise((resolve, reject) => {
             axios({
-                url: url+"?"+params,
+                url: url,
                 method: 'get',
-                //params: qs.stringify(params),
-                //params: params,
+                params: params,
+                // params: params,
                 config: config
             }).then((response) => {
                 resolve(response.data)
@@ -109,7 +109,7 @@ var http = {
      * @param {*} config   请求的config相关配置
      * @returns
      */
-    post: function (url, data = {}, params = {}, config = {}) {
+    post: function(url, data = {}, params = {}, config = {}) {
         return new Promise((resolve, reject) => {
             axios({
                 url: url,
@@ -119,11 +119,11 @@ var http = {
                 //params: qs.stringify(params),
                 config: config
             }).then((response) => {
-				//if(response.data && response.data.statusCode !== 200){
-				// 	error(response.data);
-				// 	reject(response.data)
-				// }
-				// resolve(response.data);
+                //if(response.data && response.data.statusCode !== 200){
+                // 	error(response.data);
+                // 	reject(response.data)
+                // }
+                // resolve(response.data);
 
                 resolve(response);
             }).catch((error) => {
@@ -133,5 +133,4 @@ var http = {
     }
 }
 
-export default http;
-
+export default http;

+ 5 - 4
src/views/activityMan/personList.vue

@@ -43,6 +43,7 @@
           >
             <template #right-icon>
               <van-checkbox
+                shape="square"
                 :name="item"
                 :ref="(el) => (checkboxRefs[index] = el)"
                 @click.stop
@@ -56,20 +57,20 @@
 </template>
 
 <script>
-import { ref } from "vue";
-import tools from "@/api/sys/tools";
+import { ref, onBeforeUpdate } from "vue";
+// import tools from "@/api/sys/tools";
 export default {
   name: "personList",
   emits: ["selected"],
   setup(props, { emit }) {
-    const list = [];
+    const list = ref([]);
     const loading = ref(false);
     const finished = ref(false);
     // let index = 0;
     // const onLoad = () => {
     //   // 异步更新数据
     //   new tools()
-    //     .list({
+    //     .personList({
     //       current: index + 1,
     //       size: 10,
     //     })

+ 15 - 31
src/views/activityMan/placeactivity/placeActivityList.vue

@@ -36,10 +36,12 @@
         </div>
         <van-cell is-link to="placeActivityInfo">
           <template #title>
-            {{ item.portname }}申请于{{ item.place }}举办{{ item.activity }}活动
+            {{ item.reporter.name }}申请于{{ item.placeDel }}举办{{
+              item.activityName
+            }}活动
           </template>
           <template #label>
-            {{ item.activityPlace + " " + item.address }}
+            {{ item.place }}
           </template>
         </van-cell>
       </div>
@@ -52,7 +54,7 @@
 </template>
 
 <script>
-import { reactive, ref } from "vue";
+import { reactive, ref, toRaw, toRef } from "vue";
 import router from "@/router";
 import placeActivityServer from "@/api/placeActivity/placeActivityServer";
 export default {
@@ -69,24 +71,7 @@ export default {
     // 切换
     let tabIndex = ref(0);
     // 列表
-    const list = reactive([
-      {
-        activity: "测试",
-        place: "基督教",
-        activityTime: "2023-03-28 13:00",
-        countPerson: "100",
-        list: "11,22,33",
-        portname: "张三",
-        area: "",
-        activityPlace: "盐都区/张庄街道",
-        address: "1111",
-        money: "",
-        activityName: "李四",
-        tel: "",
-        file: "",
-        into: "1111",
-      },
-    ]);
+    let list = ref([]);
     const loading = ref(false);
     const finished = ref(false);
     let index = 0;
@@ -97,17 +82,16 @@ export default {
           current: index + 1,
           size: 10,
         })
-        .then(({ data }) => {
-          console.log("获取数据", data);
-          // list.push(data);
-          // // 数据全部加载完成
-          // if (data.length < 10) {
-          //   finished.value = true;
-          // }
+        .then((res) => {
+          list.value.push(...res.records) ;
+          // 加载状态结束
+          loading.value = false;
+          index++;
+          // 数据全部加载完成
+          if (res.records.length < 10) {
+            finished.value = true;
+          }
         });
-      // 加载状态结束
-      loading.value = false;
-      index++;
     };
     // 搜索
     let value = ref("");

+ 30 - 25
src/views/activityMan/placeactivity/placeActivityView.vue

@@ -33,6 +33,7 @@
           <van-picker
             title="活动场所"
             :columns="places"
+            :columns-field-names="customFieldName"
             @cancel="showPlace = false"
             @confirm="getPlace"
           />
@@ -129,6 +130,7 @@
             :options="options"
             @close="showArea = false"
             @finish="onFinish"
+            :field-names="fieldNames"
           />
         </van-popup>
       </van-cell-group>
@@ -212,10 +214,9 @@
 import { reactive, ref } from "vue";
 import personList from "../personList.vue";
 import placeActivityServer from "@/api/placeActivity/placeActivityServer";
-import tools from '@/api/sys/tools'
+import tools from "@/api/sys/tools";
 export default {
   components: { personList },
-  tools:new tools(),
   setup() {
     // 返回
     const onClickLeft = () => {
@@ -239,17 +240,24 @@ export default {
       into: "",
     });
     // 场所名称
-    const places = [
-      { text: "杭州", value: "Hangzhou" },
-      { text: "宁波", value: "Ningbo" },
-      { text: "温州", value: "Wenzhou" },
-      { text: "绍兴", value: "Shaoxing" },
-      { text: "湖州", value: "Huzhou" },
-    ];
+    let places = ref([]);
+    const customFieldName = {
+      text: "name",
+      value: "name",
+    };
+    new tools()
+      .placeList({
+        current: 1,
+        size: 10000,
+      })
+      .then(({ records }) => {
+        places.value.push(...records) ;
+      });
     let showPlace = ref(false);
     const getPlace = ({ selectedOptions }) => {
+      // console.log("选择",selectedOptions);
       showPlace.value = false;
-      placeActivity.place = selectedOptions[0].text;
+      placeActivity.place = selectedOptions[0].name;
     };
     // 获取活动时间
     let showAct = ref(false);
@@ -278,32 +286,28 @@ export default {
     // 地区选择
     let showArea = ref(false);
     const cascaderValue = ref("");
-    tools.treeData().then((res) => {
+    const fieldNames = {
+      text: "name",
+      value: "code",
+      children: "children",
+    };
+    // 选项列表,children 代表子选项,支持多级嵌套
+    let options = ref([]);
+    new tools().treeData().then((res) => {
       console.log("area", res);
+      options.value.push(res[0]);
     });
-    // 选项列表,children 代表子选项,支持多级嵌套
-    const options = [
-      {
-        text: "浙江省",
-        value: "330000",
-        children: [{ text: "杭州市", value: "330100" }],
-      },
-      {
-        text: "江苏省",
-        value: "320000",
-        children: [{ text: "南京市", value: "320100" }],
-      },
-    ];
     // 全部选项选择完毕后,会触发 finish 事件
     const onFinish = ({ selectedOptions }) => {
       showArea.value = false;
       placeActivity.activityPlace = selectedOptions
-        .map((option) => option.text)
+        .map((option) => option.name)
         .join("/");
     };
     return {
       placeActivity,
       // 活动场所
+      customFieldName,
       showPlace,
       places,
       getPlace,
@@ -321,6 +325,7 @@ export default {
       reselected,
       // 地区选择
       showArea,
+      fieldNames,
       options,
       onFinish,
       cascaderValue,