Prechádzať zdrojové kódy

广告对接/修改配置文件精度丢失问题

zaijin 1 rok pred
rodič
commit
067332a4b9

+ 1 - 1
common/apiurl.js

@@ -157,6 +157,6 @@ export const apiurl = {
     // 获取广告列表
     getAdBannerListUrl: '/admin/advertInfo',
     // 获取广告详情
-    getAdBannerDetailsUrl: '/admin/advertInfo'
+    getAdBannerDetailsUrl: '/admin/advertInfo/detail'
   }
 };

+ 7 - 2
common/http.interceptor.js

@@ -3,7 +3,9 @@ const install = (Vue, vm) => {
   Vue.prototype.$u.http.setConfig({
     baseUrl: vm.config.baseUrl,
     loadingText: '努力加载中~',
-    loadingTime: 800
+    loadingTime: 800,
+    originalData: true,
+    dataType: 'text'
   });
   // 请求拦截,配置Token等参数
   Vue.prototype.$u.http.interceptor.request = (config) => {
@@ -25,9 +27,12 @@ const install = (Vue, vm) => {
   };
   // 响应拦截,判断状态码是否通过
   Vue.prototype.$u.http.interceptor.response = (res) => {
+    // 解决出现数据精度缺失问题
+    const jsonBigint = require('json-bigint')({ storeAsString: true });
+    res = jsonBigint.parse(res.data);
     if (res.code == 200) {
       return res;
-    } else if (res.code == 401 || (res.code == 400 && res.msg == '令牌不能为空') ) {
+    } else if (res.code == 401 || (res.code == 400 && res.msg == '令牌不能为空')) {
       const backUrl = location.href,
         openidPage = vm.config.onlyWxLogin, // 只需要传openid的页面集合
         needValidPage = openidPage.filter((item) => backUrl.indexOf(item) > -1); // 是否为需要验证的页面集合

+ 8 - 8
components/ad-banner/ad-banner.vue

@@ -3,7 +3,7 @@
  * @Author: 空白格
  * @Date: 2023-05-24 09:23:58
  * @LastEditors: 空白格
- * @LastEditTime: 2023-05-24 10:14:25
+ * @LastEditTime: 2023-05-25 11:25:19
  * @FilePath: \parking_h5_all\components\ad-banner\ad-banner.vue
  * @Copyright: Copyright (c) 2016~2023 by 空白格, All Rights Reserved. 
 -->
@@ -22,20 +22,20 @@ export default {
       list: []
     };
   },
-	created() {
-		this.getBannerList();
-	},
+  created() {
+    this.getBannerList();
+  },
   methods: {
     /**
      * @description: 获取轮播列表
      * @return {*}
      */
     async getBannerList() {
-      const { code, rows } = await this.$u.api.adBannerModuleApi.getAdBannerListApi({ pageNum: 1, pageSize: 10 });
+      const { code, rows } = await this.$u.api.adBannerModuleApi.getAdBannerListApi({ pageNum: 1, pageSize: 10, onlineStatus: 1 });
       if (code === 200) {
-        this.list = rows.map(item => {
-					return { id: item.id, image: item.bannerUrl, type: item.contentType, link: item.jumpUrl, ...item }
-				});
+        this.list = rows.map((item) => {
+          return { id: String(item.id), image: item.bannerUrl, type: item.contentType, link: item.jumpUrl, ...item };
+        });
       }
     },
     /**

+ 1 - 0
package.json

@@ -107,6 +107,7 @@
 		}
 	},
 	"dependencies": {
+		"json-bigint": "^1.0.0",
 		"vconsole": "^3.15.0",
 		"vue-jsonp": "^2.0.0",
 		"weixin-js-sdk": "^1.6.0"

+ 2 - 3
pages/adBannerDetails/adBannerDetails.vue

@@ -24,10 +24,9 @@ export default {
      * @return {*}
      */
     async getBannerDetails(id) {
-      const { code, rows } = await this.$u.api.adBannerModuleApi.getAdBannerListApi({ pageNum: 1, pageSize: 10 });
+      const { code, data } = await this.$u.api.adBannerModuleApi.getAdBannerDetailsApi({ id });
       if (code === 200) {
-        this.detailsInfo = rows.find(item => String(item.id) === id);
-				console.log(this.detailsInfo)
+        this.detailsInfo = data;
       }
     }
   }