本DEMO只适用厚建出品APP
具体使用方法:
1:利用第三方工具(草料二维码)生成一个二维码
2:利用APP扫码功能打开此链接
3:点击预览demo
客户端有提供隐藏导航栏以及获取电池栏方法,
但是由于js中是异步取值,所以会有抖动
所以提供方法二(建议):直接在h5链接后面拼接参数
hideTopView=1&showStatusBar=1
这样客户端再初始化webview的时候会优先取这两个值,
这样就不在有抖动
显示顶栏右侧分享按钮,可以在链接后面拼接:
?showOutlinkMenu=1&hgWebShareTitle=
hgWebShareTitle的值是可以自定义分享标题,
不传则用默认title
SmartCity.closeWebViewBounces(data) data: 1 或者 0 传1关闭web的弹性下拉 传0开启弹性下拉 (默认开启)
// 点击某个服务 SmartCity.getServicePage({ serviceType: 'service', service_id:'xxx', // 服务id service_name:'xxxx' // 服务名称 }) // 进入某个服务界面 SmartCity.getServicePage({ serviceType: 'service_page' })
SmartCity.createShortCut({ linkUrl: "http://share.plus.hugd.com/ index.html", // 引导页地址 name: "我的应用", // 应用名称 outLink: "wifinantaihu://my", // ios目标链接 outLink_android: "www.baidu.com",// android的目标链接 iconUrl: "https://ami-cps .oss-cn-hangzhou.aliyuncs.com/ 1642672773004 loginStyle15_logo%403x .png"// 应用图标 })
SmartCity.stopUnload({ text: '您确定要退出吗?', sureText: '确定', cancelText: '取消' },function(res){ if( res == "1" || res == 1 ){ alert('点击了确定') SmartCity.goBack(); } if( res == "0" || res == 0 ){ alert('点击了取消') } })新页面打开看效果
SmartCity.vibrateFeedback(vibratetype,function(){ alert(vibratetype) }) vibratetype: success, error, warning
function applicationState(){ SmartCity.applicationState(function(res){ if( res.status==0 || res.status=="0" ){ alert('程序隐藏'); } if( res.status==1 || res.status=="1" ){ alert('程序显示'); } if( res.status==2 || res.status=="2" ){ alert('程序退出'); }applicationState();}); } res = { status: 0,1,2 } 0- 进入后台,1-进入前台,2-退出注意:由于客户端的机制不能保持一直连接, 可以在回调里面再调用一次
var isSmartCityApp = SmartCity.isSmartCityApp(); isSmartCityApp为true标识是在厚建客户端打开, 否则不是。
SmartCity.getUserInfo(function(res){ console.log(res); if( res && res.userInfo){ console.log(res); }else{ SmartCity.goLogin(); } }) 返回值res说明: { "userInfo": { "mobile_operator": { // 设备操作信息 "province": "江苏", // 省份 "city": "南京", // 城市 "area_code": "025", // 区号 "operator": "电信" // 运营商 }, "user_last_login_time": "", // 用户最后登录时间 "user_identification": "", "user_create_time": "", // 用户创建时间 "telephone": "189****6929", // 用户手机号 "real_name": "", "userid": "545************424", // 用户id "userXYTokenKey": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9", "picurl": "http://xxxx.cn/file/storage1-mmdsstatic/xxxx.jpg", // 用户头像地址 "unit_name": "", "m2ouid": "sbwh545340467332583424", "real_name_certificate": "0", "weixin_open_id": "", // 微信的openid "site_id": "", "unit_id": "", "userTokenKey": "Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9", // 用户token "username": "厚建" // 用户名 } }
SmartCity.getHMASUserInfo({ needlogin: '1' },function(res){ console.log(res); }) 参数needlogin说明: 1: 当前已登录返回用户信息,未登录自动跳转到登录页, 登录后返回用户信息 0: 当前已登录返回用户信息,未登录返回的用户信息为空 返回值res说明: { // needlogin传0且在未登录下返回空对象 "userInfo": { "userid": "100385", //用户id "member_name":"13770513867", //用户名 "picurl": "", //用户头像 "m2ouid": "JinRiZiYang100385", "real_name_certificate": "0", "userTokenKey": "", //用户token "user_identification": "", "username": "Ctrl + R", //用户昵称 "email": "", //用户邮箱 "telephone": "18061756449", //用户手机 "real_name": "", //用户名 "isVerify":"" //是否实名0或1 }, "parameter": null, }
SmartCity.getSystemInfo(function(res){ console.log(res); }); 返回值res说明: { "deviceInfo": { types : 手机平台信息,例如:iPhone9,2 debug : 1 program_version : app版本号 device_token : 设备令牌 program_name : app名称 appid : m2o加密id appid : m2o加密key system : 系统版本,例如:iOS 13.1.3, appStatusBarHeight: "手机电量栏高度" }, "parameter": "传给客户端的参数", }
SmartCity.getLocation(function(res){ console.log(res); }); 返回值res说明: { "longitude": "经度 ", "latitude": "纬度", "provinces": "省", "city": "市", "area": "区", "address": "地址", "parameter": "传给客户端的参数", }
SmartCity.makeCall({ tel : '180****6175' });
SmartCity.sendMail({ mailto: "收件人", subject: "邮件标题", messageBody: "邮件内容" });
SmartCity.makeMsm({ sms: "180****6449", subject: "短信主题", messageBody: "短信内容", });
SmartCity.goLogin();
SmartCity.goUcenter();
SmartCity.goBack();
SmartCity.goAbort();
SmartCity.goRoot();
SmartCity.shareTo({ title: "分享标题", brief: "分享简介", contentURL: "分享内容url", imageLink: "分享图片链接", content_type: '' //新版统计参数 类型: share content_title: '' // 新版统计参数: 标题 url: '' // 新版统计参数: 网页地址 content_id: '' // 新版统计参数: id operate_type: '' // 新版统计参数 操作: share realDataType: '1' // 新版统计参数:默认为1 }); 回调: { "message": "分享取消/失败/成功", "shareState": "cancel/failure/success" }
SmartCity.shareTo({ showShareButton: "1" });
SmartCity.shareTo({ showShareButton: "0" });
SmartCity.shareTo({ // 1: 更新分享数据且不弹分享视图。 updateShareData: "1", title: "更新后的标题", brief: "更新后的描述", contentURL: "更新后的url", imageLink: "更新后的图片" });
注意: js调用shareTo方法之前,同时调用onShareSuccess(), 此方法后期不在维护。请使用shareTo()方法callback进 行你的业务处理。 SmartCity.onShareSuccess(function(res){ console.log(res); });
SmartCity.linkTo({ innerLink: "news#2734" }); // 2023年8月之前立项的App, 内链跳转使用此。之后废弃此字段; { "innerLink" : "用模块标识加#加id" , } // 2023年8月之后立项的App,内外链均使用此字段; { "outlink": "跳转链接" }
SmartCity.clickImage({ url: "图片地址" });
SmartCity.saveImage({ url: "图片地址" });
SmartCity.appTLUnifyAllinpay({ "sign": "e23c7808e62713233cf12c1c689d1d85", "orgid": "561391053991HU4", "notifyurl": "", "subject": "yunshanfuZF20210120153132512", "paytype": "unionpay", "reqsn": "1351794482567200768D1", "appid": "00187910", "cusid": "55239105399QZLR", "backurl": "", "validtime": "60", "trxamt": "1", "signtype": "MD5" }); orgid 机构号,即父商户号 cusid 子商户号 appid 应用ID,平台分配的机构对接appid reqsn 订单号,通商云返回的reqPayInterfaceNo subject 订单标题 trxamt 订单金额,单位:分 validtime 订单超时时间,以分为单位 notifyurl 结果通知地址 signtype 签名类型 sign 签名字符串,已传字段排序后的MD5 paytype 支付渠道,云闪付app backurl 支付后的跳转界面 注:客户端不提供回调状态通知是否支付成功! h5调用可以弹出一个对话框(参考支付宝), 是否已支付?点击是 去查询订单信息或者支付记录, 已支付跳转到对应页面, 未支付提示支付失败!
SmartCity.appCommonPay({ "channel": "weixin", "name": "商品", "price": 100, "orderNumber": "weixinZF20210120153132512", "orderInfo":'{"appid":"partnerid","partnerid":"1622631701", "prepayid":"wx05153839948524a6ecd9fc049541e70000","timestamp":"1659685120", "noncestr":"gP5BOdK73hJordGT","package":"Sign=WXPay", "sign":"D834EC39198BAF71921CAD1D53FBD79B"}' }); channel 支付方式 weixin 微信 name 订单标题 orderNumber 订单号 orderInfo 订单信息
SmartCity.hideTopView({ isShow: 0 });
SmartCity.goVRPlayer({ VRPlayURL: "播放链接", });
SmartCity.chooseImage({ count : 2 },function(res){ console.log(res); }); 传递参数说明: count 选择的图片张数,默认为1张 返回值res说明:res返回一个数组 [ { name:"图片名称", type:"图片类型:image/jpg", size:"图片大小", filePath:"图片路径", imageData:"图片data的base64字符串" } ]
SmartCity.uploadFile({ url : '', data : { file:'本地路径' } },function(res){ })
SmartCity.previewImage({ urls:[ "图片链接地址1", "图片链接地址1", "图片链接地址2" ], index:0 }); 或者 SmartCity.previewImage({ current: "图片链接地址1", index:"当前展示的索引值" });
SmartCity.clearHistory();
SmartCity.getRequestHeader(function(res){ console.log(res); }); 返回值res说明: { "X-API-TIMESTAMP": "加密时间戳", "X-API-KEY": "加密key", "X-AUTH-TYPE": "加密类型", "X-API-VERSION": "加密版本", "X-API-SIGNATURE": "加密的签名", "X-KEY": "加密id" }
SmartCity.scanQRCode(function(res){ console.log(res); }); 返回值说明: 1.成功状态: res = { scanSuccess: "1", resultStr:"扫描结果" } 失败状态: res = { scanSuccess: "0", resultStr:"" }
SmartCity.startRecord(function(res){ console.log(res); });
SmartCity.stopRecord();
SmartCity.playVoice(url);
SmartCity.pauseVoice(url);
SmartCity.goBind();
SmartCity.goToAuthentication(function(res){ console.log(res) }); 返回值res说明: { data:{ "cancel":"1表示取消了实名认证" }, isSuccess:"1认证成功,0认证失败" }
SmartCity.goToRealPersionAuth({ name: '张三', // 真实姓名 idCardNumber: 'xxxxx' // 身份证号码 }, function(res){ console.log(res) }); 返回值res说明: data:{ "cancel":"1表示取消了实人认证" }, isSuccess:"1认证成功,0认证失败" }
SmartCity.goToCamera({ deviceFront : 0 },function(res){ console.log(res); }); 传递参数说明: deviceFront 设置方向,1前置摄像头,0后置摄像头 返回值res说明: { imagePath: "图片路径", imageData: "图片data的base64字符串" }
SmartCity.optionalAreaForPhotos({ idCardFront : 1, // 扫描框背景,不传则使用默认 bgImgUrl : 'https://xingyunos.oss-cn-hang
zhou.aliyuncs.com/tmp/scan_idcard_font_bg2.png' },function(res){ console.log(res); }); 传递参数说明: idCardFront :1代表拍摄身份证正面,0代表拍摄身份证反面 bgImgUrl : 可选区域背景,有值时则idCardFront字段无效; 返回值res说明: { imagePath: "图片路径", imageData: "图片data的base64字符串" }
SmartCity.goToLivingStyle(function(res){ console.log(res); }); 返回值res说明: { isSuccess: "1成功,0失败", imageData: "认证图片data的Base64字符串" }
SmartCity.interactivePopDisabled("1"); 0或者1的字符串,1禁用,0不禁用
SmartCity.sendAnalysisData({ xxx : "******", xxx : "******", content_type: '', //新版统计参数:类型 1文稿:article 2图集:gallery 3视频:video 4专题:topic 5:外链link 6:报料contribute 7音频:audio 8首页:home 9栏目:column 10下载:download 11商城:good 12积分商城:integral_good 13活动:activity 14活动-投票:activity_vote 15活动-报名:activity_register 16活动-综合:activity_comprehensive 17活动-单页:activity_page 18活动-抽奖:activity_draw 19酷虎:kuhu content_title: '', // 新版统计参数:标题 url: '', // 新版统计参数: 网页地址 content_id: '', // 新版统计参数:id operate_type: '', // 新版统计参数:操作类型 1参与数:partake 2收藏数:collection 3分享数:share 4点赞数:like 5点击数:click realDataType: '1' //新版统计参数:默认为1 }); 参数根据实际接口要求传递
SmartCity.requestApi({ url : '', method : 'GET', params : { xxxx :"******" } },function(res){ console.log(res); }); 传递参数说明: { "url":"请求url", "method":"请求方法", "params":{ "******":"******" } }
SmartCity.goToJXMealCardLivingStyle
(function(res){ console.log(res); }); 返回值res说明: { isSuccess: "1活检成功,0活检失败", errorMessage:返回提示信息 imageData: "认证图片data的Base64字符串" }
SmartCity.goToJXMealCardSafetyKeyboard
(function(res){ console.log(res); }); 返回值res说明: { result: "键盘输入结果” }
SmartCity.chooseVideo(function(res){ console.log(res); }); 返回值res说明: { size:”视频大小", videoData:”视频data的base64字符串" }
SmartCity.linkToSubApp({ innerLink : "应用信息字符串" });
SmartCity.getStepDayData({ date: '2022-03-15' }, function(res){ console.log(res); }); 传参说明: date 为空,则表示获取当日运动量; 建议最大不超过10天。具体根据不同手机而定; 按示例格式传入日期; 返回值说明: 当日数据,随时间实时更新; 历史数据不变,为每日总数; { "errorCode":"0", "errorMessage":"", "stepData":{ "steps":2333,// 步数 } } errroCode不为0,stepData无法返回具体数据; 如,未取得用户授权、小米、华为SDK授权异常等; 如果数据返回-1,表示无权限,需要通过 `SmartCity.linkTo(outLink: {sign}/
CompHealthKitAuth)` sign: my (默认) 如果数据返回0,表示未获取数据, 可能由于设备未绑定心率和血压检测设备;
SmartCity.getHealthDayData({ date: '2022-03-15' }, function(res){ console.log(res); }); 传参说明: date 为空,则表示获取当日运动量; 建议最大不超过10天。具体根据不同手机而定; 按示例格式传入日期; 返回值说明: 当日数据,随时间实时更新; 历史数据不变,为每日总数; { "errorCode":"0", "errorMessage":"", "healthData":{ "heart":2333,// 心率 "bloodPressure":123 // 血压 } } errroCode不为0,healthData无法返回具体数据; 如,未取得用户授权、小米、华为SDK授权异常等; 如果数据返回-1,表示无权限,需要通过 `SmartCity.linkTo(outLink: {sign}/
CompHealthKitAuth)` sign: my (默认) 如果数据返回0,表示未获取数据, 可能由于设备未绑定心率和血压检测设备;
SmartCity.embedVideoPlayer({ url : '', top : 0, left : 0, right : 0, aspect_ratio : '0.75', is_audio : false, image_url : '', ratio : '0.75', is_svideo : true, isLive : true, isScroll : true }); 传递参数说明: { "url": "播放链接", "top": "播放器距离页面顶部距离", "left": "播放器距离页面左边距离", "right": "播放器距离页面右边距离", "aspect_ratio": "播放器宽高比",传数值0.75,1.25... "is_audio": "是否是音频:0或者1", "image_url": "音频展示的索引图", "ratio": "播放器宽高比",传数值0.75,1.25... "is_svideo": "是否是竖屏视频:0或者1", "isLive": "是否是直播:0或者1", "isScroll": "是否需要播放器跟随滚动:0或者1" }
SmartCity.destroyVideoPlayer();
SmartCity.loadBarrageData( [ { "content" : "xxxxx", "color" : 'red', "time" : "9837432222" } ] ); 传递参数说明:传递一个数组[] [ { "content" : "弹幕内容", "color" : "弹幕颜色", "time" : "弹幕发送当前时间戳10位" } ]
SmartCity.goUniWallet(data);
SmartCity.videoRecording({ videoMaxDuration:30 videoMinDuration:10 recordingModel:0 camera_tip: 请将手机竖向拍摄 show_localVideo: 0 },function(res){ alert(res) }); 传递参数说明: { videoMaxDuration:视频最大长度(秒为单位) (默认:不限制) videoMinDuration:视频最小长度(秒为单位) (默认:10) recordingModel:视频拍摄模式, 0长按,1单击显示进度,2单击显示时长(默认:0) camera_tip:拍摄提示文案(默认:请将手机竖向拍摄) show_localVideo: 是否显示本地视频上传入口(默认:0) }
SmartCity.openSmartDialog({ isOpen:1 },function(res){ alert(res) });
SmartCity.openSmartDialog({ isOpen:0 },function(res){ alert(res) });
SmartCity.creditRulesUpdate({ availableScore: "84", totalScore: "84", addScore: "1" });
SmartCity.appCCBPay({ orderInfo: "MERCHANTID=105421097080009&POS
ID=902807340&BRANCHID=360000000&ORDERID=46356&
PAYMENT=0.01&CURCODE=01&TXCODE=520100&REMARK1
=&REMARK2=&TYPE=1&GATEWAY=&CLIENTIP=
手机IP(获取方法见上文)&INFO=xiaofeixia&PROINFO=
digital&REFERER=&THIRDAPPINFO=ccbdemo&MAC=
fb009c2f6570d415032860072c8c4bd8" });
SmartCity.canScreenshot({ canScreenshot: "0" //0为禁止截屏,其他和默认
为允许截屏 });
SmartCity.showKakuAnimations(function(res){ alert(res) });
SmartCity.getBluetoothDevices(function(res){ console.log(res); }); 返回值res说明: [{ "name":"蓝牙设备名称,某些设备可能没有", "deviceld":"蓝牙设备 id" "RSSI":当前蓝牙设备的信号强度,单位 dBm }]
SmartCity.startBluetoothDevicesDiscovery( function(res){ console.log(res); } ); 返回值res说明: { "status":"0",// 0:失败, 1: 成功 }
SmartCity.stopBluetoothDevicesDiscovery( function(res){ console.log(res); } ); 返回值res说明: { "status":"0",// 0:失败, 1: 成功 }
SmartCity.floatingWindow({ "title":直播标题, "play_url":播放地址, "outlink":当前H5地址, "play_time":当前播放时长 },function(res){ console.log(res); } );