Sfoglia il codice sorgente

消息列表开发

tanxue 1 mese fa
parent
commit
01887bcc35

+ 152 - 0
components/dialog/cameraCommon.vue

@@ -0,0 +1,152 @@
+<template>
+	<uni-popup ref="commonPopup" :animation="false" :is-mask-click="false" mask-background-color="rgba(0, 0, 0, 0.4)">
+		<view class="phone-common-dialog">
+			<view class="common-body-box">
+				<view class="common-title">{{title}}</view>
+				<view class="common-content" :class="dialogContentClass">
+					<view v-if="showCamera" class="camera-modal">
+						<view class="mask" @click="closeCamera"></view>
+						<view class="modal-content">
+							<camera class="camera-view" device-position="front"></camera>
+							<button class="not-confirm-btn" @click="closeCamera">关闭</button>
+						</view>
+					</view>
+				</view>
+				<view class="common-btn-box">
+					<view class="not-confirm-btn" @click="handleClose">{{notBtn}}</view>
+					<view class="confirm-btn" @click="confirmBtn">{{okBtn}}</view>
+				</view>
+			</view>
+		</view>
+	</uni-popup>
+</template>
+
+<script setup>
+	import {
+		ref
+	} from 'vue';
+	const props = defineProps({
+		title: {
+			type: String,
+			default: ''
+		},
+		content: {
+			type: String,
+			require: true,
+			default: ''
+		},
+		dialogContentClass: {
+			type: String,
+			require: true,
+			default: 'content-center-class'
+		},
+		notBtn: {
+			type: String,
+			require: true,
+			default: '取消'
+		},
+		okBtn: {
+			type: String,
+			require: true,
+			default: '确认'
+		},
+	});
+	const commonPopup = ref(null);
+	let showCamera = ref(false)
+	let cameraContext = ref(null)
+	let listener = ref(null)
+	const $emit = defineEmits(['confirm-btn'])
+
+	function handleShow() {
+		commonPopup.value.open();
+		handleCheck()
+	}
+
+	function handleClose() {
+		commonPopup.value.close();
+		showCamera.value = false;
+	}
+
+	function confirmBtn() {
+		$emit('confirm-btn');
+		commonPopup.value.close();
+		showCamera.value = false;
+	}
+
+	function handleCheck() {
+		try {
+			const systemInfo = uni.getSystemInfo();
+			// if (!systemInfo.cameraAuthorized) {
+			// 	uni.showToast({
+			// 		title: '设备不支持摄像头',
+			// 		duration: 2000
+			// 	});
+			// }	
+			uni.getSetting({
+				success(res) {
+					const authSetting = res.authSetting || {}
+					if (!authSetting['scope.camera']) {
+						const {
+							errMsg
+						} = uni.authorize({
+							scope: 'scope.camera'
+						});
+						// if (errMsg !== 'authorize:ok') {
+						// 	throw new Error('权限被拒绝');
+						// }
+					}
+					showCamera.value = true;
+					setTimeout(() => {
+						cameraContext.value = uni.createCameraContext();
+						console.log('cameraContext.value', cameraContext.value);
+						listener.value = cameraContext.value.onCameraFrame((frame) => {
+							//  console.log(frame.data instanceof ArrayBuffer, frame.width, frame.height)
+						})
+						//	console.log('listener.value',listener.value);
+						listener.value.start()
+					}, 500)
+				},
+				fail(err) {
+					handleError(err)
+				}
+			})
+
+
+		} catch (err) {
+			handleError(err);
+		}
+	}
+
+	function closeCamera() {
+		if (listener.value) {
+			listener.value.stop();
+		}
+		showCamera.value = false;
+		handleClose()
+	}
+
+
+
+	function handleError(err) {
+		uni.showModal({
+			title: '权限验证失败',
+			content: err.message,
+			confirmText: '去设置',
+			success: (res) => {
+				if (res.confirm) {
+					// #ifdef MP-WEIXIN
+					wx.openSetting();
+					// #endif
+				}
+			}
+		});
+	}
+	defineExpose({
+		handleShow,
+		handleCheck,
+		handleClose
+	})
+</script>
+
+<style>
+</style>

+ 21 - 0
components/scroll-list-card-mes/scroll-list-card-mes.vue

@@ -0,0 +1,21 @@
+<template>
+	<view class="notice-list-card">
+		<view class="notice-list-title">
+		    <text v-if="!data.wait" class="notice-list-read">已读</text>
+		    <text v-if="data.wait" class="notice-list-unread">未读</text>
+		    <view class="notice-title">{{data.name}}</view>
+		</view>
+		<view class="news-page-word">{{data.createTime}}</view>
+	</view>
+</template>
+
+<script setup>
+	import {toRefs,ref,computed} from "vue";
+
+	const props = defineProps({
+		data: {
+			type: Object,
+		},
+	});
+	const {data} = toRefs(props);
+</script>

+ 1 - 1
pages.json

@@ -33,7 +33,7 @@
 				"navigationBarTitleText" : "消息"
 			}
 		},
-			{
+		{
 			"path" : "pages/my/zhengshu",
 			"style" :
 			{

+ 10 - 5
pages/my/index.vue

@@ -54,6 +54,10 @@
 				<text>设置</text>
 			</view>
 		</view>
+		
+		<view>
+			<cameraCommon ref="cameraCommonRef"></cameraCommon>
+		</view>
 	</view>
 </template>
 
@@ -62,7 +66,7 @@
 	import {toast} from "@/utils/common";
 	import {getMineInfo} from '@/api/my.js'
 	import {onLoad,onShow} from '@dcloudio/uni-app';
-	
+	import cameraCommon from "@/components/dialog/cameraCommon.vue";
 	let myInfoData = reactive({
 		userImg: '',
 		realName: '',
@@ -74,7 +78,7 @@
 		countNotice:'',
 
 	});
-	
+	const cameraCommonRef = ref(null)
 	onLoad(() => {})
 	
 	onShow(() => {getMyInit()})
@@ -135,9 +139,10 @@
 			
 			// 摄像头测试
 			case 'sxtcs':
-			    uni.navigateTo({
-			    	url:'/pages/admin/my/myInfo?from=my'
-			    })
+			cameraCommonRef.value.handleShow()
+			    // uni.navigateTo({
+			    // 	url:'/pages/admin/my/myInfo?from=my'
+			    // })
 			break;
 			
 			// 摄像头说明

+ 41 - 0
pages/my/mesList.vue

@@ -0,0 +1,41 @@
+<template>
+	<!-- <custom-scroll-list :hasSearcBar="false" :refreshFn="getNoticeList" :hasTab="false">
+		<template #default="{list}">
+			<scroll-list-card-mes  v-for="(item,index) in list" :key="item.noticeId"
+				:data="item"></scroll-list-card-mes>
+		</template>
+	</custom-scroll-list> -->
+</template>
+
+<script setup>
+	import {getNoticeList} from '@/api/my.js'
+	import {onLoad,onReady,} from "@dcloudio/uni-app"
+	import {reactive,ref} from "vue";
+	let pageFrom = ref('');
+	onLoad((options) => {
+		pageFrom.value = options.from;
+		console.log('pageFrom.value', pageFrom.value);
+		
+	
+	});
+	function onBackPress() { 
+		switch (pageFrom.value) {
+			case 'my':
+			    uni.redirectTo({
+			       url: '/pages/my/index' 
+			     });
+			    break;
+			case 'index':
+			    uni.redirectTo({
+			       url: '/pages/index/index' 
+			     });
+			    break;	
+			case 'indexPeixun':
+			    uni.redirectTo({
+			       url: '/pages/index/index' 
+			     });
+			    break;
+		}
+	   
+	  }
+</script>