Skip to content

Commit 50db251

Browse files
添加领取指南
1 parent b162f26 commit 50db251

File tree

7 files changed

+184
-19
lines changed

7 files changed

+184
-19
lines changed

pages.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
{
88
"path": "pages/index/index",
99
"style": {
10-
10+
"navigationBarTitleText": "元气封面"
1111
}
1212
}, {
1313
"path": "pages/user/user",
@@ -26,6 +26,15 @@
2626
}
2727

2828
}
29+
,{
30+
"path" : "pages/linkOthers/linkOthers",
31+
"style" :
32+
{
33+
"navigationBarTitleText": "公众号",
34+
"enablePullDownRefresh": false
35+
}
36+
37+
}
2938
],
3039
"tabBar": {
3140
"backgroundColor": "#F7F7FA",

pages/detail/detail.vue

+82-15
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,34 @@
3434
</button>
3535
</view>
3636
<view class="func" v-if="num <= 0">
37+
<button plain class="func-btn error" v-if="coverDetail.inviteLockNum > 0">
38+
<image src="/static/share.png" mode="" class="func-btn-img"></image>
39+
邀请好友情况({{lockEdInfo.inviteLockNum}}/{{coverDetail.inviteLockNum}})
40+
</button>
41+
<button plain class="func-btn error" v-if="coverDetail.lookVideoLockNum > 0">
42+
<image src="/static/video.png" mode="" class="func-btn-img"></image>
43+
观看视频情况({{lockEdInfo.lookVideoLockNum}}/{{coverDetail.lookVideoLockNum}})
44+
</button>
3745
<button plain class="func-btn error">
38-
该封面已被领完
46+
抱歉,该封面已被领完
3947
</button>
4048
</view>
4149
<view class="recommand" v-if="modalShow">更多封面👇👇👇</view>
4250
<ad-custom :unit-id="ad.three" v-if="ad.three"></ad-custom>
4351
<ad :unit-id="ad.four" ad-type="video" ad-theme="white" v-if="ad.four"></ad>
44-
<view class="modal" @touchmove.stop="handle" @click="closeModal" v-if="modalShow">
52+
<view class="modal func" @touchmove.stop="handle" @click="closeModal" v-if="modalShow">
4553
<view class="modal-content" @click.stop="openModal">
4654
<view class="modal-content-body">
4755
<view class="modal-content-body-title">
4856
领取方式
4957
</view>
5058
<text user-select decode class="modal-content-body-getdesc">{{coverDetail.getDesc}}</text>
51-
<text user-select decode class="modal-content-body-getdesc">\n{{id}}\n{{openid}}</text>
59+
<button plain class="modal-content-body-copy success" @click="copyCode" v-if="lockEdInfo.isLocked">
60+
复制代码
61+
</button>
62+
<button plain class="modal-content-body-copy success" @click="linkOthers" v-if="lockEdInfo.isLocked">
63+
前往公众号
64+
</button>
5265
<button plain class="modal-content-body-question" open-type="contact">有疑问?</button>
5366
</view>
5467
<image src="/static/close.png" mode="" class="modal-content-cancel" @click.stop="closeModal"></image>
@@ -66,7 +79,7 @@ export default {
6679
data() {
6780
return {
6881
id: '',
69-
num: 0,
82+
num: 1,
7083
modalShow: '',
7184
coverDetail: {
7285
inviteLockNum: 0,
@@ -89,7 +102,6 @@ export default {
89102
},
90103
onLoad(e) {
91104
this.id = e.id
92-
this.num = parseInt(e.num)
93105
if (e.openid){
94106
this.openid = e.openid
95107
}else{
@@ -107,7 +119,7 @@ export default {
107119
onShareAppMessage(res) {
108120
let shareConfig = {
109121
title: '送你个性微信红包封面,发红包时可用',
110-
path: '/pages/detail/detail?openid='+ this.openid + '&id=' + this.id + '&num=' + this.num,
122+
path: '/pages/detail/detail?openid='+ this.openid + '&id=' + this.id,
111123
imageUrl: this.coverDetail.pic
112124
}
113125
return shareConfig
@@ -116,12 +128,20 @@ export default {
116128
let shareConfig = {
117129
title: '送你个性微信红包封面,发红包时可用',
118130
path: '/pages/detail/detail',
119-
query: 'openid='+ this.openid + '&id=' + this.id + '&num=' + this.num,
131+
query: 'openid='+ this.openid + '&id=' + this.id,
120132
imageUrl: this.coverDetail.pic
121133
}
122134
return shareConfig
123135
},
124136
methods: {
137+
linkOthers(){
138+
// 此处填写你要跳转的绑定公众号文章的链接地址或者已经在小程序后台配置好业务域名的地址
139+
var url = "https://mp.weixin.qq.com/s?__biz=MzU3MzY0OTAwNQ==&mid=2247484014&idx=1&sn=98969bf1a25f3ced92150e39e83d80bc&chksm=fd3f3b6cca48b27a00fafc3335ccbb9a52949b16a6ecbec177cfe1e31f14b7a2058ce166b339&token=1026867263&lang=zh_CN#rd"
140+
uni.navigateTo({
141+
// 此处的链接为小程序上面新建的webview页面路径,参数url为要跳转外链的地址
142+
url:"/pages/linkOthers/linkOthers?url=" + encodeURIComponent(url)
143+
});
144+
},
125145
handle(){
126146
return
127147
},
@@ -133,6 +153,7 @@ export default {
133153
console.log(res.result)
134154
this.coverDetail = res.result.data.coverDetail
135155
this.lockEdInfo = res.result.data.lockEdInfo
156+
this.num = res.result.data.coverDetail.num
136157
this.ad = res.result.data.ad
137158
console.log('inviteStatus', getApp().globalData.inviteStatus)
138159
if (getApp().globalData.inviteStatus && getApp().globalData.inviteStatus.status == 1){
@@ -145,20 +166,46 @@ export default {
145166
this.lookInviteVideoLockNum = 0;
146167
}
147168
console.log('this.coverDetail', this.coverDetail)
148-
if(isFirst && this.ad){
149-
//激励视频和插屏广告
150-
if(this.ad.one && !this.lookInviteVideoLockNum){
151-
this.adinsertInit(this.ad.one)
152-
}
153-
if(this.ad.five){
154-
this.adInit(this.ad.five);
169+
try{
170+
if(isFirst && this.ad){
171+
//激励视频和插屏广告
172+
if(this.ad.one && !this.lookInviteVideoLockNum && !this.lockEdInfo.isLocked){
173+
174+
this.adinsertInit(this.ad.one)
175+
}
176+
if(this.ad.five){
177+
this.adInit(this.ad.five);
178+
}
155179
}
180+
} catch (error) {
181+
console.log('广告初始化出错',error)
156182
}
157-
if(this.lockEdInfo.isLocked && isFirst){
183+
if(this.lockEdInfo.isLocked && isFirst && this.num > 0){
158184
this.modalShow = true
159185
}
160186
uni.hideLoading()
161187
},
188+
copyCode(){
189+
console.log('复制剪切板')
190+
const _this = this;
191+
uni.setClipboardData({
192+
data: '元气封面领取码\n' + this.id + '\n' + this.openid,
193+
success: function() {
194+
uni.showToast({
195+
title: '获取成功',
196+
icon: 'success',
197+
duration: 4000
198+
});
199+
},
200+
fail: function(err) {
201+
uni.showToast({
202+
title: '获取失败',
203+
icon: 'none',
204+
duration: 2000
205+
});
206+
}
207+
});
208+
},
162209
lookAd: function(event) {
163210
console.log('观看广告', event)
164211
let lookType = event.currentTarget.dataset['type'];
@@ -230,6 +277,7 @@ export default {
230277
},
231278
//看视频上报
232279
async trackLookVideo(isEnded){
280+
console.log('看视频上报')
233281
await lookVideo({
234282
openid: getApp().globalData.openid,
235283
id: this.id,
@@ -343,6 +391,25 @@ export default {
343391
color: #576b95;
344392
margin-top: 30rpx;
345393
}
394+
&-copy{
395+
margin: auto;
396+
display: block;
397+
border: none;
398+
padding: 0 40rpx;
399+
height: 90rpx;
400+
width: 50%;
401+
align-items: center;
402+
justify-content: center;
403+
background-color: #fbd926;
404+
border-radius: 90rpx;
405+
margin-top: 30rpx;
406+
font-size: 34rpx;
407+
font-weight: 700;
408+
&.success{
409+
background-color: #07c160;
410+
color: #FFFFFF;
411+
}
412+
}
346413
}
347414
&-cancel{
348415
width: 50rpx;

pages/index/index.vue

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<view class="list-item" v-for="(cover, i) in coverList" @click="goDetail(cover._id, cover.num)" :key="i">
2424
<image :src="cover.pic" mode="" class="list-item-img"></image>
2525
<view class="list-item-left" v-if="cover.num > 0">{{cover.num}}人已领</view>
26-
<view class="list-item-left" v-else-if="cover.num <= 0">已被领光</view>
26+
<view class="list-item-left" v-else-if="cover.num <= 0">点击查看</view>
2727
</view>
2828
</view>
2929
</view>

pages/linkOthers/linkOthers.vue

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<template>
2+
<view>
3+
<view>
4+
<!-- url为要跳转外链的地址-->
5+
<web-view :src="url">
6+
</web-view>
7+
</view>
8+
</view>
9+
</template>
10+
11+
<script>
12+
export default {
13+
data() {
14+
return {
15+
url:""
16+
}
17+
},
18+
onLoad(val) {
19+
this.url = decodeURIComponent(val.url);
20+
// 设置当前的title 如果外链中有的话将被覆盖
21+
if(this.isNotEmpty(val.title)){
22+
this.setTitle(val.title);
23+
}
24+
},
25+
methods: {
26+
isNotEmpty(obj) {
27+
if (typeof obj == undefined || obj == null || obj == "" || obj == "undefined" || obj.length == 0) {
28+
return false;
29+
} else {
30+
return true;
31+
}
32+
},
33+
// 设置title
34+
setTitle(title) {
35+
uni.setNavigationBarTitle({
36+
title: title
37+
})
38+
},
39+
}
40+
}
41+
</script>
42+
43+
<style>
44+
45+
</style>

uniCloud-aliyun/cloudfunctions/api/index.js

+11
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const coverModel = require('./models/cover')
44
const loginModel = require('./models/login')
55
const adModel = require('./models/ad')
66
const inviteModel = require('./models/invite')
7+
const wechatModel = require('./models/wechat')
78

89
exports.main = async (event, context) => {
910
//event为客户端上传的参数
@@ -42,6 +43,16 @@ exports.main = async (event, context) => {
4243
resp = inviteAdd
4344
return response.success(resp)
4445
break;
46+
case '/wechat/search':
47+
var recordSearch = await wechatModel.recordSearch(event.queryStringParameters)
48+
resp = recordSearch
49+
return response.success(resp)
50+
break;
51+
case '/wechat/provide':
52+
var recordProvide = await wechatModel.recordProvide(event.queryStringParameters)
53+
resp = recordProvide
54+
return response.success(resp)
55+
break;
4556
default:
4657

4758
}

uniCloud-aliyun/cloudfunctions/api/models/cover.js

+17-2
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ var cover = {
2020
let adLookVideo = await db.collection('ad').where({
2121
openid: req.openid,
2222
id: req.id,
23-
isEnded: "true",
23+
isEnded: true,
2424
lookType: "2"
2525
}).count()
2626
let adLookInviteVideo = await db.collection('ad').where({
2727
openid: req.openid,
2828
id: req.id,
29-
isEnded: "true",
29+
isEnded: true,
3030
lookType: "1"
3131
}).count()
3232
let invite = await db.collection('invite').where({
@@ -38,6 +38,21 @@ var cover = {
3838
let inviteLockNum = invite.total
3939
if(detail.data[0].isFree || ((lookVideoLockNum > 0 && lookVideoLockNum >= detail.data[0].lookVideoLockNum) || (inviteLockNum > 0 && inviteLockNum >= detail.data[0].inviteLockNum))){
4040
var isLocked = true
41+
var recordQuery = await db.collection('record').where({
42+
_id: req.id + req.openid,
43+
}).count();
44+
let recordNum = recordQuery.total;
45+
if (recordNum == 0){
46+
var res = await db.collection('record').add({
47+
_id: req.id + req.openid,
48+
openid: req.openid,
49+
id: req.id,
50+
status: 0,
51+
dateStr: new Date().toLocaleString('zh', {hour12: false, timeZone: 'Asia/Shanghai'}),
52+
})
53+
console.log('可以领取,插入成功')
54+
}
55+
4156
}else{
4257
var isLocked = false
4358
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const db = uniCloud.database();
2+
3+
var wechat = {
4+
recordSearch: async (req) => {
5+
let record = await db.collection('record').where({
6+
_id: req._id,
7+
status: 0,
8+
}).get()
9+
return record
10+
},
11+
recordProvide: async (req) => {
12+
let res = await db.collection('record').doc(req._id).update({
13+
status: 1,
14+
});
15+
return {'status': 1}
16+
},
17+
}
18+
module.exports = wechat;

0 commit comments

Comments
 (0)