This commit is contained in:
18631081161 2025-06-20 16:18:52 +08:00
commit 4e1c375d41
25 changed files with 1112 additions and 252 deletions

2
.gitattributes vendored Normal file
View File

@ -0,0 +1,2 @@
# manifest.json merge=ours
# common/env.js merge=ours

10
.gitignore vendored Normal file
View File

@ -0,0 +1,10 @@
.vscode/
.hbuilderx/
.history/
.idea/
node_modules/
unpackage/dist/
unpackage/cache/
unpackage/resources/
/.vs
.DS_Store

14
README.md Normal file
View File

@ -0,0 +1,14 @@
# 友达赏
## 代码
```sh
# 导入基础
import { defineComponent, ref } from 'vue';
# 导入页面加载方法
import { onLoad } from '@dcloudio/uni-app';
let icon = ref("/static/app-plus/icon_108.png");
# 使用页面加载方法
onLoad(() => {
console.log('页面加载中');
});
```

0
common/config.js Normal file
View File

40
common/env.js Normal file
View File

@ -0,0 +1,40 @@
/**
* 项目环境配置文件
* 集中管理所有环境相关的配置参数
*/
// 开发环境配置
const development = {
// API基础URL
baseUrl: 'https://testapi.zfunbox.cn',
// 图片资源URL
imageUrl: 'https://image.zfunbox.cn',
routeMapSecretKey: 'g6R@9!zB2fL#1cVm',
normalizeResponseKeys: 'g6R@9!zB2fL#1cVm'
};
// 生产环境配置
const production = {
baseUrl: 'https://api.zfunbox.cn',
imageUrl: 'https://image.zfunbox.cn',
routeMapSecretKey: 'g6R@9!zB2fL#1cVm',
normalizeResponseKeys: 'g6R@9!zB2fL#1cVm'
};
// 测试环境配置
const testing = {
baseUrl: 'https://testapi.zfunbox.cn',
imageUrl: 'https://image.zfunbox.cn',
routeMapSecretKey: 'g6R@9!zB2fL#1cVm',
normalizeResponseKeys: 'g6R@9!zB2fL#1cVm'
};
// 根据环境变量选择对应配置
let currentEnv = testing;//production;//testing;
// 衍生配置
const config = {
...currentEnv,
// API请求完整路径
apiBaseUrl: currentEnv.baseUrl + '/api/',
};
export default config;

View File

@ -0,0 +1,12 @@
import BasePlatform from './BasePlatform';
class AppPlatform extends BasePlatform {
constructor() {
super();
this.code = 'APP_ANDROID';
this.env = 'app';
}
}
export default AppPlatform;

View File

@ -0,0 +1,157 @@
/**
* 多端平台抽象基类父类
* 定义所有端必须实现的方法
*/
class BasePlatform {
constructor() {
if (new.target === BasePlatform) {
throw new Error('BasePlatform 是抽象类,不能直接实例化');
}
this.code = ''; // 平台代码WEB/MP/APP
this.env = ''; // 运行环境标识
this.config = null;
this.version = '1.0.0';
}
async getConfig() {
return {};
}
async appData() {
}
/**
* 加载缓存
*/
async loadCacheData() {
}
/**
* 获取是否需要审核
* @returns {boolean} 是否需要审核
*/
getIsCheck(tag) {
return this.config?.isCheck ?? false;
}
getPayData(url, data) {
throw new Error('子类必须实现 getPayData 方法');
}
/**
*
*/
chooseAddress() {
return new Promise((resolve, reject) => {
throw new Error('子类必须实现 chooseAddress 方法');
});
}
/**
* 支付方法子类必须实现
* @param {number} amount - 支付金额
* @param {string} orderId - 订单号
*/
pay({
data
}, event) {
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 || ''
};
}
downloadFile(url) {
return new Promise((resolve, reject) => {
throw new Error('子类必须实现 downloadFile 方法');
});
}
AppLaunch(options) {
throw new Error('子类必须实现 AppLaunch 方法');
}
/**
* 获取订单号
*/
getOrderNo(event) {
throw new Error('子类必须实现 getOrderNo 方法');
}
delOrderNo() {
}
/**
* 获取用户中心菜单列表
* @returns {Array} 菜单项数组每项包含id, show, title, icon, path和handler
*/
getUserMenuList() {
return [];
}
/**
* 导航到指定页面
* @param {Object} item 菜单项
*/
navigateToPath(item) {
}
/**
* 处理退出登录
*/
handleLogout() {
uni.showModal({
title: '提示',
content: '确定要退出登录吗?',
success: (res) => {
if (res.confirm) {
}
}
});
}
/**
* 开启调试
*/
startDeb() {
}
/**
* 关闭调试
*/
closeDeb() {
}
getVersion() {
return this.version;
}
getUserAgreement() {
// navigateTo('/pages/guize/guize', { type: 4 })
}
getPrivacyAgreement() {
// navigateTo('/pages/guize/guize', { type: 5 })
}
}
export default BasePlatform;

View File

@ -0,0 +1,23 @@
import BasePlatform from './BasePlatform.js';
import AppPlatform from './AppPlatform';
//#ifdef APP
// import AppPlatform from './AppPlatform';
//#endif
class PlatformFactory {
static create() {
console.log('获取平台获取平台获取平台获取平台获取平台获取平台');
//#ifdef APP
return new AppPlatform();
//#endif
// 默认返回
return new AppPlatform();
}
}
// 使用示例
const platform = PlatformFactory.create();
export {
platform
};

10
common/server/config.js Normal file
View File

@ -0,0 +1,10 @@
import HttpRequest from "../system/request";
/**
* 获取系统配置
* @returns {}
*/
export const getConfig = async () => {
const res = await HttpRequest.getOrCache('/config');
return res.data;
}

View File

@ -0,0 +1,66 @@
/**
* 设置缓存,持久化到本地
* @param {String} key 缓存key
* @param {Object} value 缓存数据
*/
export const setCache = (key, value) => {
uni.setStorageSync(key, value);
}
/**
* 获取缓存
* @param {String} key 缓存key
* @returns {Object} 缓存数据
*/
export const getCache = (key) => {
return uni.getStorageSync(key);
}
/**
* 删除缓存
* @param {String} key 缓存key
*/
export const removeCache = (key) => {
uni.removeStorageSync(key);
}
/**
* 本地缓存
*/
let localCache = {};
/**
* 设置缓存非持久化
* @param {String} key 缓存key
* @param {Object} value 缓存数据
* @param {Number} time 缓存时间
*/
export const setLocalStorage = (key, value, time = 0) => {
localCache[key] = {
value: value,
expireTime: time > 0 ? Date.now() + time * 1000 : 0,
createTime: Date.now()
}
}
/**
* 获取缓存非持久化
* @param {String} key 缓存key
* @returns {Object} 缓存数据
*/
export const getLocalStorage = (key) => {
if (localCache[key]) {
if (localCache[key].expireTime > 0 && localCache[key].expireTime > Date.now()) {
return localCache[key].value;
}
}
return null;
}
/**
* 删除缓存非持久化
* @param {String} key 缓存key
*/
export const removeLocalStorage = (key) => {
delete localCache[key];
}

212
common/system/request.js Normal file
View File

@ -0,0 +1,212 @@
/**
* 网络请求工具类
* 封装统一的网络请求方法
*/
import EnvConfig from '@/common/env.js';
import md5 from 'js-md5';
import { normalizeResponseKeys, getRouteMap } from '@/common/system/routeMap.js';
import { platform } from '@/common/platform/PlatformFactory';
import { getLocalStorage, setLocalStorage } from './cacheService';
import qs from 'qs';
class HttpRequest {
/**
* 生成唯一的nonce值
* @returns {String} nonce值
*/
static generateNonce() {
return md5(Date.now() + Math.random().toString(36).substring(2, 15));
}
/**
* 创建签名
* @param {Object} data 请求数据
* @param {String} host 主机名
* @returns {Object} 带签名的数据和参数字符串
* @private
*/
static _createSignature(data, host) {
// 添加时间戳
data.timestamp = Math.floor(Date.now() / 1000);
// 添加nonce随机字符串
data.nonce = HttpRequest.generateNonce();
// 按照键名对参数进行排序
const sortedParams = {};
Object.keys(data).sort().forEach(key => {
sortedParams[key] = data[key];
});
// 组合参数为字符串
let signStr = '';
for (const key in sortedParams) {
if (typeof sortedParams[key] === 'object') {
signStr += key + '=' + JSON.stringify(sortedParams[key]) + '&';
} else {
signStr += key + '=' + sortedParams[key] + '&';
}
}
// 获取时间戳,组合为密钥
const timestamp = data.timestamp;
const appSecret = host + timestamp;
// 添加密钥并去除最后的&
signStr = signStr.substring(0, signStr.length - 1) + appSecret;
// 使用MD5生成签名
const sign = md5(signStr);
data.sign = sign;
return { data, signStr };
}
/**
* 构建请求URL
* @param {String} url 请求路径
* @returns {Object} 包含请求URL和主机名的对象
* @private
*/
static _buildRequestUrl(url) {
let requestUrl = '';
if (url.startsWith('http://') || url.startsWith('https://')) {
// 如果是完整的URL直接使用
requestUrl = url;
} else {
// 否则拼接基础URL和相对路径
// 确保基础URL以/结尾,而请求路径不以/开头
const apiBaseUrl = EnvConfig.apiBaseUrl;
const baseUrlWithSlash = apiBaseUrl.endsWith('/') ? apiBaseUrl : apiBaseUrl + '/';
let routeMap = getRouteMap(url);
const path = routeMap.startsWith('/') ? routeMap.substring(1) : routeMap;
requestUrl = baseUrlWithSlash + path;
}
// 使用正则表达式从URL中提取主机名
const hostRegex = /^(?:https?:\/\/)?([^\/]+)/i;
const matches = requestUrl.match(hostRegex);
const host = matches && matches[1] ? matches[1] : 'localhost';
return { requestUrl, host };
}
/**
* 发送请求
* @param {String} url 请求地址
* @param {Object} fromData 请求数据
* @param {String} method 请求方式
* @param {Boolean} showLoading 是否显示加载提示
* @returns {Promise} 返回请求Promise
*/
static request(url, fromData = {}, method = 'POST', showLoading = false) {
return new Promise((resolve, reject) => {
// 使用传入的method而不是重新声明
const requestMethod = method.toUpperCase();
const token = uni.getStorageSync('token');
const client = platform.code;
let data = { ...fromData }; // 创建数据的深拷贝,避免修改原数据
// 构建请求URL和提取主机名
const { requestUrl, host } = HttpRequest._buildRequestUrl(url);
// 显示加载提示
if (showLoading) {
uni.showLoading({
title: '正在加载中...',
mask: true
});
}
// 创建签名并准备请求数据和头信息
const { data: signedData } = HttpRequest._createSignature(data, host);
data = signedData;
// 根据请求方法设置不同的headers
const header = {
platform: client,
token: token,
version: platform.getVersion(),
'content-type': requestMethod === 'POST'
? 'application/x-www-form-urlencoded'
: 'application/json'
};
const startDate = Date.now();
// 发起网络请求
uni.request({
url: requestUrl,
method: requestMethod,
header: header,
data: data,
timeout: 30000, // 设置30秒超时
success: res => {
const endDate = Date.now();
console.log(requestUrl, "请求消耗时间", endDate - startDate);
const normalizedRes = normalizeResponseKeys(res);
resolve(normalizedRes);
},
fail: e => {
console.error('网络请求失败:', e);
uni.showToast({
title: e.errMsg || '发送请求失败,请稍后再试!',
icon: 'none'
});
reject(e);
},
complete: () => {
if (showLoading) {
uni.hideLoading();
}
}
});
});
}
/**
* 发送GET请求
* @param {String} url 请求地址
* @param {Object} data 请求参数
* @param {Boolean} showLoading 是否显示加载提示
* @returns {Promise} 返回请求Promise
*/
static get(url, data = {}, showLoading = false) {
return HttpRequest.request(url, data, 'GET', showLoading);
}
/**
* 发送POST请求
* @param {String} url 请求地址
* @param {Object} data 请求参数
* @param {Boolean} showLoading 是否显示加载提示
* @returns {Promise} 返回请求Promise
*/
static post(url, data = {}, showLoading = false) {
return HttpRequest.request(url, data, 'POST', showLoading);
}
/**
* 发送get请求如果缓存存在则返回缓存数据否则发送请求并缓存数据
* @param {String} url 请求地址
* @param {Object} data 请求参数
* @param {Number} time 缓存时间
* @param {Boolean} showLoading 是否显示加载提示
* @returns {Promise} 返回请求Promise
*/
static async getOrCache(url, data = {}, time = 300, showLoading = false) {
const cacheKey = 'cache_' + url + '_' + qs.stringify(data);
const cacheData = getLocalStorage(cacheKey);
if (cacheData) {
console.log('getOrCache', cacheKey, '缓存命中');
return cacheData;
}
const res = await HttpRequest.request(url, data, 'GET', showLoading);
setLocalStorage(cacheKey, res, time);
return res;
}
}
export default HttpRequest;

124
common/system/routeMap.js Normal file

File diff suppressed because one or more lines are too long

13
common/system/router.js Normal file
View File

@ -0,0 +1,13 @@
import { platform } from '@/common/platform/PlatformFactory';
export const navigateTo = (url) => {
uni.navigateTo({
url: url,
fail: (err) => {
uni.switchTab({
url: url
});
}
});
}

33
common/utils.js Normal file
View File

@ -0,0 +1,33 @@
/**
* 延迟执行
* @param {Number} ms
* @returns
*/
export function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
/**
* 解析查询字符串
* @param {string} urlOrQueryString
* @returns {Object} 查询参数对象
*/
export function parseQueryString(urlOrQueryString) {
// 如果传入的是完整URL如 "/path?name=value"),提取查询部分
let queryString = urlOrQueryString;
const questionMarkIndex = queryString.indexOf('?');
if (questionMarkIndex !== -1) {
queryString = queryString.slice(questionMarkIndex + 1);
}
const params = {};
if (!queryString) return params; // 如果没有查询参数,返回空对象
const pairs = queryString.split('&');
for (const pair of pairs) {
const [key, value] = pair.split('=');
// 解码 URI 组件,并处理无值情况(如 "key" 而不是 "key=value"
params[key] = value ? decodeURIComponent(value) : '';
}
return params;
}

14
main.js
View File

@ -6,17 +6,19 @@ import './uni.promisify.adaptor'
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
...App
...App
})
app.$mount()
// #endif
// #ifdef VUE3
import { createSSRApp } from 'vue'
import {
createSSRApp
} from 'vue'
export function createApp() {
const app = createSSRApp(App)
return {
app
}
const app = createSSRApp(App)
return {
app
}
}
// #endif

View File

@ -17,7 +17,10 @@
"delay" : 0
},
/* */
"modules" : {},
"modules" : {
"Camera" : {},
"Payment" : {}
},
/* */
"distribute" : {
/* android */
@ -41,9 +44,18 @@
]
},
/* ios */
"ios" : {},
"ios" : {
"idfa" : false
},
/* SDK */
"sdkConfigs" : {}
"sdkConfigs" : {
"payment" : {
"alipay" : {
"__platform__" : [ "ios", "android" ]
}
},
"share" : {}
}
}
},
/* */

289
package-lock.json generated Normal file
View File

@ -0,0 +1,289 @@
{
"name": "youdas",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"crypto-js": "^4.2.0",
"js-md5": "^0.8.3",
"qs": "^6.14.0"
}
},
"node_modules/call-bind-apply-helpers": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz",
"integrity": "sha512-Sp1ablJ0ivDkSzjcaJdxEunN5/XvksFJ2sMBFfq6x0ryhQV/2b/KwFe21cMpmHtPOSij8K99/wSfoEuTObmuMQ==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/call-bound": {
"version": "1.0.4",
"resolved": "https://registry.npmjs.org/call-bound/-/call-bound-1.0.4.tgz",
"integrity": "sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"get-intrinsic": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/crypto-js": {
"version": "4.2.0",
"resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz",
"integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==",
"license": "MIT"
},
"node_modules/dunder-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/dunder-proto/-/dunder-proto-1.0.1.tgz",
"integrity": "sha512-KIN/nDJBQRcXw0MLVhZE9iQHmG68qAVIBg9CqmUYjmQIhgij9U5MFvrqkUL5FbtyyzZuOeOt0zdeRe4UY7ct+A==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.1",
"es-errors": "^1.3.0",
"gopd": "^1.2.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-define-property": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz",
"integrity": "sha512-e3nRfgfUZ4rNGL232gUgX06QNyyez04KdjFrF+LTRoOXmrOgFKDg4BCdsjW8EnT69eqdYGmRpJwiPVYNrCaW3g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-errors": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/es-errors/-/es-errors-1.3.0.tgz",
"integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/es-object-atoms": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/es-object-atoms/-/es-object-atoms-1.1.1.tgz",
"integrity": "sha512-FGgH2h8zKNim9ljj7dankFPcICIK9Cp5bm+c2gQSYePhpaG5+esrLODihIorn+Pe6FGJzWhXQotPv73jTaldXA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/function-bind": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.2.tgz",
"integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-intrinsic": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.3.0.tgz",
"integrity": "sha512-9fSjSaos/fRIVIp+xSJlE6lfwhES7LNtKaCBIamHsjr2na1BiABJPo0mOjjz8GJDURarmCPGqaiVg5mfjb98CQ==",
"license": "MIT",
"dependencies": {
"call-bind-apply-helpers": "^1.0.2",
"es-define-property": "^1.0.1",
"es-errors": "^1.3.0",
"es-object-atoms": "^1.1.1",
"function-bind": "^1.1.2",
"get-proto": "^1.0.1",
"gopd": "^1.2.0",
"has-symbols": "^1.1.0",
"hasown": "^2.0.2",
"math-intrinsics": "^1.1.0"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/get-proto": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/get-proto/-/get-proto-1.0.1.tgz",
"integrity": "sha512-sTSfBjoXBp89JvIKIefqw7U2CCebsc74kiY6awiGogKtoSGbgjYE/G/+l9sF3MWFPNc9IcoOC4ODfKHfxFmp0g==",
"license": "MIT",
"dependencies": {
"dunder-proto": "^1.0.1",
"es-object-atoms": "^1.0.0"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/gopd": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz",
"integrity": "sha512-ZUKRh6/kUFoAiTAtTYPZJ3hw9wNxx+BIBOijnlG9PnrJsCcSjs1wyyD6vJpaYtgnzDrKYRSqf3OO6Rfa93xsRg==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/has-symbols": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz",
"integrity": "sha512-1cDNdwJ2Jaohmb3sg4OmKaMBwuC48sYni5HUw2DvsC8LjGTLK9h+eb1X6RyuOHe4hT0ULCW68iomhjUoKUqlPQ==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/hasown": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.2.tgz",
"integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==",
"license": "MIT",
"dependencies": {
"function-bind": "^1.1.2"
},
"engines": {
"node": ">= 0.4"
}
},
"node_modules/js-md5": {
"version": "0.8.3",
"resolved": "https://registry.npmjs.org/js-md5/-/js-md5-0.8.3.tgz",
"integrity": "sha512-qR0HB5uP6wCuRMrWPTrkMaev7MJZwJuuw4fnwAzRgP4J4/F8RwtodOKpGp4XpqsLBFzzgqIO42efFAyz2Et6KQ==",
"license": "MIT"
},
"node_modules/math-intrinsics": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/math-intrinsics/-/math-intrinsics-1.1.0.tgz",
"integrity": "sha512-/IXtbwEk5HTPyEwyKX6hGkYXxM9nbj64B+ilVJnC/R6B0pH5G4V3b0pVbL7DBj4tkhBAppbQUlf6F6Xl9LHu1g==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
}
},
"node_modules/object-inspect": {
"version": "1.13.4",
"resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.13.4.tgz",
"integrity": "sha512-W67iLl4J2EXEGTbfeHCffrjDfitvLANg0UlX3wFUUSTx92KXRFegMHUVgSqE+wvhAbi4WqjGg9czysTV2Epbew==",
"license": "MIT",
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/qs": {
"version": "6.14.0",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.14.0.tgz",
"integrity": "sha512-YWWTjgABSKcvs/nWBi9PycY/JiPJqOD4JA6o9Sej2AtvSGarXxKC3OQSk4pAarbdQlKAh5D4FCQkJNkW+GAn3w==",
"license": "BSD-3-Clause",
"dependencies": {
"side-channel": "^1.1.0"
},
"engines": {
"node": ">=0.6"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz",
"integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3",
"side-channel-list": "^1.0.0",
"side-channel-map": "^1.0.1",
"side-channel-weakmap": "^1.0.2"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-list": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/side-channel-list/-/side-channel-list-1.0.0.tgz",
"integrity": "sha512-FCLHtRD/gnpCiCHEiJLOwdmFP+wzCmDEkc9y7NsYxeF4u7Btsn1ZuwgwJGxImImHicJArLP4R0yX4c2KCrMrTA==",
"license": "MIT",
"dependencies": {
"es-errors": "^1.3.0",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-map": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/side-channel-map/-/side-channel-map-1.0.1.tgz",
"integrity": "sha512-VCjCNfgMsby3tTdo02nbjtM/ewra6jPHmpThenkTYh8pG9ucZ/1P8So4u4FGBek/BjpOVsDCMoLA/iuBKIFXRA==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/side-channel-weakmap": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/side-channel-weakmap/-/side-channel-weakmap-1.0.2.tgz",
"integrity": "sha512-WPS/HvHQTYnHisLo9McqBHOJk2FkHO/tlpvldyrnem4aeQp4hai3gythswg6p01oSoTl58rcpiFAjF2br2Ak2A==",
"license": "MIT",
"dependencies": {
"call-bound": "^1.0.2",
"es-errors": "^1.3.0",
"get-intrinsic": "^1.2.5",
"object-inspect": "^1.13.3",
"side-channel-map": "^1.0.1"
},
"engines": {
"node": ">= 0.4"
},
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
}
}
}

7
package.json Normal file
View File

@ -0,0 +1,7 @@
{
"dependencies": {
"crypto-js": "^4.2.0",
"js-md5": "^0.8.3",
"qs": "^6.14.0"
}
}

View File

@ -1,5 +1,11 @@
{
"pages": [ //pageshttps://uniapp.dcloud.io/collocation/pages
"pages": [
{
"path": "pages/index/index",
"style": {
"navigationStyle": "custom"
}
},
{
"path": "pages/news/news",
"style": {
@ -7,13 +13,7 @@
"navigationBarTitleText": ""
}
},
{
"path": "pages/index/index",
"style": {
"navigationStyle": "custom",
"navigationBarTitleText": ""
}
},
{
"path": "pages/mall/mall",
"style": {
@ -27,12 +27,6 @@
"navigationStyle": "custom",
"navigationBarTitleText": ""
}
},
{
"path": "pages/news/news_details",
"style": {
"navigationBarTitleText": ""
}
}
],
"globalStyle": {
@ -41,13 +35,13 @@
"navigationBarBackgroundColor": "#FFFFFF",
"backgroundColor": "#F7F7F7"
},
"tabBar": {
"color": "#C6C6C6",
"selectedColor": "#333333",
"borderStyle": "black",
"height": "124.05rpx",
"list": [{
"list": [
{
"pagePath": "pages/news/news",
"text": "资讯",
"iconPath": "/static/tabbar/news.png",
@ -65,9 +59,6 @@
"iconPath": "/static/tabbar/me.png",
"selectedIconPath": "/static/tabbar/me_s.png"
}
]
}
}

View File

@ -1,179 +1,82 @@
<template>
<view class="content">
<view class="" style="width: 100%; height: 225.19rpx; background-color: white; position: relative;">
<view class="tab">
<view class="tab-item" v-for="(item, i) in tabList" :key="i" :class="tabC == i ? 'act' : 'unact'"
@click="tabChange(i)">
<text>{{ item }}</text>
</view>
</view>
<view class="page">
<view class="welcome">
<image class="welcome__logo" :src="icon" mode="aspectFit">
</image>
<image :src="login_icon" class="welcome__animation"></image>
<view class="welcome__tips">{{ tips_text }}</view>
</view>
<scroll-view class="" scroll-y="true" style="width: 688.93rpx; height: 1211rpx; margin: 15rpx auto;">
<view class="view-data" v-for="(item,index) in dataList" @click="toDetails(item.id)">
<view class="title">
{{item.title}}
</view>
<view class="time">
{{item.tiem}}
</view>
<view class="img">
</view>
</view>
</scroll-view>
</view>
</template>
<script>
export default {
data() {
return {
tabC: 1,
tabList: ["热榜", "精选", "关注"],
dataList: [{
id: 1,
title: "联合国预测世界人口将达到80亿这一数字这一数字",
tiem: "今天 20:01",
imgUrl: ""
}, {
id: 1,
title: "联合国预测世界人口将达到80亿这一数字……",
tiem: "今天 20:01",
imgUrl: ""
}, {
id: 1,
title: "联合国预测世界人口将达到80亿这一数字……",
tiem: "今天 20:01",
imgUrl: ""
}, {
id: 1,
title: "联合国预测世界人口将达到80亿这一数字……",
tiem: "今天 20:01",
imgUrl: ""
}, {
id: 1,
title: "联合国预测世界人口将达到80亿这一数字……",
tiem: "今天 20:01",
imgUrl: ""
}, {
id: 1,
title: "联合国预测世界人口将达到80亿这一数字……",
tiem: "今天 20:01",
imgUrl: ""
}, ]
}
},
onLoad() {
},
methods: {
tabChange(i) {
this.tabC = i
},
toDetails(i) {
//test.vue
uni.navigateTo({
url: '/pages/index/news_details'
})
},
},
<script setup>
import { defineComponent, ref } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import { getConfig } from '@/common/server/config';
import { navigateTo } from '@/common/system/router';
let icon = ref("/static/app-plus/icon_108.png");
let login_icon = ref("/static/app-plus/index_login.gif");
let tips_text = ref("正在加载中。。。");
onLoad(async () => {
//
const network = await uni.getNetworkType();
if (network.networkType === 'none') {
tips_text.value = '请检查网络连接';
//
uni.onNetworkStatusChange(checkNetwork);
return;
}
navigateTo('/pages/news/news');
// const config = await getConfig();
// console.log('config', config);
// const config1 = await getConfig();
// console.log('config1', config1);
});
/**
* 检查网络状态
* @param {Object} res 网络状态
*/
function checkNetwork(res) {
console.log('网络状态变化:', res.isConnected, res.networkType);
if (res.isConnected) {
tips_text.value = '正在加载中。。。';
// #ifdef APP
plus.runtime.restart();
// #endif
} else {
tips_text.value = '请检查网络连接';
}
}
</script>
<style lang="scss">
.content {
width: 100%;
display: flex;
flex-direction: column;
background-color: #F7F7F7;
.page {
width: 100vw;
height: 100vh;
background-color: #f8f8f8;
}
.welcome {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
&__logo {
width: 96px;
height: 96px;
margin-top: 20vh;
border-radius: 50%;
}
.tab {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
position: absolute;
bottom: 20rpx;
.tab-item {
width: 155rpx;
height: 68rpx;
position: relative;
display: flex;
align-items: center;
justify-content: center;
&.act {
font-size: 30.53rpx;
color: #000000;
&::after {
content: '';
position: absolute;
bottom: 0;
left: 50%;
transform: translateX(-50%);
width: 26.72rpx;
height: 4rpx;
background: #333333;
}
}
&.unact {
font-size: 30.53rpx;
color: #4C4C4C;
}
}
&__animation {
width: 200rpx;
height: 200rpx;
}
.view-data {
width: 100%;
height: 225.19rpx;
background-color: white;
margin-bottom: 15rpx;
border-radius: 19.08rpx;
position: relative;
.title {
width: 366.41rpx;
height: 83.97rpx;
position: absolute;
top: 32rpx;
left: 20rpx;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
display: -webkit-box;
overflow: hidden;
text-overflow: ellipsis;
}
.time {
position: absolute;
left: 20rpx;
font-size: 22.9rpx;
color: #878787;
bottom: 24rpx;
}
.img {
position: absolute;
right: 20rpx;
top: 34rpx;
width: 225.19rpx;
height: 158.4rpx;
background-color: #D8D8D8;
}
&__tips {
margin-top: 10px;
}
}
</style>

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 KiB

BIN
static/app-plus/no-data.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

View File

@ -14,63 +14,3 @@
/* 颜色变量 */
/* 行为相关颜色 */
$uni-color-primary: #007aff;
$uni-color-success: #4cd964;
$uni-color-warning: #f0ad4e;
$uni-color-error: #dd524d;
/* 文字基本颜色 */
$uni-text-color:#333;//基本色
$uni-text-color-inverse:#fff;//反色
$uni-text-color-grey:#999;//辅助灰色如加载更多的提示信息
$uni-text-color-placeholder: #808080;
$uni-text-color-disable:#c0c0c0;
/* 背景颜色 */
$uni-bg-color:#ffffff;
$uni-bg-color-grey:#f8f8f8;
$uni-bg-color-hover:#f1f1f1;//点击状态颜色
$uni-bg-color-mask:rgba(0, 0, 0, 0.4);//遮罩颜色
/* 边框颜色 */
$uni-border-color:#c8c7cc;
/* 尺寸变量 */
/* 文字尺寸 */
$uni-font-size-sm:12px;
$uni-font-size-base:14px;
$uni-font-size-lg:16px;
/* 图片尺寸 */
$uni-img-size-sm:20px;
$uni-img-size-base:26px;
$uni-img-size-lg:40px;
/* Border Radius */
$uni-border-radius-sm: 2px;
$uni-border-radius-base: 3px;
$uni-border-radius-lg: 6px;
$uni-border-radius-circle: 50%;
/* 水平间距 */
$uni-spacing-row-sm: 5px;
$uni-spacing-row-base: 10px;
$uni-spacing-row-lg: 15px;
/* 垂直间距 */
$uni-spacing-col-sm: 4px;
$uni-spacing-col-base: 8px;
$uni-spacing-col-lg: 12px;
/* 透明度 */
$uni-opacity-disabled: 0.3; // 组件禁用态的透明度
/* 文章场景相关 */
$uni-color-title: #2C405A; // 文章标题颜色
$uni-font-size-title:20px;
$uni-color-subtitle: #555555; // 二级标题颜色
$uni-font-size-subtitle:26px;
$uni-color-paragraph: #3F536E; // 文章段落颜色
$uni-font-size-paragraph:15px;