Compare commits
7 Commits
de1c110bab
...
release/v1
| Author | SHA1 | Date | |
|---|---|---|---|
| e8ccb87266 | |||
| 153c84266a | |||
| 7ae7a1d3bd | |||
| 1ebb94e9e2 | |||
| 9b53540f91 | |||
| 2223636184 | |||
| 6144dc72b8 |
@@ -2,46 +2,46 @@
|
||||
// 复制此文件并重命名为 local.config.js 以使用自定义本地配置
|
||||
|
||||
const localDevConfig = ({
|
||||
'460': { // 制氧设备平台
|
||||
uniacid: 460,
|
||||
domain: 'https://xcx30.5g-quickapp.com/',
|
||||
},
|
||||
'576-xcx30.5g': { // 活性石灰装备
|
||||
uniacid: 576,
|
||||
domain: 'https://xcx30.5g-quickapp.com/',
|
||||
},
|
||||
'2285': { // 数码喷墨墨水
|
||||
uniacid: 2285,
|
||||
domain: 'https://xcx.aigc-quickapp.com/',
|
||||
},
|
||||
'2811': { // POCT检测分析平台
|
||||
uniacid: 2811,
|
||||
domain: 'https://xcx6.aigc-quickapp.com/',
|
||||
},
|
||||
'2724': { // 生物菌肥
|
||||
uniacid: 2724,
|
||||
domain: 'https://xcx.aigc-quickapp.com/',
|
||||
},
|
||||
'2505': { // 煤矿钻机
|
||||
uniacid: 2505,
|
||||
domain: 'https://xcx.aigc-quickapp.com/',
|
||||
},
|
||||
'2777': { // 养老服务
|
||||
uniacid: 2777,
|
||||
domain: 'https://xcx.aigc-quickapp.com/',
|
||||
},
|
||||
'2812': { // IVD数商模式
|
||||
uniacid: 2812,
|
||||
domain: 'https://xcx6.aigc-quickapp.com/',
|
||||
},
|
||||
'1': { // 开发平台
|
||||
uniacid: 1,
|
||||
domain: 'https://dev.aigc-quickapp.com',
|
||||
},
|
||||
'1-test': { // 测试平台
|
||||
uniacid: 1,
|
||||
domain: 'https://test.aigc-quickapp.com',
|
||||
},
|
||||
})['2812']; // 选择要使用的环境配置
|
||||
'460': { // 制氧设备平台
|
||||
uniacid: 460,
|
||||
domain: 'https://xcx30.5g-quickapp.com/',
|
||||
},
|
||||
'576-xcx30.5g': { // 活性石灰装备
|
||||
uniacid: 576,
|
||||
domain: 'https://xcx30.5g-quickapp.com/',
|
||||
},
|
||||
'2285': { // 数码喷墨墨水
|
||||
uniacid: 2285,
|
||||
domain: 'https://xcx.aigc-quickapp.com/',
|
||||
},
|
||||
'2811': { // POCT检测分析平台
|
||||
uniacid: 2811,
|
||||
domain: 'https://xcx6.aigc-quickapp.com/',
|
||||
},
|
||||
'2724': { // 生物菌肥
|
||||
uniacid: 2724,
|
||||
domain: 'https://xcx.aigc-quickapp.com/',
|
||||
},
|
||||
'2505': { // 煤矿钻机
|
||||
uniacid: 2505,
|
||||
domain: 'https://xcx.aigc-quickapp.com/',
|
||||
},
|
||||
'2777': { // 养老服务
|
||||
uniacid: 2777,
|
||||
domain: 'https://xcx.aigc-quickapp.com/',
|
||||
},
|
||||
'1': { // 开发平台
|
||||
uniacid: 1,
|
||||
domain: 'https://dev.aigc-quickapp.com',
|
||||
},
|
||||
'1-test': { // 测试平台
|
||||
uniacid: 1,
|
||||
domain: 'https://test.aigc-quickapp.com',
|
||||
},
|
||||
'local-2': { // 测试平台
|
||||
uniacid: 2,
|
||||
domain: 'http://localhost:8050/',
|
||||
},
|
||||
})['2811']; // 选择要使用的环境配置
|
||||
|
||||
export default localDevConfig;
|
||||
@@ -6,13 +6,23 @@
|
||||
/**
|
||||
* 显示错误信息
|
||||
* @param {Exception} err
|
||||
* @param {Boolean} useModal
|
||||
*/
|
||||
const showError = (err) => {
|
||||
uni.showToast({
|
||||
title: err?.message || err?.errMsg || err?.toString(),
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
const showError = (err, useModal = false) => {
|
||||
const content = err?.message || err?.errMsg || err?.toString();
|
||||
if (!useModal) {
|
||||
uni.showToast({
|
||||
title: content,
|
||||
icon: 'none',
|
||||
duration: 3000
|
||||
});
|
||||
} else {
|
||||
uni.showModal({
|
||||
title: '错误提示',
|
||||
content,
|
||||
showCancel: false,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -33,43 +43,92 @@ export const makePhoneCall = (mobile) => {
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝文本
|
||||
* 拷贝文本(返回 Promise)
|
||||
* @param {*} text
|
||||
* @param {*} options
|
||||
* @returns {Promise} 返回 Promise,成功时 resolve,失败时 reject
|
||||
*/
|
||||
export const copyText = (text, { copySuccess = '', copyFailed = '' } = {}) => {
|
||||
try {
|
||||
console.log('copyText');
|
||||
uni.setClipboardData({
|
||||
data: `${text}`,
|
||||
success: () => {
|
||||
console.error('复制成功');
|
||||
try {
|
||||
uni.showToast({
|
||||
title: copySuccess,
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
} catch (e) {
|
||||
showError(e);
|
||||
export const copyTextAsync = (text, { copySuccess = '', copyFailed = '' } = {}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
// 输入验证
|
||||
if (!text && text !== '') {
|
||||
const error = new Error('复制文本不能为空');
|
||||
showError(error);
|
||||
reject(error);
|
||||
return;
|
||||
}
|
||||
|
||||
// 超时监测
|
||||
const timeoutId = setTimeout(() => {
|
||||
let error = new Error('复制操作长时间无响应,请检查相关权限及配置是否正确');
|
||||
// #ifdef MP-WEIXIN
|
||||
error = new Error([
|
||||
'复制操作长时间无响应!',
|
||||
'原因:',
|
||||
'1.微信平台->用户隐私保护指引->"剪贴板"功能未添加或审核未通过;',
|
||||
'2.微信平台对剪贴板API调用频率有限制'
|
||||
].join('\r\n'));
|
||||
// #endif
|
||||
showError(error, true);
|
||||
reject(error);
|
||||
}, 5000);
|
||||
|
||||
try {
|
||||
uni.setClipboardData({
|
||||
data: `${text}`,
|
||||
success: (res) => {
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
try {
|
||||
if (copySuccess) {
|
||||
uni.showToast({
|
||||
title: copySuccess,
|
||||
icon: 'success',
|
||||
duration: 2000
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
showError(e);
|
||||
}
|
||||
|
||||
resolve(res);
|
||||
},
|
||||
fail: (err) => {
|
||||
clearTimeout(timeoutId);
|
||||
try {
|
||||
uni.showToast({
|
||||
title: err.message || err.errMsg || copyFailed || '复制失败',
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
} catch (e) {
|
||||
showError(e);
|
||||
}
|
||||
reject(err);
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('复制失败:', err);
|
||||
try {
|
||||
uni.showToast({
|
||||
title: err.message || err.errMsg || copyFailed,
|
||||
icon: 'none',
|
||||
duration: 2000
|
||||
});
|
||||
} catch (e) {
|
||||
showError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (err) {
|
||||
clearTimeout(timeoutId);
|
||||
showError(err);
|
||||
reject(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 拷贝文本(回调形式,兼容旧代码)
|
||||
* @param {*} text
|
||||
* @param {*} options
|
||||
* @param {Function} callback 回调函数,接收 (success, error) 参数
|
||||
*/
|
||||
export const copyText = (text, options = {}, callback) => {
|
||||
copyTextAsync(text, options)
|
||||
.then(res => {
|
||||
if (callback) callback(true, null);
|
||||
})
|
||||
.catch(err => {
|
||||
if (callback) callback(false, err);
|
||||
});
|
||||
} catch (err) {
|
||||
showError(err);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -130,9 +130,7 @@ export default {
|
||||
*/
|
||||
redirectTo(to, param = {}, mode = 'navigateTo') {
|
||||
let url = to;
|
||||
if (to.indexOf('/article/list') !== -1) {
|
||||
mode = 'reLaunch';
|
||||
}
|
||||
|
||||
// 替换url中的前缀
|
||||
console.log('页面跳转 redirectTo', to, param, mode);
|
||||
url = adaptSubpackageUrl(url);
|
||||
|
||||
@@ -17,6 +17,24 @@
|
||||
<text class="ai-icon" v-if="!aiAgentimg">🤖</text>
|
||||
</view>
|
||||
|
||||
<!-- 微信小程序客服按钮 -->
|
||||
<!-- #ifdef MP-WEIXIN -->
|
||||
<button class="btn-item common-bg" hoverClass="none" openType="contact" sessionFrom="weapp" showMessageCard="true"
|
||||
:style="[{ backgroundImage: kefuimg ? `url(${kefuimg})` : '', backgroundSize: '100% 100%' }, customButtonStyle]">
|
||||
<text class="icox icox-kefu" v-if="!kefuimg"></text>
|
||||
</button>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 普通客服(仅当未启用 AI 时显示) -->
|
||||
<!-- #ifdef H5 -->
|
||||
<template v-if="fixBtnShow">
|
||||
<button class="btn-item common-bg" hoverClass="none" @click="openCustomerSelectPopup"
|
||||
:style="[{ backgroundImage: kefuimg ? `url(${kefuimg})` : '', backgroundSize: '100% 100%' }, customButtonStyle]">
|
||||
<text class="icox icox-kefu" v-if="!kefuimg"></text>
|
||||
</button>
|
||||
</template>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- 电话按钮(始终显示) -->
|
||||
<view v-if="fixBtnShow" class="btn-item common-bg" @click="call()"
|
||||
:style="[{ backgroundImage: phoneimg ? `url(${phoneimg})` : '', backgroundSize: '100% 100%' }, customButtonStyle]">
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
export const lang = {
|
||||
//title为每个页面的标题
|
||||
title: '新闻'
|
||||
title: '文章详情'
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
export const lang = {
|
||||
//title为每个页面的标题
|
||||
title: '新闻',
|
||||
title: '文章列表',
|
||||
emptyText:"当前暂无文章信息"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
{
|
||||
"scripts": {
|
||||
"mp-weixin": "node scripts/mp-weixin.patch.js"
|
||||
"mp-weixin": "node scripts/mp-weixin.patch.js",
|
||||
"mp-weixin:patch": "node scripts/mp-weixin.patch.js --no-zip",
|
||||
"mp-weixin:dev": "node scripts/mp-weixin.patch.js --mode development",
|
||||
"mp-weixin:dev:patch": "node scripts/mp-weixin.patch.js --mode development --no-zip"
|
||||
},
|
||||
"devDependencies": {
|
||||
"dart-sass": "^1.25.0",
|
||||
|
||||
1945
pages.json
1945
pages.json
File diff suppressed because it is too large
Load Diff
@@ -1,52 +1,187 @@
|
||||
<template>
|
||||
<view style="padding: 20rpx;" :style="themeColor">
|
||||
<rich-text :nodes="content"></rich-text>
|
||||
<view class="view-container" :style="themeColor">
|
||||
<!-- 加载状态 -->
|
||||
<view v-if="loading" class="loading-state">
|
||||
<view class="loading-spinner"></view>
|
||||
</view>
|
||||
|
||||
<!-- 空状态 -->
|
||||
<view v-else-if="!content" class="empty-state">
|
||||
<view class="empty-icon">📄</view>
|
||||
<text class="empty-title">暂无内容</text>
|
||||
<text class="empty-desc">该协议内容暂未设置</text>
|
||||
<button class="empty-button" @click="getcontent">重新加载</button>
|
||||
</view>
|
||||
|
||||
<!-- 内容状态 -->
|
||||
<rich-text v-else :nodes="content"></rich-text>
|
||||
|
||||
<to-top v-if="showTop" @toTop="scrollToTopNative()"></to-top>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import htmlParser from '@/common/js/html-parser';
|
||||
import scroll from '@/common/js/scroll-view.js';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
content:'',
|
||||
type:'',
|
||||
uniacid:0
|
||||
};
|
||||
},
|
||||
onLoad(option) {
|
||||
data() {
|
||||
return {
|
||||
content: '',
|
||||
type: '',
|
||||
uniacid: 0,
|
||||
loading: true
|
||||
};
|
||||
},
|
||||
mixins: [scroll],
|
||||
onLoad(option) {
|
||||
this.type = option.type
|
||||
this.uniacid = option.uniacid?option.uniacid:0
|
||||
|
||||
this.isIphoneX = this.$util.uniappIsIPhoneX()
|
||||
this.getcontent()
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
getcontent() {
|
||||
this.uniacid = option.uniacid ? option.uniacid : 0
|
||||
|
||||
this.isIphoneX = this.$util.uniappIsIPhoneX()
|
||||
this.getcontent()
|
||||
},
|
||||
onShow() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
getcontent() {
|
||||
this.loading = true
|
||||
// privacy content
|
||||
var data = {
|
||||
type:this.type
|
||||
type: this.type
|
||||
}
|
||||
if(this.uniacid > 0) data.uniacid = this.uniacid
|
||||
this.$api.sendRequest({
|
||||
url: '/api/config/agreement',
|
||||
data:data,
|
||||
success: res => {
|
||||
if (this.uniacid > 0) data.uniacid = this.uniacid
|
||||
this.$api.sendRequest({
|
||||
url: '/api/config/agreement',
|
||||
data: data,
|
||||
success: res => {
|
||||
console.log(res.data.title)
|
||||
uni.setNavigationBarTitle({
|
||||
title:res.data.title
|
||||
title: res.data.title
|
||||
})
|
||||
this.content = res.data.content
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
this.loading = false
|
||||
},
|
||||
fail: () => {
|
||||
this.loading = false
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
<style lang="scss" scoped>
|
||||
.view-container {
|
||||
padding: 40rpx;
|
||||
background: #ffffff;
|
||||
border-radius: 12rpx;
|
||||
box-shadow: 0 2rpx 12rpx rgba(0, 0, 0, 0.06), 0 1rpx 2rpx rgba(0, 0, 0, 0.09);
|
||||
margin: 4rpx 20rpx;
|
||||
// max-width: 800rpx;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
min-height: 100vh;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
// 增强纸张纹理效果
|
||||
.view-container::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200" viewBox="0 0 200 200"><defs><pattern id="grain" width="100" height="100" patternUnits="userSpaceOnUse"><circle cx="25" cy="25" r="0.5" fill="%23f5f5f5" opacity="0.3"/><circle cx="75" cy="75" r="0.3" fill="%23f0f0f0" opacity="0.2"/><circle cx="15" cy="85" r="0.4" fill="%23f8f8f8" opacity="0.25"/><circle cx="85" cy="15" r="0.2" fill="%23ebebeb" opacity="0.3"/><path d="M0 0L200 200M200 0L0 200" stroke="%23f2f2f2" stroke-width="0.3" fill="none" opacity="0.15"/></pattern></defs><rect width="200" height="200" fill="url(%23grain)"/></svg>');
|
||||
opacity: 0.4;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
// 加载状态样式
|
||||
.loading-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 60vh;
|
||||
padding: 40rpx;
|
||||
|
||||
.loading-spinner {
|
||||
width: 50rpx;
|
||||
height: 50rpx;
|
||||
border: 4rpx solid #f3f3f3;
|
||||
border-top: 4rpx solid #6c8ebf;
|
||||
border-radius: 50%;
|
||||
animation: spin 1s linear infinite;
|
||||
margin-bottom: 24rpx;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
0% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
|
||||
100% {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
|
||||
// 空状态样式
|
||||
.empty-state {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-height: 60vh;
|
||||
padding: 40rpx;
|
||||
text-align: center;
|
||||
|
||||
.empty-icon {
|
||||
font-size: 120rpx;
|
||||
margin-bottom: 32rpx;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
.empty-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: 600;
|
||||
color: #4e5969;
|
||||
margin-bottom: 16rpx;
|
||||
}
|
||||
|
||||
.empty-desc {
|
||||
font-size: 24rpx;
|
||||
color: #8492a6;
|
||||
margin-bottom: 40rpx;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.empty-button {
|
||||
width: 200rpx;
|
||||
height: 70rpx;
|
||||
line-height: 70rpx;
|
||||
background-color: #6c8ebf;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 35rpx;
|
||||
font-size: 26rpx;
|
||||
font-weight: 500;
|
||||
box-shadow: 0 2rpx 8rpx rgba(108, 142, 191, 0.3);
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background-color: #5a78a8;
|
||||
transform: translateY(-2rpx);
|
||||
box-shadow: 0 4rpx 12rpx rgba(108, 142, 191, 0.4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
::v-deep .mescroll-totop {
|
||||
right: 27rpx !important;
|
||||
bottom: 120rpx !important;
|
||||
}
|
||||
</style>
|
||||
@@ -10,8 +10,7 @@
|
||||
</view>
|
||||
|
||||
<!-- 消息列表 -->
|
||||
<view v-for="(message, index) in messages" :key="`msg-${message.id || message.timestamp}-${index}`"
|
||||
class="message-item" :class="[message.role, { 'first-message': index === 0 }]">
|
||||
<view v-for="item in messagesWithKey" :key="item.__renderKey" class="message-item" :class="[item.role, { 'first-message': item.__index === 0 }]">
|
||||
|
||||
<!-- 用户消息 -->
|
||||
<view v-if="message.role === 'user'" class="user-message">
|
||||
@@ -392,6 +391,19 @@ export default {
|
||||
isFetchingHistory: false
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
// 为每条消息生成兼容小程序的唯一 key
|
||||
messagesWithKey() {
|
||||
return this.messages.map((msg, idx) => {
|
||||
const uniqueId = msg.id || msg.timestamp || idx;
|
||||
return {
|
||||
...msg,
|
||||
__renderKey: `msg_${uniqueId}_${idx}`,
|
||||
__index: idx // 保留原始索引,用于判断 first-message 等
|
||||
};
|
||||
});
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
// 优先读取本地缓存的会话 ID
|
||||
const localConvId = this.getConversationIdFromLocal();
|
||||
|
||||
@@ -1,172 +1,156 @@
|
||||
<template>
|
||||
<view class="page" :style="themeColor">
|
||||
<view class="help-title">{{ detail.article_title }}</view>
|
||||
<view class="help-meta" v-if="detail.is_show_release_time == 1">
|
||||
<text class="help-time">发表时间: {{ $util.timeStampTurnTime(detail.create_time) }}</text>
|
||||
</view>
|
||||
<view class="help-content"><rich-text :nodes="content"></rich-text></view>
|
||||
<view class="bottom-area">
|
||||
<view v-if="detail.is_show_read_num == 1">
|
||||
阅读:
|
||||
<text class="price-font">{{ detail.read_num + detail.initial_read_num }}</text>
|
||||
</view>
|
||||
<view v-if="detail.is_show_dianzan_num == 1">
|
||||
<text class="price-font">{{ detail.dianzan_num + detail.initial_dianzan_num }}</text>
|
||||
人已赞
|
||||
</view>
|
||||
</view>
|
||||
<loading-cover ref="loadingCover"></loading-cover>
|
||||
<view class="page" :style="themeColor">
|
||||
<view class="help-title">{{ detail.article_title }}</view>
|
||||
<view class="help-meta" v-if="detail.is_show_release_time == 1">
|
||||
<text class="help-time">发表时间: {{ $util.timeStampTurnTime(detail.create_time) }}</text>
|
||||
</view>
|
||||
<view class="help-content"><rich-text :nodes="content"></rich-text></view>
|
||||
<view class="bottom-area">
|
||||
<view v-if="detail.is_show_read_num == 1">
|
||||
阅读:
|
||||
<text class="price-font">{{ detail.read_num + detail.initial_read_num }}</text>
|
||||
</view>
|
||||
<view v-if="detail.is_show_dianzan_num == 1">
|
||||
<text class="price-font">{{ detail.dianzan_num + detail.initial_dianzan_num }}</text>
|
||||
人已赞
|
||||
</view>
|
||||
</view>
|
||||
<loading-cover ref="loadingCover"></loading-cover>
|
||||
|
||||
<!-- 隐私弹窗 -->
|
||||
<privacy-popup ref="privacyPopup"></privacy-popup>
|
||||
|
||||
|
||||
<view class="page-bottom" v-if="openBottomNav">
|
||||
<diy-bottom-nav @callback="callback" :name="name" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 隐私弹窗 -->
|
||||
<privacy-popup ref="privacyPopup"></privacy-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import htmlParser from '@/common/js/html-parser';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
articleId: 0,
|
||||
detail: {},
|
||||
content: '',
|
||||
openBottomNav: true,
|
||||
name: 'article'
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
this.articleId = options.article_id || 0;
|
||||
// 小程序扫码进入
|
||||
if (options.scene) {
|
||||
var sceneParams = decodeURIComponent(options.scene);
|
||||
this.articleId = sceneParams.split('-')[1];
|
||||
}
|
||||
if (this.articleId == 0) {
|
||||
this.$util.redirectTo('/pages_tool/article/list', {}, 'redirectTo');
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.getData();
|
||||
},
|
||||
methods: {
|
||||
getData() {
|
||||
this.$api.sendRequest({
|
||||
url: '/api/article/info',
|
||||
data: {
|
||||
article_id: this.articleId
|
||||
},
|
||||
success: res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
this.detail = res.data;
|
||||
this.$langConfig.title(this.detail.article_title);
|
||||
this.content = htmlParser(this.detail.article_content);
|
||||
this.setPublicShare();
|
||||
} else {
|
||||
this.$util.showToast({
|
||||
title: res.message
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.$util.redirectTo('/pages_tool/article/list', {}, 'redirectTo');
|
||||
}, 2000);
|
||||
}
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
},
|
||||
fail: res => {
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 设置公众号分享
|
||||
setPublicShare() {
|
||||
let shareUrl = this.$config.h5Domain + '/pages_tool/article/detail?article_id=' + this.articleId;
|
||||
this.$util.setPublicShare({
|
||||
title: this.detail.article_title,
|
||||
desc: '',
|
||||
link: shareUrl,
|
||||
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) : ''
|
||||
});
|
||||
},
|
||||
callback(data) {
|
||||
}
|
||||
},
|
||||
onShareAppMessage(res) {
|
||||
var title = this.detail.article_title;
|
||||
var path = '/pages_tool/article/detail?article_id=' + this.articleId;
|
||||
return {
|
||||
title: title,
|
||||
path: path,
|
||||
success: res => {},
|
||||
fail: res => {}
|
||||
};
|
||||
},
|
||||
// 分享到朋友圈
|
||||
onShareTimeline() {
|
||||
var title = this.detail.article_title;
|
||||
var query = 'article_id=' + this.articleId;
|
||||
return {
|
||||
title: title,
|
||||
query: query,
|
||||
imageUrl: ''
|
||||
};
|
||||
}
|
||||
};
|
||||
import htmlParser from '@/common/js/html-parser';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
articleId: 0,
|
||||
detail: {},
|
||||
content: ''
|
||||
};
|
||||
},
|
||||
onLoad(options) {
|
||||
this.articleId = options.article_id || 0;
|
||||
// 小程序扫码进入
|
||||
if (options.scene) {
|
||||
var sceneParams = decodeURIComponent(options.scene);
|
||||
this.articleId = sceneParams.split('-')[1];
|
||||
}
|
||||
if (this.articleId == 0) {
|
||||
this.$util.redirectTo('/pages_tool/article/list', {}, 'redirectTo');
|
||||
}
|
||||
},
|
||||
onShow() {
|
||||
this.getData();
|
||||
},
|
||||
methods: {
|
||||
getData() {
|
||||
this.$api.sendRequest({
|
||||
url: '/api/article/info',
|
||||
data: {
|
||||
article_id: this.articleId
|
||||
},
|
||||
success: res => {
|
||||
if (res.code == 0 && res.data) {
|
||||
this.detail = res.data;
|
||||
this.$langConfig.title(this.detail.article_title);
|
||||
this.content = htmlParser(this.detail.article_content);
|
||||
this.setPublicShare();
|
||||
} else {
|
||||
this.$util.showToast({
|
||||
title: res.message
|
||||
});
|
||||
setTimeout(() => {
|
||||
this.$util.redirectTo('/pages_tool/article/list', {}, 'redirectTo');
|
||||
}, 2000);
|
||||
}
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
},
|
||||
fail: res => {
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
// 设置公众号分享
|
||||
setPublicShare() {
|
||||
let shareUrl = this.$config.h5Domain + '/pages_tool/article/detail?article_id=' + this.articleId;
|
||||
this.$util.setPublicShare({
|
||||
title: this.detail.article_title,
|
||||
desc: '',
|
||||
link: shareUrl,
|
||||
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) : ''
|
||||
});
|
||||
}
|
||||
},
|
||||
onShareAppMessage(res) {
|
||||
var title = this.detail.article_title;
|
||||
var path = '/pages_tool/article/detail?article_id=' + this.articleId;
|
||||
return {
|
||||
title: title,
|
||||
path: path,
|
||||
success: res => {},
|
||||
fail: res => {}
|
||||
};
|
||||
},
|
||||
//分享到朋友圈
|
||||
onShareTimeline() {
|
||||
var title = this.detail.article_title;
|
||||
var query = 'article_id=' + this.articleId;
|
||||
return {
|
||||
title: title,
|
||||
query: query,
|
||||
imageUrl: ''
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
.page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
}
|
||||
.page {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
padding: 30rpx;
|
||||
box-sizing: border-box;
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.help-title {
|
||||
font-size: $font-size-toolbar;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
}
|
||||
.help-title {
|
||||
font-size: $font-size-toolbar;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.help-content {
|
||||
margin-top: $margin-updown;
|
||||
word-break: break-all;
|
||||
}
|
||||
.help-content {
|
||||
margin-top: $margin-updown;
|
||||
word-break: break-all;
|
||||
}
|
||||
|
||||
.help-meta {
|
||||
text-align: left;
|
||||
margin-top: $margin-updown;
|
||||
color: $color-tip;
|
||||
.help-meta {
|
||||
text-align: left;
|
||||
margin-top: $margin-updown;
|
||||
color: $color-tip;
|
||||
|
||||
.help-time {
|
||||
font-size: $font-size-tag;
|
||||
}
|
||||
}
|
||||
.help-time {
|
||||
font-size: $font-size-tag;
|
||||
}
|
||||
}
|
||||
|
||||
.bottom-area {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 40rpx;
|
||||
.bottom-area {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-top: 40rpx;
|
||||
|
||||
.price-font {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
.price-font {
|
||||
font-weight: normal !important;
|
||||
}
|
||||
|
||||
view {
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
.page-bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 999;
|
||||
}
|
||||
view {
|
||||
color: #999;
|
||||
font-size: 24rpx;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,243 +1,215 @@
|
||||
<template>
|
||||
<view :style="themeColor">
|
||||
<!-- 主内容区域 -->
|
||||
<view
|
||||
class="page-img"
|
||||
:style="{
|
||||
backgroundColor: bgColor,
|
||||
minHeight: openBottomNav ? 'calc(100vh - 55px)' : '100vh'
|
||||
}"
|
||||
>
|
||||
<mescroll-uni @getData="getData" ref="mescroll">
|
||||
<block slot="list">
|
||||
<view class="article-wrap" v-if="list.length">
|
||||
<ns-adv keyword="NS_ARTICLE" class-name="adv-wrap"></ns-adv>
|
||||
<view class="item" v-for="(item, index) in list" :key="index" @click="toDetail(item)">
|
||||
<view class="article-img">
|
||||
<image
|
||||
class="cover-img"
|
||||
:src="$util.img(item.cover_img)"
|
||||
mode="widthFix"
|
||||
@error="imgError(index)"
|
||||
/>
|
||||
</view>
|
||||
<view class="info-wrap">
|
||||
<text class="title">{{ item.article_title }}</text>
|
||||
<view class="read-wrap">
|
||||
<block v-if="item.category_name">
|
||||
<text class="category-icon"></text>
|
||||
<text>{{ item.category_name }}</text>
|
||||
</block>
|
||||
<text class="date">{{ $util.timeStampTurnTime(item.create_time, 'date') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty-wrap">
|
||||
<ns-empty text="暂无文章" :isIndex="false"></ns-empty>
|
||||
</view>
|
||||
<loading-cover ref="loadingCover"></loading-cover>
|
||||
</block>
|
||||
</mescroll-uni>
|
||||
<view :style="themeColor">
|
||||
<mescroll-uni @getData="getData" ref="mescroll">
|
||||
<block slot="list">
|
||||
<view class="article-wrap" v-if="list.length">
|
||||
<ns-adv keyword="NS_ARTICLE" class-name="adv-wrap"></ns-adv>
|
||||
<view class="item" v-for="(item, index) in list" :key="index" @click="toDetail(item)">
|
||||
<view class="article-img">
|
||||
<image class="cover-img" :src="$util.img(item.cover_img)" mode="widthFix"
|
||||
@error="imgError(index)" />
|
||||
</view>
|
||||
<view class="info-wrap">
|
||||
<text class="title">{{ item.article_title }}</text>
|
||||
<view class="read-wrap">
|
||||
<block v-if="item.category_name">
|
||||
<text class="category-icon"></text>
|
||||
<text>{{ item.category_name }}</text>
|
||||
</block>
|
||||
<text class="date">{{ $util.timeStampTurnTime(item.create_time, 'date') }}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view v-else class="empty-wrap"><ns-empty text="暂无文章" :isIndex="false"></ns-empty></view>
|
||||
<loading-cover ref="loadingCover"></loading-cover>
|
||||
</block>
|
||||
</mescroll-uni>
|
||||
|
||||
<!-- 隐私弹窗 -->
|
||||
<privacy-popup ref="privacyPopup"></privacy-popup>
|
||||
</view>
|
||||
<view class="page-bottom" v-if="openBottomNav">
|
||||
<diy-bottom-nav @callback="callback" :name="name" />
|
||||
</view>
|
||||
</view>
|
||||
<!-- 隐私弹窗 -->
|
||||
<privacy-popup ref="privacyPopup"></privacy-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
list: [],
|
||||
|
||||
openBottomNav: true,
|
||||
name: 'article',
|
||||
bgColor: '#ffffff'
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.setPublicShare();
|
||||
},
|
||||
methods: {
|
||||
getData(mescroll) {
|
||||
this.$api.sendRequest({
|
||||
url: '/api/article/page',
|
||||
data: {
|
||||
page_size: mescroll.size,
|
||||
page: mescroll.num
|
||||
},
|
||||
success: res => {
|
||||
let newArr = [];
|
||||
let msg = res.message;
|
||||
if (res.code == 0 && res.data) {
|
||||
newArr = res.data.list;
|
||||
} else {
|
||||
this.$util.showToast({
|
||||
title: msg
|
||||
});
|
||||
}
|
||||
mescroll.endSuccess(newArr.length);
|
||||
if (mescroll.num == 1) this.list = [];
|
||||
this.list = this.list.concat(newArr);
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
},
|
||||
fail: res => {
|
||||
mescroll.endErr();
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
toDetail(item) {
|
||||
this.$util.redirectTo('/pages_tool/article/detail', {
|
||||
article_id: item.article_id
|
||||
});
|
||||
},
|
||||
imgError(index) {
|
||||
if (this.list[index]) this.list[index].cover_img = this.$util.getDefaultImage().article;
|
||||
},
|
||||
setPublicShare() {
|
||||
let shareUrl = this.$config.h5Domain + '/pages_tool/article/list';
|
||||
this.$util.setPublicShare({
|
||||
title: '新闻',
|
||||
desc: '',
|
||||
link: shareUrl,
|
||||
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) : ''
|
||||
});
|
||||
},
|
||||
callback(data) {
|
||||
}
|
||||
},
|
||||
onShareAppMessage(res) {
|
||||
var title = '新闻';
|
||||
var path = '/pages_tool/article/list';
|
||||
return {
|
||||
title: title,
|
||||
path: path,
|
||||
success: res => {},
|
||||
fail: res => {}
|
||||
};
|
||||
},
|
||||
onShareTimeline() {
|
||||
var title = '新闻';
|
||||
var query = '/pages_tool/article/list';
|
||||
return {
|
||||
title: title,
|
||||
query: query,
|
||||
imageUrl: ''
|
||||
};
|
||||
}
|
||||
data() {
|
||||
return {
|
||||
list: []
|
||||
};
|
||||
},
|
||||
onShow() {
|
||||
this.setPublicShare();
|
||||
},
|
||||
methods: {
|
||||
getData(mescroll) {
|
||||
this.$api.sendRequest({
|
||||
url: '/api/article/page',
|
||||
data: {
|
||||
page_size: mescroll.size,
|
||||
page: mescroll.num
|
||||
},
|
||||
success: res => {
|
||||
let newArr = [];
|
||||
let msg = res.message;
|
||||
if (res.code == 0 && res.data) {
|
||||
newArr = res.data.list;
|
||||
} else {
|
||||
this.$util.showToast({
|
||||
title: msg
|
||||
});
|
||||
}
|
||||
mescroll.endSuccess(newArr.length);
|
||||
//设置列表数据
|
||||
if (mescroll.num == 1) this.list = []; //如果是第一页需手动制空列表
|
||||
this.list = this.list.concat(newArr); //追加新数据
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
},
|
||||
fail: res => {
|
||||
mescroll.endErr();
|
||||
if (this.$refs.loadingCover) this.$refs.loadingCover.hide();
|
||||
}
|
||||
});
|
||||
},
|
||||
toDetail(item) {
|
||||
this.$util.redirectTo('/pages_tool/article/detail', {
|
||||
article_id: item.article_id
|
||||
});
|
||||
},
|
||||
imgError(index) {
|
||||
if (this.list[index]) this.list[index].cover_img = this.$util.getDefaultImage().article;
|
||||
},
|
||||
// 设置公众号分享
|
||||
setPublicShare() {
|
||||
let shareUrl = this.$config.h5Domain + '/pages_tool/article/list';
|
||||
this.$util.setPublicShare({
|
||||
title: '文章列表',
|
||||
desc: '',
|
||||
link: shareUrl,
|
||||
imgUrl: this.siteInfo ? this.$util.img(this.siteInfo.logo_square) : ''
|
||||
});
|
||||
}
|
||||
},
|
||||
onShareAppMessage(res) {
|
||||
var title = '文章列表';
|
||||
var path = '/pages_tool/article/list';
|
||||
return {
|
||||
title: title,
|
||||
path: path,
|
||||
success: res => { },
|
||||
fail: res => { }
|
||||
};
|
||||
},
|
||||
//分享到朋友圈
|
||||
onShareTimeline() {
|
||||
var title = '文章列表';
|
||||
var query = '/pages_tool/article/list';
|
||||
return {
|
||||
title: title,
|
||||
query: query,
|
||||
imageUrl: ''
|
||||
};
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .fixed {
|
||||
position: relative;
|
||||
top: 0;
|
||||
position: relative;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
.empty-wrap {
|
||||
padding-top: 200rpx;
|
||||
padding-top: 200rpx;
|
||||
}
|
||||
|
||||
.article-wrap {
|
||||
background: #f8f8f8;
|
||||
background: #f8f8f8;
|
||||
|
||||
.adv-wrap {
|
||||
margin: 24rpx 24rpx 0 24rpx;
|
||||
width: auto;
|
||||
}
|
||||
.adv-wrap {
|
||||
margin: 24rpx 24rpx 0 24rpx;
|
||||
width: auto;
|
||||
}
|
||||
|
||||
.item {
|
||||
display: flex;
|
||||
padding: 20rpx;
|
||||
background-color: #fff;
|
||||
margin: 24rpx;
|
||||
border-radius: 16rpx;
|
||||
.item {
|
||||
display: flex;
|
||||
padding: 20rpx;
|
||||
background-color: #fff;
|
||||
margin: 24rpx;
|
||||
border-radius: 16rpx;
|
||||
|
||||
.article-img {
|
||||
margin-right: 20rpx;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
.article-img {
|
||||
margin-right: 20rpx;
|
||||
width: 160rpx;
|
||||
height: 160rpx;
|
||||
overflow: hidden;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
image {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
image {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
.info-wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
.info-wrap {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-between;
|
||||
|
||||
.title {
|
||||
font-weight: bold;
|
||||
margin-bottom: 10rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
font-size: 30rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
.title {
|
||||
font-weight: bold;
|
||||
margin-bottom: 10rpx;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
font-size: 30rpx;
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
.abstract {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
font-size: $font-size-tag;
|
||||
}
|
||||
.abstract {
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 2;
|
||||
-webkit-box-orient: vertical;
|
||||
font-size: $font-size-tag;
|
||||
}
|
||||
|
||||
.read-wrap {
|
||||
display: flex;
|
||||
color: #999ca7;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
margin-top: 10rpx;
|
||||
line-height: 1;
|
||||
.read-wrap {
|
||||
display: flex;
|
||||
color: #999ca7;
|
||||
justify-content: flex-start;
|
||||
align-items: center;
|
||||
margin-top: 10rpx;
|
||||
line-height: 1;
|
||||
|
||||
text {
|
||||
font-size: $font-size-tag;
|
||||
}
|
||||
text {
|
||||
font-size: $font-size-tag;
|
||||
}
|
||||
|
||||
.iconfont {
|
||||
font-size: 36rpx;
|
||||
vertical-align: bottom;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.iconfont {
|
||||
font-size: 36rpx;
|
||||
vertical-align: bottom;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.category-icon {
|
||||
width: 8rpx;
|
||||
height: 8rpx;
|
||||
border-radius: 50%;
|
||||
background: $base-color;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
.category-icon {
|
||||
width: 8rpx;
|
||||
height: 8rpx;
|
||||
border-radius: 50%;
|
||||
background: $base-color;
|
||||
margin-right: 10rpx;
|
||||
}
|
||||
|
||||
.date {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
.page-bottom {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
z-index: 999;
|
||||
.date {
|
||||
margin-left: 20rpx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1,12 +1,13 @@
|
||||
{
|
||||
"description": "项目配置文件",
|
||||
"packOptions": {
|
||||
"ignore": []
|
||||
"ignore": [],
|
||||
"include": []
|
||||
},
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
"es6": true,
|
||||
"enhance": false,
|
||||
"enhance": true,
|
||||
"postcss": true,
|
||||
"preloadBackgroundData": false,
|
||||
"minified": true,
|
||||
@@ -37,7 +38,15 @@
|
||||
"userConfirmedBundleSwitch": false,
|
||||
"packNpmManually": false,
|
||||
"packNpmRelationList": [],
|
||||
"minifyWXSS": true
|
||||
"minifyWXSS": true,
|
||||
"condition": true,
|
||||
"swc": false,
|
||||
"disableSWC": true,
|
||||
"minifyWXML": true,
|
||||
"compileWorklet": true,
|
||||
"localPlugins": false,
|
||||
"disableUseStrict": false,
|
||||
"useCompilerPlugins": false
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.16.1",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"libVersion": "3.12.0",
|
||||
"projectname": "lucky_shop",
|
||||
"projectname": "mp-weixin",
|
||||
"condition": {},
|
||||
"setting": {
|
||||
"urlCheck": true,
|
||||
|
||||
@@ -9,7 +9,10 @@
|
||||
* 如果这个文件开头已经有了这行代码,则不追加
|
||||
*
|
||||
* 使用:
|
||||
* node fix-wechat-miniapp.js
|
||||
* node fix-wechat-miniapp.js # 打补丁并创建 ZIP 文件(默认 mode=production)
|
||||
* node fix-wechat-miniapp.js --no-zip # 只打补丁,不创建 ZIP 文件
|
||||
* node fix-wechat-miniapp.js --mode development # 使用 development 模式打补丁
|
||||
* node fix-wechat-miniapp.js --mode production # 使用 production 模式打补丁(默认)
|
||||
*
|
||||
* 注意:
|
||||
* - 在 Windows 上路径使用反斜杠也是可以的;脚本使用 path.join 来兼容不同平台。
|
||||
@@ -29,8 +32,6 @@ async function commonPatch(mode = 'production') {
|
||||
// 根据当前脚本所在目录(scripts),定位到项目根目录
|
||||
const cwd = path.join(__dirname, '..');
|
||||
|
||||
|
||||
|
||||
const srcSitePath = path.join(cwd, 'site.js');
|
||||
const destDir = path.join(cwd, 'unpackage', 'dist', mode === 'production' ? 'build' : 'dev', 'mp-weixin');
|
||||
const destSitePath = path.join(destDir, 'site.js');
|
||||
@@ -47,6 +48,22 @@ async function commonPatch(mode = 'production') {
|
||||
// 确保目标目录存在
|
||||
await ensureDir(destDir);
|
||||
|
||||
// 复制 project.config.json 及 project.private.config.json 文件到 destDir 下面
|
||||
const configFiles = ['project.config.json', 'project.private.config.json'];
|
||||
for (const fileName of configFiles) {
|
||||
const srcPath = path.join(cwd, fileName);
|
||||
const destPath = path.join(destDir, fileName);
|
||||
|
||||
// 检查源文件是否存在
|
||||
const fileExists = await exists(srcPath);
|
||||
if (fileExists) {
|
||||
await fsp.copyFile(srcPath, destPath);
|
||||
console.log(`已拷贝: ${srcPath} -> ${destPath}`);
|
||||
} else {
|
||||
console.warn(`源文件不存在,跳过复制: ${srcPath}`);
|
||||
}
|
||||
}
|
||||
|
||||
// 复制 site.js 到目标目录(覆盖)
|
||||
await fsp.copyFile(srcSitePath, destSitePath);
|
||||
console.log(`已拷贝: ${srcSitePath} -> ${destSitePath}`);
|
||||
@@ -96,22 +113,37 @@ async function commonPatch(mode = 'production') {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function main() {
|
||||
// 解析命令行参数
|
||||
const argv = process.argv.slice(2);
|
||||
const options = {
|
||||
noZip: argv.includes('--no-zip'),
|
||||
mode: 'production' // 默认值
|
||||
};
|
||||
|
||||
// 解析 --mode 参数
|
||||
const modeIndex = argv.indexOf('--mode');
|
||||
if (modeIndex !== -1 && modeIndex + 1 < argv.length) {
|
||||
options.mode = argv[modeIndex + 1];
|
||||
}
|
||||
|
||||
// 1) 打补丁
|
||||
await commonPatch('production');
|
||||
await commonPatch(options.mode);
|
||||
// await commonPatch('development');
|
||||
|
||||
// 2) 创建 ZIP 文件
|
||||
const cwd = path.join(__dirname, '..');
|
||||
const sourceDir = path.join(cwd, 'unpackage', 'dist', 'build', 'mp-weixin');
|
||||
const destDir = path.join(cwd, 'unpackage', 'dist', 'build');
|
||||
const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir);
|
||||
console.log(`ZIP 文件路径: ${zipFilePath}`);
|
||||
// 2) 创建 ZIP 文件(如果未指定 --no-zip)
|
||||
if (!options.noZip) {
|
||||
const cwd = path.join(__dirname, '..');
|
||||
const sourceDir = path.join(cwd, 'unpackage', 'dist', 'build', 'mp-weixin');
|
||||
const destDir = path.join(cwd, 'unpackage', 'dist', 'build');
|
||||
const zipFilePath = await createZipWithSystemCommand(sourceDir, destDir);
|
||||
console.log(`ZIP 文件路径: ${zipFilePath}`);
|
||||
|
||||
// 3) 自动打开zip所在的目录
|
||||
await openFileDirectory(zipFilePath);
|
||||
// 3) 自动打开zip所在的目录
|
||||
await openFileDirectory(zipFilePath);
|
||||
} else {
|
||||
console.log('跳过创建 ZIP 文件和打开目录');
|
||||
}
|
||||
}
|
||||
|
||||
async function exists(p) {
|
||||
|
||||
Reference in New Issue
Block a user