This commit is contained in:
王鹏
2025-08-14 14:52:01 +08:00
commit 0c2edb6036
1551 changed files with 41152 additions and 0 deletions

View File

@@ -0,0 +1,162 @@
import articleApi from "../../../api/articleApi"
import userArticleApi from '../../../api/userArticleApi'
import Dialog from '@vant/weapp/dialog/dialog';
import clientConfig from "../../../config/index"
import tool from "../../../utils/tool"
let rewardedVideoAd = null
Page({
previewImage(e) {
const url = e.currentTarget.dataset.url;
wx.previewImage({
current: url,
urls: [url]
});
},
data: {
article: {},
downloaded: false,
collectioned: false
},
goback() {
const pages = getCurrentPages();
if (pages.length > 1) {
wx.navigateBack(1)
} else {
wx.switchTab({
url: '/pages/tabpages/index/index'
})
}
},
handleCollection() {
let param = {
id: this.data.article.id
}
userArticleApi.addUserArticleCollection(param).then(res => {
if (res.code === 200) {
this.setData({
collectioned: !this.data.collectioned
})
wx.showToast({
title: res.msg,
icon: 'none'
})
}
})
},
handleDownloadNoAd() {
// 复制到剪贴板
wx.setClipboardData({
data: this.data.article.attachmentUrl,
success: function (res) {
wx.showToast({
title: '已复制到剪贴板',
icon: 'none'
})
}
})
},
handleDownloadHasAd() {
let _this = this;
wx.showModal({
title: '温馨提示',
content: '为了持续维护小程序,为大家更新更多优质项目源码。领取免费资料时需要看小广告,即可获取。',
confirmText: '可以理解', // 自定义确认按钮文本
cancelText: '残忍拒绝', // 自定义取消按钮文本
success: function (res) {
if (res.confirm) {
console.log('用户点击确定执行');
_this.openVideoAd();
} else if (res.cancel) {
console.log('用户点击取消操作');
}
}
});
},
onShareAppMessage() {
var that = this;
return {
title: that.article.title,
path: `pages/subpages/articledetail/articledetail?id=${that.article.id}`,
imageUrl: that.article.cover
}
},
openVideoAd() {
if (rewardedVideoAd) {
rewardedVideoAd.show().then(() => {}).catch(() => {
// 失败重试
rewardedVideoAd.load().then(() => rewardedVideoAd.show()).catch(err => {
console.log('激励视频 广告显示失败')
})
})
}
},
onLoad(options) {
// const userId = tool.data.get('USER_INFO').id
let id = options.id
articleApi.detail({
id
}).then(res => {
// res.data.tags = JSON.parse(res.data.tags)
res.data.cover = res.data.fileList[0].fileUrl
this.setData({
article: res.data
})
// if (res.data.downloadUserIds) {
// const downloadUserIds = res.data.downloadUserIds.split(',')
// if (downloadUserIds.includes(userId)) {
// this.setData({downloaded: true})
// // 获取下载链接
// articleApi.getDownLoadLink({id: this.data.article.id}).then(res=>{
// this.setData({
// 'article.link': res.data
// })
// })
// }
// }
if (res.data.collectionUserIds) {
const collectionUserIds = res.data.collectionUserIds.split(',')
if (collectionUserIds.includes(userId)) {
this.setData({
collectioned: true
})
}
}
if(wx.createRewardedVideoAd){
rewardedVideoAd = wx.createRewardedVideoAd({ adUnitId: 'adunit-448866eb135432e9' })
rewardedVideoAd.onLoad(() => {
console.log('onLoad event emit')
})
rewardedVideoAd.onError((err) => {
console.log('onError event emit', err)
})
rewardedVideoAd.onClose((res) => {
if (res && res.isEnded || res === undefined) {
// 复制到剪贴板
wx.setClipboardData({
data: this.data.article.attachmentUrl,
success: function (res) {
wx.showToast({
title: '已复制到剪贴板',
icon: 'none'
})
}
})
} else {
//不下发奖励
}
})
}
})
}
})

View File

@@ -0,0 +1,10 @@
{
"usingComponents": {
"van-nav-bar": "@vant/weapp/nav-bar/index",
"van-tag": "@vant/weapp/tag/index",
"van-divider": "@vant/weapp/divider/index",
"van-dialog": "@vant/weapp/dialog/index",
"van-sticky": "@vant/weapp/sticky/index"
},
"navigationStyle": "custom"
}

View File

@@ -0,0 +1,69 @@
<van-sticky>
<van-nav-bar
title="资源详情"
left-text="返回"
left-arrow
bind:click-left="goback"
/>
</van-sticky>
<view class="card-blank content">
<!-- <view class="shopcard_content_auth">
<text wx:if="{{article.category == 2}}" style="color: #07C160;">免费
</text>
<text wx:if="{{article.category == 1}}" style="color: #d40909;">付费
</text>
<text wx:else style="color: #E7406B;">{{ data.needScore }} 积分</text>
</view> -->
<image class="cover-image" mode="widthFix" style="width: 100%; height: 200rpx; margin: 10px 0;" src="{{article.cover}}"/>
<!-- 标签区域注释块需要正确闭合 -->
<!-- <view class="tags">
<text>适用:</text>
<van-tag plain type="primary" wx:for="{{ article.tags }}" wx:key="index">
{{ item }}
</van-tag>
</view> -->
<view class="title">{{article.title}}</view>
<van-divider />
<text wx:if="{{article.link}}" class="downloadLink" user-select>链接:{{article.link}}</text>
<van-divider wx:if="{{article.link}}" />
<video wx:if="{{article.video}}" id="myVideo" src='{{article.video}}' controls></video>
<van-divider wx:if="{{article.video}}" />
<!-- 富文本 -->
<rich-text style="line-height: 23px;" nodes="{{article.content}}" />
<view wx:if="{{article.fileList}}" class="screenshot-container">
<view class="screenshot-title">### 项目截图</view>
<view wx:for="{{article.fileList}}" wx:key="index" class="file-item">
<text class="file-index">{{index + 1}}. </text>
<text class="file-name" style="font-size: 12px; ">{{item.fileName}}</text>
<image class="file-image" src="{{item.fileUrl}}" mode="widthFix" style="width: 100%; height: 200rpx; margin: 10px 0;" bindtap="previewImage" data-url="{{item.fileUrl}}"/>
</view>
</view>
<van-divider />
<text class="note">项目价格¥99包含源码 + 远程部署 + 项目问题答疑等服务</text>
<text class="node1">购买源码或者代码定制需求请长按二维码添加微信forfeastcoding备注小程序</text>
<image class="qrcode" src="../../../static/tabbar/qrcode.jpg" show-menu-by-longpress="true"></image>
</view>
<view wx:if="{{!downloaded}}" class="article-action">
<!-- <view class="collection" bindtap="handleCollection">
<van-icon color="{{collectioned?'#FFD252':''}}" name="{{collectioned?'star':'star-o'}}" />
<text>收藏</text>
</view> -->
<button class="share-btn" size="mini" open-type="share" plain="true">
<van-icon name="guide-o" />
<text>分享</text>
</button >
<!-- <view wx:if="{{article.category == 2}}" class="download" bindtap="handleDownloadHasAd">
<van-button type="primary" round size="small">立即获取</van-button>
</view>
<view wx:if="{{article.category == 1}}" class="download" bindtap="handleDownloadNoAd">
<van-button type="primary" round size="small">立即获取</van-button>
</view> -->
</view>
<van-dialog id="van-dialog" />

View File

@@ -0,0 +1,123 @@
page{
background-color: #fff;
position: relative;
}
.card-blank{
padding: 12px;
}
.title{
font-size: 20px;
font-weight: bold;
margin-bottom: 16px;
display: block;
width: 100%;
height: auto;
margin: 0 auto;
}
.tags{
font-size: 12px;
color: #888;
display: flex;
gap: 6px;
}
.totalPoint{
color: red;
}
.totalPoint text{
font-size: 20px;
}
.van-goods-action{
width: 300px;
margin: auto;
}
.content{
padding-bottom: 23%;
}
.article-action{
padding: 10px 0 15px 0;
width: 100%;
position: fixed;
background-color: #fff;
bottom: 0;
display: flex;
align-items: flex-end;
font-size: 10px;
color: #707070;
justify-content: space-around;
}
.article-action>view{
display: flex;
flex-direction: column;
}
.article-action van-icon{
font-size: 22px;
}
button.share-btn {
border: none;
/* 可以添加其他样式,如背景色、字体大小等 */
background-color: none;
font-size: 17px;
}
.download .van-button{
width: 140px;
height: 36px;
font-size: 16px;
right: 30px;
}
.needScore{
font-size: 14px;
flex-direction: row!important;
align-items: flex-end;
}
.needScore .score{
font-weight: bold;
line-height: 23px;
color: red;
margin-left: 10px;
font-size: 22px;
}
.downloadLink{
display: block;
padding: 10px;
background-color:#F0F0F0;
border-radius: 4px;
}
.note{
display: block;
font-size: 12px;
color: rgb(6, 80, 240);
}
.node1{
margin-top: 15px;
font-size: 12px;
color: rgb(252, 7, 7);
display: block;
text-align: center;
}
.qrcode{
margin: 10px auto 0 auto;
height: 150px;
width: 150px;
display: flex;
justify-content: center;
}
#myVideo{
display: block;
width: 100%;
height: 190px;
}
.screenshot-title {
font-weight: 1000;
margin-top: 5px;
margin-bottom: 5px;
}