diff --git a/App.vue b/App.vue
index 5c197ab..5853906 100644
--- a/App.vue
+++ b/App.vue
@@ -15,6 +15,7 @@ export default {
// 在需要检查的地方
this.$config.init().then(async (data) => {
+ console.log('加载抽奖音乐。。。。');
//加载配置
let src = await that.$config.getAppSettingAsync("win_audio");
if (src == null || src == "") {
@@ -47,7 +48,6 @@ export default {
}
//创建中奖音乐
const slotBgm = uni.createInnerAudioContext();
- // Vue.prototype.bgmCtx = {};
slotBgm.src = src2;
Vue.prototype.bgmCtx.slotBgm = slotBgm;
//超神音效
diff --git a/common/config.js b/common/config.js
index 14a38cb..d981d33 100644
--- a/common/config.js
+++ b/common/config.js
@@ -8,7 +8,7 @@ import RequestManager from '@/common/request.js'
let configData = null;
let isLoading = false;
let loadPromise = null;
-const wx_version = "114";
+const wx_version = "117";
// 白名单页面(不需要登录即可访问)
export const whiteList = [
@@ -32,7 +32,7 @@ export const whiteList = [
"pages/shouye/slots",
"pages/other/web-pay-order", // 网页支付订单
"pages/other/web-pay-success", // 网页支付成功
- "pages/other/about"
+ "pages/other/about"// 其它页面
];
@@ -238,48 +238,46 @@ class ConfigManager {
if (isLoading) {
return loadPromise;
}
-
isLoading = true;
loadPromise = new Promise((resolve, reject) => {
- RequestManager.get('config')
- .then(res => {
- if (res.status === 1 && res.data) {
- configData = res.data;
- console.log('全局配置数据加载成功');
- let _configData = uni.getStorageSync("configData");
- uni.setStorageSync('configData', configData);
- if (_configData != null && _configData != '') {
- if (_configData.app_setting.applet_version != configData.app_setting
- .applet_version) {
- console.log('版本号不一致,需要更新');
- const updateManager = uni.getUpdateManager();
- uni.showModal({
- title: "更新提示",
- content: "新版本已经准备好,是否重启应用?",
- showCancel: false,
- success(res) {
- if (res.confirm) {
- console.log('开始重启');
- wx.restartMiniProgram({
- path: "/pages/shouye/index"
- });
- // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
- //updateManager.applyUpdate();
+ RequestManager.getCache('config').then(res => {
+ if (res.status === 1 && res.data) {
+ configData = res.data;
+ console.log('全局配置数据加载成功');
+ let _configData = uni.getStorageSync("configData");
+ uni.setStorageSync('configData', configData);
+ if (_configData != null && _configData != '') {
+ if (_configData.app_setting.applet_version != configData.app_setting
+ .applet_version) {
+ console.log('版本号不一致,需要更新');
+ const updateManager = uni.getUpdateManager();
+ uni.showModal({
+ title: "更新提示",
+ content: "新版本已经准备好,是否重启应用?",
+ showCancel: false,
+ success(res) {
+ if (res.confirm) {
+ console.log('开始重启');
+ wx.restartMiniProgram({
+ path: "/pages/shouye/index"
+ });
+ // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
+ //updateManager.applyUpdate();
- //#ifdef MP-WEIXIN
+ //#ifdef MP-WEIXIN
- //#endif
- }
- },
- });
- }
+ //#endif
+ }
+ },
+ });
}
- resolve(configData);
- } else {
- console.error('加载配置数据失败:', res.msg || '未知错误');
- reject(new Error(res.msg || '加载配置失败'));
}
- })
+ resolve(configData);
+ } else {
+ console.error('加载配置数据失败:', res.msg || '未知错误');
+ reject(new Error(res.msg || '加载配置失败'));
+ }
+ })
.catch(err => {
console.error('请求配置数据失败:', err);
isLoading = false;
@@ -397,7 +395,26 @@ class ConfigManager {
}
return key in appSetting ? appSetting[key] : null;
}
+ /**
+ * 获取其它配置
+ * @returns
+ */
+ static getBaseConfig() {
+ let baseConfig = this.get('base_config');
+ return baseConfig;
+ }
+ /**
+ * 获取其它配置
+ * @returns
+ */
+ static getBaseConfigKey(key) {
+ let baseConfig = this.getBaseConfig();
+ if (key == null) {
+ return baseConfig;
+ }
+ return key in baseConfig ? baseConfig[key] : null;
+ }
/**
* 获取指定键的配置值
* @param {String} key 配置键
diff --git a/common/env.js b/common/env.js
index d604d9e..adaa76e 100644
--- a/common/env.js
+++ b/common/env.js
@@ -42,21 +42,6 @@ const testing = {
// 根据环境变量选择对应配置
let currentEnv = testing;//production;//testing;//production_wz;
-
-// 判断当前环境
-// #ifdef H5
-// if (process.env.NODE_ENV === 'production') {
-// currentEnv = production;
-// } else if (process.env.NODE_ENV === 'testing') {
-// currentEnv = testing;
-// }
-// #endif
-
-// #ifdef MP-WEIXIN
-// currentEnv =testing;//小程序默认使用测试环境配置
-// currentEnv = production; // 小程序默认使用生产环境配置
-// #endif
-
// 衍生配置
const config = {
...currentEnv,
diff --git a/common/platform/AppPlatform.js b/common/platform/AppPlatform.js
index 3f91525..c4a99da 100644
--- a/common/platform/AppPlatform.js
+++ b/common/platform/AppPlatform.js
@@ -11,6 +11,7 @@ import {
import {
getPlatform
} from '../server/config';
+
class AppPlatform extends BasePlatform {
constructor() {
super();
@@ -23,6 +24,8 @@ class AppPlatform extends BasePlatform {
AppLaunch(options) {
console.log("AppLaunch", options);
+ }
+ async appData() {
this.getConfig().then(res => {
console.log("AppLaunch", res);
if (res.isCheck) {
@@ -59,7 +62,6 @@ class AppPlatform extends BasePlatform {
});
}
})
-
}
getOrderNo(event) {
@@ -233,7 +235,7 @@ class AppPlatform extends BasePlatform {
} else {
menuList.push(menu);
}
- if(menu.title=="用户协议"){
+ if (menu.title == "用户协议") {
menuList.push(customServiceMenu);
}
}
diff --git a/common/platform/BasePlatform.js b/common/platform/BasePlatform.js
index f597d16..fed21e2 100644
--- a/common/platform/BasePlatform.js
+++ b/common/platform/BasePlatform.js
@@ -2,8 +2,9 @@ import {
navigateTo
} from '@/common/router'
import {
- getPlatform
+ getPlatform, getAdvert, getConfig, getDanYe
} from '../server/config';
+import ConfigManager from '../config';
/**
* 多端平台抽象基类(父类)
* 定义所有端必须实现的方法
@@ -19,7 +20,7 @@ class BasePlatform {
}
async getConfig() {
// return new Promise((resolve, reject) => {
- console.log("获取配置", this.config);
+ console.log("获取配置", this.config);
if (this.config != null) {
return this.config;
}
@@ -27,6 +28,27 @@ class BasePlatform {
this.config = res;
return this.config;
}
+ async appData() {
+ await this.loadCacheData();
+ // uni.switchTab({
+ // url: '/pages/shouye/index'
+ // });
+ }
+
+ /**
+ * 加载缓存
+ */
+ async loadCacheData() {
+ this.cacheData = {};
+ await ConfigManager.init();
+ console.log('初始化成功.。。。。');
+ //首页轮播图
+ await getAdvert(1);
+ //推荐
+ await getAdvert(5);
+ //公告
+ await getDanYe(3);
+ }
/**
* 获取是否需要审核
* @returns {boolean} 是否需要审核
@@ -173,12 +195,12 @@ class BasePlatform {
})
}
const customServiceMenu = {
- id: 10,
- show: true,
- title: '关于',
- icon: 'my/about.png',
- path: '/pages/other/about',
- handler: this.navigateToPath.bind(this)
+ id: 10,
+ show: true,
+ title: '关于',
+ icon: 'my/about.png',
+ path: '/pages/other/about',
+ handler: this.navigateToPath.bind(this)
};
m.push(customServiceMenu);
return m;
diff --git a/common/platform/MiniProgramPlatform.js b/common/platform/MiniProgramPlatform.js
index 7f768fd..4b122ce 100644
--- a/common/platform/MiniProgramPlatform.js
+++ b/common/platform/MiniProgramPlatform.js
@@ -223,6 +223,17 @@ class MiniProgramPlatform extends BasePlatform {
// });
// }
}
+ async appData() {
+ const t= await uni.getAccountInfoSync();
+ console.log("getAccountInfoSync",t);
+ await this.loadCacheData();
+ uni.switchTab({
+ url: '/pages/shouye/index'
+ });
+ // this.getConfig().then(res => {
+ // console.log(res, 'res');
+ // })
+ }
async getOrderNo(event) {
return new Promise(async (resolve, reject) => {
console.log(event.$scope.$page.fullPath, 'this.$scope.$page.fullPath');
diff --git a/common/request.js b/common/request.js
index d21b136..e1db137 100644
--- a/common/request.js
+++ b/common/request.js
@@ -5,11 +5,69 @@
import EnvConfig from '@/common/env.js'
import md5 from 'js-md5'
-import ConfigManager from '@/common/config.js'
+
import { apiWhiteList } from '@/common/config.js'
import RouterManager from '@/common/router.js'
import { platform } from '@/common/platform/PlatformFactory'
class RequestManager {
+ // 缓存对象
+ static cache = {
+ data: new Map(),
+ // 缓存过期时间(毫秒)
+ expireTime: 5 * 60 * 1000, // 5分钟
+ // 缓存时间戳
+ timestamps: new Map()
+ };
+
+ /**
+ * 检查缓存是否存在且未过期
+ * @param {string} cacheKey 缓存键
+ * @returns {boolean} 缓存是否有效
+ */
+ static isCacheValid(cacheKey) {
+ const now = Date.now();
+ if (this.cache.data.has(cacheKey)) {
+ const timestamp = this.cache.timestamps.get(cacheKey);
+ return now - timestamp < this.cache.expireTime;
+ }
+ return false;
+ }
+
+ /**
+ * 更新缓存
+ * @param {string} cacheKey 缓存键
+ * @param {any} data 缓存数据
+ */
+ static updateCache(cacheKey, data) {
+ this.cache.data.set(cacheKey, data);
+ this.cache.timestamps.set(cacheKey, Date.now());
+ }
+
+ /**
+ * 发送带缓存的GET请求
+ * @param {String} url 请求地址
+ * @param {Object} data 请求参数
+ * @param {Boolean} showLoading 是否显示加载提示
+ * @returns {Promise} 返回请求Promise
+ */
+ static getCache(url, data = {}, showLoading = true) {
+ // 生成缓存键
+ const cacheKey = url + JSON.stringify(data);
+
+ // 检查缓存是否有效
+ if (this.isCacheValid(cacheKey)) {
+ console.log(cacheKey + '缓存有效');
+ return Promise.resolve(this.cache.data.get(cacheKey));
+ }
+
+ // 如果缓存无效,发起新请求
+ return this.get(url, data, showLoading).then(result => {
+ // 更新缓存
+ this.updateCache(cacheKey, result);
+ return result;
+ });
+ }
+
/**
* 判断URL是否在白名单中
* @param {String} url 请求地址
diff --git a/common/server/config.js b/common/server/config.js
index 24176eb..813479a 100644
--- a/common/server/config.js
+++ b/common/server/config.js
@@ -1,8 +1,8 @@
-
import RequestManager from '../request';
import common from '../common';
import { platform } from '@/common/platform/PlatformFactory'
+
/**
* 获取系统配置
* @returns
@@ -10,6 +10,7 @@ import { platform } from '@/common/platform/PlatformFactory'
export const getConfig = () => {
return RequestManager.get("config", {});
}
+
/**
* 获取平台配置
* @returns
@@ -17,4 +18,24 @@ export const getConfig = () => {
export const getPlatform = async () => {
const res = await RequestManager.get("getPlatformConfig", {});
return res.data;
-}
\ No newline at end of file
+}
+
+/**
+ * 获取轮播图
+ * @param {number} type_id 类型
+ * @returns
+ */
+export const getAdvert = async (type_id) => {
+ const res = await RequestManager.getCache("getAdvert", { type_id });
+ return res.data;
+}
+
+/**
+ * 获取单页规则
+ * @param {number} type 类型
+ * @returns
+ */
+export const getDanYe = async (type) => {
+ const res = await RequestManager.getCache("getDanye", { type });
+ return res.data;
+}
diff --git a/components/detail-preview-popup/detail-preview-popup.vue b/components/detail-preview-popup/detail-preview-popup.vue
index 76109cf..6132cff 100644
--- a/components/detail-preview-popup/detail-preview-popup.vue
+++ b/components/detail-preview-popup/detail-preview-popup.vue
@@ -11,14 +11,14 @@
{{ innerTipTitle }}
-
+
-
+
@@ -32,11 +32,18 @@
暂无商品
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
@@ -301,6 +308,14 @@ export default {
this.loading = false;
}
},
+
+ getRows(list, perRow) {
+ const rows = [];
+ for (let i = 0; i < list.length; i += perRow) {
+ rows.push(list.slice(i, i + perRow));
+ }
+ return rows;
+ },
}
}
@@ -361,18 +376,38 @@ export default {
}
.list {
- width: 100%;
+ width: 98%;
height: 610rpx;
background-color: #ffffff;
border-radius: 16rpx;
- margin: 0rpx auto;
+ // margin: 0rpx auto;
.res-list {
- padding: 5rpx 15rpx;
- display: grid;
- grid-template-columns: repeat(3, 33%);
- gap: 20rpx 8rpx;
- justify-content: center;
+ height: 610rpx;
+ padding-top: 5rpx;
+ padding-left: 8rpx;
+
+
+ .row {
+ display: flex;
+ flex-direction: row;
+ justify-content: flex-start;
+ gap: 8rpx;
+ margin-bottom: 10rpx;
+ height: 275rpx;
+ }
+
+ .item {
+ flex: 1 1 0;
+ max-width: calc(33.33% - 6rpx);
+ box-sizing: border-box;
+ }
+
+ .item.empty {
+ background: transparent;
+ pointer-events: none;
+ // 保证空白格不显示内容
+ }
}
}
@@ -406,6 +441,7 @@ export default {
box-sizing: border-box;
border-radius: 25rpx;
}
+
.baoxiang-tag {
height: 64rpx;
width: 136rpx;
diff --git a/main.js b/main.js
index 6737a0e..b586873 100644
--- a/main.js
+++ b/main.js
@@ -66,11 +66,11 @@ app.globalData = {
siteBaseUrl: EnvConfig.apiBaseUrl
}
-// 应用启动时加载全局配置
-ConfigManager.init().then(config => {
- console.log('全局配置加载完成')
-}).catch(err => {
- console.error('全局配置加载失败', err)
-})
+// // 应用启动时加载全局配置
+// ConfigManager.init().then(config => {
+// console.log('全局配置加载完成')
+// }).catch(err => {
+// console.error('全局配置加载失败', err)
+// })
app.$mount()
\ No newline at end of file
diff --git a/pages.json b/pages.json
index 473f382..ae8bd1a 100644
--- a/pages.json
+++ b/pages.json
@@ -454,7 +454,8 @@
"backgroundColor": "#FFFFFF",
"iconWidth": "24px",
"iconHeight": "24px",
- "list": [{
+ "list": [
+ {
"pagePath": "pages/shouye/index",
"iconPath": "static/tabbar/m1.png",
"selectedIconPath": "static/tabbar/s1.png",
diff --git a/pages/index/index.vue b/pages/index/index.vue
index 9ee8dd9..602bbdc 100644
--- a/pages/index/index.vue
+++ b/pages/index/index.vue
@@ -76,7 +76,9 @@ export default {
} else {
// 有网络权限
console.log('网络权限已授予');
- that.toHome();
+ that.$platform.appData();
+ // that.toHome();
+ // AppData()
}
},
fail() {
diff --git a/pages/shouye/detail_wuxian.vue b/pages/shouye/detail_wuxian.vue
index 9532108..f131862 100644
--- a/pages/shouye/detail_wuxian.vue
+++ b/pages/shouye/detail_wuxian.vue
@@ -195,7 +195,7 @@
-
+
@@ -213,7 +213,7 @@ import DetailWuxianRage from '@/components/detail-wuxian-rage/detail-wuxian-rage
// 导入抽取的抽奖组件
import DetailLucky from "@/components/detail-lucky/detail-lucky.vue";
//超神特效
-
+
import PayDialog from '@/components/pay-dialog/pay-dialog.vue'
import {
sleep
diff --git a/pages/shouye/index.vue b/pages/shouye/index.vue
index 4baf1e6..f72c032 100644
--- a/pages/shouye/index.vue
+++ b/pages/shouye/index.vue
@@ -5,22 +5,18 @@
-->
-
+
-
-
+
+
-
+
-
-
@@ -52,7 +48,7 @@
-
+
@@ -87,9 +83,6 @@
-
@@ -97,11 +90,7 @@
-
-
@@ -115,7 +104,6 @@
立即收下
-
@@ -135,18 +123,19 @@