cordova-11/www/js/6.js

1 line
2.8 KiB
JavaScript
Raw Normal View History

2022-05-25 07:48:07 +08:00
(window["webpackJsonp"]=window["webpackJsonp"]||[]).push([[6],{"44a3":function(t,e,o){"use strict";o.r(e);var a=function(){var t=this,e=t.$createElement,o=t._self._c||e;return o("div",[t._v("\n 电池电量: "),o("strong",[t._v(t._s(t.batteryStatus))]),o("div",[o("q-btn",{attrs:{color:"primary",label:"唤起相机"},on:{click:t.takePhoto}}),o("img",{attrs:{src:t.imageSrc}})],1),o("div",[t._v(t._s(t.info))]),o("q-btn",{attrs:{color:"primary",label:"唤起弹窗"},on:{click:t.basicAlert}}),o("div",[o("q-btn",{attrs:{color:"primary",label:"获取地理位置"},on:{click:t.getPlace}})],1),o("div",[o("q-btn",{attrs:{color:"primary",label:"震动"},on:{click:t.move}})],1),o("div",[o("q-btn",{attrs:{color:"primary",label:"扫描二维码"},on:{click:t.scan}})],1)],1)},r=[],i={data(){return{batteryStatus:"determining...",imageSrc:"",info:device}},methods:{updateBatteryStatus(t){this.batteryStatus=`Level: ${t.level}, plugged: ${t.isPlugged}`},onBatteryLow(t){alert("低电量"+t.level+"%")},takePhoto(t){let e=null;e=t?Camera.PictureSourceType.CAMERA:Camera.PictureSourceType.PHOTOLIBRARY,window.navigator.camera.getPicture((t=>{this.uploadPhoto(t).then((t=>{this.imageList.push(JSON.parse(t).result),this.$emit("update:imageList",this.imageList),this.$refs.popover&&this.$refs.popover.doClose()})).catch((t=>{this.$message.error("上传图片失败"),this.$refs.popover&&this.$refs.popover.doClose()}))}),(t=>{this.$message.warning("取消拍照"),this.$refs.popover&&this.$refs.popover.doClose()}),{quality:50,destinationType:Camera.DestinationType.FILE_URI,sourceType:e})},basicAlert(){navigator.notification.alert("111",(()=>{}),"title","submit")},getPlace(){navigator.geolocation.getCurrentPosition(this.onSuccess,this.onError)},onSuccess(){alert("Latitude: "+position.coords.latitude+"\nLongitude: "+position.coords.longitude+"\nAltitude: "+position.coords.altitude+"\nAccuracy: "+position.coords.accuracy+"\nAltitude Accuracy: "+position.coords.altitudeAccuracy+"\nHeading: "+position.coords.heading+"\nSpeed: "+position.coords.speed+"\nTimestamp: "+position.timestamp+"\n")},onError(t){alert("code: "+t.code+"\nmessage: "+t.message+"\n")},move(){navigator.vibrate([200])},scan(){cloudSky.zBar.scan({text_title:"扫码",text_instructions:"请把相机对准二维码",camera:"red",flash:"auto",drawSight:!0},(function(t){console.log(t,"success")}),(function(t){console.log(t,"error")}))}},created(){window.addEventListener("batterystatus",this.updateBatteryStatus,!1),window.addEventListener("batterylow",onBatteryLow,!1)},beforeDestroy(){window.removeEventListener("batterystatus",this.updateBatteryStatus,!1),window.removeEventListener("batterylow",this.updateBatteryStatus,!1)}},s=i,n=o("2877"),c=o("9c40"),l=o("eebe"),d=o.n(l),u=Object(n["a"])(s,a,r,!1,null,null,null);e["default"]=u.exports;d()(u,"components",{QBtn:c["a"]})}}]);