时时笑笑 發表於 2019-11-27 09:03:00

小程序云开发,博客小程序,云开发小程序

<h2 id="h2-u5BFCu8BED">导语</h2>
<p>一直对小程序很感兴趣,之前就准备做一款自己的小程序,无奈还需要购买云服务器和部署后台,有点麻烦,自从知道有了云开发这个东东,就一鼓作气花了几个周末的时间做了一款自己的博客小程序,如果你也想打造一款自己的博客,那你阅读这篇文章就够啦</p>
<ul>
<li>
<h4 id="h4-u6570u636Eu5E93u8BBEu8BA1">数据库设计</h4>
</li>
<li>
<h4 id="h4-u8BC4u8BBAu529Fu80FDu8BBEu8BA1">评论功能设计</h4>
</li>
<li>
<h4 id="h4-u9879u76EEu8FD0u884C">项目运行</h4>
</li>
<li>
<h4 id="h4-u53D1u5E03u6CE8u610Fu4E8Bu9879">发布注意事项</h4>
<h2 id="h2--">一,介绍</h2>
<blockquote>
<p>主要功能:文章的发布及浏览,评论,点赞,浏览历史,分类,排行榜,分享,生成海报图</p>
</blockquote>
</li>
</ul>
<p>&nbsp;</p>
<p align="center"><br><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E5%B0%8F%E7%A8%8B%E5%BA%8F%E7%A0%81.jpg?sign=f4cad9f1d9332de97807ceb5a7e53d5f&amp;t=1566538869"></p>
<h4 id="h4-u6548u679Cu5C55u793A">效果展示</h4>
<p><img src="https://img2020.cnblogs.com/blog/1363775/202005/1363775-20200517221020780-939353023.png"></p>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E5%88%86%E7%B1%BB.png?sign=e87741c9a66f0dd2edffae12f4909ffa&amp;t=1566539648"><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E6%8E%92%E8%A1%8C%E6%A6%9C.png?sign=885d0db97f89edb5e77b6fcc61cfed20&amp;t=1566539676"></p>
<p>&nbsp;</p>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E6%8E%92%E8%A1%8C%E6%A6%9C.png?sign=885d0db97f89edb5e77b6fcc61cfed20&amp;t=1566539676"></p>
<p>&nbsp;</p>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E6%8E%92%E8%A1%8C%E6%A6%9C.png?sign=885d0db97f89edb5e77b6fcc61cfed20&amp;t=1566539676"></p>
<h5 id="h5-u6211u7684u9875u9762"><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E6%88%91%E7%9A%84.png?sign=e3c703885506e6fa2a529e5a0eca390a&amp;t=1566539710"></h5>
<h5 id="h5-u6211u7684u9875u9762">&nbsp;</h5>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E8%AF%A6%E6%83%853.png?sign=6a60d743c73f88b1e1ae748160145e9d&amp;t=1573968408"><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E8%AF%A6%E6%83%854.png?sign=82313063a67290ebb17b479f4ce3c843&amp;t=1573968465"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2>&nbsp;</h2>
<h2><img src="https://img2020.cnblogs.com/blog/1363775/202005/1363775-20200517221223920-408711469.png"></h2>
<h2>&nbsp;</h2>
<h2 id="h2--">二,数据库设计</h2>
<blockquote>
<p>数据库主要就7张表,分别为:用户表,分类表,文章表,文章内容表,评论表,点赞表,历史浏览表</p>










</blockquote>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E6%95%B0%E6%8D%AE%E5%BA%93%E7%BB%93%E6%9E%84%E8%A1%A8.png?sign=e209512dcd75a20358e4977d910cd9f2&amp;t=1573983288"></p>
<h2 id="h2--">三,评论功能设计</h2>
<blockquote>
<p>以文章评论功能为例,我们来看看代码以及小程序云开发的整个流程</p>










</blockquote>
<h3 id="h3-1-">1.实现思路</h3>
<p>一开始的实现思路是准备搞两张表,一张评论主表,一张回复评论的子表,后来想着不用这么复杂,其实就用一张表也能实现评论及回复的功能。</p>
<h3 id="h3-2-">2.代码实现</h3>
<blockquote>
<p>发表评论有三种情况,第一种是评论文章,为一级评论,第二种是评论别人的评论,为二级评论,第三种是回复别人的评论,为三级评论</p>










</blockquote>
<h5 id="h5-2-1-">2.1 如何新增一条评论</h5>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E8%AF%84%E8%AE%BA%E8%AE%BE%E8%AE%A1.png?sign=8846f03cb20b172989a75cb538420c7f&amp;t=1573987543"></p>
<p>&nbsp;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp;结合上面图片,我们再来看看代码,就很清晰了</p>
<p>  </p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span>   <span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
</span><span style="color: rgba(0, 128, 128, 1)">2</span> <span style="color: rgba(0, 128, 0, 1)">   * 发布评论
</span><span style="color: rgba(0, 128, 128, 1)">3</span>    <span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 128, 1)">4</span> <span style="color: rgba(0, 0, 0, 1)">submit() {
</span><span style="color: rgba(0, 128, 128, 1)">5</span>   <span style="color: rgba(0, 0, 255, 1)">var</span> comment = <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.inputData
</span><span style="color: rgba(0, 128, 128, 1)">6</span>   <span style="color: rgba(0, 0, 255, 1)">if</span> (comment == ''<span style="color: rgba(0, 0, 0, 1)">) {
</span><span style="color: rgba(0, 128, 128, 1)">7</span> <span style="color: rgba(0, 0, 0, 1)">      wx.showToast({
</span><span style="color: rgba(0, 128, 128, 1)">8</span>         title: '请填写评论'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)">9</span>         icon: 'none'
<span style="color: rgba(0, 128, 128, 1)"> 10</span> <span style="color: rgba(0, 0, 0, 1)">      })
</span><span style="color: rgba(0, 128, 128, 1)"> 11</span>   } <span style="color: rgba(0, 0, 255, 1)">else</span><span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)"> 12</span>       console.log("我的评论:" + <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.inputData)
</span><span style="color: rgba(0, 128, 128, 1)"> 13</span>       <span style="color: rgba(0, 0, 255, 1)">var</span> type = <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.data.type;
</span><span style="color: rgba(0, 128, 128, 1)"> 14</span>       <span style="color: rgba(0, 0, 255, 1)">if</span> (type == 1) { <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 1是评论别人的评论》二级评论</span>
<span style="color: rgba(0, 128, 128, 1)"> 15</span>         <span style="color: rgba(0, 0, 255, 1)">this</span>.replyComment(1<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)"> 16</span>       } <span style="color: rgba(0, 0, 255, 1)">else</span> <span style="color: rgba(0, 0, 255, 1)">if</span> (type == 2<span style="color: rgba(0, 0, 0, 1)">) {
</span><span style="color: rgba(0, 128, 128, 1)"> 17</span>         <span style="color: rgba(0, 0, 255, 1)">this</span>.replyComment(2) <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 2是回复别人的评论》三级评论</span>
<span style="color: rgba(0, 128, 128, 1)"> 18</span>       } <span style="color: rgba(0, 0, 255, 1)">else</span> <span style="color: rgba(0, 0, 255, 1)">if</span> (type == 3) { <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 3是评论文章》一级评论</span>
<span style="color: rgba(0, 128, 128, 1)"> 19</span>         <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">.addComment();
</span><span style="color: rgba(0, 128, 128, 1)"> 20</span> <span style="color: rgba(0, 0, 0, 1)">      }
</span><span style="color: rgba(0, 128, 128, 1)"> 21</span> <span style="color: rgba(0, 0, 0, 1)">    }
</span><span style="color: rgba(0, 128, 128, 1)"> 22</span> <span style="color: rgba(0, 0, 0, 1)">},
</span><span style="color: rgba(0, 128, 128, 1)"> 23</span>    <span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
</span><span style="color: rgba(0, 128, 128, 1)"> 24</span> <span style="color: rgba(0, 128, 0, 1)">   * 新增评论
</span><span style="color: rgba(0, 128, 128, 1)"> 25</span>    <span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 128, 1)"> 26</span> <span style="color: rgba(0, 0, 0, 1)">addComment() {
</span><span style="color: rgba(0, 128, 128, 1)"> 27</span>   <span style="color: rgba(0, 0, 255, 1)">var</span> _this = <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 28</span>   <span style="color: rgba(0, 0, 255, 1)">var</span> openid = wx.getStorageSync("openid"<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)"> 29</span> <span style="color: rgba(0, 0, 0, 1)">    wx.showLoading({
</span><span style="color: rgba(0, 128, 128, 1)"> 30</span>       title: '正在加载...'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)"> 31</span> <span style="color: rgba(0, 0, 0, 1)">    })
</span><span style="color: rgba(0, 128, 128, 1)"> 32</span>   <span style="color: rgba(0, 0, 255, 1)">var</span> create_date = util.formatTime(<span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> Date());
</span><span style="color: rgba(0, 128, 128, 1)"> 33</span>   console.log("当前时间为:" +<span style="color: rgba(0, 0, 0, 1)"> create_date);
</span><span style="color: rgba(0, 128, 128, 1)"> 34</span>   <span style="color: rgba(0, 0, 255, 1)">var</span> timestamp = Date.parse(<span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> Date());
</span><span style="color: rgba(0, 128, 128, 1)"> 35</span>   timestamp = timestamp / 1000<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 36</span>   console.log("当前时间戳为:" +<span style="color: rgba(0, 0, 0, 1)"> timestamp);
</span><span style="color: rgba(0, 128, 128, 1)"> 37</span>   <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 调用云函数</span>
<span style="color: rgba(0, 128, 128, 1)"> 38</span> <span style="color: rgba(0, 0, 0, 1)">    wx.cloud.callFunction({
</span><span style="color: rgba(0, 128, 128, 1)"> 39</span>       name: 'addComment'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)"> 40</span> <span style="color: rgba(0, 0, 0, 1)">      data: {
</span><span style="color: rgba(0, 128, 128, 1)"> 41</span>         <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)">_id: timestamp + _this.data.otherUserInfo._id,</span>
<span style="color: rgba(0, 128, 128, 1)"> 42</span> <span style="color: rgba(0, 0, 0, 1)">      id: _this.data.articleDetail._id,
</span><span style="color: rgba(0, 128, 128, 1)"> 43</span> <span style="color: rgba(0, 0, 0, 1)">      _openid: openid,
</span><span style="color: rgba(0, 128, 128, 1)"> 44</span> <span style="color: rgba(0, 0, 0, 1)">      avatarUrl: _this.data.userInfo.avatarUrl,
</span><span style="color: rgba(0, 128, 128, 1)"> 45</span> <span style="color: rgba(0, 0, 0, 1)">      nickName: _this.data.userInfo.nickName,
</span><span style="color: rgba(0, 128, 128, 1)"> 46</span> <span style="color: rgba(0, 0, 0, 1)">      comment: _this.data.inputData,
</span><span style="color: rgba(0, 128, 128, 1)"> 47</span> <span style="color: rgba(0, 0, 0, 1)">      create_date: create_date,
</span><span style="color: rgba(0, 128, 128, 1)"> 48</span>         flag: 0<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)"> 49</span> <span style="color: rgba(0, 0, 0, 1)">      article_id: _this.data.articleDetail.article_id,
</span><span style="color: rgba(0, 128, 128, 1)"> 50</span> <span style="color: rgba(0, 0, 0, 1)">      timestamp: timestamp,
</span><span style="color: rgba(0, 128, 128, 1)"> 51</span> <span style="color: rgba(0, 0, 0, 1)">      childComment: [],
</span><span style="color: rgba(0, 128, 128, 1)"> 52</span> <span style="color: rgba(0, 0, 0, 1)">      },
</span><span style="color: rgba(0, 128, 128, 1)"> 53</span>       success: res =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)"> 54</span>         <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> res.data 包含该记录的数据</span>
<span style="color: rgba(0, 128, 128, 1)"> 55</span>         console.log("新增评论成功---"<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)"> 56</span> <span style="color: rgba(0, 0, 0, 1)">      wx.showToast({
</span><span style="color: rgba(0, 128, 128, 1)"> 57</span>         title: '评论提交成功'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)"> 58</span> <span style="color: rgba(0, 0, 0, 1)">      })
</span><span style="color: rgba(0, 128, 128, 1)"> 59</span> <span style="color: rgba(0, 0, 0, 1)">      wx.navigateBack({
</span><span style="color: rgba(0, 128, 128, 1)"> 60</span>         delta: 1
<span style="color: rgba(0, 128, 128, 1)"> 61</span> <span style="color: rgba(0, 0, 0, 1)">      })
</span><span style="color: rgba(0, 128, 128, 1)"> 62</span> <span style="color: rgba(0, 0, 0, 1)">      },
</span><span style="color: rgba(0, 128, 128, 1)"> 63</span>       fail: err =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)"> 64</span>         console.error('[云函数]调用失败'<span style="color: rgba(0, 0, 0, 1)">, err)
</span><span style="color: rgba(0, 128, 128, 1)"> 65</span> <span style="color: rgba(0, 0, 0, 1)">      },
</span><span style="color: rgba(0, 128, 128, 1)"> 66</span>       complete: res =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)"> 67</span> <span style="color: rgba(0, 0, 0, 1)">      wx.hideLoading()
</span><span style="color: rgba(0, 128, 128, 1)"> 68</span> <span style="color: rgba(0, 0, 0, 1)">      }
</span><span style="color: rgba(0, 128, 128, 1)"> 69</span> <span style="color: rgba(0, 0, 0, 1)">    })
</span><span style="color: rgba(0, 128, 128, 1)"> 70</span> <span style="color: rgba(0, 0, 0, 1)">},
</span><span style="color: rgba(0, 128, 128, 1)"> 71</span>   <span style="color: rgba(0, 128, 0, 1)">/*</span><span style="color: rgba(0, 128, 0, 1)">*
</span><span style="color: rgba(0, 128, 128, 1)"> 72</span> <span style="color: rgba(0, 128, 0, 1)">   * 回复评论
</span><span style="color: rgba(0, 128, 128, 1)"> 73</span>    <span style="color: rgba(0, 128, 0, 1)">*/</span>
<span style="color: rgba(0, 128, 128, 1)"> 74</span> <span style="color: rgba(0, 0, 0, 1)">replyComment(commentType) {
</span><span style="color: rgba(0, 128, 128, 1)"> 75</span>   <span style="color: rgba(0, 0, 255, 1)">var</span> _this = <span style="color: rgba(0, 0, 255, 1)">this</span><span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 76</span> <span style="color: rgba(0, 0, 0, 1)">    wx.showLoading({
</span><span style="color: rgba(0, 128, 128, 1)"> 77</span>       title: '正在加载...'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)"> 78</span> <span style="color: rgba(0, 0, 0, 1)">    })
</span><span style="color: rgba(0, 128, 128, 1)"> 79</span>   <span style="color: rgba(0, 0, 255, 1)">var</span> create_date = util.formatTime(<span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> Date());
</span><span style="color: rgba(0, 128, 128, 1)"> 80</span>   console.log("当前时间为:" +<span style="color: rgba(0, 0, 0, 1)"> create_date);
</span><span style="color: rgba(0, 128, 128, 1)"> 81</span>   <span style="color: rgba(0, 0, 255, 1)">var</span> timestamp = Date.parse(<span style="color: rgba(0, 0, 255, 1)">new</span><span style="color: rgba(0, 0, 0, 1)"> Date());
</span><span style="color: rgba(0, 128, 128, 1)"> 82</span>   timestamp = timestamp / 1000<span style="color: rgba(0, 0, 0, 1)">;
</span><span style="color: rgba(0, 128, 128, 1)"> 83</span> <span style="color: rgba(0, 0, 0, 1)">    wx.cloud.callFunction({
</span><span style="color: rgba(0, 128, 128, 1)"> 84</span>       name: 'replyComment'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)"> 85</span> <span style="color: rgba(0, 0, 0, 1)">      data: {
</span><span style="color: rgba(0, 128, 128, 1)"> 86</span> <span style="color: rgba(0, 0, 0, 1)">      id: _this.data.articleDetail._id,
</span><span style="color: rgba(0, 128, 128, 1)"> 87</span> <span style="color: rgba(0, 0, 0, 1)">      _id: _this.data.otherUserInfo._id,
</span><span style="color: rgba(0, 128, 128, 1)"> 88</span> <span style="color: rgba(0, 0, 0, 1)">      avatarUrl: _this.data.userInfo.avatarUrl,
</span><span style="color: rgba(0, 128, 128, 1)"> 89</span> <span style="color: rgba(0, 0, 0, 1)">      nickName: _this.data.userInfo.nickName,
</span><span style="color: rgba(0, 128, 128, 1)"> 90</span> <span style="color: rgba(0, 0, 0, 1)">      openId: _this.data.openid,
</span><span style="color: rgba(0, 128, 128, 1)"> 91</span> <span style="color: rgba(0, 0, 0, 1)">      comment: _this.data.inputData,
</span><span style="color: rgba(0, 128, 128, 1)"> 92</span> <span style="color: rgba(0, 0, 0, 1)">      createDate: create_date,
</span><span style="color: rgba(0, 128, 128, 1)"> 93</span> <span style="color: rgba(0, 0, 0, 1)">      flag: commentType,
</span><span style="color: rgba(0, 128, 128, 1)"> 94</span> <span style="color: rgba(0, 0, 0, 1)">      opposite_avatarUrl: _this.data.otherUserInfo.avatarUrl,
</span><span style="color: rgba(0, 128, 128, 1)"> 95</span> <span style="color: rgba(0, 0, 0, 1)">      opposite_nickName: _this.data.otherUserInfo.nickName,
</span><span style="color: rgba(0, 128, 128, 1)"> 96</span> <span style="color: rgba(0, 0, 0, 1)">      opposite_openId: _this.data.otherUserInfo._openid,
</span><span style="color: rgba(0, 128, 128, 1)"> 97</span> <span style="color: rgba(0, 0, 0, 1)">      timestamp: timestamp,
</span><span style="color: rgba(0, 128, 128, 1)"> 98</span> <span style="color: rgba(0, 0, 0, 1)">      },
</span><span style="color: rgba(0, 128, 128, 1)"> 99</span>       success: res =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">100</span>         <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> res.data 包含该记录的数据</span>
<span style="color: rgba(0, 128, 128, 1)">101</span>         console.log("回复评论成功---"<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)">102</span> <span style="color: rgba(0, 0, 0, 1)">      wx.showToast({
</span><span style="color: rgba(0, 128, 128, 1)">103</span>         title: '回复提交成功'<span style="color: rgba(0, 0, 0, 1)">,
</span><span style="color: rgba(0, 128, 128, 1)">104</span> <span style="color: rgba(0, 0, 0, 1)">      })
</span><span style="color: rgba(0, 128, 128, 1)">105</span> <span style="color: rgba(0, 0, 0, 1)">      wx.navigateBack({
</span><span style="color: rgba(0, 128, 128, 1)">106</span>         delta: 1
<span style="color: rgba(0, 128, 128, 1)">107</span> <span style="color: rgba(0, 0, 0, 1)">      })
</span><span style="color: rgba(0, 128, 128, 1)">108</span> <span style="color: rgba(0, 0, 0, 1)">      },
</span><span style="color: rgba(0, 128, 128, 1)">109</span>       fail: err =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">110</span>         console.error('[云函数]调用失败'<span style="color: rgba(0, 0, 0, 1)">, err)
</span><span style="color: rgba(0, 128, 128, 1)">111</span> <span style="color: rgba(0, 0, 0, 1)">      },
</span><span style="color: rgba(0, 128, 128, 1)">112</span>       complete: res =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">113</span> <span style="color: rgba(0, 0, 0, 1)">      wx.hideLoading()
</span><span style="color: rgba(0, 128, 128, 1)">114</span> <span style="color: rgba(0, 0, 0, 1)">      }
</span><span style="color: rgba(0, 128, 128, 1)">115</span> <span style="color: rgba(0, 0, 0, 1)">    })
</span><span style="color: rgba(0, 128, 128, 1)">116</span>   },</pre>
</div>
<p>下面是新增评论和回复评论的两个云函数,主要用到了async和await这两个函数,让新增和回复函数执行完后我们再更新一下article文章表的评论字段,让其加1,async和await的好处就是可以让函数有序的进行,这里就不多说了</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 新增评论云函数</span>
<span style="color: rgba(0, 128, 128, 1)"> 2</span> const cloud = require('wx-server-sdk'<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)"> 3</span> <span style="color: rgba(0, 0, 255, 1)">var</span> env = 'hsf-blog-product-xxxxx'; <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 正式环境</span>
<span style="color: rgba(0, 128, 128, 1)"> 4</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> var env = 'xxxxxxxxxxxxx'; // 测试环境</span>
<span style="color: rgba(0, 128, 128, 1)"> 5</span> <span style="color: rgba(0, 0, 0, 1)">cloud.init({
</span><span style="color: rgba(0, 128, 128, 1)"> 6</span> <span style="color: rgba(0, 0, 0, 1)">env: env
</span><span style="color: rgba(0, 128, 128, 1)"> 7</span> <span style="color: rgba(0, 0, 0, 1)">})
</span><span style="color: rgba(0, 128, 128, 1)"> 8</span> const db =<span style="color: rgba(0, 0, 0, 1)"> cloud.database()
</span><span style="color: rgba(0, 128, 128, 1)"> 9</span> const _ =<span style="color: rgba(0, 0, 0, 1)"> db.command
</span><span style="color: rgba(0, 128, 128, 1)">10</span> exports.main = async(event, context) =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">11</span>   <span style="color: rgba(0, 0, 255, 1)">try</span><span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">12</span>   let res = await db.collection('comment'<span style="color: rgba(0, 0, 0, 1)">).add({
</span><span style="color: rgba(0, 128, 128, 1)">13</span> <span style="color: rgba(0, 0, 0, 1)">      data: {
</span><span style="color: rgba(0, 128, 128, 1)">14</span> <span style="color: rgba(0, 0, 0, 1)">      _openid: event._openid,
</span><span style="color: rgba(0, 128, 128, 1)">15</span> <span style="color: rgba(0, 0, 0, 1)">      avatarUrl: event.avatarUrl,
</span><span style="color: rgba(0, 128, 128, 1)">16</span> <span style="color: rgba(0, 0, 0, 1)">      nickName: event.nickName,
</span><span style="color: rgba(0, 128, 128, 1)">17</span> <span style="color: rgba(0, 0, 0, 1)">      comment: event.comment,
</span><span style="color: rgba(0, 128, 128, 1)">18</span> <span style="color: rgba(0, 0, 0, 1)">      create_date: event.create_date,
</span><span style="color: rgba(0, 128, 128, 1)">19</span> <span style="color: rgba(0, 0, 0, 1)">      flag: event.flag,
</span><span style="color: rgba(0, 128, 128, 1)">20</span> <span style="color: rgba(0, 0, 0, 1)">      article_id: event.article_id,
</span><span style="color: rgba(0, 128, 128, 1)">21</span> <span style="color: rgba(0, 0, 0, 1)">      timestamp: event.timestamp,
</span><span style="color: rgba(0, 128, 128, 1)">22</span> <span style="color: rgba(0, 0, 0, 1)">      childComment: [],
</span><span style="color: rgba(0, 128, 128, 1)">23</span> <span style="color: rgba(0, 0, 0, 1)">      }
</span><span style="color: rgba(0, 128, 128, 1)">24</span>   }).then(res =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">25</span>       <span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> res;
</span><span style="color: rgba(0, 128, 128, 1)">26</span> <span style="color: rgba(0, 0, 0, 1)">    })
</span><span style="color: rgba(0, 128, 128, 1)">27</span>   await db.collection('article'<span style="color: rgba(0, 0, 0, 1)">).doc(event.id).update({
</span><span style="color: rgba(0, 128, 128, 1)">28</span> <span style="color: rgba(0, 0, 0, 1)">      data: {
</span><span style="color: rgba(0, 128, 128, 1)">29</span>         comment_count: _.inc(1<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)">30</span> <span style="color: rgba(0, 0, 0, 1)">      }
</span><span style="color: rgba(0, 128, 128, 1)">31</span> <span style="color: rgba(0, 0, 0, 1)">    })
</span><span style="color: rgba(0, 128, 128, 1)">32</span>   <span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> res;
</span><span style="color: rgba(0, 128, 128, 1)">33</span>   } <span style="color: rgba(0, 0, 255, 1)">catch</span><span style="color: rgba(0, 0, 0, 1)"> (e) {
</span><span style="color: rgba(0, 128, 128, 1)">34</span> <span style="color: rgba(0, 0, 0, 1)">    console.error(e)
</span><span style="color: rgba(0, 128, 128, 1)">35</span> <span style="color: rgba(0, 0, 0, 1)">}
</span><span style="color: rgba(0, 128, 128, 1)">36</span> }</pre>
</div>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 回复评论云函数</span>
<span style="color: rgba(0, 128, 128, 1)"> 2</span> const cloud = require('wx-server-sdk'<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)"> 3</span> <span style="color: rgba(0, 0, 255, 1)">var</span> env = 'hsf-blog-product-xxxxx';<span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> 正式环境</span>
<span style="color: rgba(0, 128, 128, 1)"> 4</span> <span style="color: rgba(0, 128, 0, 1)">//</span><span style="color: rgba(0, 128, 0, 1)"> var env = 'xxxxxxxxxxxxxx'; // 测试环境</span>
<span style="color: rgba(0, 128, 128, 1)"> 5</span> <span style="color: rgba(0, 0, 0, 1)">cloud.init({
</span><span style="color: rgba(0, 128, 128, 1)"> 6</span> <span style="color: rgba(0, 0, 0, 1)">env: env
</span><span style="color: rgba(0, 128, 128, 1)"> 7</span> <span style="color: rgba(0, 0, 0, 1)">})
</span><span style="color: rgba(0, 128, 128, 1)"> 8</span> const db =<span style="color: rgba(0, 0, 0, 1)"> cloud.database()
</span><span style="color: rgba(0, 128, 128, 1)"> 9</span> const _ =<span style="color: rgba(0, 0, 0, 1)"> db.command
</span><span style="color: rgba(0, 128, 128, 1)">10</span> exports.main = async(event, context) =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">11</span>   <span style="color: rgba(0, 0, 255, 1)">try</span><span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">12</span>   let res = await db.collection('comment'<span style="color: rgba(0, 0, 0, 1)">).doc(event._id).update({
</span><span style="color: rgba(0, 128, 128, 1)">13</span> <span style="color: rgba(0, 0, 0, 1)">      data: {
</span><span style="color: rgba(0, 128, 128, 1)">14</span> <span style="color: rgba(0, 0, 0, 1)">      childComment: _.push({
</span><span style="color: rgba(0, 128, 128, 1)">15</span> <span style="color: rgba(0, 0, 0, 1)">          avatarUrl: event.avatarUrl,
</span><span style="color: rgba(0, 128, 128, 1)">16</span> <span style="color: rgba(0, 0, 0, 1)">          nickName: event.nickName,
</span><span style="color: rgba(0, 128, 128, 1)">17</span> <span style="color: rgba(0, 0, 0, 1)">          openId: event.openId,
</span><span style="color: rgba(0, 128, 128, 1)">18</span> <span style="color: rgba(0, 0, 0, 1)">          comment: event.comment,
</span><span style="color: rgba(0, 128, 128, 1)">19</span> <span style="color: rgba(0, 0, 0, 1)">          createDate: event.createDate,
</span><span style="color: rgba(0, 128, 128, 1)">20</span> <span style="color: rgba(0, 0, 0, 1)">          flag: event.flag,
</span><span style="color: rgba(0, 128, 128, 1)">21</span> <span style="color: rgba(0, 0, 0, 1)">          opposite_avatarUrl: event.opposite_avatarUrl,
</span><span style="color: rgba(0, 128, 128, 1)">22</span> <span style="color: rgba(0, 0, 0, 1)">          opposite_nickName: event.opposite_nickName,
</span><span style="color: rgba(0, 128, 128, 1)">23</span> <span style="color: rgba(0, 0, 0, 1)">          opposite_openId: event.opposite_openId,
</span><span style="color: rgba(0, 128, 128, 1)">24</span> <span style="color: rgba(0, 0, 0, 1)">          timestamp: event.timestamp,
</span><span style="color: rgba(0, 128, 128, 1)">25</span> <span style="color: rgba(0, 0, 0, 1)">      })
</span><span style="color: rgba(0, 128, 128, 1)">26</span> <span style="color: rgba(0, 0, 0, 1)">      }
</span><span style="color: rgba(0, 128, 128, 1)">27</span>   }).then(res =&gt;<span style="color: rgba(0, 0, 0, 1)"> {
</span><span style="color: rgba(0, 128, 128, 1)">28</span>       <span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> res;
</span><span style="color: rgba(0, 128, 128, 1)">29</span> <span style="color: rgba(0, 0, 0, 1)">    })
</span><span style="color: rgba(0, 128, 128, 1)">30</span>   await db.collection('article'<span style="color: rgba(0, 0, 0, 1)">).doc(event.id).update({
</span><span style="color: rgba(0, 128, 128, 1)">31</span> <span style="color: rgba(0, 0, 0, 1)">      data: {
</span><span style="color: rgba(0, 128, 128, 1)">32</span>         comment_count: _.inc(1<span style="color: rgba(0, 0, 0, 1)">)
</span><span style="color: rgba(0, 128, 128, 1)">33</span> <span style="color: rgba(0, 0, 0, 1)">      }
</span><span style="color: rgba(0, 128, 128, 1)">34</span> <span style="color: rgba(0, 0, 0, 1)">    })
</span><span style="color: rgba(0, 128, 128, 1)">35</span>   <span style="color: rgba(0, 0, 255, 1)">return</span><span style="color: rgba(0, 0, 0, 1)"> res;
</span><span style="color: rgba(0, 128, 128, 1)">36</span>   } <span style="color: rgba(0, 0, 255, 1)">catch</span><span style="color: rgba(0, 0, 0, 1)"> (e) {
</span><span style="color: rgba(0, 128, 128, 1)">37</span> <span style="color: rgba(0, 0, 0, 1)">    console.error(e)
</span><span style="color: rgba(0, 128, 128, 1)">38</span> <span style="color: rgba(0, 0, 0, 1)">}
</span><span style="color: rgba(0, 128, 128, 1)">39</span> }</pre>
</div>
<p>&nbsp;</p>
<h5 id="h5-2-2-">2.2 如何显示每一条评论</h5>
<p>从数据库取出评论的数据,循环遍历每一条父评论,如果有子回复也一并循环。这里每一条评论的唯一标识是用户的openId,那么我们可以用这个做一些事情,如:可以判断如果是自己的评论是不能回复的。</p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span>&lt;view class="comment" wx:<span style="color: rgba(0, 0, 255, 1)">if</span>="{{commentList.length&gt;0}}"&gt;
<span style="color: rgba(0, 128, 128, 1)"> 2</span>       &lt;view class="comment-line"&gt;
<span style="color: rgba(0, 128, 128, 1)"> 3</span>         &lt;text class="comment-text"&gt;评论交流&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)"> 4</span>         &lt;view class="bottom-line"&gt;&lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)"> 5</span>       &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)"> 6</span>       &lt;block wx:<span style="color: rgba(0, 0, 255, 1)">for</span>='{{commentList}}' wx:key='*this' wx:<span style="color: rgba(0, 0, 255, 1)">for</span>-item="itemfather"&gt;
<span style="color: rgba(0, 128, 128, 1)"> 7</span>         &lt;view class='commentList'&gt;
<span style="color: rgba(0, 128, 128, 1)"> 8</span>         &lt;view class="top-info"&gt;
<span style="color: rgba(0, 128, 128, 1)"> 9</span>             &lt;view class='img-name'&gt;
<span style="color: rgba(0, 128, 128, 1)">10</span>               &lt;image src="{{itemfather.avatarUrl}}"&gt;&lt;/image&gt;
<span style="color: rgba(0, 128, 128, 1)">11</span>               &lt;label&gt;{{itemfather.nickName}}&lt;/label&gt;
<span style="color: rgba(0, 128, 128, 1)">12</span>             &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">13</span>         &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">14</span>         &lt;view class="father-content"&gt;
<span style="color: rgba(0, 128, 128, 1)">15</span>             &lt;text class="text"&gt;{{itemfather.comment}}&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">16</span>             &lt;view class="father-reply-time"&gt;
<span style="color: rgba(0, 128, 128, 1)">17</span>               &lt;text class="create-time"&gt;{{itemfather.create_date}}&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">18</span>               &lt;text class="reply" data-item="{{itemfather}}" bindtap='clickFatherConter' wx:<span style="color: rgba(0, 0, 255, 1)">if</span>="{{openid != itemfather._openid}}"&gt;回复&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">19</span>             &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">20</span>         &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">21</span>         &lt;view class="children-content"&gt;
<span style="color: rgba(0, 128, 128, 1)">22</span>             &lt;block wx:<span style="color: rgba(0, 0, 255, 1)">for</span>='{{itemfather.childComment}}' wx:key='*this'&gt;
<span style="color: rgba(0, 128, 128, 1)">23</span>               &lt;view class='childComment'&gt;
<span style="color: rgba(0, 128, 128, 1)">24</span>               &lt;view class="child-img-name"&gt;
<span style="color: rgba(0, 128, 128, 1)">25</span>                   &lt;view class="avatar-name"&gt;
<span style="color: rgba(0, 128, 128, 1)">26</span>                     &lt;image src="{{item.avatarUrl}}"&gt;&lt;/image&gt;
<span style="color: rgba(0, 128, 128, 1)">27</span>                     &lt;text class='nickName'&gt;{{item.nickName}}&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">28</span>                   &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">29</span>               &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">30</span>               &lt;view class="child-comment" wx:<span style="color: rgba(0, 0, 255, 1)">if</span>="{{item.flag==2 }}"&gt;
<span style="color: rgba(0, 128, 128, 1)">31</span>                   &lt;text class='huifu'&gt;回复&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">32</span>                   &lt;text class='opposite-nickName'&gt;{{item.opposite_nickName}}&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">33</span>                   &lt;text class='comment-text'&gt;{{item.comment}}&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">34</span>               &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">35</span>               &lt;view class="child-comment" wx:<span style="color: rgba(0, 0, 255, 1)">if</span>="{{item.flag==1}}"&gt;
<span style="color: rgba(0, 128, 128, 1)">36</span>                   &lt;text class='comment-text'&gt;{{item.comment}}&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">37</span>               &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">38</span>               &lt;view class="child-reply-time"&gt;
<span style="color: rgba(0, 128, 128, 1)">39</span>                   &lt;text class="child-create-time"&gt;{{item.createDate}}&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">40</span>                   &lt;text class="reply" data-item="{{item}}" data-id="{{itemfather._id}}" bindtap='clickChildrenConter' wx:<span style="color: rgba(0, 0, 255, 1)">if</span>="{{openid != item.openId}}"&gt;回复&lt;/text&gt;
<span style="color: rgba(0, 128, 128, 1)">41</span>               &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">42</span>               &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">43</span>             &lt;/block&gt;
<span style="color: rgba(0, 128, 128, 1)">44</span>         &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">45</span>         &lt;/view&gt;
<span style="color: rgba(0, 128, 128, 1)">46</span>       &lt;/block&gt;
<span style="color: rgba(0, 128, 128, 1)">47</span>   &lt;/view&gt;</pre>
</div>
<p>&nbsp;</p>
<h2 id="h2--">四,项目运行</h2>
<h3 id="h3-1-">1. 下载源码</h3>
<p>在github上将代码下载到本地https://github.com/husanfeng/hsf_blog.git</p>
<h3 id="h3-2-">2. 环境准备</h3>
<p>1.下载小程序开发工具<br>2.注册appid<br>3.使用小程序开发工具导入下载的代码,填入自己注册的AppID</p>
<h3 id="h3-3-">3. 云开发准备</h3>
<h4>1.开通云开发功能</h4>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/kaitong.png?sign=c33aeb7185cb140f3678a4d0997f6a5d&amp;t=1574079699"></p>
<h4>2.创建测试环境和生产环境</h4>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/%E7%8E%AF%E5%A2%83ID.png?sign=331c712cf18104bed3c2256a60470dc8&amp;t=1573997586"></p>
<h3 id="h3-4-id">4. 修改环境ID</h3>
<h4>1.修改app.js中的环境ID为自己的环境ID</h4>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/ID1.png?sign=4f3760277d824ed698b160771145ca06&amp;t=1574079550"></p>
<h3 id="h3-5-">5. 云函数部署</h3>
<h4>1.右键云函数目录,点击在终端中打开,执行&nbsp;<code>npm install --save wx-server-sdk@latest</code></h4>
<p><img src="https://img2020.cnblogs.com/blog/1363775/202109/1363775-20210908114013034-1437166477.jpg"></p>
<p>&nbsp;</p>
<p>&nbsp;<br><img src="https://img2020.cnblogs.com/blog/1363775/202109/1363775-20210908114322271-1465347670.png"></p>
<p>&nbsp;</p>
<h4>2.右键执行上传并部署:所有文件</h4>
<p><img src="https://img2020.cnblogs.com/blog/1363775/202109/1363775-20210908120521478-4567273.jpg"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h3 id="h3-6-npm">6. 构建npm</h3>
<h4>1.进到项目根目录,执行npm install</h4>
<p><img src="https://img2020.cnblogs.com/blog/1363775/202005/1363775-20200524093026980-208212622.png"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>2.勾选使用npm模块<br><br><br></p>
<p><img src="https://6873-hsf-blog-product-jqt54-1256640731.tcb.qcloud.la/github.md/goujianNPM.png?sign=5f01eb43ef5824551540b36b1c319300&amp;t=1574080153"></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><img src="https://img2020.cnblogs.com/blog/1363775/202005/1363775-20200524093329107-1689929249.png"></p>
<p>&nbsp;</p>
<p><img src="https://img2020.cnblogs.com/blog/1363775/202005/1363775-20200524093157734-756537970.png"></p>
<p>&nbsp;</p>
<h3 id="h3-7-">7. 创建数据库集合(这里我只把你需要的集合截图出来了,其他的集合都是自动生成的,例如评论集合,浏览记录集合)</h3>
<p><img src="https://img2020.cnblogs.com/blog/1363775/202109/1363775-20210908115857989-609831016.png"></p>
<p>&nbsp;</p>
<p>&nbsp;<img src="https://img2020.cnblogs.com/blog/1363775/202109/1363775-20210908115040632-111165660.png"></p>
<p>&nbsp;</p>
<p>&nbsp;<img src="https://img2020.cnblogs.com/blog/1363775/202109/1363775-20210908115930047-257584249.png"></p>
<p>&nbsp;</p>
<p>&nbsp;<img src="https://img2020.cnblogs.com/blog/1363775/202109/1363775-20210908115946489-680745657.png"></p>
<p>&nbsp;</p>
<h2 id="h2--">五,发布注意事项</h2>
<blockquote>
<p>小程序现在审核也是越来越严谨了,为了不让大家在审核道路上走弯路,我把我的一些经验分享给大家</p>










</blockquote>
<h5 id="h5-1-">1.在微信公众平台上为小程序选择正确恰当的服务类目,例如博客类的小程序就可以选择教育信息服务</h5>
<h5 id="h5-2-">2.如果你的小程序需要账号密码登录,提交审核时需要提交一个账号和密码,而且这个账号不能是测试账号,不能出现测试数据</h5>
<h5 id="h5-3-">3.提交审核的版本首页需要有数据展示,例如:博客小程序你需要发布一篇或者多篇文章</h5>
<h5 id="h5-4-">4.文章内容不能存在敏感内容</h5>
<h5 id="h5-5-api-">5.评论功能审核比较严格了,一旦评论中存在敏感词汇,肯定审核不通过,官方建议调用小程序内容安全API,或使用其他技术、人工审核手段,过滤色情、违法等有害信息,保障发布内容的安全。</h5><br><br>
来源:https://www.cnblogs.com/husfBK/p/11939733.html
頁: [1]
查看完整版本: 小程序云开发,博客小程序,云开发小程序