Commit f57ec0a0 authored by zhoucong's avatar zhoucong

处理安卓手机相机组件圆角无效

parent 237539b8
...@@ -10,13 +10,15 @@ const request = (url = '', data = {}, type = 'POST') => { ...@@ -10,13 +10,15 @@ const request = (url = '', data = {}, type = 'POST') => {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
uni.request({ uni.request({
method: type, method: type,
url: baseUrl + url+'?token='+uni.getStorageSync("openid"), url: baseUrl + url+'?token='+uni.getStorageSync("token"),
data:data, data:data,
dataType: 'json', dataType: 'json',
}).then((response) => { }).then((response) => {
uni.hideLoading()
let [error, res] = response; let [error, res] = response;
resolve(res.data); resolve(res.data);
}).catch(error => { }).catch(error => {
uni.hideLoading()
let [err, res] = error; let [err, res] = error;
reject(err) reject(err)
}) })
......
...@@ -84,7 +84,6 @@ ...@@ -84,7 +84,6 @@
this.getUserInfo() //获取用户信息 this.getUserInfo() //获取用户信息
this.getScenicList() //获取景区列表 this.getScenicList() //获取景区列表
this.openCamera() //打开权限 this.openCamera() //打开权限
}, },
onReady() { //代替 vue 里面的 mounted onReady() { //代替 vue 里面的 mounted
}, },
...@@ -116,7 +115,6 @@ ...@@ -116,7 +115,6 @@
} }
this.$request("distribution/vlog/getScenicList", data).then(res => { this.$request("distribution/vlog/getScenicList", data).then(res => {
if (res.code === "00") { //请求成功 if (res.code === "00") { //请求成功
console.log("景区列表", res.data.list);
this.scenicList = res.data.list this.scenicList = res.data.list
} else { } else {
uni.showModal({ uni.showModal({
...@@ -124,14 +122,13 @@ ...@@ -124,14 +122,13 @@
showCancel: false showCancel: false
}) })
} }
}) })
}, },
vlogRegister() { //用户注册 vlogRegister() { //用户注册
let data = { let data = {
"nickName": this.userInfo.nickname, //昵称 "nickName": this.userInfo.nickname.substr(0,10), //昵称
"userId": this.userInfo.openid, //用户id(用微信openid) "userId": this.userInfo.openid, //用户id(用微信openid)
"phone": 18523953636, //手机 "phone": 17347895200, //手机
"outUserId": this.userInfo.openid, //用户Id, //外部应用id(用微信openid) "outUserId": this.userInfo.openid, //用户Id, //外部应用id(用微信openid)
"userType": "WECHAT", //ALIPAY-支付宝小程序,WECHAT-微信小程序,OTHER-其他 "userType": "WECHAT", //ALIPAY-支付宝小程序,WECHAT-微信小程序,OTHER-其他
"gender": this.userInfo.gender //0-男,1-女 "gender": this.userInfo.gender //0-男,1-女
......
...@@ -40,20 +40,26 @@ ...@@ -40,20 +40,26 @@
onShareAppMessage(res) { //分享 onShareAppMessage(res) { //分享
let productId = res.target.dataset.productid let productId = res.target.dataset.productid
let productUrl= res.target.dataset.producturl let productUrl= res.target.dataset.producturl
this.$request("wechatUser/myPage/updateVlogRecord", {
productId,
openid: uni.getStorageSync("openid")
}).then(res => {
if (res.code === "00") {
this.getMyVlogList()
}
})
if (res.from === "button") { if (res.from === "button") {
this.$request("wechatUser/myPage/updateVlogRecord", {
productId,
openid: uni.getStorageSync("openid")
}).then(res => {
if (res.code === "00") {
this.getMyVlogList()
}
})
return { return {
title: '胖丁旅行', title: '胖丁旅行',
type: 4, type: 4,
path: '/pages/vlog/share/share?url='+productUrl, path: '/pages/vlog/share/share?url='+productUrl,
} }
}else{
return {
title: '胖丁旅行',
type: 4,
path: '/pages/vlog/vlogIndex/vlogIndex',
}
} }
}, },
methods: { methods: {
......
<template> <template>
<view class="content"> <view class="content">
<view class="d1"></view> <view class="bg">
<view class="d2"></view> <image src="../../../static/img/vlog/icon/camera.png"></image>
<camera class="camera" device-position="front" flash="off" @error="error"></camera> </view>
<camera class="camera" device-position="front" flash="off" @error="error" @initdone="initdone"></camera>
<view class="surface" v-show="show"> <view class="surface" v-show="show">
<view>请正对镜头</view> <view>请正对镜头</view>
<text>{{text}}</text> <text>{{text}}</text>
</view> </view>
<image class="photo" v-show="src" :src="src"></image> <image class="photo" v-show="src" :src="src"></image>
<view class="hint"> <view class="hint">
<!-- <u-icon name="error-circle"></u-icon>
没有检测到人脸,请正对拍摄框拍摄哦~ -->
</view> </view>
<view class="hint1"> <view class="hint1">
<view class="item"> <view class="item">
...@@ -33,7 +32,7 @@ ...@@ -33,7 +32,7 @@
<view>不遮挡面部</view> <view>不遮挡面部</view>
</view> </view>
</view> </view>
<u-button v-if="buttonShow" type="success" size="medium" @click="scanFace">开始识别</u-button> <u-button v-if="buttonShow" type="success" size="medium" @click="takePhoto">开始识别</u-button>
</view> </view>
</template> </template>
...@@ -64,21 +63,22 @@ ...@@ -64,21 +63,22 @@
optimalFramesNum: 3, //最优帧数量(默认填3就行) optimalFramesNum: 3, //最优帧数量(默认填3就行)
enableImgBeauty: true //默认填true enableImgBeauty: true //默认填true
} }
this.$request("distribution/vlog/createVlog", data).then(res => { this.$request("distribution/vlog/createVlog",data).then(res => {
if (res.code == "00") { uni.showLoading({
title: '人脸识别中'
});
if (res.code === "00") {
setTimeout(() => { setTimeout(() => {
this.$request("distribution/vlog/getVlogCreateInfo", { this.$request("distribution/vlog/getVlogCreateInfo", {
userId: uni.getStorageSync("openid") userId: uni.getStorageSync("openid")
}).then(res => { }).then(res => {
if (res.code == "00") { if (res.code === "00") {
uni.hideLoading()
uni.showToast({ uni.showToast({
title: '识别成功', title: '识别成功',
duration: 1500 duration: 1500
}); });
this.$u.route("pages/vlog/myVlog/myVlog") this.$u.route("pages/vlog/myVlog/myVlog")
} else { } else {
uni.hideLoading()
uni.showModal({ uni.showModal({
title: '提示', title: '提示',
content: '识别失败,请重新扫脸', content: '识别失败,请重新扫脸',
...@@ -92,6 +92,10 @@ ...@@ -92,6 +92,10 @@
}) })
}, },
takePhoto() { //扫脸 takePhoto() { //扫脸
this.buttonShow = false
this.src = "";
this.text = 3;
this.show = true;
var test = setInterval(() => { var test = setInterval(() => {
this.text = this.text - 1; this.text = this.text - 1;
if (this.text === -1) { if (this.text === -1) {
...@@ -115,16 +119,16 @@ ...@@ -115,16 +119,16 @@
} }
}, 1000) }, 1000)
}, },
initdone(){//相机初始化完成自动开始拍照
this.takePhoto()
},
error(e) { //相机报错 error(e) { //相机报错
console.log(e.detail); uni.showModal({
title: '提示',
content: e.detail,
showCancel:false
});
}, },
scanFace() { //重新扫脸
this.buttonShow = false
this.src = "";
this.text = 3;
this.show = true;
this.takePhoto()
}
} }
} }
</script> </script>
...@@ -132,40 +136,31 @@ ...@@ -132,40 +136,31 @@
<style lang="scss" scoped> <style lang="scss" scoped>
.content { .content {
padding: 0 20rpx; padding: 0 20rpx;
background-color: #ffffff;
height: 100%; height: 100%;
width: 100%; width: 100%;
text-align: center; text-align: center;
.bg{
.d1 { width: 650rpx;
width: 500rpx; height: 650rpx;
height: 500rpx;
border-radius: 50%;
background-color: #CEE5FF;
position: absolute; position: absolute;
top: 150rpx; top: 80rpx;
left: 50%; left: 50%;
transform: translate(-40%) transform: translate(-50%);
} z-index: 5;
image{
.d2 { width: 100%;
width: 500rpx; height: 100%;
height: 500rpx; }
border-radius: 50%;
background-color: #ECF5FF;
position: absolute;
top: 150rpx;
left: 50%;
transform: translate(-60%)
} }
.camera { .camera {
width: 500rpx; width: 550rpx;
height: 500rpx; height: 550rpx;
border-radius: 50%; border-radius: 50%;
position: absolute; position: absolute;
top: 150rpx; top: 140rpx;
left: 50%; left: 50%;
transform: translate(-50%) transform: translate(-50%);
} }
.surface { .surface {
...@@ -179,36 +174,34 @@ ...@@ -179,36 +174,34 @@
text-align: center; text-align: center;
font-size: 40rpx; font-size: 40rpx;
color: #fff; color: #fff;
z-index: 3;
view { view {
margin: 100rpx 0; margin: 100rpx 0;
} }
text { text {
font-size: 70rpx; font-size: 70rpx;
} }
} }
.photo { .photo {
width: 500rpx; width: 550rpx;
height: 500rpx; height: 550rpx;
border-radius: 50%; border-radius: 50%;
position: absolute; position: absolute;
top: 150rpx; top: 140rpx;
left: 50%; left: 50%;
transform: translate(-50%) transform: translate(-50%);
} }
.hint { .hint {
color: red; color: red;
padding-top: 680rpx; padding-top: 680rpx;
} }
.hint1 { .hint1 {
height: 300rpx; height: 300rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
padding-top: 50rpx; padding-top: 50rpx;
padding-left: 80rpx;
padding-right: 80rpx;
.item { .item {
width: 30%; width: 30%;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment