diff --git a/App.vue b/App.vue
index b285b21..27ba6ed 100644
--- a/App.vue
+++ b/App.vue
@@ -10,7 +10,7 @@ export default {
},
onLaunch: function (options) {
// console.log("App Launch", options, window.location.href);
-
+
// #ifdef MP-WEIXIN
const updateManager = uni.getUpdateManager();
diff --git a/common/platform/PlatformFactory.js b/common/platform/PlatformFactory.js
index b64643b..5edd5df 100644
--- a/common/platform/PlatformFactory.js
+++ b/common/platform/PlatformFactory.js
@@ -1,7 +1,7 @@
import MiniProgramPlatform from './MiniProgramPlatform';
import AppPlatform from './AppPlatform';
import H5Platform from './H5Platform';
-
+import WebAppPlatform from './WebAppPlatform';
class PlatformFactory {
static create() {
// 判断小程序环境
@@ -15,6 +15,28 @@ class PlatformFactory {
//#endif
// 判断 H5 环境
//#ifdef WEB
+ // if(window.location.href.includes('cb2039d0e35094521ae46a1d11b0ddd1')){
+ // return new WebAppPlatform();
+ // }
+ console.log(window.location.href);
+ //window.location.search
+ let is_web_app = uni.getStorageSync('is_web_app');
+ let search = window.location.search;
+
+ if (search != null && search != '') {
+ const searchParams = new URLSearchParams(window.location.search);
+ const code = searchParams.get('_p');
+ if (code && code == 'cb2039d0e35094521ae46a1d11b0ddd1') {
+ uni.setStorageSync('is_web_app', true);
+ is_web_app = true;
+ }
+ }
+ if (uni.getStorageSync('is_web_app') != null && uni.getStorageSync('is_web_app') != '') {
+ is_web_app = true;
+ }
+ if (is_web_app) {
+ return new WebAppPlatform();
+ }
return new H5Platform();
//#endif
diff --git a/common/platform/WebAppPlatform.js b/common/platform/WebAppPlatform.js
new file mode 100644
index 0000000..dc50442
--- /dev/null
+++ b/common/platform/WebAppPlatform.js
@@ -0,0 +1,82 @@
+import BasePlatform from './BasePlatform';
+import H5Platform from './H5Platform';
+
+
+function parseQueryString(queryString) {
+ // 如果以 ? 开头,先去掉 ?
+ if (queryString.startsWith('?')) {
+ queryString = queryString.substring(1);
+ }
+
+ const params = {};
+ const pairs = queryString.split('&');
+
+ for (const pair of pairs) {
+ const [key, value] = pair.split('=');
+ // 解码 URI 组件
+ params[key] = decodeURIComponent(value);
+ }
+
+ return params;
+}
+
+class WebAppPlatform extends H5Platform {
+ constructor() {
+ super();
+ this.code = 'WEB_APP';
+ this.env = 'WEB_APP';
+ }
+ share({ title, desc, image, url }) {
+ console.log(`H5分享:${title} - ${desc}`);
+ // 调用浏览器原生分享(如果可用)
+ if (navigator.share) {
+ return navigator.share({ title, text: desc, url });
+ }
+ // 降级方案
+ alert(`请手动分享:${url}`);
+ }
+
+
+ downloadFile(url) {
+ return new Promise((resolve, reject) => {
+ try {
+ // 创建一个隐藏的a标签
+ const a = document.createElement('a');
+ a.href = url;
+ a.download = url.split('/').pop() || 'download'; // 使用URL中的文件名或默认名称
+ a.style.display = 'none';
+ document.body.appendChild(a);
+ a.click(); // 触发下载
+ document.body.removeChild(a); // 清理DOM
+ resolve({ success: true });
+ } catch (error) {
+ console.error('下载失败:', error);
+ // 降级方案,直接打开
+ window.location.href = url;
+ resolve({ success: false, error: error.message });
+ }
+ });
+ }
+ /**
+ * 重写获取用户中心菜单列表,添加微信小程序特有菜单
+ * @returns {Array} 菜单项数组
+ */
+ getUserMenuList() {
+ // 获取基础菜单列表
+ const baseMenuList = super.getUserMenuList();
+
+ // 添加客服菜单项(仅微信小程序)
+ const customServiceMenu = {
+ id: 10,
+ show: true,
+ title: '关于',
+ icon: 'my/about.png',
+ path: '/pages/other/about',
+ handler: this.navigateToPath.bind(this)
+ };
+
+ // 将客服菜单插入到第二个位置
+ return [...baseMenuList.slice(0, baseMenuList.length-1), customServiceMenu, ...baseMenuList.slice(baseMenuList.length-1)];
+ }
+}
+export default WebAppPlatform;
\ No newline at end of file
diff --git a/pages.json b/pages.json
index f01c650..675efc3 100644
--- a/pages.json
+++ b/pages.json
@@ -383,6 +383,12 @@
"style": {
"navigationStyle": "custom"
}
+ },
+ {
+ "path" : "pages/other/about",
+ "style": {
+ "navigationStyle": "custom"
+ }
}
],
"subPackages": [{
diff --git a/pages/other/about.vue b/pages/other/about.vue
new file mode 100644
index 0000000..67ba042
--- /dev/null
+++ b/pages/other/about.vue
@@ -0,0 +1,31 @@
+
+
+
+
+
+
+
+
+
diff --git a/pages/user/recharge-page.vue b/pages/user/recharge-page.vue
index 154abcc..25cba09 100644
--- a/pages/user/recharge-page.vue
+++ b/pages/user/recharge-page.vue
@@ -34,8 +34,9 @@
-
- 确认支付
+
+ {{isPaying ? '支付中...' : '确认支付'}}
@@ -54,6 +55,7 @@ import {getDiamondList,createOrderProducts,getDiamondOrderLog} from '@/common/se
money:0
},
order_num:"",
+ isPaying: false,
}
},
onLoad(options){
@@ -91,14 +93,24 @@ import {getDiamondList,createOrderProducts,getDiamondOrderLog} from '@/common/se
* 支付
*/
async pay(){
- let pro= this.dataList[this.currentIndex];
- console.log(pro);
- const res= await createOrderProducts(pro.products_id);
- console.log(res);
- this.order_num= res.order_num;
- const status = await this.$platform.pay({ data: res.res });
- if (status == 'success') {
- this.getPrizeLog(res.order_num);
+ if(this.isPaying) {
+ return;
+ }
+ try {
+ this.isPaying = true;
+ let pro= this.dataList[this.currentIndex];
+ console.log(pro);
+ const res= await createOrderProducts(pro.products_id);
+ console.log(res);
+ this.order_num= res.order_num;
+ const status = await this.$platform.pay({ data: res.res });
+ if (status == 'success') {
+ this.getPrizeLog(res.order_num);
+ }
+ } catch(e) {
+ console.error(e);
+ } finally {
+ this.isPaying = false;
}
},
/**
@@ -165,4 +177,9 @@ import {getDiamondList,createOrderProducts,getDiamondOrderLog} from '@/common/se
}
+
+ .btn-active {
+ opacity: 0.8;
+ transform: scale(0.98);
+ }
\ No newline at end of file
diff --git a/pages/user/tui-guang.vue b/pages/user/tui-guang.vue
index c6151ce..dd52071 100644
--- a/pages/user/tui-guang.vue
+++ b/pages/user/tui-guang.vue
@@ -36,7 +36,7 @@
奖励总额
{{ commission }}
- 元
+
@@ -47,11 +47,19 @@
+
+
+ 我的邀请码
+ {{ userInfo.uid }}
+
+
-
+
+
+
@@ -74,7 +82,6 @@
{{ item.addtime }}
-
消费¥{{ item.commission_money }}
@@ -93,11 +100,24 @@
:src="getXiaZai()">
+
+
+