diff --git a/App.vue b/App.vue index cb0a25b..2fccc1b 100644 --- a/App.vue +++ b/App.vue @@ -11,31 +11,7 @@ export default { onLaunch: function (options) { // console.log("App Launch", options, window.location.href); - // #ifdef MP-WEIXIN - const updateManager = uni.getUpdateManager(); - - updateManager.onCheckForUpdate(function (res) { - // 请求完新版本信息的回调 - console.log(res.hasUpdate); - }); - - updateManager.onUpdateReady(function (res) { - uni.showModal({ - title: "更新提示", - content: "新版本已经准备好,是否重启应用?", - success(res) { - if (res.confirm) { - // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 - updateManager.applyUpdate(); - } - }, - }); - }); - - updateManager.onUpdateFailed(function (res) { - // 新的版本下载失败 - }); - //#endif + var that = this; this.$config.init().then(async (data) => { diff --git a/common/env.js b/common/env.js index 54e6e69..d604d9e 100644 --- a/common/env.js +++ b/common/env.js @@ -41,7 +41,7 @@ const testing = { // 根据环境变量选择对应配置 -let currentEnv = production_wz;//production;//testing;//production_wz; +let currentEnv = testing;//production;//testing;//production_wz; // 判断当前环境 // #ifdef H5 diff --git a/common/platform/H5Platform.js b/common/platform/H5Platform.js index 078e928..27e647c 100644 --- a/common/platform/H5Platform.js +++ b/common/platform/H5Platform.js @@ -14,7 +14,6 @@ class H5Platform extends BasePlatform { if (erudaInstance != null && erudaInstance != "") { this.startDeb(); } - this.startDeb(); // eruda.init(); } getPayData(url, data) { diff --git a/common/platform/IOSPlatform.js b/common/platform/IOSPlatform.js new file mode 100644 index 0000000..d0957d4 --- /dev/null +++ b/common/platform/IOSPlatform.js @@ -0,0 +1,170 @@ +import BasePlatform from './BasePlatform'; + +import { + parseQueryString +} from '@/common/util'; + + + +class IOSPlatform extends BasePlatform { + constructor() { + super(); + this.code = 'IOS'; + this.env = 'ios'; + + } + getPayData(url, data) { + data['quitUrl'] = escape(window.location.href); + data['returnUrl'] = escape(window.location.href); + console.log('处理数据', data); + return data; + } + pay({ + data + }, event) { + console.log('支付1111'); + + return new Promise((resolve) => { + console.log(data); + // 检查是否已存在同ID的表单,如果存在则先删除 + const existingForm = document.getElementById('alipaysubmit'); + if (existingForm) { + existingForm.parentNode.removeChild(existingForm); + } + + // 创建一个临时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}`); + } + + /** + * 选择地址 + * @returns + */ + chooseAddress() { + return new Promise((resolve, reject) => { + uni.navigateTo({ + url: '/pages/other/choose_address', + events: { + // 为指定事件添加一个监听器,获取被打开页面传送到当前页面的数据 + selectAddress: function(data) { + console.log(data, { + userName: data.address.receiver_name, + telNumber: data.address.receiver_phone, + detailed_address: data.address.detailed_address + }) + resolve({ + userName: data.address.receiver_name, + telNumber: data.address.receiver_phone, + detailed_address: data.address.detailed_address + }); + }, + someEvent: function(data) { + console.log(data) + } + + }, + success: function(res) { + // 通过eventChannel向被打开页面传送数据 + res.eventChannel.emit('acceptDataFromOpenerPage', { + data: 'data from starter page' + }) + } + }) + }); + } + downloadFile(url) { + return new Promise((resolve, reject) => { + resolve({ + success: true + }); + }); + } + AppLaunch(options) { + console.log("AppLaunch", options); + + } + getOrderNo(event) { + return new Promise((resolve, reject) => { + resolve(null); + }); + } + + /** + * 重写获取用户中心菜单列表,处理H5特有的菜单需求 + * @returns {Array} 菜单项数组 + */ + getUserMenuList() { + // 获取基础菜单列表 + const baseMenuList = super.getUserMenuList(); + + // H5环境下可能需要修改某些菜单项的行为 + return baseMenuList.map(item => { + // 示例:在H5环境下可能需要特殊处理某些菜单项 + if (item.id === 6) { // 加入福利群菜单 + return { + ...item, + // 重新绑定处理函数,可能需要增加H5特有的逻辑 + handler: (menuItem, context) => { + this.handleJoinGroup(menuItem, context); + // 在H5环境下可能需要额外的处理,比如尝试复制群号等 + } + }; + } + return item; + }); + } + + /** + * 开启调试 + */ + startDeb() { + + } + /** + * 关闭调试 + */ + closeDeb() { + + } + getVersion() { + return '1.0.0'; + } +} +export default H5Platform; \ No newline at end of file diff --git a/common/platform/MiniProgramPlatform.js b/common/platform/MiniProgramPlatform.js index 8043a03..0934616 100644 --- a/common/platform/MiniProgramPlatform.js +++ b/common/platform/MiniProgramPlatform.js @@ -1,7 +1,12 @@ import BasePlatform from './BasePlatform'; import RequestManager from '@/common/request.js' -import { sleep, parseQueryString } from '@/common/util.js' -import { getOrderStatus } from '@/common/server/order.js' +import { + sleep, + parseQueryString +} from '@/common/util.js' +import { + getOrderStatus +} from '@/common/server/order.js' /** * 小程序平台 */ @@ -17,7 +22,9 @@ class MiniProgramPlatform extends BasePlatform { if (this.config) { return this.config; } - this.config = { isWebPay: true }; + this.config = { + isWebPay: true + }; return this.config; } getPayData(url, data) { @@ -49,19 +56,21 @@ class MiniProgramPlatform extends BasePlatform { let respay = await RequestManager.post(url, payPostData, false); if (respay.status === 1) { - event.$refs.payDialog.showDialogHand("支付提示", "支付成功后,请点击「支付已完成」按钮查看所购商品。如支付完成1分钟后仍显示异常,请关闭当前窗口,前往「我的」-「消费记录」查看订单状态。", "支付已完成", "关闭", async () => { - let resPayStatus = await getOrderStatus(data.data['order_num']); - if (resPayStatus.data == 1) { - event.$refs.payDialog.closeHand(); - resolve('success'); - } else { - uni.showToast({ - title: resPayStatus.msg, - icon: 'none', - duration: 1000 - }); - } - }); + event.$refs.payDialog.showDialogHand("支付提示", + "支付成功后,请点击「支付已完成」按钮查看所购商品。如支付完成1分钟后仍显示异常,请关闭当前窗口,前往「我的」-「消费记录」查看订单状态。", + "支付已完成", "关闭", async () => { + let resPayStatus = await getOrderStatus(data.data['order_num']); + if (resPayStatus.data == 1) { + event.$refs.payDialog.closeHand(); + resolve('success'); + } else { + uni.showToast({ + title: resPayStatus.msg, + icon: 'none', + duration: 1000 + }); + } + }); } @@ -134,7 +143,8 @@ class MiniProgramPlatform extends BasePlatform { return new Promise((resolve, reject) => { uni.chooseAddress({ success: res => { - res.detailed_address = res.provinceName + res.cityName + res.countyName + res.detailInfo; + res.detailed_address = res.provinceName + res.cityName + res.countyName + + res.detailInfo; resolve(res) }, fail: err => { @@ -188,6 +198,26 @@ class MiniProgramPlatform extends BasePlatform { } AppLaunch(options) { console.log("AppLaunch", options); + const updateManager = uni.getUpdateManager(); + updateManager.onCheckForUpdate(function(res) { + // 请求完新版本信息的回调 + console.log(res.hasUpdate); + }); + updateManager.onUpdateReady(function(res) { + uni.showModal({ + title: "更新提示", + content: "新版本已经准备好,是否重启应用?", + success(res) { + if (res.confirm) { + // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启 + updateManager.applyUpdate(); + } + }, + }); + }); + updateManager.onUpdateFailed(function(res) { + // 新的版本下载失败 + }); } async getOrderNo(event) { return new Promise(async (resolve, reject) => { @@ -217,7 +247,7 @@ class MiniProgramPlatform extends BasePlatform { } }); } - delOrderNo() { } + delOrderNo() {} /** * 重写获取用户中心菜单列表,添加微信小程序特有菜单 @@ -236,7 +266,7 @@ class MiniProgramPlatform extends BasePlatform { path: '', isCustomService: true, // 客服按钮不需要处理函数,由微信小程序原生组件处理 - handler: () => { } + handler: () => {} }; // 将客服菜单插入到第二个位置 diff --git a/common/platform/PlatformFactory.js b/common/platform/PlatformFactory.js index 9dc6cdc..d8bec76 100644 --- a/common/platform/PlatformFactory.js +++ b/common/platform/PlatformFactory.js @@ -1,53 +1,65 @@ import MiniProgramPlatform from './MiniProgramPlatform'; +//#ifdef APP-PLUS import AppPlatform from './AppPlatform'; +//#endif //#ifdef WEB import H5Platform from './H5Platform'; import WebAppPlatform from './WebAppPlatform'; //#endif +//#ifdef APP-IOS +import IOSPlatform from './IOSPlatform' +//#endif class PlatformFactory { - static create() { - // 判断小程序环境 - //#ifdef MP-WEIXIN - return new MiniProgramPlatform(); - //#endif + static create() { - // 判断 App 环境 - //#ifdef APP-ANDROID - return new AppPlatform(); - //#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; + // 判断小程序环境 + //#ifdef MP-WEIXIN + return new MiniProgramPlatform(); + //#endif + // 判断 IOS环境 + //#ifdef APP-IOS + return new IOSPlatform(); + //#endif + // 判断 App 环境 + //#ifdef APP-PLUS + return new AppPlatform(); + //#endif - 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 + // 判断 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; - // 默认返回 小程序 - return new MiniProgramPlatform(); - } + 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 + + // 默认返回 小程序 + return new MiniProgramPlatform(); + } } // 使用示例 const platform = PlatformFactory.create(); console.log(platform.env); -export { platform }; \ No newline at end of file +export { + platform +}; \ No newline at end of file diff --git a/components/detail-lucky/detail-lucky-web.vue b/components/detail-lucky/detail-lucky-web.vue new file mode 100644 index 0000000..21092e7 --- /dev/null +++ b/components/detail-lucky/detail-lucky-web.vue @@ -0,0 +1,107 @@ + + + + + diff --git a/components/detail-lucky/detail-lucky.vue b/components/detail-lucky/detail-lucky.vue index 4114c07..e6e3083 100644 --- a/components/detail-lucky/detail-lucky.vue +++ b/components/detail-lucky/detail-lucky.vue @@ -16,6 +16,7 @@ 跳过动画 + diff --git a/main.js b/main.js index 0378f73..97ae920 100644 --- a/main.js +++ b/main.js @@ -48,28 +48,7 @@ function loadScript(url) { loadScript('https://res.wx.qq.com/open/js/jweixin-1.6.0.js') // #endif -// #ifdef MP-WEIXIN -const updateManager = wx.getUpdateManager() -updateManager.onCheckForUpdate(function (res) { - console.log(res.hasUpdate) -}) - -updateManager.onUpdateReady(function () { - wx.showModal({ - title: '更新提示', - content: '新版本已经准备好,是否重启应用?', - success(res) { - if (res.confirm) { - updateManager.applyUpdate() - } - } - }) -}) - -updateManager.onUpdateFailed(function () { - // 新版本下载失败 -}) -// #endif + Vue.config.productionTip = false Vue.mixin(Mixin) diff --git a/pages.json b/pages.json index 08391c5..b7f2fcd 100644 --- a/pages.json +++ b/pages.json @@ -413,6 +413,12 @@ "style": { "navigationStyle": "custom" } + }, + { + "path": "pages/other/web-detail-lucky", + "style": { + "navigationStyle": "custom" + } } ], "subPackages": [{ @@ -491,7 +497,9 @@ "navigationBarBackgroundColor": "#222222", "backgroundColor": "#000000" }, - "usingComponents": {}, + "usingComponents": { + "web-view": "pages/other/web-detail-lucky" + }, "tabBar": { "custom": true, "color": "#CCCCCC", diff --git a/pages/other/web-detail-lucky.vue b/pages/other/web-detail-lucky.vue new file mode 100644 index 0000000..9822af9 --- /dev/null +++ b/pages/other/web-detail-lucky.vue @@ -0,0 +1,41 @@ + + + + \ No newline at end of file diff --git a/pages/shouye/index.vue b/pages/shouye/index.vue index 114f556..daa7b06 100644 --- a/pages/shouye/index.vue +++ b/pages/shouye/index.vue @@ -5,7 +5,7 @@ -->