本文记录我基于小程序云开发模式,进行小程序“口算卡”的全部历程,篇幅较长,分为以下篇章
- 需求概述及简单上手
- 小程序云函数使用(写入DB及读取DB)
- 小程序云函数(语音识别,从思路到实现到放弃使用云函数)
- 语音识别,从小程序云函数到自建服务器转码识别
书接上回,有个口算结果、时间、错题数、题量、我们得把它存储起来,方便之后看看趋势和进步;
所以这里要研究下小程序云开发里的 databaseGuide ,很方便的写入和读取;
写入成绩代码如下
saveScore(){
const db = wx.cloud.database()
db.collection('shuzi132').add({
data: {
type:'132',
addtime: parseInt(new Date()/1000),
total:this.total,
totalFail:this.totalFail,
time:this.time,
}
})
},
读取成绩列表
getHistory(){
const db = wx.cloud.database()
db.collection('shuzi132')
.where({_openid: getApp().globalData.openid})
.orderBy('addtime', 'desc')
.skip(this.offset)//分页offset
.limit(this.limit)//分页limit
.get()
.then(res=>{
console.log(res);
if(res.data.length<this.limit){
this.hasMore=false;
}
if(res.data.length>0){
this.formatRows(res.data);
}
})
},
基本已经达到需求,为了更舒适使用,下章我们开始语音识别之旅
- 需求概述及简单上手
- 小程序云函数使用(写入DB及读取DB)
- 小程序云函数(语音识别,从思路到实现到放弃使用云函数)
- 语音识别,从小程序云函数到自建服务器转码识别
打赏
微信扫一扫,打赏作者吧~