写在最前

审核失败: 原因存在运营内容不完整问题,违反《微信小程序平台运营规范常见拒绝情形3.3》

这里我通过云函数对部分未完成的项目进行隐藏,审核过后再进行显示:
即: 审核时,数据库对未完成的项目进行隐藏(设为false),审核过后,再进行显示(设为true) 通过云函数进行判断

示例

数据库

在数据库中创建 project 集合,示例数据结构如下:

1
2
3
4
5
6
7
8
{
"id": "xxx",
"name": "项目名称",
"description": "项目描述",
"isShow": true, // 控制显示状态
"isAudit": false, // 是否处于审核状态
"createTime": 1643673600000
}

云函数

创建 getProjects 云函数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
const db = uniCloud.database()
const collection = db.collection('project')
exports.main = async (event, context) => {
// 获取环境信息
const { PLATFORM } = context
try {
let query = {}
// 如果是微信小程序环境
if (PLATFORM === 'mp-weixin') {
// 获取当前是否为体验版或审核版本
const { version } = await uniCloud.getWXContext()
// 审核版本时只显示 isShow 为 true 的项目
if (version === 'trial' || version === 'audit') {
query.isShow = true
// 更新审核状态
await collection.where({
isAudit: false
}).update({
isAudit: true
})
}
}
const { data } = await collection
.where(query)
.orderBy('createTime', 'desc')
.get()
return {
code: 0,
msg: 'success',
data
}
} catch(e) {
return {
code: -1,
msg: e.message,
data: null
}
}
}

前端

在页面中调用云函数:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<template>
<view class="container">
<view v-for="item in projectList" :key="item.id" class="project-item">
<text class="project-name">{{item.name}}</text>
<text class="project-desc">{{item.description}}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
projectList: []
}
},
onLoad() {
this.getProjectList()
},
methods: {
async getProjectList() {
try {
const { result } = await uniCloud.callFunction({
name: 'getProjects'
})
if (result.code === 0) {
this.projectList = result.data
} else {
uni.showToast({
title: result.msg,
icon: 'none'
})
}
} catch(e) {
uni.showToast({
title: '获取项目列表失败',
icon: 'none'
})
}
}
}
}
</script>
<style>
.container {
padding: 20rpx;
}
.project-item {
margin-bottom: 20rpx;
padding: 20rpx;
background-color: #fff;
border-radius: 8rpx;
}
.project-name {
font-size: 32rpx;
font-weight: bold;
}
.project-desc {
font-size: 28rpx;
color: #666;
margin-top: 10rpx;
}
</style>

实现原理

  1. 在数据库中通过 isShow 字段控制项目是否显示
  2. 通过云函数获取当前环境,判断是否为审核版本
  3. 在审核版本中只返回 isShow 为 true 的项目
  4. 审核通过后,可以通过管理后台或云函数修改 isShow 状态

注意事项

可能不符合微信小程序审核规范, 后续被发现违规可能会被官方下线小程序, 但是无奈于小程序的xx审核,所有版块在上线的时候都强制需要有内容