Merge branch 'youda' of http://192.168.195.14:3000/shang/yfs into youda

This commit is contained in:
18631081161 2025-06-16 12:18:24 +08:00
commit 3d50519473
18 changed files with 1173 additions and 1148 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ unpackage/dist/
unpackage/cache/
unpackage/resources/
/.vs
.DS_Store

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

@ -41,22 +41,7 @@ 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
let currentEnv = production;//production;//testing;//production_wz;
// 衍生配置
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

@ -170,11 +170,11 @@ class H5Platform extends BasePlatform {
}
}
if (window.location.pathname == "/" || window.location.pathname == "/pages/index/index") {
uni.switchTab({
url: '/pages/shouye/index'
});
}
// if (window.location.pathname == "/" || window.location.pathname == "/pages/index/index") {
// uni.switchTab({
// url: '/pages/shouye/index'
// });
// }
}
getOrderNo(event) {
return new Promise((resolve, reject) => {

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 = false) {
// 生成缓存键
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;
}

BIN
components/.DS_Store vendored

Binary file not shown.

View File

@ -1,44 +1,44 @@
<template>
<uni-popup ref="popup" type="center" maskBackgroundColor="rgba(0,0,0,0.9)">
<view v-if="visible"
style="width: 100vw;height: 100vh;background-color:rgba(0,0,0,0.9) ;position: fixed;top: 0px;left: 0px;z-index: 9999;display: flex;justify-content: center;align-items: center;"
@touchmove.stop.prevent="">
<view v-if="visible" class="preview-popup" @touchmove.stop.prevent="moveHandle">
<!-- 翻转卡片容器 -->
<view class="flip-container" :class="{ 'flipped': showList }">
<view class="flipper">
<!-- 正面商品图片 -->
<view class="front">
<view class="pic center relative" @click="toggleList">
<image :src="innerImgUrl" lazy-load mode="aspectFill"></image>
<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>
</view>
<!-- 商品图片 -->
<view v-if="!showList" class="pic center relative" @click="toggleList">
<image :src="innerImgUrl" lazy-load mode="aspectFill"></image>
<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>
<!-- 背面赏品列表 -->
<view class="back">
<view class="listt">
<scroll-view class="list" :scroll-y="true">
<!-- 加载中状态 -->
<view class="loading-container center" v-if="loading">
<view class="loading-icon">
<image :src="$img('/static/img/loading.gif')" mode="aspectFit" @error="handleLoadingError"></image>
<view class="loading-dot" v-if="loadingError"></view>
</view>
<view class="loading-text">加载中...</view>
</view>
<!-- 空列表状态 -->
<view class="empty-container center" v-else-if="children.length === 0 && !loading">
<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>
<!-- 赏品列表 -->
<view class="listt" v-if="showList">
<view class="list">
<!-- 加载中状态 -->
<view class="loading-container center" v-if="loading">
<view class="loading-icon">
<image :src="$img('/static/img/loading.gif')" mode="aspectFit" @error="handleLoadingError">
</image>
<view class="loading-dot" v-if="loadingError"></view>
</view>
<view class="loading-text">加载中...</view>
</view>
<!-- 空列表状态 -->
<view class="empty-container center" v-else-if="children.length === 0 && !loading">
<view class="empty-text">暂无商品</view>
</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>
@ -52,7 +52,6 @@
<view class="info-item" v-if="innerProbability">{{ innerProbability }}</view>
<view class="info-item highlight" v-if="isTips" @click="toggleList">
{{ showList ? '收起' : '查看奖品' }}
<!-- <text class="arrow-icon">{{ showList ? '↑' : '↓' }}</text> -->
</view>
<view class="info-item" v-if="innerProductType">产品类型: {{ innerProductType }}</view>
<view class="info-item" v-for="(item, index) in innerExtraInfo" :key="'info-' + index">{{ item }}</view>
@ -63,7 +62,8 @@
<image :src="$img('/static/img/close.png')" lazy-load></image>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
@ -241,30 +241,12 @@ export default {
open() {
this.visible = true;
this.$nextTick(() => {
if (this.$refs.popup) {
//
setTimeout(() => {
this.$refs.popup.open();
}, 50);
} else {
console.error('popup ref不存在请检查组件是否正确挂载');
//
setTimeout(() => {
if (this.$refs.popup) {
this.$refs.popup.open();
}
}, 300);
}
});
},
//
closePopup() {
this.visible = false;
if (this.$refs.popup) {
this.$refs.popup.close();
}
this.$emit('close');
},
@ -301,6 +283,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>
@ -312,45 +302,6 @@ export default {
box-sizing: border-box;
height: 850rpx;
//
.flip-container {
perspective: 1000px;
width: 100%;
height: 620rpx;
&.flipped .flipper {
transform: rotateY(180deg);
}
.flipper {
transition: 0.6s;
transform-style: preserve-3d;
position: relative;
width: 100%;
height: 100%;
}
.front,
.back {
backface-visibility: hidden;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 16rpx;
}
.front {
z-index: 2;
transform: rotateY(0deg);
}
.back {
transform: rotateY(180deg);
}
}
.listt {
width: 100%;
padding-top: 5rpx;
@ -358,21 +309,39 @@ export default {
background-color: #ffffff;
border-radius: 16rpx;
margin: 0rpx auto;
transition: all 0.3s ease;
}
.list {
width: 100%;
width: 98%;
height: 610rpx;
background-color: #ffffff;
border-radius: 16rpx;
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 +375,7 @@ export default {
box-sizing: border-box;
border-radius: 25rpx;
}
.baoxiang-tag {
height: 64rpx;
width: 136rpx;
@ -468,10 +438,6 @@ export default {
font-weight: 500;
display: flex;
align-items: center;
.arrow-icon {
margin-left: 4rpx;
}
}
}
}

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/tab/n1.png",
"selectedIconPath": "static/tab/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

File diff suppressed because it is too large Load Diff

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