APIClouder 制作一款预约功能的APP
为了参加比赛 制作了一款简单的预约用APP 使用APICloude的混合开发模式。
自我感觉适合新手使用
因为我也是新手
<!--fnWriteType向apicloud的数据库中进行修改 采用软删除的方式-->
function fnWriteType(tg) {
var model = api.require("model");
var query = api.require("query");
model.config({
appKey: '39ADA496-BAA4-DE29-FA1F-800DCCDF08A4',
host:'https://d.apicloud.com/'
});
query.createQuery(function(ret,err){
if(ret&&ret.qid){
model.findAll({
class: 'yuYue',
qid: ret.qid
},function(ret,err){
var type = ret[tg].yuYuetype;
if(type==1){
alert("该位置已被占用,请选择其他位置")
}
else {
model.updateById({
class: 'yuYue',
id: ret[tg].id,
value:{
yuYuetype:1 //更新
}
},function(ret,err){
if(ret){
alert("预约成功,请在10分钟之内到达");
var countDown = $api.byId('countDown');
var idPai = ret.location;
var pai = Math.floor(idPai/10);
var lie = idPai%10;
countDown.innerHTML = "预约的位置是"+pai+'_'+lie; 显示预约位置
var liId = $api.byId(idPai.toString());
liId.style.color = "#72a9dc";
}
});
}
});
}
});
}
<!--fnGaiColor() 注册在load事件中对提前预约过的位置进行颜色的改变 提示-->
function fnGaiColor(){
var query = api.require("query");//引入模块
var model = api.require("model");
query.createQuery(function(ret,err){ 创建查询
if(ret&&ret.qid){
model.findAll({
class: 'yuYue', //数据库里面的字段
qid: ret.qid
},function(ret,err){ //相当于callback 回调
var length = ret.length;
for(var i=0;i<length;i++){ 遍历数据库里所有
if(ret[i].yuYuetype==1){ 假设位置已经被占用
var id = ret[i].location.toString();
var clolrShow = $api.byId(id);
clolrShow.style.color = "#ff8610"; //对选择好的位置进行颜色的替换
}
}
});
}
});
}
```![在这里插入图片描述](https://img-blog.csdnimg.cn/20190804102640318.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyNzUyNzEy,size_16,color_FFFFFF,t_70)
代码下载地址(csdn的积分不能自己手动设置吗??)
https://download.csdn.net/download/qq_42752712/11469957