|
@@ -429,6 +429,26 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
</u-popup>
|
|
|
+ <u-mask :show="photoPopup" >
|
|
|
+ <!-- 播放前拍照start -->
|
|
|
+ <view v-if="photoPopup" :mask-close-able="false" style="bottom: 0;position: fixed;width: 100%;z-index: 999;">
|
|
|
+ <view class="photoBox">
|
|
|
+ <view class="photoTop">
|
|
|
+ <view class="sqzz" v-if="false"><u-icon name="close" color="#333333" size="30" @click="closePhoto"></u-icon></view>
|
|
|
+ <view class="centersq">请正视手机屏幕</view>
|
|
|
+ <view class="sqzz"></view>
|
|
|
+ </view>
|
|
|
+ <view class="photoCenter">
|
|
|
+ <view style="width: 100%; height: 979rpx;position: fixed;" v-if="photoPopup">
|
|
|
+ <camera device-position="front" flash="off" @error="error" style="width: 100%; height: 100%;" ></camera>
|
|
|
+ </view>
|
|
|
+ <view class="custom"><image src="@/pages2/static/zhezhao.png" mode=""></image></view>
|
|
|
+ </view>
|
|
|
+ <view class="btnResult" @click="takePhoto">拍照</view>
|
|
|
+ </view>
|
|
|
+ </view>
|
|
|
+
|
|
|
+ </u-mask>
|
|
|
</view>
|
|
|
</template>
|
|
|
|
|
@@ -436,6 +456,7 @@
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ photoPopup:false,
|
|
|
showpopups: false,
|
|
|
id: '',
|
|
|
current: 0,
|
|
@@ -465,7 +486,8 @@ export default {
|
|
|
isFromVideo:'',
|
|
|
gradeId:'',
|
|
|
courseId:0,
|
|
|
- cgType: 0 //对应设计稿弹窗编码
|
|
|
+ cgType: 0 ,//对应设计稿弹窗编码,
|
|
|
+ avatarUrl:''
|
|
|
};
|
|
|
},
|
|
|
onLoad(option) {
|
|
@@ -510,6 +532,124 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ postStudyRecord() {
|
|
|
+ let data = {
|
|
|
+ photo: self.ossAvatarUrl,
|
|
|
+ recordId: self.recordId
|
|
|
+ };
|
|
|
+ console.log('提交接口', data);
|
|
|
+ this.$api.studyExamPhotoRecord(data).then(res => {
|
|
|
+ self.ossAvatarUrl = ''
|
|
|
+ console.log(res);
|
|
|
+ });
|
|
|
+ },
|
|
|
+ uploadFile(options, int) {
|
|
|
+ var self = this;
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ var data = {
|
|
|
+ imageStatus: int
|
|
|
+ };
|
|
|
+ self.$api.aliyunpolicy(data).then(res => {
|
|
|
+ if (res.data.code != 200) {
|
|
|
+ self.$method.showToast('签名错误' + JSON.stringify(res.data));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ var ossToken = res.data.data.resultContent;
|
|
|
+ if (ossToken.host == null || ossToken.host == undefined) {
|
|
|
+ self.$method.showToast('上传路径报错' + JSON.stringify(res.data));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ uni.uploadFile({
|
|
|
+ url: ossToken.host,
|
|
|
+ name: 'file',
|
|
|
+ filePath: options,
|
|
|
+ fileType: 'image',
|
|
|
+ header: {
|
|
|
+ AuthorizationToken: 'WX ' + uni.getStorageSync('token')
|
|
|
+ },
|
|
|
+ formData: {
|
|
|
+ key: ossToken.dir,
|
|
|
+ OSSAccessKeyId: ossToken.accessid,
|
|
|
+ policy: ossToken.policy,
|
|
|
+ Signature: ossToken.signature,
|
|
|
+ callback: ossToken.callback,
|
|
|
+ success_action_status: 200
|
|
|
+ },
|
|
|
+ success: result => {
|
|
|
+ if (result.statusCode === 200) {
|
|
|
+ self.ossAvatarUrl = ossToken.dir;
|
|
|
+ resolve();
|
|
|
+ } else {
|
|
|
+ uni.showToast({
|
|
|
+ title: '上传失败',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: error => {
|
|
|
+ uni.showToast({
|
|
|
+ title: '上传接口报错' + error,
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ imageInfos() {
|
|
|
+ var self = this;
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ uni.getImageInfo({
|
|
|
+ src: self.avatarUrl,
|
|
|
+ success: async res => {
|
|
|
+ let canvasWidth = res.width; //图片原始长宽
|
|
|
+ let canvasHeight = res.height;
|
|
|
+ if (canvasWidth > 1000 || canvasHeight > 1000) {
|
|
|
+ uni.compressImage({
|
|
|
+ src: self.avatarUrl,
|
|
|
+ quality: 75,
|
|
|
+ width: '50%',
|
|
|
+ height: '50%',
|
|
|
+ success: async rest => {
|
|
|
+ const waitUpload = await self.uploadFile(rest.tempFilePath, 0);
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ console.log('无需压缩');
|
|
|
+ const waitUpload = await self.uploadFile(self.avatarUrl, 0);
|
|
|
+ resolve();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+ async submit() {
|
|
|
+ const waitYS = await this.imageInfos();
|
|
|
+ this.postStudyRecord(); //提交记录
|
|
|
+
|
|
|
+ console.log(this.ossAvatarUrl, '拍照完成456');
|
|
|
+ },
|
|
|
+ //确认拍照
|
|
|
+ takePhoto() {
|
|
|
+ var self = this;
|
|
|
+ const ctx = uni.createCameraContext();
|
|
|
+ ctx.takePhoto({
|
|
|
+ quality: 'high',
|
|
|
+ success: res => {
|
|
|
+ console.log(res.tempImagePath);
|
|
|
+ self.avatarUrl = res.tempImagePath;
|
|
|
+ self.submit();
|
|
|
+
|
|
|
+ self.photoPopup = false;
|
|
|
+ },
|
|
|
+ fail: err => {
|
|
|
+ console.log(err);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
/**
|
|
|
* 是否有上传图片
|
|
|
*/
|
|
@@ -983,6 +1123,7 @@ export default {
|
|
|
* hasSpecial (是否包含简答和案例) true 包含 false 不包含
|
|
|
*/
|
|
|
examRecord(hasSpecial) {
|
|
|
+ let self = this
|
|
|
let questionList = 0;
|
|
|
if(!hasSpecial) {
|
|
|
this.questionList.forEach((item, index) => {
|
|
@@ -1005,6 +1146,7 @@ export default {
|
|
|
})
|
|
|
.then(res => {
|
|
|
this.recordId = res.data.data;
|
|
|
+ self.photoPopup = true; //拍照
|
|
|
});
|
|
|
|
|
|
},
|
|
@@ -1562,6 +1704,56 @@ export default {
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
+ .photoBox {
|
|
|
+ background-color: #FFFFFF;
|
|
|
+ border-radius: 32px 32px 0px 0px;
|
|
|
+ .photoTop {
|
|
|
+ height: 74upx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ padding: 0upx 38upx;
|
|
|
+ .sqzz {
|
|
|
+ width: 28upx;
|
|
|
+ height: 28upx;
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: center;
|
|
|
+ }
|
|
|
+ .centersq {
|
|
|
+ color: #333;
|
|
|
+ font-size: 30upx;
|
|
|
+ font-weight: 500;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .photoCenter {
|
|
|
+ width: 750upx;
|
|
|
+ height: 979upx;
|
|
|
+ position: relative;
|
|
|
+ .custom {
|
|
|
+ width: 750upx;
|
|
|
+ height: 979upx;
|
|
|
+ position: absolute;
|
|
|
+ z-index: 1000;
|
|
|
+ top: 0;
|
|
|
+ left: 0;
|
|
|
+ image {
|
|
|
+ width: 100%;
|
|
|
+ height: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .btnResult {
|
|
|
+ height: 100rpx;
|
|
|
+ width: 100%;
|
|
|
+ background-color: #07c160;
|
|
|
+ text-align: center;
|
|
|
+ line-height: 100upx;
|
|
|
+ color: #fff;
|
|
|
+ font-size: 32upx;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ }
|
|
|
.swiper {
|
|
|
width: 100%;
|
|
|
height: calc(100vh - 65px);
|