Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,35 @@
### 魔改版说明

#### 改进

- 封面详情页插屏广告移至首页(详情页想开可以自己开)需发版
- 用户超额完成任务处理(防止出现 33/10)需发版
- 增加用户完成情况查看与处理功能 无需发版,更新云函数即可
- 增加用户封面领取记录表 无需发版,更新云函数即可

#### 已知问题

- 由于网络抖动等原因领取记录表可能会出现重复数据,目测不影响
- 用户领取完成情况查看和处理从浏览器打开返回结果会当作json文件下载,curl无此问题(待大佬修复)

#### 使用说明

使用魔改版请在云数据库创建 `cover_code` 领取记录表。

用户完成情况查看与处理使用:

1.查看用户完成情况
```shell
$ curl https://{云空间spaceid}.bspapp.com/http/api/view?openid={用户openid}
openid:用户openid
codeId:领取id coverId:封面id invite:所邀请人数 ad:视频观看数 code:兑换码 useTime:领取时间
```

2.更新用户领取封面的兑换码或其它领取字样,标记该用户已领取此封面。防openid冒领。
```shell
$ curl https://{云空间spaceid}.bspapp.com/http/api/view?codeid={codeId}&code={兑换码或者其它已领取字样}
update success
```

### 微信红包封面领取小程序,用户观看视频广告或者邀请新用户可获取微信红包封面序列号,还可给外卖优惠券引流

Expand Down
1 change: 0 additions & 1 deletion pages/detail/detail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
领取封面
</button>
</view>
<view class="recommand">更多封面👇👇👇</view>
<ad-custom :unit-id="ad.three" v-if="ad.three"></ad-custom>
<ad :unit-id="ad.four" ad-type="video" ad-theme="white" v-if="ad.four"></ad>
<view class="modal" @touchmove.stop="handle" @click="closeModal" v-if="modalShow">
Expand Down
20 changes: 20 additions & 0 deletions pages/index/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

<script>
import { cover } from '../../request'
var interstitialAd = null
export default {
data() {
return {
Expand Down Expand Up @@ -57,8 +58,27 @@
this.couponList = res.result.data.couponList
this.coverList = res.result.data.coverList
this.tips = res.result.data.tips
this.ads = res.data.data.ads
if(this.ads && this.ads.one){
this.adinsertInit(this.ads.one)
}
uni.hideLoading()
},
//初始化插屏广告
adinsertInit(adUnitId) {
if (wx.createInterstitialAd) {
interstitialAd = wx.createInterstitialAd({
adUnitId: adUnitId
})
interstitialAd.onLoad(() => {
interstitialAd.show().catch((err) => {
console.error(err)
})
})
interstitialAd.onError((err) => {})
interstitialAd.onClose(() => {})
}
},
toCoupon(i){
console.log(this.couponList[i])
if(this.couponList[i].minapp){
Expand Down
13 changes: 13 additions & 0 deletions uniCloud-aliyun/cloudfunctions/api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ exports.main = async (event, context) => {
resp.couponList = await coverModel.coupons()
resp.coverList = await coverModel.list()
resp.tips = await coverModel.tips()
resp.ads = await coverModel.ads()
return response.success(resp)
break;
//封面详情
Expand All @@ -42,6 +43,18 @@ exports.main = async (event, context) => {
resp = inviteAdd
return response.success(resp)
break;
//完成情况
case '/view':
var view = await coverModel.view(event.queryStringParameters)
return {
mpserverlessComposedResponse: true,
statusCode: 200,
headers: {
'content-type': 'text/html'
},
body: view
}
break;
default:

}
Expand Down
77 changes: 76 additions & 1 deletion uniCloud-aliyun/cloudfunctions/api/models/cover.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ var cover = {
}).get();
return tips.data[0].value
},
ads: async () => {
let ads = await db.collection('config').where({
name: "ad"
}).get();
return ads.data[0].value.detail
},
detail: async (req) => {
let detail = await db.collection('cover').doc(req.id).get();
let adLookVideo = await db.collection('ad').where({
Expand All @@ -33,12 +39,43 @@ var cover = {
}else{
var isLocked = false
}

//超额完成任务处理
if (lookVideoLockNum > detail.data[0].lookVideoLockNum) {
lookVideoLockNum = detail.data[0].lookVideoLockNum
}
if (inviteLockNum > detail.data[0].inviteLockNum) {
inviteLockNum = detail.data[0].inviteLockNum
}

//已解锁创建领取记录
if (isLocked) {
let hasExistCoverCode = await db.collection('cover_code').where({
coverId: req.id,
bindOpenid: req.openid
}).limit(1).get()
if (hasExistCoverCode.affectedDocs == 0) {
let ins_res = await db.collection('cover_code').add({
coverId: req.id,
code: "",
bindOpenid: req.openid,
useTime: new Date().toLocaleString('zh', {hour12: false, timeZone: 'Asia/Shanghai'}),
isUse: true
})
}

//附加openid
detail.data[0].getDesc += "\n" + req.openid
}

//广告位配置
let adConfig = await db.collection('config').where({
name: "ad"
}).get();
let ad = adConfig.data[0].value.detail
detail.data[0].getDesc += "\n" + req.openid
//详情页不显示插屏
ad.one = ""

return {
coverDetail: detail.data[0],
lockEdInfo: {
Expand All @@ -49,6 +86,44 @@ var cover = {
ad,
}
},
view: async (req) => {
let return_str = ""
if (req.openid) {
return_str = "openid:"+req.openid+"\n"
let user_info = await db.collection('user').where({
openid: req.openid,
}).get();
if(user_info.affectedDocs == 0){
return_str += "用户信息不存在!注意伪造openid!\n"
}
let cover_code_list = await db.collection('cover_code').where({bindOpenid:req.openid}).field({'_id':true,'coverId':true,'code':true,'useTime':true}).get();
if (cover_code_list.affectedDocs) {
for (let cover_code of cover_code_list.data) {
var adLookVideo = await db.collection('ad').where({
openid: req.openid,
id: cover_code.coverId,
isEnded: "true",
}).count()
var invite = await db.collection('invite').where({
inviteOpenid: req.openid,
id: cover_code.coverId,
}).count()
return_str += "codeId:"+cover_code._id+" coverId:"+cover_code.coverId+" invite:"+invite.total+" ad:"+adLookVideo.total+" code:"+cover_code.code+" useTime:"+cover_code.useTime+"\n"
}

}

}

if (req.code && req.codeid) {
await db.collection('cover_code').doc(req.codeid).update({
code : req.code,
})
return_str += "update success\n"
}

return return_str
}
}

module.exports = cover;