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

# Conflicts:
#	pages/shouye/detail_wuxian.vue
This commit is contained in:
18631081161 2025-05-03 13:15:14 +08:00
commit c98e012fd5
11 changed files with 254 additions and 42 deletions

View File

@ -32,6 +32,8 @@ const testing = {
wxAppId: 'wx0e33d80d35e4a3b1'
};
// 根据环境变量选择对应配置
let currentEnv = testing;

View File

@ -0,0 +1,29 @@
import BasePlatform from './BasePlatform';
class AppPlatform extends BasePlatform {
constructor() {
super();
this.code = 'APP_ANDROID';
this.env = 'app';
}
getPayData(url,data) {
return data;
}
pay({ data }) {
return new Promise((resolve) => {
console.log(`App支付${data.amount}分,订单号:${data.orderId}`);
// 模拟调用H5支付SDK
// window.H5PaySDK?.pay(data.amount, data.orderId, resolve);
});
}
share({ title, desc, image, url }) {
console.log(`H5分享${title} - ${desc}`);
// 调用浏览器原生分享(如果可用)
if (navigator.share) {
return navigator.share({ title, text: desc, url });
}
// 降级方案
alert(`请手动分享:${url}`);
}
}
export default AppPlatform;

View File

@ -0,0 +1,46 @@
/**
* 多端平台抽象基类父类
* 定义所有端必须实现的方法
*/
class BasePlatform {
constructor() {
if (new.target === BasePlatform) {
throw new Error('BasePlatform 是抽象类,不能直接实例化');
}
this.code = ''; // 平台代码WEB/MP/APP
this.env = ''; // 运行环境标识
}
getPayData(url,data) {
throw new Error('子类必须实现 getPayData 方法');
}
/**
* 支付方法子类必须实现
* @param {number} amount - 支付金额
* @param {string} orderId - 订单号
*/
pay({ data }) {
throw new Error('子类必须实现 pay 方法');
}
/**
* 分享方法子类必须实现
* @param {object} params - 分享参数 { title, desc, image, url }
*/
share({ title, desc, link, image }) {
throw new Error('子类必须实现 share 方法');
}
/**
* 通用方法所有端共用
*/
getPlatformInfo() {
return {
code: this.code,
env: this.env,
ua: navigator?.userAgent || ''
};
}
}
export default BasePlatform;

View File

@ -0,0 +1,48 @@
import BasePlatform from './BasePlatform';
class H5Platform extends BasePlatform {
constructor() {
super();
this.code = 'WEB_H5';
this.env = 'h5';
}
getPayData(url, data) {
data['quitUrl']=escape(window.location.href);
data['returnUrl']=escape(window.location.href);
console.log('处理数据',data);
return data;
}
pay({ data }) {
console.log('支付1111');
return new Promise((resolve) => {
console.log(data);
// 创建一个临时div元素
const tempDiv = document.createElement('div');
// 将data作为HTML插入到div中假设data是表单的HTML字符串
tempDiv.innerHTML = data;
// 将表单添加到body中
document.body.appendChild(tempDiv.firstChild);
// 获取表单并提交
const form = document.getElementById('alipaysubmit');
if (form) {
form.submit();
resolve({ success: true });
} else {
resolve({ success: false, message: '表单创建失败' });
}
});
}
share({ title, desc, image, url }) {
console.log(`H5分享${title} - ${desc}`);
// 调用浏览器原生分享(如果可用)
if (navigator.share) {
return navigator.share({ title, text: desc, url });
}
// 降级方案
alert(`请手动分享:${url}`);
}
}
export default H5Platform;

View File

@ -0,0 +1,64 @@
import BasePlatform from './BasePlatform';
/**
* 小程序平台
*/
class MiniProgramPlatform extends BasePlatform {
constructor() {
super();
this.code = 'MP-WEIXIN';
this.env = 'miniProgram';
}
getPayData(url, data) {
return data;
}
pay({ data }) {
return new Promise((resolve, reject) => {
let provider = "weixin";
uni.requestPayment({
provider,
...data,
success: res => {
// console.log(res)
},
fail: err => {
// console.log('common.wxMpPay-error', err)
},
complete: res => {
console.log('complete (res)', res)
if (res.errMsg == 'requestPayment:fail cancel') {
this.toast({
title: '取消支付',
icon: 'none',
duration: 500,
success: () => {
/* 取消订单 */
}
})
resolve('cancel')
}
if (res.errMsg == 'requestPayment:ok') {
this.toast({
title: '支付成功',
icon: 'success',
duration: 500,
success: () => {
resolve('success')
}
})
}
}
})
})
}
share({ title, desc, image, url }) {
wx.showShareMenu({
withShareTicket: true,
menus: ['shareAppMessage', 'shareTimeline']
});
// 监听用户点击分享按钮
wx.onShareAppMessage(() => ({ title, imageUrl: image }));
}
}
export default MiniProgramPlatform;

View File

@ -0,0 +1,29 @@
import MiniProgramPlatform from './MiniProgramPlatform';
import AppPlatform from './AppPlatform';
import H5Platform from './H5Platform';
class PlatformFactory {
static create() {
// 判断小程序环境
//#ifdef MP-WEIXIN
return new MiniProgramPlatform();
//#endif
// 判断 App 环境
//#ifdef APP-ANDROID
return new AppPlatform();
//#endif
// 判断 H5 环境
//#ifdef WEB
return new H5Platform();
//#endif
// 默认返回 小程序
return new MiniProgramPlatform();
}
}
// 使用示例
const platform = PlatformFactory.create();
console.log(platform.env);
export { platform };

View File

@ -8,6 +8,7 @@ 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 {
/**
* 判断URL是否在白名单中
@ -69,18 +70,14 @@ class RequestManager {
}
}
})
const url = param.url || ''
const method = param.method || 'POST'
const data = param.data || {}
const Loading = param.Loading || false
const token = uni.getStorageSync('token')
let client = ""
// #ifdef H5
client = "h5"
// #endif
let client = platform.code
// 获取API基础URL
const apiBaseUrl = EnvConfig.apiBaseUrl

View File

@ -24,6 +24,13 @@
<text style="font-size: 20rpx; color: #999999;">查看更多 ></text>
</view>
</view>
<view>
<view v-if="localBossCardData && localBossCardData.king_user" class="lingzhu-img relative"
style="position: absolute;right: 12px;top: 180rpx;height: 120rpx;height: 120rpx;">
<image :src="localBossCardData.king_user.headimg" mode="aspectFill"></image>
<image :src="$img1('index/king.png')"></image>
</view>
</view>
<!-- 领主弹窗 - 显示领主详细信息和挑战人数/领主记录 -->
<uni-popup ref="bossPop" type="bottom" mask-background-color="rgba(0,0,0,0.8)">
@ -324,7 +331,7 @@ export default {
width: 75rpx;
height: 76rpx;
position: absolute;
bottom: 4rpx;
bottom: 8rpx;
left: 50%;
transform: translateX(-50%);
z-index: 1;

15
main.js
View File

@ -7,6 +7,7 @@ import router from '@/common/router.js'
import ConfigManager from '@/common/config.js'
import RequestManager from '@/common/request.js'
import EnvConfig from '@/common/env.js'
import { platform } from '@/common/platform/PlatformFactory'
// 全局注册uni-popup组件
import uniPopup from '@/uni_modules/uni-popup/components/uni-popup/uni-popup.vue'
@ -22,7 +23,7 @@ Vue.prototype.$img1 = url => EnvConfig.iconBaseUrl + url
Vue.prototype.$sys = () => uni.getSystemInfoSync()
Vue.prototype.$loginPage = EnvConfig.loginPage
Vue.prototype.$wxloginPage = EnvConfig.wxLoginUrl
Vue.prototype.$platform = platform;
// 公共方法
Vue.prototype.gotoPage = gotopage
// 注册路由方法到Vue实例改用自定义属性名
@ -49,11 +50,11 @@ loadScript('https://res.wx.qq.com/open/js/jweixin-1.6.0.js')
// #ifdef MP-WEIXIN
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function(res) {
updateManager.onCheckForUpdate(function (res) {
console.log(res.hasUpdate)
})
updateManager.onUpdateReady(function() {
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
@ -65,7 +66,7 @@ updateManager.onUpdateReady(function() {
})
})
updateManager.onUpdateFailed(function() {
updateManager.onUpdateFailed(function () {
// 新版本下载失败
})
// #endif
@ -80,14 +81,14 @@ const app = new Vue({
// 创建全局数据对象
app.globalData = {
siteBaseUrl: EnvConfig.apiBaseUrl
siteBaseUrl: EnvConfig.apiBaseUrl
}
// 应用启动时加载全局配置
ConfigManager.init().then(config => {
console.log('全局配置加载完成')
console.log('全局配置加载完成')
}).catch(err => {
console.error('全局配置加载失败', err)
console.error('全局配置加载失败', err)
})
app.$mount()

View File

@ -1,5 +1,5 @@
<template>
<page-container ref="pageContainer" :title="title" :showBack="true">
<page-container :title="title" :showBack="true">
<view class="content minHeight100">
<view class="header relative" v-if="pageData && pageData.goods"
:style="{ background: 'url(' + pageData.goods.imgurl_detail + ') no-repeat 0 0 / 100% 100%' }">
@ -46,7 +46,7 @@
</view>
</view>
<!--选项卡-->
<detail-toolbar v-if="goods != null" :goods-type="goods.type" :current-tab="tabCur"
<detail-toolbar v-if="goods!=null" :goods-type="goods.type" :current-tab="tabCur"
@rule-click="$refs.rulePop.getRule(pageData.danye_id, '购买说明')" @tab-change="tabChange"
@change-box="changeBox" :isWuxian="true"></detail-toolbar>
<detail-wuxian-lingzhu v-if="goods != null && goods.lingzhu_is == 1" :goods-num="0" :goods="goods">
@ -144,9 +144,6 @@
<detail-button v-if="pageData" :pageData="pageData" :isWuxian="true" @button-click="confirmSubmit"
@button-wx-click="wuxianchou"></detail-button>
<!-- 抽奖结果 -->
<uni-popup ref="resPop" type="center" mask-background-color="rgba(0,0,0,0.8)">
<view class="res-pop common_bg column center" @click="close('resPop')">
@ -243,6 +240,7 @@
<!-- 添加直接引用的预览组件 -->
<detail-preview-popup ref="localPreviewPopup"></detail-preview-popup>
</view>
<!-- 老虎机 -->
<uni-popup ref="slotPop" type="center">
@ -250,17 +248,16 @@
<view class="slot-view">
<view class=""
style="width: 100%; height: 152.78rpx; background-color: aquamarine; margin-top: 195rpx;">
<tiner-swiper-loop ref="lottryRef"
:items="productList" :aTime="5" :isLottry="true" :excessCount="0" :disableTouch="true"
style="height: 152.78rpx; width: 100%;">
<template v-slot="{item,index}">
<view class="item-lottry">{{item.title}}</view>
</template>
</tiner-swiper-loop>
</view>
style="width: 100%; height: 152.78rpx; background-color: aquamarine; margin-top: 195rpx;">
<tiner-swiper-loop ref="lottryRef" :items="productList" :aTime="5" :isLottry="true"
:excessCount="0" :disableTouch="true" style="height: 152.78rpx; width: 100%;">
<template v-slot="{item,index}">
<view class="item-lottry">{{item.title}}</view>
</template>
</tiner-swiper-loop>
</view>
</view>
<text style="color: #484848; font-size: 19rpx;">动画结果因设备差异可能会显示异常获得赏品以恭喜获得结果为准</text>
@ -432,11 +429,10 @@
num: 0,
};
// console.log(a);
//console.log( this.optData.type_text);
// 使
preview({
productType: this.title,
productType: this.optData.type_text,
dataItem: obj,
goods: goods
}).then(() => {
@ -570,6 +566,8 @@
confirmSubmit([type, num, flag]) {
this.$refs.slotPop.open();
this.bgmCtx.slotBgm.play()
this.$refs.lottryRef.startDraw();
return;
this.choujiangloading = true;
@ -751,8 +749,6 @@
})
if (res.data.goods.type_text) {
this.title = res.data.goods.type_text
// 使$refs访page-container
// this.$refs.pageContainer.setNavTitle(res.data.goods.type_text);
}
this.pageData = res.data
let goodType = this.$config.getGoodTypeFind(this.pageData.goods.type);
@ -896,13 +892,6 @@
})
}
}
},
lotteryItemSize() {
console.log("8888888888");
let height = uni.upx2px(220);
let width = uni.upx2px(170);
return [width, height];
}
}
}

Binary file not shown.