Quellcode durchsuchen

管理端页面开发

tanxue vor 2 Monaten
Ursprung
Commit
d866eb280f
4 geänderte Dateien mit 375 neuen und 1 gelöschten Zeilen
  1. 1 0
      common/styles/global/pages.scss
  2. 13 0
      pages.json
  3. 142 1
      pages/admin/my/index.vue
  4. 219 0
      pages/admin/my/myInfo.vue

+ 1 - 0
common/styles/global/pages.scss

@@ -431,6 +431,7 @@
 		.uni-file-picker__container{justify-content: center;border: 0;border-radius: 50%;}
 		.file-picker__box-content{border: 0;border-width: 0 !important;}
 		.user-file-picker{
+			.is-add{justify-content: space-between;}
 			.file-picker__box{width: 100%!important;}
 			.file-picker-image{max-height: 200rpx;max-width: 160rpx;}
 			img{max-width: 100%;max-height: 200rpx;}

+ 13 - 0
pages.json

@@ -136,6 +136,13 @@
 			}
 		},
 		{
+			"path" : "pages/admin/my/index",
+			"style" : 
+			{
+				"navigationStyle": "custom"
+			}
+		},
+		{
 			"path" : "pages/admin/Chengji/list",
 			"style" : 
 			{
@@ -149,6 +156,12 @@
 			}
 		},
 		{
+			"path" : "pages/admin/my/myInfo",
+			"style": {
+				"navigationStyle": "custom"
+			}
+		},
+		{
 			"path" : "pages/client/Kecheng/study",
 			"style" : 
 			{

+ 142 - 1
pages/admin/my/index.vue

@@ -1,7 +1,148 @@
 <template>
+	<view class="client-my-page">
+		<view class="my-head-box">
+			<view class="head-img-box">
+				<img class="head-img" :src="myInfoData.userImg" v-if="myInfoData.userImg">
+				<icon class="phone-default-userImg" v-else></icon>
+			</view>
+			<view class="head-content-box">
+				<text>{{myInfoData.realName}}</text>
+				<view class="head-content-row-box" v-if="myInfoData.userName">
+					<icon class="tel-icon"></icon>
+					<text class="content-text" >{{myInfoData.userName}}</text>
+				</view>
+				<view class="head-content-row-box" v-if="myInfoData.idcard">
+					<icon class="idcard-icon"></icon>
+					<text class="content-text" >{{myInfoData.idcard}}</text>
+				</view>
+			</view>
+		</view>
+		
+		<view class="my-list-box">
+			<view class="list-row" @click="goToPage('grcj')">
+				<icon class="list-icon user-icon"></icon>
+				<text>修改个人信息</text>
+			</view>
+			<view class="list-row" @click="showZhuaPaiConfirm">
+				<icon class="list-icon sxtcs-icon"></icon>
+				<text>摄像头测试</text>
+			</view>
+			<view class="list-row" @click="showMessageDl">
+				<icon class="list-icon sxtsm-icon"></icon>
+				<text>摄像头说明</text>
+			</view>
+			<view class="list-row" @click="exitLogin">
+				<icon class="list-icon login-out-icon"></icon>
+				<text>退出登录</text>
+			</view>
+		</view>
+		<!-- 底部区域 -->
+		<customTabbarClient :currentTab="1"></customTabbarClient>
+		<common-dialog ref="commonDialogRef" :title="exitTitle" :content="exitContent"@confirm-btn="exitBtn"></common-dialog>
+		<shexiangDialogVue ref="shexiangRef" title="摄像头说明"></shexiangDialogVue>
+		
+		<!-- 摄像头确认 -->
+		<zhuapaiConfrimVue ref="zpRef" @error="zpConfirmError" title="摄像头测试"></zhuapaiConfrimVue>
+	</view>
 </template>
 
-<script>
+<script setup>
+	import {toast} from "@/utils/common";
+	import {onLoad,onShow} from '@dcloudio/uni-app';
+	import cacheManager from '@/utils/cacheManager.js';
+	import {getMineUser,getMineInfo,getMineLogout} from '@/api/my.js'
+	import {reactive,ref} from "vue";
+	import customTabbarClient from "@/components/custom-tabbar/custom-tabbar-admin.vue"
+	import commonDialog from '@/components/dialog/commonDialog.vue';
+	import shexiangDialogVue from "@/components/dialog/shexiangDialog.vue";
+	import zhuapaiConfrimVue from "@/components/zhuapaiConfirm/index.vue";
+	
+	let myInfoData = reactive({
+		userImg: '',
+		realName: '',
+		idcard: '',
+		userName: '',
+		kaoshiCount: '',
+		kechengCount: '',
+		lianxiCount: '',
+		from:''
+	});
+	const commonDialogRef = ref(null);
+	const shexiangRef = ref(null);
+	const zpRef = ref(null);
+	const exitContent = '你确定要执行这个操作吗?';
+	const exitTitle = '退出登录';
+	function getMyInit() {
+		getUserInfo();
+		getNumInfo();
+	}
+	// 获取用户头像
+	function goToPage(data){
+		switch (data) {
+			case 'grcj':
+			    uni.navigateTo({
+			    	url:'/pages/admin/my/myInfo?from=my'
+			    })
+			    break;
+		}
+	}
+	function getUserInfo(){
+		getMineUser({}).then(res => {
+			myInfoData.userImg= res.data.icon;
+			myInfoData.realName = res.data.realName;
+			myInfoData.idcard = res.data.idcard;
+			myInfoData.userName = res.data.userName;
+		})
+	}
+	function getNumInfo(){
+		getMineInfo({}).then(res => {
+			myInfoData.kaoshiCount = res.data.kaoshiCount;
+			myInfoData.kechengCount = res.data.kechengCount;
+			myInfoData.lianxiCount = res.data.lianxiCount;
+		})
+	}
+	function exitLogin(){
+		commonDialogRef.value.handleShow();
+		
+	}
+	function exitBtn(){
+		getMineLogout().then(res => {
+			toast('退出登录成功')
+			cacheManager.clearAll();
+			uni.reLaunch({
+				url: '/pages/Login/index'
+			});
+		}).catch(err => {
+			toast('退出登录失败,请稍后重试')
+		})
+	}
+	
+	function showMessageDl() {
+		console.log(shexiangRef.value)
+		shexiangRef.value.handleShow()
+	}
+	
+	function showZhuaPaiConfirm() {
+		zpRef.value.showDialog()
+	}
+	
+	function zpConfirmSuccess() {
+		zpRef.value.showDialog()
+	}
+	function zpConfirmError() {
+		uni.showToast({
+			title: '摄像头唤起异常',
+			icon: 'none'
+		})
+	}
+	
+	onLoad(() => {
+    
+	})
+
+  onShow(() => {
+	getMyInit()
+  })
 </script>
 
 <style>

+ 219 - 0
pages/admin/my/myInfo.vue

@@ -0,0 +1,219 @@
+<template>
+	<view class="my-info-page">
+		<!-- 导航区域 -->
+		<view class="icon-title-navBar-box">
+			<view @click="handleBack" class="nav-bar-icon"></view>
+			<text class="nav-bar-title">个人信息</text>
+		</view>
+		<!-- 头像 -->
+		<view class="user-img-box">
+			
+			<uni-file-picker limit="1" :del-icon="false" disable-preview :auto-upload="false"
+				@select="handleSelect" file-mediatype="image" class="phone-file-picker user-file-picker">
+				<text class="user-title">头像</text>
+				<img class="head-img" :src="data.icon" v-if="data.icon">
+				<icon class="phone-default-userImg" v-else></icon>
+				<icon class="user-jt-icon"></icon>
+			</uni-file-picker>
+			<!-- <view>图片地址:{{data.icon}}</view> -->
+		</view>
+		<!-- 姓名 -->
+		<view class="form-label-input">
+			<view class="phone-form-label"><text class="form-label-require">*</text>姓名</view>
+			<input v-model="data.realName"  placeholder="请输入姓名" />
+			<icon></icon>
+		</view>
+		<!-- 手机号 -->
+		<view class="form-label-input">
+			<view class="phone-form-label"><text class="form-label-require">*</text>手机号</view>
+			<input v-model="data.userName"  placeholder="请输入手机号" />
+			<icon></icon>
+		</view>
+		<button type="default" class="phone-green-btn info-btn" @click="handleUpdate">修改资料</button>
+	</view>
+</template>
+
+<script setup>
+	import * as myApi from "@/api/my.js";
+	import {getAliyunPolicy} from "@/api/jiazheng.js"
+	import {ref,reactive} from "vue"
+	import {onLoad} from "@dcloudio/uni-app"
+
+	const imageStyles = ref({
+		width: 120,
+		height: 120,
+	});
+
+	const data = reactive({
+		from: 'shouye', // my | kaoshi | shouye
+		gender: 0,
+		icon: '',
+		realName: '',
+		userName: '',
+		userId: null
+	})
+
+	onLoad((options) => {
+		data.from = options.from || 'shouye';
+		initPage();
+	})
+
+	function handleSelect(e) {
+		console.log('eee',e)
+		doUploadImage(e)
+	}
+
+	function genderSelect(genderValue){
+		data.gender = genderValue;
+	}
+
+	function doUploadImage(params) {
+		const filePath = params.tempFiles[0];
+		const fileUrl = params.tempFilePaths;
+
+		
+		try {
+			const suffix = filePath.file.name.split('.').pop();
+			let req = {
+				prefix: 'resource/',
+				suffix: suffix,
+			}
+			uni.showLoading({
+				title: '上传中...',
+				mask: true
+			});
+			getAliyunPolicy(req).then(res => {
+				if (res.code == 0) {
+					const policyData = res.data;
+					
+					const formData = {
+						key:  policyData.key,
+						policy:  policyData.policy,
+						signature:  policyData.signature,
+						OSSAccessKeyId:  policyData.accessid,
+						success_action_status:  '200',
+					}
+					
+					uni.uploadFile({
+						url: policyData.uploadUrl,
+						filePath: fileUrl[0],
+						name: 'file',
+						formData: formData,
+						success(uploadRes) {
+							if (uploadRes.statusCode === 200) {
+								console.log('uploadRes',uploadRes)
+								data.icon = `${policyData.downloadUrl}/${policyData.key}`;
+								console.log( `${policyData.downloadUrl}/${policyData.key}`)
+								uni.showToast({
+									title: '上传成功',
+									icon: 'success'
+								});
+								
+							} else {
+								uni.showToast({
+									icon: 'none',
+									title: '上传失败',
+								});
+								uni.hideLoading();
+							}
+			
+						},
+						fail(err) {
+							uni.showToast({
+								icon: 'none',
+								title: '上传失败',
+							});
+							uni.hideLoading();
+						}
+					});
+
+				} else {
+					uni.showToast({
+						title: '获取凭证失败',
+					});
+					uni.hideLoading();
+				}
+			})
+		} catch (error) {
+			uni.showToast({
+				title: '上传失败',
+				icon: 'none'
+			});
+			uni.hideLoading();
+		}
+	}
+
+	function handleUpdate() {
+		let arr = [];
+		if (!data.realName) {
+			arr.push('姓名');
+		}
+		if (!data.userName) {
+			arr.push('电话');
+		}
+		if (!data.icon) {
+			arr.push('头像');
+		}
+		if (!data.realName || !data.userName||!data.icon) {
+			uni.showToast({
+				icon: 'none',
+				title: `请完善${arr.join('、')}信息!`
+			})
+			return;
+		}
+		
+		const opt = {
+			gender: data.gender,
+			icon: data.icon, 
+			realName: data.realName,
+			userId: data.userId,
+			userName: data.userName,
+		}
+		myApi.getMineUpdate(opt).then(res => {
+			if (res.data) {
+				uni.showToast({
+					title: '更新成功'
+				})
+				handleBack();
+			}
+		})
+
+	}
+
+	function handleBack() {
+		const pages = getCurrentPages();
+		if (pages.length>1) {
+			uni.navigateBack()
+		} else {
+			/* if (data.from == 'my') {
+				uni.redirectTo({
+					url: '/pages/client/my/index'
+				})
+			} else if (data.from == 'kaoshi') {
+				uni.redirectTo({
+					url: '/pages/client/ShouYe/shouye'
+				})
+			} else {
+				uni.redirectTo({
+					url: '/pages/client/my/index'
+				})
+			} */
+			history.back();
+		}
+	}
+
+	function initPage() {
+		myApi.getMineUser().then(res => {
+			const {gender,icon,realName,userName,userId} = res.data;
+			data.gender = res.data.gender;
+			data.icon = res.data.icon;
+			data.realName = res.data.realName; 
+			data.userName = res.data.userName;
+			data.userId = res.data.userId;
+		})
+	}
+</script>
+
+<style>
+
+</style>