使用APICloud AVM多端框架开发消防检查助手App项目实践分享

相逢意气为君饮,系马高楼垂柳边。这篇文章主要讲述使用APICloud AVM多端框架开发消防检查助手App项目实践分享相关的知识,希望能为你提供帮助。
一、功能介绍把消防检查过程中,需要手写填报的文档,在App端以表单填写进行实现。同时可以添加手写签名,关联照片,而且App端表单填报很多项目进行下拉选择,极大的提高了工作效率;表单填报完成之后可通过系统后台生成word模板文件,App端下载到手机,通过手机连接打印机,可把纸质文件进行打印。
App开发采用APICloud AVM框架,后台采用php。
 
功能要点:
1、场所登记,分为九小场所和合用场所登记
2、监督检查记录
3、责令整改通知书
4、基本情况拍照,检查过程记录拍照
5、后台针对上述数据进行多维度分析,导出Excel表格,Word模板文件
 
二、思维导图

使用APICloud AVM多端框架开发消防检查助手App项目实践分享

文章图片
< text class="item-info"> item.address< /text>
< /view>
< view class="item-sub-box">
< image class="item-sub-ico" src="https://www.songbingjia.com/images/CT.png" mode="aspectFit"> < /image>
< text class="item-info"> item.type< /text>
< /view>
< /view>
< /view>
< /view>
< view class="footer">
< text class="loadDesc"> loadStateDesc< /text>
< /view>
< /scroll-view>
< /view>
< /template>
< script>
import Model from ../../utils/model.js
import Config from "../../utils/config.js"
import $util from "../../utils/util.js"
export default
name: unitlist,
data()
return
list:[],
skip: 0,
loading: false,
refresherTriggered: false,
haveMoreData: true,
tab:,
tabtitle:,
key:

,
computed:
loadStateDesc()
if (this.data.loading || this.data.haveMoreData)
return 加载中...;
else if (this.list.length > 0)
return 没有更多啦;
else
return 暂时没有内容;


,
methods:
apiready()
this.data.tab=api.pageParam.tab;
this.data.tabtitle=api.pageParam.tabtitle;
this.data.refresherTriggered = true;
this.loadData(false);
api.addEventListener(
name: setuserinfo
, (ret, err) =>
this.loadData(false);
);
//监听增加修改基本信息
api.addEventListener(
name: addbase
, (ret, err) =>
this.loadData(false);
);
api.addEventListener(
name: delbase
, (ret, err) =>
this.loadData(false);
);
,
loadData(loadMore)
this.data.loading = true;
var that = this;
var limit = 20;
var skip = loadMore?that.data.skip+1:0;
let params =
data:
values:
secret: Config.secret,
userid: api.getPrefs(sync: true,key: userid),
roleid: api.getPrefs(sync: true,key: roleid),
partid: api.getPrefs(sync: true,key: partid),
skip: skip,
limit: limit,
key:this.data.key



api.showProgress();
Model.querylist(params, (res,err) =>
// console.log(JSON.stringify(res));
// console.log(JSON.stringify(err));
if (res & & res.flag == Success)
let lists = res.data;
that.data.haveMoreData = https://www.songbingjia.com/android/lists.length == limit;
if (loadMore)
that.data.list = that.data.list.concat(lists);
else
that.data.list = lists;

that.data.skip = skip;
else
that.data.haveMoreData = https://www.songbingjia.com/android/false;

that.data.loading = false;
that.data.refresherTriggered = false;
api.hideProgress();
);
,
//打开填写表格
openTable(e)
var id = e.currentTarget.dataset.id;
$util.openWin(
name: this.data.tab,
url: ../index/+this.data.tab+.stml,
title: this.data.tabtitle,
pageParam:
id:id

);
,
/*下拉刷新页面*/
onrefresherrefresh()
this.data.refresherTriggered = true;
this.loadData(false);
,
onscrolltolower()
if (this.data.haveMoreData)
this.loadData(true);

,
getKey(e)
this.data.key = e.detail.value;
,
onconfirm()
this.loadData(false);



< /script>
< style>
.main
height: 100%;
background-color: #eaf0fa;

.item-box
background-color: #fff;
margin: 5px;

.item
border-bottom: 1px solid #efefef;
margin: 0 10px;
justify-content:flex-start;
flex-direction:column;

.item-content
font-size: 17PX;
margin-top: 10px;

.item-info
font-size: 13PX;
color: #666;
margin: 10px 0;

.item-sub
justify-content:space-between;
flex-direction:row;

.footer
height: 44px;
justify-content: center;
align-items: center;

.loadDesc
width: 200px;
text-align: center;

.item-sub-ico
width: 15px;
margin: 10px 0;

.item-sub-box
flex-flow: row nowrap;

.search-box
flex-flow: row nowrap;
align-items: center;
background-color: #2c6ddc;
border-radius: 5px;
margin: 5px;

.serach-input
padding: 5px;
width: 80%;
height: 50px;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;

.search-btn
width: 20%;
text-align: center;
color: #ffffff;

< /style>

6、双击退出程序在首页页面和登陆页面中,添加双击退出程序功能,避免出现单击退出键出现不必要的页面跳转失误。此监听事件要在apiready中执行。
//监听返回双击退出程序
api.setPrefs(
key: time_last,
value: 0
);
api.addEventListener(
name : keyback
, function(ret, err)
var time_last = api.getPrefs(sync: true,key: time_last);
var time_now = Date.parse(new Date());
if (time_now - time_last > 2000)
api.setPrefs(key:time_last,value:time_now);
api.toast(
msg : 再按一次退出APP,
duration : 2000,
location : bottom
);
else
api.closeWidget(
silent : true
);

);


7、账号有效性确认由于后台针对用户账号,启用了停用功能,后台一旦设置账号停用,App中也应响应的将用户进行退出系统操作。此操作在首页的apiready中进行执行。
isLogin()
if(!api.getPrefs(sync: true,key:userid))
$util.openWin(
name: login,
url: ../user/login.stml,
title: ,
hideNavigationBar:true
);

else
let params =
data:
values:
secret: Config.secret,
userid: api.getPrefs(sync: true,key:userid)



api.showProgress();
Model.checkUserStatus(params, (res,err) =>
// console.log(JSON.stringify(res));
// console.log(JSON.stringify(err));
if (res & & res.flag == Success)
if(ret.data=https://www.songbingjia.com/android/=02)
//清楚缓存用户数据
api.removePrefs(
key: name
);
api.removePrefs(
key: userid
);
api.removePrefs(
key: partname
);
api.removePrefs(
key: partid
);
api.removePrefs(
key: role
);
api.removePrefs(
key: rolename
);
api.removePrefs(
key: username
);
//用户已停用 退出系统
$util.openWin(
name: login,
url: ../user/login.stml,
title: ,
hideNavigationBar:true
);

else
//清除用户信息
api.removePrefs(
key: name
);
api.removePrefs(
key: userid
);
api.removePrefs(
key: partname
);
api.removePrefs(
key: partid
);
api.removePrefs(
key: role
);
api.removePrefs(
key: rolename
);
api.removePrefs(
key: username
);
//用户异常 退出重新登陆
$util.openWin(
name: login,
url: ../user/login.stml,
title: ,
hideNavigationBar:true
);

api.hideProgress();
);



8、表单提交、回显表单使用的事AVM官方的 from组件,通过onsubmit进行表单数据的提交。其中主要用到了input、textarea、radio、checkbox; 每个控件的具体使用方法,在官方文档中否有详细的介绍。下面就具体的代码示例进行展示。

?
页面代码 
< template name=addbase>
< scroll-view class="page" scroll-y>
< form onsubmit=this.onsubmit>
< view class="item">
< text> 单位名称:< /text>
< input name="dwmc" value=https://www.songbingjia.com/android/this.data.dwmc placeholder="请输入单位名称"/>
< /view>
< view class="item">
< text> 单位地址:< /text>
< input name="dwdz"value=https://www.songbingjia.com/android/this.data.dwdz placeholder="请输入单位详细地址"/>
< /view>
< checkbox-group class="item" name="dwlb">
< text> 单位类别:< /text>
< view class="item-checkbox">
< label v-for="item in dwlbarr">
< checkbox value=https://www.songbingjia.com/android/item v-bind:checked="this.data.seldwlb.indexOf(item)!=-1?true:false"/>
< text> item< /text>
< /label>
< /view>
< input name="dwlb_qt" value=https://www.songbingjia.com/android/this.data.dwlb_qt placeholder="请输入单位类别"/>
< /checkbox-group>
< checkbox-group class="item" name="dwxz">
< text> 单位性质:< /text>
< view class="item-checkbox">
< label v-for="item in dwxzarr">
< checkbox value=https://www.songbingjia.com/android/item v-bind:checked="this.data.seldwxz.indexOf(item)!=-1?true:false"/>
< text> item< /text>
< /label>
< /view>
< /checkbox-group>
< view class="item">
< text> 职工总数:< /text>
< input name="zgzs" value=https://www.songbingjia.com/android/this.data.zgzs keyboard-type="number" placeholder="请输入单位职工总数"/>
< /view>
< view class="item">
< text> 消防安全责任人:< /text>
< input name="xfaqzrr_xm" value=https://www.songbingjia.com/android/this.data.xfaqzrr_xm placeholder="请输入负责人姓名"/>
< input name="xfaqzrr_zw" value=https://www.songbingjia.com/android/this.data.xfaqzrr_zw placeholder="请输入负责人职务"/>
< input name="xfaqzrr_dh" value=https://www.songbingjia.com/android/this.data.xfaqzrr_dh keyboard-type="number" placeholder="请输入负责人电话"/>
< /view>
< view class="item">
< text> 消防安全管理人:< /text>
< input name="xfaqglr_xm" value=https://www.songbingjia.com/android/this.data.xfaqglr_xm placeholder="请输入管理人姓名"/>
< input name="xfaqglr_zw" value=https://www.songbingjia.com/android/this.data.xfaqglr_zw placeholder="请输入管理人职务"/>
< input name="xfaqglr_dh" value=https://www.songbingjia.com/android/this.data.xfaqglr_dh keyboard-type="number" placeholder="请输入管理人电话"/>
< /view>
< view class="item">
< text> 专兼职防火干部:< /text>
< input name="zjzfhgb_xm" value=https://www.songbingjia.com/android/this.data.zjzfhgb_xm placeholder="请输入专兼职防火干部姓名"/>
< input name="zjzfhgb_zw" value=https://www.songbingjia.com/android/this.data.zjzfhgb_zw placeholder="请输入专兼职防火干部职务"/>
< input name="zjzfhgb_dh" value=https://www.songbingjia.com/android/this.data.zjzfhgb_dh keyboard-type="number" placeholder="请输入专兼职防火干部电话"/>
< /view>
< view class="item">
< label class="label-box">
< text class="label-title"> 建筑层数(层)< /text>
< input class="label-input" name="jzcs" value=https://www.songbingjia.com/android/this.data.jzcs keyboard-type="number" placeholder="请输入建筑层数(层)"/>
< /label>
< label class="label-box">
< text class="label-title"> 所在层数(层)< /text>
< input class="label-input" name="szcs" value=https://www.songbingjia.com/android/this.data.szcs keyboard-type="number" placeholder="请输入所在层数(层)"/>
< /label>
< label class="label-box">
< text class="label-title"> 建筑高度(m)< /text>
< input class="label-input" name="jzgd" value=https://www.songbingjia.com/android/this.data.jzgd keyboard-type="number" placeholder="请输入建筑高度(m)"/>
< /label>
< label class="label-box">
< text class="label-title"> 总建筑面积(㎡)< /text>
< input class="label-input" name="zjzmj" value=https://www.songbingjia.com/android/this.data.zjzmj keyboard-type="decimal" placeholder="请输入总建筑面积(㎡)"/>
< /label>
< label class="label-box">
< text class="label-title"> 每层建筑面积(㎡)< /text>
< input class="label-input" name="mcjzmj" value=https://www.songbingjia.com/android/this.data.mcjzmj keyboard-type="decimal" placeholder="请输入每层建筑面积(㎡)"/>
< /label>
< label class="label-box">
< text class="label-title"> 营业面积(㎡)< /text>
< input class="label-input" name="yymj" value=https://www.songbingjia.com/android/this.data.yymj keyboard-type="decimal" placeholder="请输入营业面积(㎡)"/>
< /label>
< label class="label-box">
< text class="label-title"> 检查时间< /text>
< input class="label-input" name="jcsj" value=https://www.songbingjia.com/android/this.data.jcsj keyboard-type="number" placeholder="请输入检查时间"/>
< /label>
< label class="label-box">
< text class="label-title"> 投入使用时间< /text>
< input class="label-input" name="trsysj" value=https://www.songbingjia.com/android/this.data.trsysj keyboard-type="number" placeholder="请输入投入使用时间"/>
< /label>
< label class="label-box">
< text class="label-title"> 开业时间< /text>
< input class="label-input" name="kysj" value=https://www.songbingjia.com/android/this.data.kysj keyboard-type="number" placeholder="请输入开业时间"/>
< /label>
< label class="label-box">
< text class="label-title"> 租赁房屋户主姓名< /text>
< input class="label-input" name="zlfwhzxm" value=https://www.songbingjia.com/android/this.data.zlfwhzxm placeholder="请输入租赁房屋户主姓名"/>
< /label>
< /view>
< view class="item">
< text> 生产经营状况:< /text>
< input name="scjyzk" value=https://www.songbingjia.com/android/this.data.scjyzk placeholder="请输入单位生产经营状况"/>
< /view>
< view class="item">
< text> 隶属社区:< /text>
< input name="lssq" value=https://www.songbingjia.com/android/this.data.lssq placeholder="请输入单位隶属社区"/>
< /view>
< radio-group class="item" name="ssyjfl">
< text> 三色预警分类:< /text>
< view class="item-checkbox">
< label v-for="item in ssyjflarr">
< radio value=https://www.songbingjia.com/android/item v-bind:checked="this.data.ssyjfl==item?true:false"/>
< text> item< /text>
< /label>
< /view>
< /radio-group>
< view class="item">
< text> 消防设置种类及数量:< /text>
< textarea name="xfsszljsl" value=https://www.songbingjia.com/android/this.data.xfsszljsl placeholder="请输入消防设置种类及数量"/>
< /view>
< view class="item">
< text> 检查登记情况:< /text>
< textarea name="jcqkdj_1" value=https://www.songbingjia.com/android/this.data.jcqkdj_1 placeholder="请输入检查登记情况"/>
< textarea name="jcqkdj_2" value=https://www.songbingjia.com/android/this.data.jcqkdj_2 placeholder="请输入检查登记情况"/>
< textarea name="jcqkdj_3" value=https://www.songbingjia.com/android/this.data.jcqkdj_3 placeholder="请输入检查登记情况"/>
< textarea name="jcqkdj_4" value=https://www.songbingjia.com/android/this.data.jcqkdj_4 placeholder="请输入检查登记情况"/>
< /view>
< view class="item">
< text> 填表说明:< /text>
< /view>
< button class="btn-submit" type="submit"> 提交< /button>
< /form>
< button v-show="isdelete" class="btn-delete" type="button" @click="delbase"> 删除< /button>
< /scroll-view>
< /template>

data()
return
dwmc:,
dwdz:,
dwlb:,
dwxz:,
zgzs:0,
xfaqzrr_xm:,
xfaqzrr_zw:,
xfaqzrr_dh:,
xfaqglr_xm:,
xfaqglr_zw:,
xfaqglr_dh:,
zjzfhgb_xm:,
zjzfhgb_zw:,
zjzfhgb_dh:,
jzcs:null,
jzgd:null,
zjzmj:null,
mcjzmj:null,
szcs:null,
yymj:null,
jcsj:,
trsysj:,
kysj:,
zlfwhzxm:,
scjyzk:,
lssq:,
ssyjfl:,
xfsszljsl:,
jcqkdj_1:,
jcqkdj_2:,
jcqkdj_3:,
jcqkdj_4:,
dwlb_qt:,
id:0,
ssyjflarr:[红,黄,绿],
dwlbarr:[购物场所,餐饮场所,住宿场所,公共娱乐场所,休闲健身场所,医疗场所,教学场所,生产加工企业,易燃易爆危险品销售、储存场所,其他],
dwxzarr:[国有,集体,股份合作公司,股份有限公司,港澳台投资,中外合资,个体私营,其他],
seldwlb:[],
seldwxz:[],
isdelete:false,
dateList: [$formatDate.lastYear30(),[1,2,3,4,5,6,7,8,9,10,11,12],[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]],
jcsjSelectorValue:[0,0,0],
trsysjSelectorValue:[0,0,0],
kysjSelectorValue:[0,0,0]

,


表单提交
onsubmit(e)
let result = e.detail.value;
this.data.dwmc = result.dwmc?result.dwmc:this.data.dwmc;
this.data.dwdz = result.dwdz?result.dwdz:this.data.dwdz;
this.data.dwlb = result.dwlb?result.dwlb.join(,):this.data.dwlb;
this.data.dwlb_qt = result.dwlb_qt?result.dwlb_qt:this.data.dwlb_qt;
this.data.dwxz = result.dwxz?result.dwxz.join(,):this.data.dwxz;
this.data.zgzs = result.zgzs?result.zgzs:this.data.zgzs;
this.data.xfaqzrr_xm = result.xfaqzrr_xm?result.xfaqzrr_xm:this.data.xfaqzrr_xm;
this.data.xfaqzrr_zw = result.xfaqzrr_zw?result.xfaqzrr_zw:this.data.xfaqzrr_zw;
this.data.xfaqzrr_dh = result.xfaqzrr_dh?result.xfaqzrr_dh:this.data.xfaqzrr_dh;
this.data.xfaqglr_xm = result.xfaqglr_xm?result.xfaqglr_xm:this.data.xfaqglr_xm;
this.data.xfaqglr_zw = result.xfaqglr_zw?result.xfaqglr_zw:this.data.xfaqglr_zw;
this.data.xfaqglr_dh = result.xfaqglr_dh?result.xfaqglr_dh:this.data.xfaqglr_dh;
this.data.zjzfhgb_xm = result.zjzfhgb_xm?result.zjzfhgb_xm:this.data.zjzfhgb_xm;
this.data.zjzfhgb_zw = result.zjzfhgb_zw?result.zjzfhgb_zw:this.data.zjzfhgb_zw;
this.data.zjzfhgb_dh = result.zjzfhgb_dh?result.zjzfhgb_dh:this.data.zjzfhgb_dh;
this.data.jzcs = result.jzcs?result.jzcs:this.data.jzcs;
this.data.jzgd = result.jzgd?result.jzgd:this.data.jzgd;
this.data.zjzmj = result.zjzmj?result.zjzmj:this.data.zjzmj;
this.data.mcjzmj = result.mcjzmj?result.mcjzmj:this.data.mcjzmj;
this.data.szcs = result.szcs?result.szcs:this.data.szcs;
this.data.yymj = result.yymj?result.yymj:this.data.yymj;
this.data.jcsj = result.jcsj?result.jcsj:this.data.jcsj;
this.data.trsysj = result.trsysj?result.trsysj:this.data.trsysj;
this.data.kysj = result.kysj?result.kysj:this.data.kysj;
this.data.zlfwhzxm = result.zlfwhzxm?result.zlfwhzxm:this.data.zlfwhzxm;
this.data.scjyzk = result.scjyzk?result.scjyzk:this.data.scjyzk;
this.data.lssq = result.lssq?result.lssq:this.data.lssq;
this.data.ssyjfl = result.ssyjfl?result.ssyjfl:this.data.ssyjfl;
this.data.xfsszljsl = result.xfsszljsl?result.xfsszljsl:this.data.xfsszljsl;
this.data.jcqkdj_1 = result.jcqkdj_1?result.jcqkdj_1:this.data.jcqkdj_1;
this.data.jcqkdj_2 = result.jcqkdj_1?result.jcqkdj_2:this.data.jcqkdj_2;
this.data.jcqkdj_3 = result.jcqkdj_1?result.jcqkdj_3:this.data.jcqkdj_3;
this.data.jcqkdj_4 = result.jcqkdj_1?result.jcqkdj_4:this.data.jcqkdj_4;

if(this.data.dwmc==)
api.toast(
msg:单位名称不能为空!
);
return false;

if(this.data.dwdz==)
api.toast(
msg:单位地址不能为空!
);
return false;

if(this.data.dwlb==)
api.toast(
msg:单位类别不能为空!
);
return false;

if(this.data.dwxz==)
api.toast(
msg:单位性质不能为空!
);
return false;

let params =
data:
values:
secret: Config.secret,
userid: api.getPrefs(sync: true,key: userid),
id:this.data.id,
dwmc:this.data.dwmc,
dwdz:this.data.dwdz,
dwlb:this.data.dwlb,
dwxz:this.data.dwxz,
zgzs:this.data.zgzs,
xfaqzrr_xm:this.data.xfaqzrr_xm,
xfaqzrr_zw:this.data.xfaqzrr_zw,
xfaqzrr_dh:this.data.xfaqzrr_dh,
xfaqglr_xm:this.data.xfaqglr_xm,
xfaqglr_zw:this.data.xfaqglr_zw,
xfaqglr_dh:this.data.xfaqglr_dh,
zjzfhgb_xm:this.data.zjzfhgb_xm,
zjzfhgb_zw:this.data.zjzfhgb_zw,
zjzfhgb_dh:this.data.zjzfhgb_dh,
jzcs:this.data.jzcs,
jzgd:this.data.jzgd,
zjzmj:this.data.zjzmj,
mcjzmj:this.data.mcjzmj,
szcs:this.data.szcs,
yymj:this.data.yymj,
jcsj:this.data.jcsj,
trsysj:this.data.trsysj,
kysj:this.data.kysj,
zlfwhzxm:this.data.zlfwhzxm,
scjyzk:this.data.scjyzk,
lssq:this.data.lssq,
ssyjfl:this.data.ssyjfl,
xfsszljsl:this.data.xfsszljsl,
jcqkdj_1:this.data.jcqkdj_1,
jcqkdj_2:this.data.jcqkdj_2,
jcqkdj_3:this.data.jcqkdj_3,
jcqkdj_4:this.data.jcqkdj_4,
dwlb_qt:this.data.dwlb_qt



api.showProgress();
Model.addbase(params, (res,err) =>
// console.log(JSON.stringify(res));
// console.log(JSON.stringify(err));
if (res & & res.flag == Success)
api.toast(
msg:登记成功
);
api.sendEvent(
name: addbase,
);
api.closeWin();
else
api.toast(
msg:res.msg
)

api.hideProgress();
);
,


数据回显 
//查询已添加的数据
loadData()
let params =
data:
values:
secret: Config.secret,
id:this.data.id



api.showProgress();
Model.querybasebyid(params, (res,err) =>
// console.log(JSON.stringify(res));
// console.log(JSON.stringify(err));
if (res & & res.flag == Success)
//填充数据
let result=res.data;

this.data.dwmc = result.dwmc?result.dwmc:this.data.dwmc;
this.data.dwdz = result.dwdz?result.dwdz:this.data.dwdz;
this.data.seldwlb = result.dwlb?result.dwlb.split(,):this.data.dwlb;
this.data.dwlb_qt = result.dwlb_qt?result.dwlb_qt:this.data.dwlb_qt;
this.data.seldwxz = result.dwxz?result.dwxz.split(,):this.data.dwxz;
this.data.zgzs = result.zgzs?result.zgzs:this.data.zgzs;
this.data.xfaqzrr_xm = result.xfaqzrr_xm?result.xfaqzrr_xm:this.data.xfaqzrr_xm;
this.data.xfaqzrr_zw = result.xfaqzrr_zw?result.xfaqzrr_zw:this.data.xfaqzrr_zw;
this.data.xfaqzrr_dh = result.xfaqzrr_dh?result.xfaqzrr_dh:this.data.xfaqzrr_dh;
this.data.xfaqglr_xm = result.xfaqglr_xm?result.xfaqglr_xm:this.data.xfaqglr_xm;
this.data.xfaqglr_zw = result.xfaqglr_zw?result.xfaqglr_zw:this.data.xfaqglr_zw;
this.data.xfaqglr_dh = result.xfaqglr_dh?result.xfaqglr_dh:this.data.xfaqglr_dh;
this.data.zjzfhgb_xm = result.zjzfhgb_xm?result.zjzfhgb_xm:this.data.zjzfhgb_xm;
this.data.zjzfhgb_zw = result.zjzfhgb_zw?result.zjzfhgb_zw:this.data.zjzfhgb_zw;
this.data.zjzfhgb_dh = result.zjzfhgb_dh?result.zjzfhgb_dh:this.data.zjzfhgb_dh;
this.data.jzcs = result.jzcs?result.jzcs:this.data.jzcs;
this.data.jzgd = result.jzgd?result.jzgd:this.data.jzgd;
this.data.zjzmj = result.zjzmj?result.zjzmj:this.data.zjzmj;
this.data.mcjzmj = result.mcjzmj?result.mcjzmj:this.data.mcjzmj;
this.data.szcs = result.szcs?result.szcs:this.data.szcs;
this.data.yymj = result.yymj?result.yymj:this.data.yymj;
this.data.jcsj = result.jcsj?result.jcsj:this.data.jcsj;
this.data.trsysj = result.trsysj?result.trsysj:this.data.trsysj;
this.data.kysj = result.kysj?result.kysj:this.data.kysj;
this.data.zlfwhzxm = result.zlfwhzxm?result.zlfwhzxm:this.data.zlfwhzxm;
this.data.scjyzk = result.scjyzk?result.scjyzk:this.data.scjyzk;
this.data.lssq = result.lssq?result.lssq:this.data.lssq;
this.data.ssyjfl = result.ssyjfl?result.ssyjfl:this.data.ssyjfl;
this.data.xfsszljsl = result.xfsszljsl?result.xfsszljsl:this.data.xfsszljsl;
this.data.jcqkdj_1 = result.jcqkdj_1?result.jcqkdj_1:this.data.jcqkdj_1;
this.data.jcqkdj_2 = result.jcqkdj_1?result.jcqkdj_2:this.data.jcqkdj_2;
this.data.jcqkdj_3 = result.jcqkdj_1?result.jcqkdj_3:this.data.jcqkdj_3;
this.data.jcqkdj_4 = result.jcqkdj_1?result.jcqkdj_4:this.data.jcqkdj_4;

else
api.toast(
msg:res.msg
)

api.hideProgress();
);
,


9、拍照及上传照片,图片预览【使用APICloud AVM多端框架开发消防检查助手App项目实践分享】拍照使用的是FNPhotograph模块,自带UI的open接口,可选择拍照照片的质量,可配置使用摄像头方向,同时可配置照片不用存储到相册中,禁用显示相册按钮,保证用户只能现场拍照,可以满足项目需求。

 
项目中很多页面涉及到图片预览的功能,分为单图预览和多图预览。图片预览采用的是photoBrowser 模块。photoBrowser 是一个图片浏览器,支持单张、多张图片查看的功能,可放大缩小图片,支持本地和网络图片资源。若是网络图片资源则会被缓存到本地,缓存到本地上的资源可以通过 clearCache 接口手动清除。同时本模块支持横竖屏显示,在本app支持横竖屏的情况下,本模块底层会自动监听当前设备的位置状态,自动适配横竖屏以展示图片。使用此模块开发者看实现炫酷的图片浏览器。
 

getPicture(e)
this.data.type = e.currentTarget.dataset.type;
api.actionSheet(
title: 请选择,
cancelTitle: 取消,
buttons: [选择图片,图片预览]
, (ret, err)=>
// console.log(JSON.stringify(ret));
// console.log(JSON.stringify(err));
// var index = ret.buttonIndex;
if(ret.buttonIndex==1)
var FNPhotograph = api.require(FNPhotograph);
FNPhotograph.open(
album: true ,
quality: medium
, (ret)=>
// console.log(JSON.stringify(ret));
if(ret.eventType==takePhoto)
FNPhotograph.close();
//上传图片
let params =
data:
values:
secret: Config.secret,
baseid:this.data.baseid,
type:this.data.type
,
files:
file:ret.imagePath,



api.showProgress();
Model.addbasepicbyid(params, (res,err) =>
// console.log(JSON.stringify(res));
// console.log(JSON.stringify(err));
if (res & & res.flag == Success)

    推荐阅读