国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

h5和微信小程序?qū)崿F(xiàn)拍照功能(其中h5暫時(shí)無法調(diào)用閃光燈)

這篇具有很好參考價(jià)值的文章主要介紹了h5和微信小程序?qū)崿F(xiàn)拍照功能(其中h5暫時(shí)無法調(diào)用閃光燈)。希望對大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

h5和微信小程序?qū)崿F(xiàn)拍照功能(其中h5暫時(shí)無法調(diào)用閃光燈),微信小程序,小程序

代碼如下文章來源地址http://www.zghlxwxcb.cn/news/detail-826262.html

<template>
	<view class="camera">
		
		<!-- #ifdef MP -->
		  <camera ref="myCamera" id="myCamera" device-position="back" :flash="flash" @error="error" style="display: block;">
		  	<view class="chejiaQie">
		  	<view @click="qie(0)" :class="cheJiaQieStatus==0?'textColorOne':'textColorTwo'" >拍車架號</view>
		  	
		  	<view @click="qie(1)" :class="cheJiaQieStatus==1?'textColorOne':'textColorTwo'" >拍行駛證</view>
		  	</view>
		  </camera>
		<!-- #endif -->
		<!-- #ifdef H5 -->
		<input type="file" accept="image/*" mutiple="mutiple" capture="camera" />
			<view class="chejiaQie">
			<view @click="qie(0)" :class="cheJiaQieStatus==0?'textColorOne':'textColorTwo'" >拍車架號</view>
			
			<view @click="qie(1)" :class="cheJiaQieStatus==1?'textColorOne':'textColorTwo'" >拍行駛證</view>
			</view>
			<view style="width: 100%;height: 690px;">
			 <image mode="widthFix" :src="src" style="width: 100%; height: 100%;"></image>
			</view>
			
		</input>
	  	<!-- #endif -->
		
		<view class="footer">
					
					<view class="album" @click="toggleFlashlight">
						<view>	
						<image style="width: 42px;height: 42px;" :src="deng==1?require('../../static/imgs/shanguangdengMing.png'):require('../../static/imgs/shanguangdeng-liang.png')" mode="aspectFill" />
						<view style="text-align: center;">
						 閃光燈
						</view>
						</view>
					</view>
					
							<!-- #ifdef MP -->
						<view class="takePhoto" @click="takePhoto">
						<view>
							<image style="width: 42px;height: 42px;" :src="require('../../static/imgs/paizhao.png')" mode="aspectFill" />
							<view style="text-align: center;">
							拍照
							</view>
						</view>
						</view>
						<!--#endif-->
						<!-- #ifdef H5 -->
						<view class="takePhoto" @click="changePic">
						<view>
							<image style="width: 42px;height: 42px;" :src="require('../../static/imgs/paizhao.png')" mode="aspectFill" />
							<view style="text-align: center;">
							拍照
							</view>
						</view>
						</view>
						<!--#endif-->
					
					<view class="devPosition" @click="saoMao">
						<view>
					<!-- 		 @click="CameraPosition" -->
						
						<image style="width: 42px;height: 42px;" :src="require('../../static/imgs/tupian.png')" mode="aspectFill" />
						<view style="text-align: center;">
						相冊
						</view>
						</view>
					</view>
		</view>
		

	</view>
</template>

<script>
	import store from '@/store';
	import {
	selectReleaseVehicles,
	selectFactoryNameplate
		} from '@/api/index.js';
	export default {
		data() {
			return {
				  
				deng:0,
				flash: 'off',
				cheJiaQieStatus:0,
				src:"",
				back:false,
				//是否重復(fù)拍照
				isReward:1,
			};
		},
		// onShow() {
		
		// 	var input = document.querySelector("input[type=file]");
		// 	input.addEventListener("change", function(e) {
		// 	  var file = e.target.files[0];
		// 	  var reader = new FileReader();
		// 	  reader.onload = function(e) {
		// 	    var dataURL = e.target.result;
		// 	    // 在此處對 dataURL 進(jìn)行操作,例如顯示圖片
		// 	  };
		// 	  reader.readAsDataURL(file);
		// 	});
		// },
		methods: {
			handlerSuccess(img) {
                this.img = img
            },
			changePic(e) {
				let thit=this;
				uni.chooseImage({
					
					sizeType: ['original', 'compressed'], //可以指定是原圖還是壓縮圖,默認(rèn)二者都有
					sourceType: ['camera'],   //album 從相冊選圖,camera 使用相機(jī)
					success: function (res) {
					console.log(res,"777777")
						 uni.uploadFile({
							url: store.state.baseUrl + '/web/common/upload',  
							filePath: res.tempFilePaths[0],
							name: 'file',
							success: (uploadFileRes) => {
									const userInfo=	uni.getStorageSync("userinfo");
								console.log(JSON.parse(uploadFileRes.data).data.src,"00999899")
							     thit.src=JSON.parse(uploadFileRes.data).data.src;
								res={image:JSON.parse(uploadFileRes.data).data.src,userId:userInfo.id}
								console.log(res,"2222222")
								
								if(thit.cheJiaQieStatus==1){
						
								selectReleaseVehicles(res).then(res=>{
												uni.setStorageSync(
												"saomiaoPai",res.data.data
												)
										   
										uni.showToast({
											title: '識別成功',
											mask: true,
											icon: 'none'
										})
										console.log("返回上個(gè)頁面之前")
											uni.navigateBack()
											console.log("返回上個(gè)頁面之后")
								}).catch((err)=>{
									uni.showToast({
										title: '識別失敗',
										mask: true,
										icon: 'none'
									})
								})}else{
									
									//
									selectFactoryNameplate(res).then(res => {
										// thit.hao = res.data.data.carno;
										
										uni.setStorageSync(
										"saomiaoPai",res.data.data
										)
										// thit.car_hao = res.data.data.carno;
										// thit.pin_name = res.data.data.carModel;
										// thit.plaecr_pai = res.data.data.licenseAddress;
										// thit.plaecr = res.data.data.carAddress;
										uni.showToast({
											title: '識別成功',
											mask: true,
											icon: 'none'
										})
										uni.navigateBack(-1)
									}).catch((err)=>{
										uni.showToast({
											title: '識別失敗',
											mask: true,
											icon: 'none'
										})
									})
									
									
								}
								
								},
								fail(err) {
									uni.showToast({
										title: '識別失敗',
										mask: true,
										icon: 'none'
									})
									console.log("識別失敗",err)
								}
								}
							)
						 
					}
				});
			},
			
			
			//選擇相冊
			saoMao(){
		
			let thit=this
			
					uni.chooseImage({
						count: 6, //默認(rèn)9
						sizeType: ['original', 'compressed'], //可以指定是原圖還是壓縮圖,默認(rèn)二者都有
						sourceType: ['album'],   //album 從相冊選圖,camera 使用相機(jī)
						success: function (res) {
						console.log(res,"777777")
							 uni.uploadFile({
								url: store.state.baseUrl + '/web/common/upload',  
								filePath: res.tempFilePaths[0],
								name: 'file',
								success: (uploadFileRes) => {
										const userInfo=	uni.getStorageSync("userinfo");
									console.log(JSON.parse(uploadFileRes.data).data.src,"00999899")
								
									res={image:JSON.parse(uploadFileRes.data).data.src,userId:userInfo.id}
									console.log(res,"2222222")
									
									if(thit.cheJiaQieStatus==1){
							
									selectReleaseVehicles(res).then(res=>{
													uni.setStorageSync(
													"saomiaoPai",res.data.data
													)
											   
											uni.showToast({
												title: '識別成功',
												mask: true,
												icon: 'none'
											})
											console.log("返回上個(gè)頁面之前")
												uni.navigateBack()
												console.log("返回上個(gè)頁面之后")
									}).catch((err)=>{
										uni.showToast({
											title: '識別失敗',
											mask: true,
											icon: 'none'
										})
									})}else{
										
										//
										selectFactoryNameplate(res).then(res => {
											// thit.hao = res.data.data.carno;
											
											uni.setStorageSync(
											"saomiaoPai",res.data.data
											)
											// thit.car_hao = res.data.data.carno;
											// thit.pin_name = res.data.data.carModel;
											// thit.plaecr_pai = res.data.data.licenseAddress;
											// thit.plaecr = res.data.data.carAddress;
											uni.showToast({
												title: '識別成功',
												mask: true,
												icon: 'none'
											})
											uni.navigateBack(-1)
										}).catch((err)=>{
											uni.showToast({
												title: '識別失敗',
												mask: true,
												icon: 'none'
											})
										})
										
										
									}
									
									},
									fail(err) {
										uni.showToast({
											title: '識別失敗',
											mask: true,
											icon: 'none'
										})
										console.log("識別失敗",err)
									}
									}
								)
							 
						}
					});
				},
			
			//切換燈光
			 toggleFlashlight() {
			   let flag = this.flash
			   				if (flag == 'off') {
								this.deng=1
			   					this.flash = 'torch'
			   				} else {
								this.deng=0
			   					this.flash = 'off'
			   				}

			    },
			 
			qie(val){
				
				this.cheJiaQieStatus=val;
			},
			//拍照
			async takePhoto() {
				if(this.isReward==0){
					uni.showToast({
						title: '識別中,請稍等!',
						mask: true,
						icon: 'none'
					})
				};
				this.isReward=0;
			           const ctx = uni.createCameraContext();
			          await ctx.takePhoto({
			               quality: 'high',
			               success: (res) => {
			                   this.src = res.tempImagePath
			               }
			           }).catch((err)=>{
						   this.isReward=1;
						   

					   });
					await   this.shibie();
			       },
				   shibie(){
					   let thit=this;
					   	const userInfo=	uni.getStorageSync("userinfo");
					  uni.uploadFile({
					  	url: store.state.baseUrl + '/web/common/upload',
					  	filePath:this.src,
					  	name: 'file',
					  	success: (uploadFileRes) => {
					  		console.log(JSON.parse(uploadFileRes.data).data.src, "00999899")
					  
					  	let	res = {
					  			image: JSON.parse(uploadFileRes.data).data.src,
					  			userId: userInfo.id
					  		}
					  		console.log(res, "2222222")
							if(this.cheJiaQieStatus==1){
								selectReleaseVehicles(res).then(res => {
									uni.setStorageSync(
									"saomiaoPai",res.data.data
									)
								  this.isReward=1;									   
									// // thit.hao = res.data.data.carno;
									// thit.car_hao = res.data.data.carno;
									// thit.pin_name = res.data.data.carModel;
									// thit.plaecr_pai = res.data.data.licenseAddress;
									// thit.plaecr = res.data.data.carAddress;
									uni.showToast({
										title: '識別成功',
										mask: true,
										icon: 'none'
									})
							        uni.navigateBack()
								}).catch((err)=>{
									this.isReward=1;	
									uni.showToast({
										title: '識別失敗',
										mask: true,
										icon: 'none'
									})
								})
							}else{
								selectFactoryNameplate(res).then(res => {
									uni.setStorageSync(
									"saomiaoPai",res.data.data
									)
									this.isReward=1;	
									// thit.hao = res.data.data.carno;
									// thit.car_hao = res.data.data.carno;
									// thit.pin_name = res.data.data.carModel;
									// thit.plaecr_pai = res.data.data.licenseAddress;
									// thit.plaecr = res.data.data.carAddress;
									uni.showToast({
										title: '識別成功',
										mask: true,
										icon: 'none'
									})
									uni.navigateBack()
								}).catch((err)=>{
									this.isReward=1;	
									uni.showToast({
										title: '識別失敗',
										mask: true,
										icon: 'none'
									})
								})
							}
					  		
					  	}
					  }) 
				   }
		}
	}
</script>

<style lang="scss" scoped>
	.textColorOne{
		width: 70px;text-align: center;
		background-color: red;
		color: white;
	}
	.textColorTwo{
		width: 70px;text-align: center;
		background-color: white;
		color: red;
	}
	.chejiaQie{
		display: flex;top: 28px; margin: 0 auto;width: 140px;
		border: 1px solid red;
		height: 28px;
		line-height: 26px;
		margin-top: 30px;
	}
	.camera {
		width: 100%;
		height: 100%;
		position: relative;
 
		.preview-img {
			width: 100%;
			height: 100%;
			position: absolute;
			top: 0;
			left: 0;
			z-index: 1;
		}
	}
 
	.camera camera {
		height: 100vh;
	}
 
	.footer {
		position: fixed;
		left: 0;
		right: 0;
		bottom: 0;
		background: #FFF;
		border-radius: 10rpx 10rpx 0 0;
		display: flex;
		justify-content: center;
		align-items: center;
		padding-top: 20rpx;
		padding-bottom: 30rpx;
		box-shadow: 0 0 15rpx rgba(244, 244, 244, 0.4);
		z-index: 5;
 
		.back,
		.album,
		.takePhoto,
		.devPosition {
			margin: auto;
 
			image {
				width: 75rpx;
				height: 75rpx;
			}
		}
 
		.album {
			image {
				width: 85rpx;
				height: 85rpx;
			}
		}
 
		.takePhoto {
			image {
				width: 120rpx;
				height: 120rpx;
			}
		}
 
	}
</style>

到了這里,關(guān)于h5和微信小程序?qū)崿F(xiàn)拍照功能(其中h5暫時(shí)無法調(diào)用閃光燈)的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • 微信小程序?qū)崿F(xiàn)拍照并拿到圖片對象功能

    微信小程序?qū)崿F(xiàn)拍照并拿到圖片對象功能

    微信小程序提供了函數(shù)chooseImage 我們可以在wxml中定義一個(gè)按鈕 這里綁定了一個(gè)點(diǎn)擊事件 叫 photograph 然后 我們在js中編寫代碼如下 這里 我們點(diǎn)擊后調(diào)用了wx.chooseImage 回調(diào)中接受了一個(gè)res對象 其中的tempFilePaths字段就是我們要到圖片集合 我們運(yùn)行代碼 然后用手機(jī)真機(jī)調(diào)試 然后

    2024年02月07日
    瀏覽(98)
  • uniapp:h5和微信小程序文件下載方式

    uniapp:h5和微信小程序文件下載方式

    一、h5瀏覽器端下載方式,直接使用a標(biāo)簽 download屬性指定下載文件的文件名,也可以不加 注意:記得一定要加ifdef注釋,不然其他端也會顯示a標(biāo)簽 二、微信小程序下載方式,通過uniapp的downloadFile和wx小程序的saveFile保存文件 wx保存文件的api只是臨時(shí)保存圖片文件,可以通過微

    2024年02月07日
    瀏覽(97)
  • 微信小程序怎么實(shí)現(xiàn)拍照功能,以及授權(quán),拍完照保存到本地。

    微信小程序怎么實(shí)現(xiàn)拍照功能,以及授權(quán),拍完照保存到本地。

    寫微信小程序就是要不停的翻閱官方文檔查閱所需要的需求。 API的使用說明 wx.getSetting 獲取用戶的當(dāng)前設(shè)置。返回值中只會出現(xiàn)小程序已經(jīng)向用戶請求過的權(quán)限 scope.camera相機(jī) wx.authorize 提前向用戶發(fā)起授權(quán)請求。調(diào)用后會立刻彈窗詢問用戶是否同意授權(quán)小程序使用某項(xiàng)功能或

    2024年02月02日
    瀏覽(26)
  • 【h5+微信小程序】vue2實(shí)現(xiàn)h5掃碼登錄功能

    需要實(shí)現(xiàn)在同域名的h5頁面上增加一個(gè)微信掃碼登錄的功能,如果用戶已經(jīng)有小程序的賬號,可以直接登錄。 使用 :vue2+微信小程序原生開發(fā) 可以實(shí)現(xiàn)上述功能的 前提 是:同一用戶,對同一個(gè)微信開放平臺下的不同應(yīng)用,UnionID是相同的。域名已經(jīng)配置。 可以用什么來區(qū)分

    2024年02月14日
    瀏覽(98)
  • 微信小程序內(nèi)嵌h5頁面,實(shí)現(xiàn)動態(tài)設(shè)置頂部標(biāo)題的功能

    一、需求描述 使用HBuilder X作為開發(fā)工具,vue作為開發(fā)語言,開發(fā)微信小程序。微信小程序頁面內(nèi)嵌h5頁面,即web-view/web-view標(biāo)簽。通過設(shè)置不同url連接地址,設(shè)置不同的標(biāo)題。 二、失敗做法 頁面A嵌入h5頁面,需要給A設(shè)置標(biāo)題。最開始寫法是在lonload頁面內(nèi),使用如下語句實(shí)現(xiàn)

    2024年02月04日
    瀏覽(150)
  • 實(shí)現(xiàn)微信小程序web-view內(nèi)嵌H5中的下載功能(大文件切片下載)

    微信小程序的開發(fā)框架是uniapp,使用uniapp腳手架搭建,其中有頁面是展示另一個(gè)小程序,在這個(gè)頁面主體內(nèi)容使用了標(biāo)簽將H5的頁面內(nèi)容展示,H5中有頁面存放了下載的路徑。點(diǎn)擊下載按鈕下載文件,或者預(yù)覽文件讓用戶手動保存。 如果是pc端,下載用一個(gè) a 標(biāo)簽就很容易,但

    2024年02月10日
    瀏覽(156)
  • vue3引入JS-SDK實(shí)現(xiàn)h5分享小卡片、跳轉(zhuǎn)微信小程序功能

    vue3引入JS-SDK實(shí)現(xiàn)h5分享小卡片、跳轉(zhuǎn)微信小程序功能

    微信js-sdk官方文檔: https://developers.weixin.qq.com/doc/offiaccount/OA_Web_Apps/JS-SDK.html 想要實(shí)現(xiàn)的效果: 1.登錄微信公眾平臺,進(jìn)入“公眾號設(shè)置”的“功能設(shè)置”里填寫“JS接口安全域名”。 2.通過npm引入js-sdk 安裝成功后,可以在package.json中找到\\\"weixin-js-sdk\\\" 3.在main.js中,將js-sdk掛載

    2024年02月11日
    瀏覽(101)
  • 微信小程序嵌套H5頁面,調(diào)用微信小程序掃碼功能,并將結(jié)果傳回H5頁面

    微信小程序嵌套H5頁面,調(diào)用微信小程序掃碼功能,并將結(jié)果傳回H5頁面

    實(shí)現(xiàn)方式: 小程序嵌套h5頁面,點(diǎn)擊h5頁面的掃碼按鈕跳轉(zhuǎn)到小程序的掃碼頁面,進(jìn)入之后會立即掃碼,拿到掃碼結(jié)果后,跳轉(zhuǎn)到小程序定義好的webview頁面,再由webview頁面進(jìn)入h5頁面。 缺點(diǎn):為了喚起掃碼,會進(jìn)入一個(gè)空白的掃碼頁面 1、小程序嵌套h5頁面方法 在小程序中,創(chuàng)

    2024年02月12日
    瀏覽(18)
  • uniapp APP、H5和微信小程序 使用百度地圖,H5動態(tài)加載百度地圖sdk,cover-image圖片不顯示,標(biāo)準(zhǔn)基座模擬器地圖不顯示,表單校驗(yàn)字段[‘**‘]在數(shù)據(jù)庫中不存在

    APP里面的幾個(gè)注意項(xiàng) 在百度地圖開放平臺申請密匙,在manifest.json App模塊配置的地圖模塊選擇百度地圖并填入申請到的appkey。 頁面使用uniapp的map標(biāo)簽,要在地圖上面覆蓋圖片、內(nèi)容等,使用cover-image、cover-view,因?yàn)閙ap是原生組件,覆蓋的內(nèi)容有時(shí)不顯示,使用v-if控制(這里

    2024年02月11日
    瀏覽(113)
  • 基于SpringBoot和微信小程序的校園失物招領(lǐng)系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn)

    ?? 作者主頁:超級無敵暴龍戰(zhàn)士塔塔開 ?? 簡介:Java領(lǐng)域優(yōu)質(zhì)創(chuàng)作者??、 簡歷模板、學(xué)習(xí)資料、面試題庫【關(guān)注我,都給你】 ??文末獲取源碼聯(lián)系?? 基于SpringBoot和微信小程序的校園失物招領(lǐng)系統(tǒng)的設(shè)計(jì)與實(shí)現(xiàn),java項(xiàng)目。 eclipse和idea都能打開運(yùn)行。 推薦環(huán)境配置:eclip

    2024年01月16日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包