欢迎来到258分享网,纯净的网络源码分享基地!

258资源分享网

全部作品
全部作品
网站源码
微信源码
素材特效
源码插件
视频教程
建站学院
热门搜索: 织梦  农业种植  农业  安全设置  官方
258资源分享 > 建站学院 > 微信开发 > 微信小程序使用相机

推荐下载

HTML5响应式自适应网咯设计

2020-05-12   浏览:736

高端HTML5响应式企业通用网

2020-05-06   浏览:517

html5响应式外贸网站英文版

2020-05-08   浏览:505

HTML5自适应律师工作室类网

2020-04-04   浏览:501

HTML5影视传媒文化公司类网

2020-05-12   浏览:495

微信小程序使用相机

发布时间:2020-10-15  

 

 

 

 

 

<view class="page-body">

<view class="page-body-wrapper">

<camera device-position="back" flash="off" binderror="error" style="width: 100%; height: 300px;"></camera>

<view class="btn-area">

<button type="primary" bindtap="takePhoto">拍照</button>

</view>

<view class="btn-area">

<button type="primary" bindtap="startRecord">开始录像</button>

</view>

<view class="btn-area">

<button type="primary" bindtap="stopRecord">结束录像</button>

</view>

<view class="preview-tips">预览</view>

<image wx:if="{{src}}" mode="widthFix" src=http://www.yiyongtong.com/archives/"{{src}}"></image>

<video wx:if="{{videoSrc}}" class="video" src=http://www.yiyongtong.com/archives/"{{videoSrc}}"></video>

</view>

</view>

 

onLoad() {

this.ctx = wx.createCameraContext()

},

takePhoto() {

this.ctx.takePhoto({

quality: 'high',

success: (res) => {

this.setData({

src: res.tempImagePath

})

}

})

},

startRecord() {

this.ctx.startRecord({

success: (res) => {

console.log('startRecord')

}

})

},

stopRecord() {

this.ctx.stopRecord({

success: (res) => {

this.setData({

src: res.tempThumbPath,

videoSrc: res.tempVideoPath

})

}

})

},

error(e) {

console.log(e.detail)

}

 

/* pages/one/one.wxss */

.preview-tips {

margin: 20rpx 0;

}

 

.video {

margin: 50px auto;

width: 100%;

height: 300px;

}

 

 

本文标签

:备案管家服务帮您把复杂流程变简单,解决您在进行网站备案过程中遇到的效率低下和成功率不高的问题。个人300/2个域名,企业500/5个域名,qq1650004.