This commit is contained in:
zpc 2025-06-13 16:09:24 +08:00
parent 293d9d3ba6
commit 948e6452bb
15 changed files with 282 additions and 188 deletions

View File

@ -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;
//

View File

@ -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 配置键

View File

@ -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,

View File

@ -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);
}
}

View File

@ -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;

View File

@ -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');

View File

@ -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 请求地址

View File

@ -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;
}
}
/**
* 获取轮播图
* @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;
}

View File

@ -11,14 +11,14 @@
<view class="type-tag justify-center"
:style="{ backgroundColor: dataItem.shang_info ? dataItem.shang_info.color : '#000000' }"
v-if="innerTipTitle">{{ innerTipTitle }}</view>
<view class="baoxiang-tag justify-center" v-if="isTips"></view>
<view class="baoxiang-tag justify-center" v-if="isTips"></view>
</view>
</view>
<!-- 背面赏品列表 -->
<view class="back">
<view class="listt">
<scroll-view class="list" :scroll-y="true">
<view class="list">
<!-- 加载中状态 -->
<view class="loading-container center" v-if="loading">
<view class="loading-icon">
@ -32,11 +32,18 @@
<view class="empty-text">暂无商品</view>
</view>
<!-- 赏品列表内容 -->
<view class="res-list" v-else>
<detail-list-item v-for="(item, i) in children" :key="i" :item="item" imageHeight="180rpx"
@click="handleItemClick" />
</view>
</scroll-view>
<scroll-view class="res-list" :scroll-y="true" v-else>
<view class="row" v-for="(row, rowIndex) in getRows(children, 3)" :key="'row-' + rowIndex">
<view class="item" v-for="(item, i) in row" :key="i">
<detail-list-item :item="item" imageHeight="180rpx" @click="handleItemClick" />
</view>
<!-- 补齐空白格保证每行3个 -->
<view v-for="n in 3 - row.length" :key="'empty-' + n" class="item empty"></view>
</view>
<view style="height:20rpx;width: 100%;"></view>
</scroll-view>
</view>
</view>
</view>
</view>
@ -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;
},
}
}
</script>
@ -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;

12
main.js
View File

@ -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()

View File

@ -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",

View File

@ -76,7 +76,9 @@ export default {
} else {
//
console.log('网络权限已授予');
that.toHome();
that.$platform.appData();
// that.toHome();
// AppData()
}
},
fail() {

View File

@ -195,7 +195,7 @@
<!-- 使用抽取的老虎机组件 -->
<DetailLucky ref="detailLucky" @end="onLuckyEnd" />
<PayDialog ref="payDialog" />
</page-container>
</template>
@ -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

View File

@ -5,22 +5,18 @@
-->
<template>
<view class="content">
<view class="navLeft align-center" :style="{ top: $sys().statusBarHeight + 'px' }" @tap="jumapSlots()">
<view class="navLeft align-center" :style="{ top: statusBarHeight + 'px' }" @tap="jumapSlots()">
<view class="flex" style="width: 100%">
<view class="title1" style="width: 166rpx; height: 64rpx; margin-top: 5rpx;" >
<image :src="$img1('common/home_logo.png')" style="width: 166rpx; height: 64rpx;" mode="" ></image>
<view class="title1" style="width: 166rpx; height: 64rpx; margin-top: 5rpx;">
<image :src="$img1('common/home_logo.png')" style="width: 166rpx; height: 64rpx;" mode=""></image>
</view>
</view>
</view>
<mescroll-body ref="mescrollRef" class="valbox" @init="mescrollInit" :down="downOption" @down="downCallback"
@up="loadData">
<view style="width: 100%;" :style="{ height: $sys().statusBarHeight + 'px' }"></view>
<view style="width: 100%;" :style="{ height: statusBarHeight + 'px' }"></view>
<view style="width: 100%;height: 70rpx;"></view>
<banner :type-id="9" :height="300" :img-width="94"></banner>
<!-- 指示器 -->
<!-- <view class="sw-dot relative">
<view class="sw-dot-item" v-for="(item, i) in advert" :key="i" :class="{act: swCur == i}"></view>
</view> -->
<!-- 公告 -->
<view class="news-box flex row" @click="$refs.rulePop.getRule(3, '提示')">
@ -52,7 +48,7 @@
</view>
</scroll-view>
<view class="qbt_con">
<view class="qbt_con" v-if="tabCur > -1">
<view v-for="(item, index) in listdata" :key="index" class="qbt_con_item" @click="todetails(item)">
<view class="list_1 center" style="background-color: #d8d8d8;border-radius: 16rpx 16rpx 0rpx 0rpx;">
<image :src="item.imgurl" mode="aspectFill"></image>
@ -87,9 +83,6 @@
<view v-if="item.is_shou_zhe == 1" class="half-tag">
<image class="img100" :src="$img1('common/chouBanjia.png')" mode="aspectFit"></image>
</view>
<!-- <view v-if="item.type == 1 || item.type == 6" class="lock-tag" :class="{dis: item.lock_is != 1}">
{{ item.lock_is == 1 ? '锁箱' : '竞技' }}
</view> -->
</view>
</view>
</mescroll-body>
@ -97,11 +90,7 @@
<!-- 优惠券弹窗 -->
<uni-popup ref="couponPop" type="center" maskBackgroundColor="rgba(0,0,0,0.8)">
<view v-if="couponData" class="coupon-pop common_bg relative">
<!-- <view class="coupon-pop-title">
<text>新人大礼包</text>
</view> -->
<scroll-view class="coupon-list" scroll-y>
<view v-for="(item, i) in couponData.goods.list" :key="i" class="coupon-item">
<view class="center">
@ -115,7 +104,6 @@
</view>
</scroll-view>
<view @click="receiveCoupon" class="get-btn center">立即收下</view>
<!-- <view class="bt-tip">优惠券在我的-优惠券中查看</view> -->
<view class="bt-close flex" @tap="$refs.couponPop.close()">
<image class="img100" :src="$img1('common/close.png')"></image>
</view>
@ -135,18 +123,19 @@
<script>
import lffBarrage from "@/components/lff-barrage/lff-barrage.vue";
import FloatBall from "@/components/float-ball/FloatBall.vue";
import { getAdvert, getDanYe } from "../../common/server/config";
export default {
components: {
lffBarrage,
FloatBall
},
data() {
let tabList = this.$config.getGoodType();
let tabList = [];// this.$config.getGoodType();
let statusBarHeight = this.$sys().statusBarHeight;
return {
z_imgPath: this.$z_img2 + "shouye/",
tabList: tabList,
tabCur: 0,
tabCur: -1,
keyword: "",
listdata: [],
// (, )
@ -162,15 +151,12 @@ export default {
},
advert: [], //
tuijian: [], //
notice_list: [], //
erweima: "", //
yushou_rili: "", //
jump_appid: "", // id
aa: false,
gonggao: "",
couponData: "",
canGetCoupon: false,
swCur: 0
swCur: 0,
statusBarHeight
};
},
@ -193,33 +179,22 @@ export default {
if (v.scene) {
uni.setStorageSync("pid", v.scene);
}
if (v.token) {
uni.setStorageSync("token", v.token);
}
/* 获取广告id */
if (v.ad_id) {
uni.setStorageSync("_ad_id", v.ad_id);
}
/* 获取click_id */
if (v.gdt_vid) {
uni.setStorageSync("_click_id", v.gdt_vid);
}
this.tabList = this.$config.getGoodType();
this.tabCur = 0;
},
onShow() {
let that = this;
this.aa = true;
// setTimeout(() => {
// that.colrdo()
// }, 500
this.canGetCoupon && this.getCoupon();
this.canGetCoupon && this.getnews();
this.canGetCoupon = true;
const curPages = getCurrentPages()[0]; //
if (typeof curPages.getTabBar === "function" && curPages.getTabBar()) {
this.$mp.page.getTabBar().setData({
selected: 0,
});
if (this.canGetCoupon) {
this.getCoupon();
this.getnews();
}
if (this.tabList.length == 0) {
this.tabList = this.$config.getGoodType();
this.tabCur = 0;
}
this.canGetCoupon = true;
},
onReady() {
@ -314,34 +289,17 @@ export default {
});
},
torili() {
uni.setStorageSync("rili", this.yushou_rili);
this.gotoPage("/pages/shouye/rili");
},
getnews() {
let that = this;
that.req({
url: "index",
success(res) {
if (res.status == 1) {
that.advert = res.data.advert;
that.tuijian = res.data.tuijian;
that.notice_list = res.data.new_bulletcha;
that.erweima = res.data.other.erweima;
that.gonggao = res.data.notice.content;
that.yushou_rili = res.data.other.yushou_rili;
that.jump_appid = res.data.other.jump_appid;
uni.setStorageSync("jump_appid", res.data.other.jump_appid);
uni.setStorageSync("wx_link", res.data.other.wx_link);
uni.setStorageSync("corpid", res.data.other.corpid);
if (res.data.other.is_shou_tan == 1) {
that.checkNotice();
}
}
},
});
async getnews() {
const advert = await getAdvert(1);
this.advert = advert;
const tuijian = await getAdvert(5);
this.tuijian = tuijian;
const gonggao = await getDanYe(3);
this.gonggao = gonggao.content;
let is_shou_tan = this.$config.getBaseConfigKey("is_shou_tan");
if (is_shou_tan == 1) {
this.checkNotice();
}
},
loadData({
@ -416,8 +374,8 @@ export default {
toyaqingRanking() {
this.$customRouter.navigateTo("/pages/shouye/yaoqing_ranking");
},
jumapSlots(){
jumapSlots() {
// this.$customRouter.navigateTo("/pages/other/web-detail-lucky");
}
},

View File

@ -294,24 +294,7 @@ export default {
fail: error => { }
})
},
tokefu() {
// #ifdef MP
wx.openCustomerServiceChat({
extInfo: {
url: uni.getStorageSync('wx_link') //
},
corpId: uni.getStorageSync('corpid'), //
success(res) {
console.log(res, 1)
},
fail(res) {
console.log(res, 2)
}
})
// #endif
},
getlist(index) {
this.show = index
},
@ -341,8 +324,6 @@ export default {
this.userinfo = res.data.userinfo
this.taskList = res.data.task_list
uni.setStorageSync('userinfo', this.userinfo)
uni.setStorageSync('jump_appid', res.data.other.jump_appid)
uni.setStorageSync('wx_link', res.data.other.wx_link)
uni.setStorageSync('corpid', res.data.other.corpid)
}