新增部分优惠券页面

This commit is contained in:
gyq
2025-11-20 10:27:08 +08:00
parent 805236dc5d
commit f74364a253
13 changed files with 887 additions and 368 deletions

233
App.vue
View File

@@ -3,62 +3,57 @@
App.vue本身不是页面这里不能编写视图元素也就是没有<template>
-->
<script setup>
import { onLaunch } from '@dcloudio/uni-app';
import { getVersion } from '@/http/api/index.js'
import appConfig from '@/config/appConfig.js';
import { provide,onMounted } from 'vue';
import WebsocketUtil from '@/commons/utils/websocket.js'
const websocketUtil = new WebsocketUtil(appConfig.wss, 5000); // 创建 WebSocket 工具类实例
provide('websocketUtil', websocketUtil); // 提供给所有子组件
onMounted(() => {
});
onLaunch(() => {
// 非开发工具移除 console.log console.info
// if (uni.getSystemInfoSync().platform !== "devtools") {
// console.log = () => {};
// console.info = () => {};
// }
let that = this
uni.hideTabBar()
// #ifdef MP-WEIXIN
const updateManager = wx.getUpdateManager() // 小程序版本更新管理器
updateManager.onCheckForUpdate(function(res) {
// 请求完新版本信息的回调
})
updateManager.onUpdateReady(function() {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
import { onLaunch } from '@dcloudio/uni-app';
import { getVersion } from '@/http/api/index.js';
import appConfig from '@/config/appConfig.js';
import { provide, onMounted } from 'vue';
import WebsocketUtil from '@/commons/utils/websocket.js';
})
updateManager.onUpdateFailed(function() {
// 新版本下载失败
})
// #endif
// console.log("getSystemSetting==",uni.getSystemInfoSync())
// console.log("getSystemSetting==",uni.getSystemSetting())
//#ifdef APP-PLUS
//获取当前系统版本信息
plus.runtime.getProperty(plus.runtime.appid, widgetInfo => {
//请求后台接口 解析数据 对比版本
console.log("widgetInfo==",widgetInfo)
let type = uni.getSystemInfoSync().platform == 'ios' ? 2 : 1
getVersion({source:'manager_app',type: type}).then(res => {
console.log("selectNewApp==",res)
console.log("version===",res.url && widgetInfo.version < res.version)
const websocketUtil = new WebsocketUtil(appConfig.wss, 5000); // 创建 WebSocket 工具类实例
provide('websocketUtil', websocketUtil); // 提供给所有子组件
onMounted(() => {});
onLaunch(() => {
// 非开发工具移除 console.log console.info
// if (uni.getSystemInfoSync().platform !== "devtools") {
// console.log = () => {};
// console.info = () => {};
// }
let that = this;
uni.hideTabBar();
// #ifdef MP-WEIXIN
const updateManager = wx.getUpdateManager(); // 小程序版本更新管理器
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
});
updateManager.onUpdateReady(function () {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate();
});
updateManager.onUpdateFailed(function () {
// 新版本下载失败
});
// #endif
// console.log("getSystemSetting==",uni.getSystemInfoSync())
// console.log("getSystemSetting==",uni.getSystemSetting())
//#ifdef APP-PLUS
//获取当前系统版本信息
plus.runtime.getProperty(plus.runtime.appid, (widgetInfo) => {
//请求后台接口 解析数据 对比版本
console.log('widgetInfo==', widgetInfo);
let type = uni.getSystemInfoSync().platform == 'ios' ? 2 : 1;
getVersion({ source: 'manager_app', type: type })
.then((res) => {
console.log('selectNewApp==', res);
console.log('version===', res.url && widgetInfo.version < res.version);
if (res.url && widgetInfo.version < res.version) {
console.log("version===222")
console.log('version===222');
let downloadLink = res.url;
// let downloadLink = "https://short-video.hnsiyao.cn/app/sy-duanju.apk";
console.log(downloadLink)
console.log(downloadLink);
// let androidLink = res.androidWgtUrl;
// let iosLink = res.iosWgtUrl;
let ready = false;
let ready = false;
// 校验是否强制升级
if (res.isUp == 1) {
uni.showModal({
@@ -66,81 +61,84 @@ App.vue本身不是页面这里不能编写视图元素也就是没有<tem
title: '发现新版本',
confirmText: '立即更新',
content: res.message,
success: res => {
success: (res) => {
if (res.confirm) {
uni.showLoading('下载中...');
if (uni.getSystemInfoSync().platform == 'android') {
uni.downloadFile({
url: downloadLink,
success: downloadResult => {
if (downloadResult.statusCode === 200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
entry.getParent(_oldFile=>{
entry.moveTo(_oldFile,'.apk',newFilePath=>{
console.log('newFilePath',newFilePath.fullPath)
plus.runtime.install(newFilePath.fullPath, { force: false },
d => {
console .log( 'install success...' );
plus.runtime .restart();
success: (downloadResult) => {
if (downloadResult.statusCode === 200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, (entry) => {
entry.getParent((_oldFile) => {
entry.moveTo(_oldFile, '.apk', (newFilePath) => {
console.log('newFilePath', newFilePath.fullPath);
plus.runtime.install(
newFilePath.fullPath,
{ force: false },
(d) => {
console.log('install success...');
plus.runtime.restart();
},
e => {
console.log(e)
console .error( 'install fail...' );
(e) => {
console.log(e);
console.error('install fail...');
}
);
})
})
})
});
});
});
}
}
});
}
if (uni.getSystemInfoSync().platform == 'ios') {
plus.runtime.openURL(downloadLink, function( res) {});
plus.runtime.openURL(downloadLink, function (res) {});
}
} else if (res.cancel) {
console.log('取消');
}
}
});
} else {
} else {
uni.showModal({
title: '发现新版本',
confirmText: '立即更新',
cancelText: '下次更新',
content: res.message,
success: res => {
content: res.message,
success: (res) => {
if (res.confirm) {
uni.showLoading('下载中...');
if (uni.getSystemInfoSync().platform == 'android') {
uni.downloadFile({
url: downloadLink,
success: downloadResult => {
success: (downloadResult) => {
if (downloadResult.statusCode == 200) {
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, entry => {
entry.getParent(_oldFile=>{
entry.moveTo(_oldFile,'.apk',newFilePath=>{
console.log('newFilePath',newFilePath.fullPath)
plus.runtime.install(newFilePath.fullPath, { force: false },
d => {
console.log('install success...');
plus.runtime.restart();
},
e => {
console.log(e)
console.error('install fail...');
}
);
})
})
})
plus.io.resolveLocalFileSystemURL(downloadResult.tempFilePath, (entry) => {
entry.getParent((_oldFile) => {
entry.moveTo(_oldFile, '.apk', (newFilePath) => {
console.log('newFilePath', newFilePath.fullPath);
plus.runtime.install(
newFilePath.fullPath,
{ force: false },
(d) => {
console.log('install success...');
plus.runtime.restart();
},
(e) => {
console.log(e);
console.error('install fail...');
}
);
});
});
});
}
}
});
}
if (uni.getSystemInfoSync().platform == 'ios') {
plus.runtime.openURL(downloadLink, function( res) {});
plus.runtime.openURL(downloadLink, function (res) {});
}
} else if (res.cancel) {
console.log('取消');
@@ -149,24 +147,51 @@ App.vue本身不是页面这里不能编写视图元素也就是没有<tem
});
}
}
}).catch((res)=>{
console.log(res)
})
});
// #endif
.catch((res) => {
console.log(res);
});
});
// #endif
});
</script>
<style lang="scss">
@import "uview-plus/index.scss";
@import 'uview-plus/index.scss';
/** 每个页面公共css */
@import '@/commons/style/global.scss';
@import '@/commons/style/common.scss';
/** 每个页面公共css */
@import '@/commons/style/global.scss';
@import '@/commons/style/common.scss';
/** uni 组件样式覆盖 */
@import '@/commons/style/uni-overwrite.scss';
/** uni 组件样式覆盖 */
@import '@/commons/style/uni-overwrite.scss';
</style>
// 优惠券插槽公用样式
.my-coupon-item-list {
padding-bottom: 28upx;
.my-coupon-item-item {
&:not(:first-child) {
margin-top: 28upx;
}
.my-coupon-item-row-wrap {
.row {
display: flex;
&:not(:first-child) {
margin-top: 12upx;
}
.title {
width: 200upx;
font-size: 28upx;
color: #666;
}
.info {
flex: 1;
font-size: 28upx;
color: #333;
}
}
}
}
}
</style>