文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-857997.html
<page-meta page-style="{{ showPolish ? 'overflow: hidden;' : '' }}" />
<view class="wrap">
<view class="header-tab" style="justify-content: {{typeList.length > 2 ? 'start' : 'center'}}">
<view class="tab-list {{idx == item.id ? 'active' : ''}}" wx:for="{{typeList}}" wx:key="id" data-scene="{{item.scene}}" data-idx="{{item.id}}" data-ext="{{item.ext}}" bindtap="tabHandle">
<image src="{{item.thumb}}" class="icon-daily" mode="aspectFill" />
<view class="v1">{{item.name}}</view>
</view>
<!-- <view class="tab-list v2 {{idx == '2' ? 'active' : ''}}" data-idx="2" bindtap="tabHandle">
<image src="/image/outdoors.png" class="icon-daily" mode="widthFix"/>
</view>
<view class="tab-list {{idx == '3' ? 'active' : ''}}" data-idx="3" bindtap="tabHandle">
<image src="/image/mixedcollar.png" class="icon-daily" mode="widthFix"/>
</view> -->
</view>
<!--如果是管理員-->
<block wx:if="{{isAdmin || isSeniorTeacher || isTeacherDirector}}">
<scroll-view class="scroll-class-box" scroll-x="true">
<view class="scroll-class-list {{classCheckedId == item.classId ? 'active': ''}}" wx:for="{{classData}}" wx:key="id" data-index="{{index}}" data-id="{{item.classId}}" bindtap="checkClassHandle">
{{item.className}}
</view>
</scroll-view>
</block>
<!--指向主題活動(dòng)-->
<view class="white-box record-white-box" wx:if="{{themeExt}}">
<view class="title-box">
<view class="yellow-fence"></view>
<view class="title-txt-part">
<view class="v1">指向主題活動(dòng)</view>
</view>
<view class="close-box" bindtap="openThemeHandle">
<image src="{{openTheme ? '/image/icon_arrow_up2.png' : '/image/icon_arrow_down2.png'}}" data-idx="{{index}}" class="icon-close-black"></image>
</view>
</view>
<block wx:if="{{openTheme}}">
<view class="theme-item" wx:if="{{activityList.length > 0}}">
<view class="theme-list" wx:for="{{activityList}}" wx:key="id" data-idx="{{index}}" bindtap="checkActivityHandle">
<image src="{{item.checked?'/image/icon_checkbox_checked.png':'/image/icon_checkbox.png'}}" class="icon-checkbox"></image>
<view class="v1">{{item.name}}</view>
<view class="v2">{{item.status == '1' ? '整理' : '計(jì)劃'}}{{item.monthWeek ? item.monthWeek : '-暫無(wú)'}}</view>
</view>
<view class="package-footer" bindtap="loadMoreActivity">{{moreTxt}}</view>
<view class="up-box mt20" bindtap="openThemeHandle">
<image src="/image/icon_arrow_up2.png" class="icon-close-black"></image>
</view>
</view>
<block wx:else>
<view class="close-box-str" bindtap="openThemeHandle">暫未安排活動(dòng) | 計(jì)劃-無(wú)</view>
</block>
</block>
<view class="close-box-str" wx:if="{{!openTheme}}" bindtap="openThemeHandle">{{themeStr ? themeStr : '未選擇相關(guān)主題活動(dòng)'}}</view>
</view>
<!--選擇幼兒-->
<view class="white-box record-white-box">
<view class="title-box">
<view class="yellow-fence"></view>
<view class="title-txt-part">
<view class="v1">
選擇幼兒
<text class="t1">*</text>
</view>
<view class="student-number">已選擇{{checkedStudentsTreated.length}}個(gè)幼兒</view>
</view>
<view class="close-box" bindtap="openStudentHandle">
<image src="{{openStudents ? '/image/icon_arrow_up2.png' : '/image/icon_arrow_down2.png'}}" data-idx="{{index}}" class="icon-close-black"></image>
</view>
</view>
<!--名字保留四個(gè)字-->
<block wx:if="{{openStudents}}">
<view class="student-box" wx:if="{{students.length > 0}}">
<view class="student-list" wx:for="{{students}}" wx:key="id" data-idx="{{index}}" bindtap="checkHandle">
<image src="/image/icon_check.png" class="icon-check" wx:if="{{item.checked}}" />
<image src="{{item.studentImage ? item.studentImage : '/image/default.png'}}" mode="aspectFill" class="student-photo" />
<view class="v1">{{item.studentNumber}}號(hào)-{{item.studentName}}</view>
</view>
</view>
<view class="up-box" bindtap="openStudentHandle" wx:if="{{students.length > 0}}">
<image src="/image/icon_arrow_up2.png" class="icon-close-black"></image>
</view>
<block wx:if="{{students.length == 0}}">
<view class="close-box-str">還未錄入本班幼兒信息,請(qǐng)去后臺(tái)錄入</view>
</block>
</block>
<view class="student-box" wx:if="{{!openStudents && checkedStudents.length > 0}}" bindtap="openStudentHandle">
<view class="student-list2" wx:for="{{checkedStudentsTreated}}" wx:key="id">
<image src="{{item.studentImage ? item.studentImage : '/image/default.png'}}" mode="aspectFill" class="student-photo2" />
<view class="v1">{{item.studentNumber}}號(hào)-{{item.studentName}}</view>
</view>
<view class="student-list2" wx:if="{{checkedStudents.length > 10}}">
<view class="more-box">...</view>
</view>
</view>
<view class="no-graphs" wx:if="{{!openStudents && students.length > 0 && checkedStudents.length == 0}}" bindtap="openStudentHandle">未選擇幼兒</view>
</view>
<!--記錄日期-->
<view class="white-box record-white-box only-box">
<view class="title-box">
<view class="yellow-fence"></view>
<view class="title-txt-part">
<view class="v1">記錄日期<text class="t1">*</text></view>
</view>
</view>
<view class="check-list-rig">
<picker mode="date" bindchange="bindDateChange" value="{{selectedDate}}">
<view class="picker">
{{selectedDate ? selectedDate : '日期未選'}}
</view>
</picker>
</view>
</view>
<!--觀察場(chǎng)景-->
<view class="white-box record-white-box only-box">
<view class="title-box">
<view class="yellow-fence"></view>
<view class="title-txt-part">
<view class="v1">觀察場(chǎng)景<text class="t1">*</text></view>
</view>
</view>
<view class="check-list-rig">
<picker mode="selector" range="{{observeSceneList}}" bindchange="bindParentChange" value="{{observeParentIndex}}" range-key="expenseItem">
<view class="picker">
{{observeSceneList[observeParentIndex].expenseItem}}
</view>
</picker>
<view class="ones-aline">-</view>
<picker mode="selector" range="{{childArray}}" bindchange="bindChildChange" value="{{observeChildIndex}}" range-key="expenseItem">
<view class="picker">
{{childArray[observeChildIndex].expenseItem}}
</view>
</picker>
</view>
</view>
<!--觀察目的-->
<view class="white-box record-white-box">
<view class="title-box">
<view class="yellow-fence"></view>
<view class="title-txt-part">
<view class="v1">觀察目的</view>
</view>
<!-- <view class="close-box" bindtap="openObserveHandle">
<image src="{{openObserve ? '/image/icon_arrow_up2.png' : '/image/icon_arrow_down2.png'}}" data-idx="{{index}}" class="icon-close-black"></image>
</view> -->
</view>
<view class="observe-cont mt-20">
<view class="textarea-wrap">
<textarea class="textarea-box2" value="{{observe}}" placeholder="" maxlength="500" bindinput="monitorObserveInput" style="border-radius: 10rpx 10rpx 0 0;"></textarea>
<!-- <view class="ai-wrap">
<view class="v1" data-aistyle="1" bindtap="aimAiHandle">
<image src="/image/ai.png" class="icon-ai" />
<view class="v1">AI續(xù)寫(xiě)</view>
</view>
</view> -->
<view class="textarea-foot">
<view class="textarea-foot-lef">已輸入{{observeNumber}}個(gè)字</view>
<view class="textarea-foot-rig">{{observeNumber}}/500</view>
</view>
</view>
</view>
<!--如果時(shí)間 主題 textarea都是空的 則顯示 暫無(wú)觀察情境-->
<!-- <view class="close-box-str" wx:if="{{!openObserve}}" bindtap="openObserveHandle">{{observeStr ? observeStr : '未設(shè)相關(guān)信息'}}</view> -->
</view>
<!--觀察記錄-->
<view class="white-box record-white-box" wx:for="{{activityMaterials}}" wx:key="index">
<view class="title-box">
<view class="yellow-fence"></view>
<view class="title-txt-part">
<view class="v1">觀察記錄<text class="t1">*</text></view>
</view>
<image src="/image/close.png" data-idx="{{index}}" class="icon-close-black2" bindtap="deleteHandle" style="margin-right:9rpx"></image>
</view>
<view class="textarea-box-wrap">
<view class="voice-box" wx:if="{{item.recordArr.length > 0}}">
<view class="record-item" wx:for="{{item.recordArr}}" wx:key="txt" wx:for-item="oItem" wx:for-index="oIndex">
<!--down:-160rpx up:90rpx-->
<view class="pos-box" style="margin-top:{{oItem.directionUp?'-160':'90'}}rpx;" wx:if="{{oItem.showTip}}">
<view class="pos-box-lef" data-pidx="{{index}}" data-idx="{{oIndex}}" bindtap="txtRecordHandle">
<image src="/image/icon_txt.png" class="icon-txt" />
<text class="t1">轉(zhuǎn)文字</text>
</view>
<view class="pos-box-rig" data-pidx="{{index}}" data-idx="{{oIndex}}" bindtap="delRecordHandle">
<image src="/image/icon_del.png" class="icon-del" />
<text class="t1">刪除</text>
</view>
<image src="/image/icon_arrow_down.png" wx:if="{{oItem.directionUp}}" class="icon-arrow-down" />
<image src="/image/icon_arrow_up.png" wx:if="{{!oItem.directionUp}}" class="icon-arrow-up" />
</view>
<view class="record-list" data-pidx="{{index}}" data-idx="{{oIndex}}" bindtap="playHandle" bindlongpress="onLongPress">
<image src="{{oItem.played == true ? '/image/icon_pause.png' : '/image/icon_video.png'}}" class="icon-video" />
<text class="t1">語(yǔ)音</text>
<text class="t2">00:{{oItem.time}}</text>
</view>
<view class="record-txt" wx:if="{{oItem.showTxt}}">{{oItem.txt}}</view>
</view>
</view>
<textarea class="textarea-box" value="{{item.content}}" data-idx="{{index}}" bindinput="textareaBlurHandle" placeholder="請(qǐng)輸入內(nèi)容" maxlength="19999"></textarea>
<view class="textarea-box-footer">
<!-- <view class="ai-box" data-idx="{{index}}" data-aistyle="2" bindtap="recordAiHandle">
<image src="/image/ai.png" class="icon-ai" />
<view class="v1">AI續(xù)寫(xiě)</view>
</view> -->
<button class="record-btn" data-idx="{{index}}" bindtap="recordHandle">
<image src="/image/icon_record_gray.png" wx:if="{{!item.recordState}}" class="icon-record" />
<image src="/image/icon_record_red.png" wx:else="{{item.recordState}}" class="icon-record" />
</button>
</view>
</view>
<view class="material-box">
<block wx:for="{{activityMaterials[index].material}}" wx:for-item="mItem" wx:for-index="mIndex" wx:key="url">
<view class="material-list" wx:if="{{mItem.type == 'img'}}">
<image src="/image/icon_close.png" class="icon-close" data-pidx="{{index}}" data-idx="{{mIndex}}" bindtap="closeHadle" />
<image src="{{mItem.url}}" data-src="{{mItem.url}}" data-pidx="{{index}}" data-idx="{{mIndex}}" bindtap="preview" class="material-list-m2" mode="aspectFill"></image>
</view>
<view class="material-list" wx:if="{{mItem.type == 'mp4'}}">
<image src="/image/icon_close.png" class="icon-close" data-pidx="{{index}}" data-idx="{{mIndex}}" bindtap="closeHadle" />
<video src="{{mItem.url}}" data-src="{{mItem.url}}" class="material-list-m2" mode="aspectFill"></video>
</view>
</block>
<button class="upload-box" data-idx="{{index}}" bindtap="uploadFile">
<image src="/image/icon_photo.png" class="icon-photo" />
上傳圖片、視頻
</button>
</view>
</view>
<view class="add-box" bindtap="addListHandle">
<image src="/image/add.png" mode="widthFix" class="icon-add2" />添加新的圖文描述
</view>
<!--幼兒發(fā)展水平評(píng)估-->
<view class="white-box record-white-box">
<view class="title-box">
<view class="yellow-fence"></view>
<view class="title-txt-part">
<view class="v1">幼兒發(fā)展水平評(píng)估</view>
</view>
<view class="close-box" bindtap="openAreaHandle" wx:if="{{selectArea.length > 0}}">
<image src="{{openArea ? '/image/icon_arrow_up2.png' : '/image/icon_arrow_down2.png'}}" data-idx="{{index}}" class="icon-close-black"></image>
</view>
</view>
<block wx:if="{{openArea && selectArea.length > 0}}">
<!--第一級(jí)-->
<scroll-view class="scroll-box" scroll-x="true">
<view class="domain-first {{areaFirstIndex == index ? 'active': ''}}" wx:for="{{selectArea}}" wx:key="id" data-index="{{index}}" data-id="{{item.id}}" bindtap="getSelectAreaId">
{{item.name}}
<block wx:if="{{item.checked}}">
<image src="/image/corner_mark.png" class="corner-mark"></image>
</block>
</view>
</scroll-view>
<!--有可能消失的第二級(jí) 如果第一級(jí)的id用于查詢指標(biāo)列表 指標(biāo)列表type是3 則第二級(jí)顯示 如果type是4則該第二級(jí)隱藏 ***如果沒(méi)有children 直接使用選項(xiàng)卡*** 第二級(jí)是單選-->
<view class="domain-second" wx:if="{{showAreaSecond}}">
<view class="domain-second-list {{areaSecondIndex == index ? 'active': ''}}" wx:for="{{listSelect}}" wx:key="id" data-index="{{index}}" bindtap="getAreaSecondIndex">{{item.label}}</view>
</view>
<!--必然存在的第三級(jí) 第三級(jí)的組成是title + list 第三級(jí)是子級(jí)單選 理論上有多個(gè)數(shù)組 多個(gè)數(shù)組有對(duì)應(yīng)的子級(jí)-->
<view class="domain-three" wx:if="{{showAreaSecond}}">
<view class="domain-three-item" wx:for="{{threeData.children}}" wx:key="id">
<view class="domain-three-title">
<view class="v1">{{item.label}}</view>
<view class="v2">(請(qǐng)?jiān)谙路竭x擇一個(gè)水平)</view>
</view>
<view class="domain-three-list" wx:for="{{item.children}}" wx:for-item="mItem" wx:for-index="mIndex" wx:key="id" data-parentindex="{{index}}" data-childindex="{{mIndex}}" data-item="{{mItem}}" bindtap="checkedAreaHandle">
<image src="{{mItem.checked ? '/image/icon_checkbox_checked.png' : '/image/icon_checkbox.png'}}" class="icon-checkbox"></image>
<view class="v2 {{mItem.checked ? 'active' : ''}}">{{mItem.label}}</view>
</view>
</view>
</view>
<!--type為4的時(shí)候-->
<view class="domain-three" wx:else>
<view class="domain-three-item" wx:for="{{threeData}}" wx:key="id">
<view class="domain-three-title">
<view class="v1">{{item.label}}</view>
<view class="v2">(請(qǐng)?jiān)谙路竭x擇一個(gè)水平)</view>
</view>
<view class="domain-three-list" wx:for="{{item.children}}" wx:for-item="mItem" wx:for-index="mIndex" wx:key="id" wx:for-item="mItem" wx:for-index="mIndex" wx:key="id" data-parentindex="{{index}}" data-childindex="{{mIndex}}" data-item="{{mItem}}" bindtap="checkedAreaHandle">
<image src="{{mItem.checked ? '/image/icon_checkbox_checked.png' : '/image/icon_checkbox.png'}}" class="icon-checkbox"></image>
<view class="v2 {{mItem.checked ? 'active' : ''}}">{{mItem.label}}</view>
</view>
</view>
</view>
</block>
<view wx:if="{{selectArea.length == 0}}">
<view class="no-graphs">未做幼兒發(fā)展水平評(píng)估</view>
</view>
<view class="close-box-str" wx:if="{{!openArea && selectArea.length > 0}}" bindtap="openAreaHandle">{{areaStr ? areaStr : '暫無(wú)幼兒發(fā)展水平評(píng)估'}}</view>
</view>
<view class="white-box record-white-box">
<view class="title-box">
<view class="yellow-fence"></view>
<view class="title-txt-part">
<view class="v1">改進(jìn)措施</view>
</view>
<!-- <view class="close-box">
<image src="/image/icon_arrow_down2.png" data-idx="{{index}}" class="icon-close-black"></image>
</view> -->
</view>
<view class="textarea-wrap" style="margin-top: 20rpx;">
<textarea class="textarea-box2" value="{{measure}}" placeholder="" maxlength="500" bindinput="monitorMeasureInput"></textarea>
<view class="textarea-foot">
<view class="textarea-foot-lef">已輸入{{measureNumber}}個(gè)字</view>
<view class="textarea-foot-rig">{{measureNumber}}/500</view>
</view>
</view>
</view>
<!-- <view class="save-btn" bindtap="save">提交</view> -->
<view class="white-box record-footer">
<view class="footer">
<view wx:if="{{!oid}}" class="v3" bindtap="cacelObserve">取消</view>
<view wx:if="{{oid}}" class="v3" bindtap="deleteObserve">刪除</view>
<view class="v1" data-status="0" bindtap="save">暫存</view>
<view class="v2" data-status="1" bindtap="save">提交</view>
</view>
</view>
<view class="mask" wx:if="{{maskShow}}" bindtap="closeTipHandle"></view>
<!--Ai彈窗-->
<view class="ai-mask" wx:if="{{showPolish}}">
<view class="ai-pop">
<scroll-view class="ai-pop-cont" scroll-y="true">
<textarea class="textarea-box2" value="{{aiPolish}}" placeholder="" maxlength="500" style="border-radius: 10rpx 10rpx 0 0;" bindinput="monitorPopInput"></textarea>
</scroll-view>
<view class="ai-pop-footer">
<view class="v1" bindtap="aiCancel">取消</view>
<view class="v2" bindtap="aiAgain">重寫(xiě)</view>
<view class="v3" bindtap="aiConfirm">確定</view>
</view>
</view>
</view>
</view>
const app = getApp()
const util = require('../../utils/util.js');
const api = require('../../config/api.js');
const BASE_URL = app.globalData.BASE_URL
let lock = false
//獲取當(dāng)天的年月日用‘-’分隔
function getDayDate() {
const currentDate = new Date();
const year = currentDate.getFullYear();
const month = String(currentDate.getMonth() + 1).padStart(2, '0');
const day = String(currentDate.getDate()).padStart(2, '0');
return `${year}-${month}-${day}`;
}
const innerAudioContext = wx.createInnerAudioContext({
useWebAudioImplement: false // 是否使用 WebAudio 作為底層音頻驅(qū)動(dòng),默認(rèn)關(guān)閉。對(duì)于短音頻、播放頻繁的音頻建議開(kāi)啟此選項(xiàng),開(kāi)啟后將獲得更優(yōu)的性能表現(xiàn)。由于開(kāi)啟此選項(xiàng)后也會(huì)帶來(lái)一定的內(nèi)存增長(zhǎng),因此對(duì)于長(zhǎng)音頻建議關(guān)閉此選項(xiàng)
})
const recorderManager = wx.getRecorderManager();
var wxst; //語(yǔ)音websocket
var status = 0; // 音頻的狀態(tài)
var iatResult = [] // 識(shí)別結(jié)果
const searchoptions = {
duration: 1000 * 60,
sampleRate: 16000,
numberOfChannels: 1,
encodeBitRate: 48000,
format: 'mp3',
frameSize: 6
}
Page({
data: {
idx: '1',
students: [],
activityMaterials: [],
userInfo: {},
oid: null, //跳轉(zhuǎn)過(guò)來(lái)編輯的id
//recordArr: [], recordArr率屬于activityMaterials的子集 //音頻數(shù)組 包含三個(gè)字段 url->mp3格式文件 txt:MP3的文字版的文本 time: 錄音的時(shí)間 played:是否正在播放
//錄音部分-start
parentIndex: null,
maskShow: false, //透明的遮罩層
srcMic: '',
edit_text_max: 200,
remain_length: 200,
edit_text: "",
is_focus: false,
tips: "",
index: -1,
voicePath: "",
//語(yǔ)音
//recordState: false, //錄音狀態(tài) 該字段納入作為activityMaterials的子級(jí) 由activityMaterials統(tǒng)一調(diào)配
contentTxt: '', //內(nèi)容
firstSend: true,
clientY: 0, //點(diǎn)擊的地方到頂部的距離
//錄音部分-end
activityId: null, //指向主題活動(dòng)回顯
themeList: [], //指向主題活動(dòng)
themeChecked: {}, //主題選中
themeStr: '', //指向主題活動(dòng)關(guān)閉時(shí)候顯示的文本
openTheme: false, //指向主題活動(dòng)開(kāi)關(guān)
checkedStudents: [], //選中的幼兒列表
checkedStudentsTreated: [], //選中的幼兒處理過(guò)的列表 超過(guò)10個(gè)得截取成9個(gè)
openStudents: false, //選擇幼兒開(kāi)關(guān)
openObserve: false, //觀察背景開(kāi)關(guān)
observeStr: '', //觀察關(guān)閉時(shí)候顯示的文本
openArea: false, //幼兒發(fā)展水平評(píng)估開(kāi)關(guān)
areaStr: '', //幼兒發(fā)展水平評(píng)估關(guān)閉時(shí)候顯示的文本
observe: '', //觀察目的
observeNumber: 0,
areaFirstIndex: 0, //一級(jí)選中的index 默認(rèn)第一個(gè)選中
areaSecondIndex: 0, //二級(jí)選中的index 默認(rèn)第一個(gè)選中 如果type為3
//selectArea: [], //評(píng)估對(duì)象列表
showAreaSecond: false, //是否展示二級(jí)
observationViewId: '', //編輯觀察記錄的id
listSelect: [], //指標(biāo)列表
threeData: [], //三級(jí)列表數(shù)據(jù)
evaluationItems: [], //幼兒發(fā)展水平評(píng)估最終存儲(chǔ)的數(shù)組 也就是選中的數(shù)組
activityList: [], //指向主題活動(dòng)列表
pageNum: 1,
pageSize: 6,
moreTxt: '點(diǎn)擊加載更多',
flag: false,
selectedDate: getDayDate(),
/*觀察場(chǎng)景-start*/
observeSceneList: [],
childArray: [], // 子集數(shù)組
observeParentIndex: 0, // 當(dāng)前選中的父級(jí)索引
observeChildIndex: 0, // 當(dāng)前選中的子集索引
/*觀察場(chǎng)景-end*/
measure: '', //改進(jìn)措施
measureNumber: 0,
isAdmin: false, //判斷是不是管理員
isSeniorTeacher: false,//判斷是不是超級(jí)教師
isTeacherDirector: false,//判斷是不是混齡教師
classData: [],
classCheckedId: '', //選中的classId 如果是管理員的時(shí)候 默認(rèn)選中第一個(gè) 非管理員不調(diào)用
typeList: [], //觀察記錄頂部tab
sceneChecked: '', //觀察場(chǎng)景選中對(duì)象
themeExt: false, //指向主題活動(dòng)是否顯示
//觀察目的Ai續(xù)寫(xiě)
aiPolish: '', //Ai續(xù)寫(xiě)的內(nèi)容
showPolish: false, //Ai續(xù)寫(xiě)彈窗
aistyle: null, //1是觀察目的 2是觀察記錄
aiParentIndex: null, //觀察記錄 第幾個(gè)在Ai續(xù)寫(xiě)
aimAiPolish: '', //觀察目的Ai續(xù)寫(xiě)的內(nèi)容
aimAiKeyword: '', //關(guān)鍵詞
},
onLoad() {},
onShow: function () {
wx.setStorageSync('activtyTab', {}); //重置備課助手tab的條件
wx.setStorageSync('activityAdminTab', {}); //ly-add 2023-10-09 重置主題活動(dòng)列表管理員狀態(tài)下的班級(jí)選中狀態(tài)
if (app.globalData.isActivityMaterials) return
app.globalData.isActivityMaterials = false //重置記觀察記錄的上傳狀態(tài)
lock = false;
const userInfo = wx.getStorageSync('userInfo');
//判斷roles是不是'sch'判斷當(dāng)前用戶是不是'園長(zhǎng)' 如果roles是senior_teacher那么該角色和園長(zhǎng)擁有相同'觀察評(píng)價(jià)'權(quán)限 統(tǒng)計(jì)里也要和園長(zhǎng)一樣 也就是'觀察記錄'、'觀察統(tǒng)計(jì)' 混齡賬號(hào)目前不可能是超級(jí)老師 2024-04-16
let isAdmin = false
let isSeniorTeacher = false
let isTeacherDirector = false
if(userInfo.roleKeysString){
let oarr = userInfo.roleKeysString.split(',')
isAdmin = util.arrayContainsSch(oarr)
isSeniorTeacher = util.arrayContainsSeniorteacher(oarr)
isTeacherDirector = util.arrayContainsTeacherdirector(oarr)
}
this.setData({
userInfo,
isAdmin: isAdmin,//判斷是不是管理員
isSeniorTeacher: isSeniorTeacher,//判斷是不是 超級(jí)教師
isTeacherDirector: isTeacherDirector,//判斷是不是混齡教師
})
this.loadRecord();
this.selectClass(); //加載的時(shí)候 幼兒發(fā)展水平評(píng)估 走的這個(gè)方法
//重置錄音模塊
this.initRecord();
this.resetObserve()
},
loadRecord() {
var that = this;
recorderManager.onStart(() => { //開(kāi)始錄音時(shí)觸發(fā)
status = 0;
iatResult = []
//console.log('recorder start');
that.data.firstSend = false;
});
recorderManager.onError((res) => { //錯(cuò)誤回調(diào)
//console.log(res);
});
recorderManager.onStop((res) => { //結(jié)束錄音時(shí)觸發(fā)
//console.log('recorder stop')
//console.log(res)
let otime = (res.duration / 1000).toFixed(0)
status = 2;
var sendsty = '{"data":{"status":2,"audio":"","format":"audio/L16;rate=8000","encoding":"raw"}}'
wxst.send({
data: sendsty
})
wx.uploadFile({
// 模擬https
url: BASE_URL + 'common/uploadMediaToTencent', //需要用HTTPS,同時(shí)在微信公眾平臺(tái)后臺(tái)添加服務(wù)器地址
filePath: res.tempFilePath, //上傳的文件本地地址
name: 'file',
formData: {
'userId': wx.getStorageSync('userInfo').userId,
'scene': 'observation'
},
//附近數(shù)據(jù),這里為路徑
success: function (result) {
// console.log("--結(jié)束錄音--")
// console.log(that.data.contentTxt)
// console.log(JSON.parse(result.data).url)
// console.log(otime)
if (that.data.contentTxt) {
//recordArr: []//音頻數(shù)組 包含三個(gè)字段 url->mp3格式文件 txt:MP3的文字版的文本 time: 錄音的時(shí)間 played:是否正在播放
let ourl = JSON.parse(result.data).url
let pidx = that.data.parentIndex
let params = {
url: ourl,
txt: that.data.contentTxt,
time: that.timeHandle(otime), //這個(gè)時(shí)間是用來(lái)顯示的
played: false,
showTxt: false, //語(yǔ)音的文字部分是否展示
showTip: false, //Tooltip 文字提示是否展示
directionUp: false, //Tooltip的方向是向上還是向下
}
let oarr = that.data.activityMaterials
oarr.forEach((item) => {
item.recordArr = item.recordArr && item.recordArr.length > 0 ? item.recordArr : []
})
oarr[pidx].recordArr.push(params)
that.setData({
activityMaterials: oarr
})
//console.log(that.data.activityMaterials)
} else {
//console.log("木有內(nèi)容啊")
}
},
fail: function (err) {
//console.log(err)
}
})
});
recorderManager.onFrameRecorded((res) => { //每幀觸發(fā)
const that = this
const {
frameBuffer,
isLastFrame
} = res
let params = {
'common': {
'app_id': '57198f05'
},
'business': {
'language': 'zh_cn', //?語(yǔ)種可在控制臺(tái)--語(yǔ)?聽(tīng)寫(xiě)(流式)--??/語(yǔ)種處添加試?
'domain': 'iat',
'accent': 'mandarin', //中???可在控制臺(tái)--語(yǔ)?聽(tīng)寫(xiě)(流式)--??/語(yǔ)種處添加試?
'vad_eos': 1000,
'dwa': 'wpgs' //為使該功能?效,需到控制臺(tái)開(kāi)通動(dòng)態(tài)修正功能(該功能免費(fèi))
},
'data': {
'status': 0,
'format': 'audio/L16;rate=16000',
'encoding': 'lame',
'audio': wx.arrayBufferToBase64(frameBuffer)
}
}
// 拼接數(shù)據(jù)
let status = 0
if (this.data.firstSend) {
this.data.firstSend = false
} else {
if (isLastFrame) {
status = 2
} else {
status = 1
}
}
params.data.status = status
wx.sendSocketMessage({
data: JSON.stringify(params),
success: (data) => {
//console.log('send success:' + JSON.stringify(data))
//that.resetRecordState()
},
fail: (err) => {
//console.log('send error:' + JSON.stringify(err))
//中斷錄音的時(shí)候
//that.resetRecordState()
},
completed: () => {
if (isLastFrame) {
// wx closeSocket
}
}
})
})
},
resetObserve() {
//選擇領(lǐng)域模塊
this.setData({
areaFirstIndex: 0,
selectArea: [], //評(píng)估對(duì)象列表
showAreaSecond: false, //是否展示二級(jí)
observationViewId: '', //編輯觀察記錄的id
listSelect: [], //指標(biāo)列表
idx: '1',
openTheme: false, //指向主題活動(dòng)開(kāi)關(guān)
themeStr: '', //指向主題活動(dòng)關(guān)閉時(shí)候顯示的文本
openStudents: false,
openObserve: false,
openArea: false,
observeStr: '',
areaStr: '',
evaluationItems: [],
measureNumber: 0,
observeParentIndex: 0,
oid: app.globalData.isRecordEdit ? app.globalData.recordId : '', //判斷是不是從報(bào)告頁(yè)面跳轉(zhuǎn)過(guò)來(lái) 如果是則賦值id
measure: '',
classData: [],
classCheckedId: '', //選中的classId 如果是管理員的時(shí)候 默認(rèn)選中第一個(gè) 非管理員不調(diào)用
activityId: null,
//選擇幼兒-start
checkedStudents: [],
checkedStudentsTreated: [],
students: [],
studentArr: [],
themeChecked: {},
//選擇幼兒-end
//觀察背景-start
selectedDate: getDayDate(), //記錄日期
observeParentIndex: 0,
observeChildIndex: 0,
observe: '',
observeNumber: 0,
//觀察背景-end
activityMaterials: [{
content: '',
material: []
}],
typeList: [], //觀察記錄頂部tab
sceneChecked: '', //觀察場(chǎng)景選中對(duì)象
themeExt: false, //指向主題活動(dòng)是否顯示
//觀察目的Ai續(xù)寫(xiě)
aiPolish: '', //Ai續(xù)寫(xiě)的內(nèi)容
showPolish: false, //Ai續(xù)寫(xiě)彈窗
aistyle: null, //1是觀察目的 2是觀察記錄
aiParentIndex: null, //觀察記錄 第幾個(gè)在Ai續(xù)寫(xiě)
aimAiPolish: '', //觀察目的Ai續(xù)寫(xiě)的內(nèi)容
aimAiKeyword: '', //關(guān)鍵詞
})
if (this.data.oid) {
this.loadData()
}
},
//回顯數(shù)據(jù)
loadData() {
const that = this;
util.request(api.observeDetail + this.data.oid, '', 'get').then(res => {
if (res.code == 200) {
let odata = res.data
//選擇幼兒回顯
let studentArr = this.data.students
let checkedStudents = []
if (odata.participants.length > 0) {
checkedStudents = odata.participants
//判斷兩個(gè)數(shù)組是否有相同的id 如果有相同的id 給當(dāng)前的student添加選中狀態(tài)
studentArr.forEach(item => {
const isChecked = checkedStudents.some(citem => citem.studentId === item.studentId);
item.checked = isChecked;
});
}
let oarr2 = JSON.parse(JSON.stringify(checkedStudents))
this.checkedStudentsHandle(oarr2)
//觀察背景回顯
let observeIndex = odata.scene.split(',')
let observeSceneList = this.data.observeSceneList
let observeParentIndex = 0
let observeChildIndex = 0
if (observeSceneList.length > 0) {
for (let i in observeSceneList) {
if (observeSceneList[i].expenseId == observeIndex[0]) {
observeParentIndex = i
break
}
}
for (let i in observeSceneList[observeParentIndex].children) {
if (observeSceneList[observeParentIndex].children[i].expenseId == observeIndex[1]) {
observeChildIndex = i
break
}
}
}
let scene = odata.recordDate + ',' + observeSceneList[observeParentIndex].expenseItem + observeSceneList[observeParentIndex].children[observeChildIndex].expenseItem + ',' + (odata.purpose ? odata.purpose : '')
//觀察背景回顯-end
//重組數(shù)據(jù)
//type 1圖片 3視頻
let oarr = odata.observationRecords.map(function (item) {
//console.log(item)
//由于后端返回的數(shù)據(jù)原因 導(dǎo)致得先把返回的數(shù)據(jù)剝離成兩個(gè)數(shù)組 一個(gè)是語(yǔ)音部分的數(shù)組 一個(gè)是圖片、視頻的數(shù)組
let paragraphsRecord = [] //存儲(chǔ)語(yǔ)音
let paragraphsIV = [] //存儲(chǔ)圖片視頻
let paragraphsIVLastArr = [] //存儲(chǔ)圖片視頻過(guò)濾后的最終形態(tài)
if (item.paragraphs && item.paragraphs.length > 0) {
for (let i in item.paragraphs) {
if (item.paragraphs[i].type == '2') {
paragraphsRecord.push(item.paragraphs[i])
paragraphsRecord.push(item.paragraphs[(i - 0) + 1])
}
}
paragraphsIV = item.paragraphs.slice(paragraphsRecord.length) //通過(guò)語(yǔ)音部分?jǐn)?shù)組的長(zhǎng)度切割數(shù)組 后面的數(shù)組就都是圖片或者視頻的數(shù)組了
for (let i in paragraphsIV) {
paragraphsIVLastArr.push({
url: paragraphsIV[i].content,
type: paragraphsIV[i].type == '3' ? 'mp4' : paragraphsIV[i].type == '1' ? 'img' : '', //3是視頻、1是圖片
})
}
}
let oparagraphsRecord = []
for (let i in paragraphsRecord) {
if (paragraphsRecord[i].type == '2') {
oparagraphsRecord.push({
url: paragraphsRecord[i].content,
txt: paragraphsRecord[(i - 0) + 1].content,
time: that.timeHandle(paragraphsRecord[i].fileSize - 0),
played: false,
showTxt: false, //語(yǔ)音的文字部分是否展示
showTip: false, //Tooltip 文字提示是否展示
directionUp: false, //Tooltip的方向是向上還是向下
})
}
}
return {
content: item.content,
recordArr: oparagraphsRecord, //語(yǔ)音部分
material: paragraphsIVLastArr, //圖片、視頻部分
}
})
let str = ''
let evaluationItems = odata.evaluationItems
for (let i in evaluationItems) {
str += (evaluationItems[i].sort + ':' + evaluationItems[i].syndrome)
}
str = str.substring(0, str.length - 1)
this.setData({
idx: odata.type,
activityId: odata.activityId,
activityMaterials: oarr,
students: studentArr, //處理過(guò)的學(xué)生列表
checkedStudents: checkedStudents, //選中的學(xué)生
checkedStudentsTreated: checkedStudents, //選中的學(xué)生
selectedDate: odata.recordDate, //記錄日期
observeParentIndex: observeParentIndex,
childArray: this.data.observeSceneList[observeParentIndex].children, //ly-add 2023-09-15觀察場(chǎng)景回顯的問(wèn)題
observeChildIndex: observeChildIndex,
observe: odata.purpose,
observeStr: scene,
observeNumber: odata.purpose ? odata.purpose.length : 0,
areaStr: str,
evaluationItems: odata.evaluationItems,
measure: odata.measure,
measureNumber: odata.measure ? odata.measure.length : 0,
classCheckedId: odata.classId,
pageNum: 1,
activityList: [], //指向主題活動(dòng)列表
})
if (odata.type == '2') {
this.data.themeChecked.id = odata.activityId
} else {
this.data.themeChecked.id = ''
this.setData({
activityId: null
})
}
//選擇幼兒列表
this.getStudent()
this.getListSelectArea();
this.getListSelectActivity();
} else {
wx.showToast({
title: res.msg,
icon: 'error',
duration: 2000
})
}
});
},
getObservationTypeListFun() {
util.request(api.getObservationTypeList + this.data.userInfo.schoolId, '', 'get').then(res => {
if (res.code == 200) {
//獲得列表數(shù)據(jù) 獲取第一個(gè)idx的值
this.setData({
typeList: res.rows,
idx: res.rows[0].id,
sceneChecked: res.rows[0].scene
})
//觀察場(chǎng)景請(qǐng)求數(shù)據(jù)
this.getObserveScene();
//選擇幼兒列表
this.getStudent()
this.getListSelectArea();
//指向主題活動(dòng)
this.setData({
pageNum: 1,
activityList: [], //指向主題活動(dòng)列表
flag: false,
})
this.getListSelectActivity(); //指向主題活動(dòng)
} else {
wx.showModal({
title: res.msg,
icon: 'error',
showCancel: false,
duration: 3000
});
}
});
},
selectClass() {
util.request(api.selectClass + '?userId=' + this.data.userInfo.userId, '', 'get').then(res => {
if (res.code == 200) {
this.setData({
classData: res.data,
classCheckedId: res.data[0].classId
})
var oid = app.globalData.isRecordEdit ? app.globalData.recordId : '';
if (!oid) {
this.getObservationTypeListFun()
}
} else {
wx.showModal({
title: res.msg,
icon: 'error',
showCancel: false,
duration: 3000
});
}
});
},
openThemeHandle() {
this.setData({
openTheme: this.data.openTheme ? false : true
})
},
cacelObserve() {
const that = this
wx.showModal({
title: '',
content: '是否清空當(dāng)前頁(yè)面數(shù)據(jù)',
success(res) {
if (res.confirm) {
that.resetObserve()
} else if (res.cancel) {
//console.log('用戶點(diǎn)擊取消')
}
}
})
},
//刪除觀察
deleteObserve() {
const that = this
wx.showModal({
title: '',
content: '是否刪除該觀察記錄',
success(res) {
if (res.confirm) {
util.request(api.deleteObservation + that.data.oid, '', 'delete').then(res => {
if (res.code == 200) {
wx.showToast({
title: '刪除成功!',
icon: 'success',
duration: 2000
})
wx.switchTab({
url: '/pages/report/report',
});
} else {
wx.showModal({
title: res.msg,
icon: 'error',
showCancel: false,
duration: 3000
});
}
});
} else if (res.cancel) {
//console.log('用戶點(diǎn)擊取消')
}
}
})
},
save(e) {
let ostatus = e.currentTarget.dataset.status
if (this.data.checkedStudents.length == 0) {
util.alert('請(qǐng)選擇觀察對(duì)象!')
return
}
if (!this.data.selectedDate) {
util.alert('請(qǐng)選擇記錄日期!')
return
}
let allHasContent = true //后端要求內(nèi)容必填 否則以下的內(nèi)容都不會(huì)保存
allHasContent = this.data.activityMaterials.every(function (item) {
return item.content != '' && item.content != null && item.content != undefined
})
if (!allHasContent) {
util.alert('請(qǐng)先輸入內(nèi)容!')
return
}
//this.saveDocconfirm() //保存Ai續(xù)寫(xiě)的內(nèi)容
if (lock) return
lock = true
//處理過(guò)濾activityMaterials數(shù)據(jù)
let actArr = this.data.activityMaterials.map(function (item) {
let oarr = []
//轉(zhuǎn)換數(shù)據(jù)格式
oarr[0] = {
content: item.content
}
//錄音部分轉(zhuǎn)化成特定格式給后端
for (let i in item.recordArr) {
oarr.push({
content: item.recordArr[i].url,
fileSize: item.recordArr[i].time - 0, //后端要用這個(gè)字段名稱存儲(chǔ)時(shí)間
})
oarr.push({
content: item.recordArr[i].txt
})
}
//把圖片、視頻以content的子級(jí)的方式添加到paragraphs里面
for (let i in item.material) {
oarr.push({
content: item.material[i].url
})
}
return {
paragraphs: oarr
}
})
//console.log(actArr)
for (let i in actArr) {
//title等于編輯標(biāo)題就代表沒(méi)編輯過(guò) paragraphs[0].content的值為空就代表textare沒(méi)編輯過(guò) paragraphs[1]不存在或者content為空就代表沒(méi)編輯過(guò)
if (!actArr[i].paragraphs[0].content && (!actArr[i].paragraphs[1] || !actArr[i].paragraphs[1].content)) {
actArr.splice(i, 1)
}
}
let observeSceneList = this.data.observeSceneList
let observeParentIndex = this.data.observeParentIndex
let observeChildIndex = this.data.observeChildIndex
let scene = observeSceneList[observeParentIndex].expenseId + ',' + observeSceneList[observeParentIndex].children[observeChildIndex].expenseId
//過(guò)濾數(shù)據(jù)成后臺(tái)需要的結(jié)構(gòu)
let oevaluationItems = this.data.evaluationItems
//console.log(oevaluationItems)
oevaluationItems = oevaluationItems.map(function (item) {
if (item.parentId) {
return {
evaluationIndicatorId: item.parentId,
id: item.id
}
} else {
return {
evaluationIndicatorId: item.evaluationIndicatorId,
id: item.id
}
}
})
let params = {
userId: this.data.userInfo.userId,
classId: this.data.classCheckedId,
type: this.data.idx,
activityId: this.data.themeChecked.id,
recordDate: this.data.selectedDate,
scene: scene,
purpose: this.data.observe,
measure: this.data.measure,
observationParticipants: this.data.checkedStudents,
observationRecords: actArr,
evaluationItems: oevaluationItems,
status: ostatus,
}
let requestStyle = ''
let requestUrl = ''
if (this.data.oid) {
params.id = this.data.oid
requestStyle = 'PUT'
requestUrl = api.observationViewEdit
} else {
requestStyle = 'POST'
requestUrl = api.observeSceneSave
}
wx.showLoading({
title: '提交中'
})
util.request(requestUrl, params, requestStyle, 'application/json').then(res => {
if (res.code == 200) {
wx.showToast({
title: '提交成功!',
icon: 'success',
duration: 2000
})
this.bookHandle('suc', '')
} else {
this.bookHandle('err', res)
}
});
},
bookHandle(result, ores) {
const that = this
let isSuccess = false
wx.requestSubscribeMessage({
tmplIds: ['hGQUXKwyQtenWhFPnKvGcZk1mq-hdjxOPSvh_5FT46w'],
success(res) {
if (result == 'suc') {
isSuccess = true
that.setData({
oid: '',
studentArr: [],
activityId: null,
checkedStudentsTreated: []
})
app.globalData.isActivityMaterials = false //阻止調(diào)用onshow
wx.switchTab({
url: '/pages/report/report',
});
lock = false
wx.hideLoading();
} else {
wx.showToast({
title: ores.msg,
icon: 'error',
duration: 2000
})
app.globalData.isActivityMaterials = false
lock = false
wx.hideLoading();
}
},
complete() {
//如果調(diào)用成功 則不用調(diào)用第二遍 complete是必調(diào)用的 所以攔住省得第二次觸發(fā)
if (isSuccess) return
app.globalData.isActivityMaterials = false //阻止調(diào)用onshow
wx.switchTab({
url: '/pages/report/report',
});
lock = false
wx.hideLoading();
},
})
},
saveHandle() {
if (editType == 0) { //添加
wx.switchTab({
url: '/pages/activityn/activityn',
})
} else { //修改
wx.navigateBack({
delta: 1
});
}
lock = false
wx.hideLoading();
},
tabHandle(e) {
//清掉幼兒發(fā)展水平評(píng)估的選中狀態(tài)
let oindex = e.currentTarget.dataset.idx
this.setData({
openArea: false,
idx: oindex,
areaStr: '', //重置幼兒發(fā)展水平評(píng)估選中的值
areaSecondIndex: 0,
areaFirstIndex: 0,
// threeData: [],
// selectArea: [],
evaluationItems: [],
sceneChecked: e.currentTarget.dataset.scene,
themeExt: e.currentTarget.dataset.ext == 1 ? true : false,
//classCheckedId: this.data.classData[0].classId,//ly-add 2023-10-09
})
// if(oindex == '2'){
// this.setData({
// pageNum: 1,
// activityList: [],//指向主題活動(dòng)列表
// })
// }
this.getIndex();
this.getListSelectArea();
},
monitorMeasureInput(e) {
let value = e.detail.value.replace(/\n\s*/g, '\n'); // 獲取輸入的文本內(nèi)容
if (value.length > 500) {
value = value.slice(0, 500);
}
this.setData({
measure: value,
measureNumber: value.length || 0,
})
},
bindParentChange: function (e) {
const observeParentIndex = e.detail.value;
const childArray = this.data.observeSceneList[observeParentIndex].children; // 根據(jù)選中的父級(jí)索引獲取對(duì)應(yīng)的子集數(shù)組
this.setData({
observeParentIndex: observeParentIndex,
childArray: childArray,
observeChildIndex: 0,
});
},
bindChildChange: function (e) {
const observeChildIndex = e.detail.value;
// 獲取選中的父級(jí)和子集數(shù)據(jù)
// const parentData = this.data.observeSceneList[this.data.parentIndex];
// const childData = this.data.childArray[childIndex];
this.setData({
observeChildIndex: observeChildIndex
});
},
//觀察場(chǎng)景請(qǐng)求數(shù)據(jù)
getObserveScene() {
var that = this;
util.request(api.listObserveScene, '', 'get').then(res => {
if (res.code == 200) {
that.setData({
observeSceneList: res.data
})
this.getIndex()
} else {
wx.showToast({
title: res.msg,
icon: 'error',
duration: 2000
})
}
});
},
//獲取觀察場(chǎng)景的父級(jí)index、子集index
getIndex() {
const that = this
let observeSceneList = this.data.observeSceneList
observeSceneList.forEach(function (item, index) {
//ly-edit 2023-09-15 非編輯狀態(tài)添加默認(rèn)的子級(jí) 如果是編輯狀態(tài)就重新賦值
let sceneChecked = that.data.sceneChecked
if (item.expenseId == sceneChecked.split(",")[0]) {
let cIndex = item.children.findIndex(citem => citem.expenseId == sceneChecked.split(",")[1]);
that.setData({
observeParentIndex: index,
childArray: item.children, //先給一個(gè)默認(rèn)值
observeChildIndex: cIndex
})
}
});
},
//選擇記錄日期
bindDateChange(e) {
let oval = e.detail.value
this.setData({
selectedDate: oval
});
},
//指向主題活動(dòng)加載更多
loadMoreActivity() {
if (this.data.flag) return
this.getListSelectActivity();
},
//指向主題活動(dòng)選中某一個(gè)元素
checkActivityHandle(e) {
let otheme = this.data.activityList
let oidx = e.currentTarget.dataset.idx
let obj = otheme[oidx]
//重置選中狀態(tài)
otheme = otheme.map(item => {
item.checked = false;
return item;
});
otheme[oidx].checked = true
let themeStr = otheme[oidx].name + (otheme[oidx].status == '1' ? '整理' : '計(jì)劃') + (otheme[oidx].monthWeek ? otheme[oidx].monthWeek : '')
this.setData({
activityList: otheme,
themeChecked: obj,
openTheme: false,
themeStr: themeStr,
})
},
//加載指向主題活動(dòng)數(shù)據(jù)
getListSelectActivity() {
let oclassId = this.data.classCheckedId == this.data.userInfo.schoolId ? '' : this.data.classCheckedId;
var param = '&classId=' + oclassId + '&schoolId=' + this.data.userInfo.schoolId
util.request(api.listSelectActivity + this.data.pageNum + '&pageSize=' + this.data.pageSize + param + '&id=' + (this.data.activityId ? this.data.activityId : '') + '&includeActiveAuthPlan=' + true, '', 'get').then(res => {
if (res.code == 200) {
let odata = res.rows
let newDataList = this.data.activityList.concat(odata);
//回顯
if (this.data.activityId) {
for (let i in newDataList) {
if (newDataList[i].id == this.data.activityId) {
newDataList[i].checked = true
let themeStr = newDataList[i].name + (newDataList[i].status == '1' ? '整理' : '計(jì)劃') + newDataList[i].monthWeek
this.setData({
themeStr: themeStr
})
break
}
}
}
this.setData({
activityList: newDataList,
pageNum: this.data.pageNum + 1,
})
if (newDataList.length >= res.total) {
this.setData({
flag: true,
moreTxt: '-無(wú)更多數(shù)據(jù)-'
})
} else {
this.setData({
flag: false,
moreTxt: '-點(diǎn)擊加載更多-'
})
}
} else {
wx.showModal({
title: res.msg,
icon: 'error',
showCancel: false,
duration: 3000
});
}
});
},
//開(kāi)關(guān)閉合 幼兒發(fā)展水平評(píng)估
openAreaHandle() {
//獲取areaStr的值
let str = ''
let evaluationItems = this.data.evaluationItems
for (let i in evaluationItems) {
if (evaluationItems[i].label) {
str += evaluationItems[i].label
} else {
str += (evaluationItems[i].sort + ':' + evaluationItems[i].syndrome)
}
}
str = str.substring(0, str.length - 1)
this.setData({
openArea: this.data.openArea ? false : true,
areaStr: str
})
},
checkedAreaHandle(e) {
let parentIndex = e.currentTarget.dataset.parentindex
let childindex = e.currentTarget.dataset.childindex
let oitem = e.currentTarget.dataset.item
let evaluationItems = this.data.evaluationItems
let threeData = this.data.threeData
//思路:點(diǎn)擊的時(shí)候 判斷當(dāng)前checked是否為true 如果是true則改為false 如果是false通過(guò)父級(jí)index 把父級(jí)下標(biāo)下所有的checked改為false 在子級(jí)下標(biāo)對(duì)應(yīng)的那個(gè)值改為true
//1、判斷點(diǎn)擊的元素 checked是否為true
let activeList = ''
if (this.data.showAreaSecond) {
activeList = threeData.children[parentIndex].children[childindex] //選中的元素
} else {
activeList = threeData[parentIndex].children[childindex] //選中的元素
}
if (activeList.checked) { //重置 如果是true改為false
for (let i in evaluationItems) { //刪除相同id的item
if (evaluationItems[i].id == oitem.id) {
evaluationItems.splice(i, 1)
break
}
}
activeList.checked = false
} else {
if (this.data.showAreaSecond) {
threeData.children[parentIndex].children.forEach(function (item) {
//遍歷清除該點(diǎn)擊元素同級(jí)的所有元素
for (let i in evaluationItems) {
if (item.id == evaluationItems[i].id) {
evaluationItems.splice(i, 1)
}
}
item.checked = false
})
} else {
threeData[parentIndex].children.forEach(function (item) {
//遍歷清除該點(diǎn)擊元素同級(jí)的所有元素
for (let i in evaluationItems) {
if (item.id == evaluationItems[i].id) {
evaluationItems.splice(i, 1)
}
}
item.checked = false
})
}
evaluationItems.push(oitem)
activeList.checked = true
}
//如果threeData里有checked是true 那就出現(xiàn)角標(biāo)
//獲取第一級(jí)的index
//console.log(this.data.areaFirstIndex)
//console.log(threeData)
let hasCornerMark = false
if (this.data.showAreaSecond) {
hasCornerMark = this.findCheckedItem(threeData.children)
} else {
hasCornerMark = this.findCheckedItem(threeData)
}
let selectArea = this.data.selectArea
selectArea[this.data.areaFirstIndex].checked = hasCornerMark
//console.log(evaluationItems)
this.setData({
threeData,
selectArea
})
},
//查找多層級(jí)數(shù)組中是否帶有checked為true的屬性并返回
findCheckedItem(arr) {
const that = this
for (let item of arr) {
if (item.checked === true) {
return true;
}
if (item.children && item.children.length > 0) {
const found = that.findCheckedItem(item.children);
if (found) {
return true;
}
}
}
return false;
},
updateCheckedStatus(arr1, arr2) {
for (let i = 0; i < arr1.length; i++) {
// 檢查當(dāng)前元素的id是否在arr2中存在
if (arr2.some(item => item.id === arr1[i].id)) {
arr1[i].checked = true;
}
// 遞歸遍歷children數(shù)組
if (arr1[i].children) {
this.updateCheckedStatus(arr1[i].children, arr2);
}
}
},
//第三級(jí)頁(yè)面顯示
getThreeData() {
let listSelect = this.data.listSelect
if (this.data.showAreaSecond) {
//需要加children
let areaSecondIndex = this.data.areaSecondIndex
//回顯
if(listSelect.length > 0 && this.data.evaluationItems.length > 0){
this.updateCheckedStatus(listSelect[areaSecondIndex].children, this.data.evaluationItems)
}
this.setData({
threeData: listSelect[areaSecondIndex]
})
} else {
//不需要加children
//回顯
if(listSelect.length > 0 && this.data.evaluationItems.length > 0){
this.updateCheckedStatus(listSelect, this.data.evaluationItems)
}
this.setData({
threeData: listSelect
})
}
},
getAreaSecondIndex(e) {
let index = e.currentTarget.dataset.index
this.setData({
areaSecondIndex: index
})
this.getThreeData()
},
//指標(biāo)列表
getlistSelect(id) {
util.request(api.listSelect + id + '&observationViewId=' + this.data.observationViewId, '', 'get').then(res => {
if (res.code == 200) {
//有可能消失的第二級(jí) 如果第一級(jí)的id用于查詢指標(biāo)列表 指標(biāo)列表type是3 則第二級(jí)顯示 如果type是4則該第二級(jí)隱藏 ***如果沒(méi)有children 直接使用選項(xiàng)卡*** 第二級(jí)是單選
let odata = res.data
let showAreaSecond = this.data.showAreaSecond //是否展示二級(jí)
// 使用find方法找到第一個(gè)包含非null children數(shù)組的元素
const elementWithChildren = odata.find(element => element.children !== null);
let firstType = ''
// 如果找到了包含非null children數(shù)組的元素
if (elementWithChildren) {
// 使用some方法遍歷children數(shù)組,找到第一個(gè)type字段的值
firstType = elementWithChildren.children.find(child => child.type).type;
} else {
//都沒(méi)有children的情況
//console.log('No element with non-null children found.');
}
if (odata.length > 0 && (firstType == '3')) {
showAreaSecond = true
} else {
showAreaSecond = false
}
this.setData({
listSelect: res.data,
showAreaSecond: showAreaSecond
})
//獲取并展示第三級(jí)頁(yè)面的值
this.getThreeData()
} else {
wx.showModal({
title: res.msg,
icon: 'error',
showCancel: false,
duration: 3000
});
}
});
},
//一級(jí)的tab操作
getSelectAreaId(e) {
let id = e.currentTarget.dataset.id
let index = e.currentTarget.dataset.index
this.setData({
areaFirstIndex: index,
})
this.getlistSelect(id)
},
//選擇評(píng)估對(duì)象
getListSelectArea() {
util.request(api.listSelectArea2 + (this.data.userInfo.schoolId ? this.data.userInfo.schoolId : '') + '/' + this.data.idx, '', 'get').then(res => {
if (res.code == 200) {
let odata = res.data
let arryNew = []
odata.map((item) => {
arryNew.push(Object.assign({}, item, {
checked: false
}))
})
this.setData({
selectArea: arryNew
})
if (odata.length == 0) return
//默認(rèn)查詢第一條id對(duì)應(yīng)的指標(biāo)列表
this.getlistSelect(odata[0].id)
} else {
wx.showModal({
title: res.msg,
icon: 'error',
showCancel: false,
duration: 3000
});
}
});
},
monitorObserveInput(e) {
this.setData({
observe: e.detail.value,
observeNumber: e.detail.cursor
})
},
openObserveHandle() {
let selectedDate = this.data.selectedDate
let observeSceneList = this.data.observeSceneList
let observeParentIndex = this.data.observeParentIndex
let observeChildIndex = this.data.observeChildIndex
let scene = selectedDate + ',' + observeSceneList[observeParentIndex].expenseItem + observeSceneList[observeParentIndex].children[observeChildIndex].expenseItem + ',' + (this.data.observe ? this.data.observe : '')
this.setData({
openObserve: this.data.openObserve ? false : true,
observeStr: scene
})
},
//處理選中學(xué)生如果超過(guò)十個(gè)用...顯示
checkedStudentsHandle(oarr) {
if (this.data.openStudents && oarr.length > 10) {
//如果關(guān)閉的時(shí)候 選中的列表超過(guò)10個(gè)則截取列表剩下9個(gè)顯示
oarr = oarr.slice(0, 9)
this.setData({
checkedStudentsTreated: oarr
})
} else {
this.setData({
checkedStudentsTreated: this.data.checkedStudents
})
}
},
openStudentHandle() {
let oarr = JSON.parse(JSON.stringify(this.data.checkedStudents))
this.checkedStudentsHandle(oarr)
this.setData({
openStudents: this.data.openStudents ? false : true
})
},
checkHandle(e) {
let idx = e.currentTarget.dataset.idx
let arr = this.data.students
arr[idx].checked = arr[idx].checked == true ? false : true
let checkedarr = arr.filter(function (item) {
return item.checked == true
})
this.setData({
students: arr,
checkedStudents: checkedarr
})
},
checkClassHandle(e) {
//this.data.classCheckedId == e.currentTarget.datasetid ? [] : this.data.checkedStudentsTreated
this.setData({
classCheckedId: e.currentTarget.dataset.id,
flag: false,
pageNum: 1,
activityList: [], //指向主題活動(dòng)列表
students: [],
checkedStudents: [],
checkedStudentsTreated: [],
themeChecked: {},
themeStr: '',
activityId: null
})
this.getStudent()
this.getListSelectActivity();//ly-edit 2023-10-09
this.getListSelectArea(); //ly-add 2023-10-09
},
getStudent() {
var param = {};
param.deptId = this.data.classCheckedId;
param.schoolId = wx.getStorageSync('userInfo').schoolId;
util.request(api.studentList, param, 'POST').then(res => {
if (res.code == 200) {
let oarr = res.rows.map(function (item) {
return {
studentId: item.id,
studentName: item.name,
studentNumber: item.number,
studentImage: item.headUrl ? item.headUrl : '',
sex: item.sex,
checked: false
}
})
if (this.data.checkedStudents.length > 0) {
let checkedStudents = this.data.checkedStudents
//判斷兩個(gè)數(shù)組是否有相同的id 如果有相同的id 給當(dāng)前的student添加選中狀態(tài)
oarr.forEach(item => {
const isChecked = checkedStudents.some(citem => citem.studentId === item.studentId);
item.checked = isChecked;
});
}
this.setData({
students: oarr
})
} else {
wx.showModal({
title: res.msg,
icon: 'error',
showCancel: false,
duration: 3000
});
}
});
},
timeHandle(time) {
if (time < 10) {
return '0' + time
} else {
return time
}
},
//重置錄音按鈕狀態(tài)
resetRecordState() {
let activityMaterials = this.data.activityMaterials
activityMaterials[this.data.parentIndex].recordState = false
this.setData({
activityMaterials: activityMaterials
})
},
addListHandle() {
let obj = this.data.activityMaterials
obj.push({
content: '',
material: []
})
this.setData({
activityMaterials: obj
})
},
textareaBlurHandle(e) {
let oval = e.detail.value
let obj = this.data.activityMaterials
let idx = e.currentTarget.dataset.idx
obj[idx].content = oval
this.setData({
activityMaterials: obj
})
},
preview(e) {
let currentUrl = e.currentTarget.dataset.src
let pidx = e.currentTarget.dataset.pidx //父級(jí)循環(huán)的index
const oarr = []
for (let i in this.data.activityMaterials[pidx].material) {
oarr.push(this.data.activityMaterials[pidx].material[i].url)
}
wx.previewImage({
current: currentUrl, // 當(dāng)前顯示圖片的http鏈接
urls: oarr // 需要預(yù)覽的圖片http鏈接列表
})
},
closeHadle(e) {
const that = this
wx.showModal({
title: '',
content: '是否刪除素材',
success(res) {
if (res.confirm) {
let obj = that.data.activityMaterials
let pidx = e.currentTarget.dataset.pidx //父級(jí)循環(huán)的index
let idx = e.currentTarget.dataset.idx //子級(jí)循環(huán)的index
obj[pidx].material.splice(idx, 1)
that.setData({
activityMaterials: obj
})
} else if (res.cancel) {
//console.log('用戶點(diǎn)擊取消')
}
}
})
},
//上傳圖片、視頻
uploadFile: function (e) {
//如果不添加這個(gè)判斷 則在這里會(huì)默認(rèn)調(diào)用onshow
app.globalData.isActivityMaterials = true //阻止調(diào)用onshow
const that = this
let obj = this.data.activityMaterials
let pidx = e.currentTarget.dataset.idx
wx.chooseMedia({
count: 9, // 設(shè)置為需要上傳的文件數(shù)量
mediaType: ['image', 'video'],
sizeType: ['compressed'], //壓縮圖片
success: function (res) {
const files = res.tempFiles;
// 遍歷選擇的文件數(shù)組,依次上傳每個(gè)文件
wx.showLoading({
title: '上傳中'
})
files.forEach(function (file) {
const tempFilePath = file.tempFilePath;
wx.uploadFile({
url: BASE_URL + 'common/uploadMediaToTencent',
formData: {
'userId': wx.getStorageSync('userInfo').userId,
'scene': 'observation'
},
filePath: tempFilePath,
name: 'file',
success: function (res) {
let ores = JSON.parse(res.data)
//每個(gè)數(shù)組里添加一個(gè)type值是mp4或者img,在for循環(huán)里通過(guò)type賦值到mp4或者img里面
let otype = that.getFileExtension(ores.url)
if (otype) {
let params = {
url: ores.url,
type: otype
}
obj[pidx].material.push(params)
}
that.setData({
activityMaterials: obj,
})
wx.hideLoading();
},
fail: function (res) {
// 處理上傳失敗后的邏輯
wx.hideLoading();
}
})
});
}
})
},
//用一個(gè)方法來(lái)判斷 返回的文件是mp4 還是圖片
getFileExtension(url) {
const dotIndex = url.lastIndexOf('.');
const extension = url.substring(dotIndex + 1);
if (/(jpg|jpeg|png)$/.test(extension.toLowerCase())) {
return 'img'
} else if (/(mp4|avi|mov)$/.test(extension.toLowerCase())) {
return 'mp4'
}
return false
},
deleteHandle(e) {
const that = this
wx.showModal({
title: '',
content: '是否刪除',
success(res) {
if (res.confirm) {
let obj = that.data.activityMaterials
let idx = e.currentTarget.dataset.idx //子級(jí)循環(huán)的index
obj.splice(idx, 1)
that.setData({
activityMaterials: obj
})
} else if (res.cancel) {
//console.log('用戶點(diǎn)擊取消')
}
}
})
},
//識(shí)別語(yǔ)音 -- 初始化
initRecord: function () {
var that = this;
wx.onSocketOpen((res) => { // websocket打開(kāi)
//console.log('監(jiān)聽(tīng)到 WebSocket 連接已打開(kāi)' + res);
})
wx.onSocketError((err) => { //連接失敗
//console.log('websocket連接失敗', err);
wx.showToast({
title: 'websocket連接失敗',
icon: 'none',
duration: 2000,
mask: false
})
})
wx.onSocketMessage((res) => { //接收返回值
var data = JSON.parse(res.data)
//console.log(data)
if (data.code != 0) {
//console.log("error code " + data.code + ", reason " + data.message)
return
}
let str = ""
if (data.data.status == 2) { //最終識(shí)別結(jié)果
// data.data.status ==2 說(shuō)明數(shù)據(jù)全部返回完畢,可以關(guān)閉連接,釋放資源
wxst.close();
} else { //中間識(shí)別結(jié)果
}
iatResult[data.data.result.sn] = data.data.result
if (data.data.result.pgs == 'rpl') {
data.data.result.rg.forEach(i => {
iatResult[i] = null
})
}
iatResult.forEach(i => {
if (i != null) {
i.ws.forEach(j => {
j.cw.forEach(k => {
str += k.w
})
})
}
});
// console.log('這個(gè)是中間的語(yǔ)音識(shí)別結(jié)果')
// console.log(str)
that.setData({
contentTxt: str //這個(gè)是中間的語(yǔ)音識(shí)別結(jié)果
})
if (!this.data.contentTxt) {
wx.showToast({
title: '識(shí)別失敗,請(qǐng)重新錄入',
icon: 'none',
duration: 2000,
mask: false
})
return
}
})
wx.onSocketClose((res) => { //WebSocket連接已關(guān)閉!
//var that = this;
recorderManager.stop();
// var str = that.data.contentTxt;
// console.log(str);
// str = str.replace(/\s*/g, "");//去除空格
// if (str.substr(str.length - 1, 1) == "。") {//去除句號(hào)
// str = str.substr(0, str.length - 1);
// }
// console.log('這個(gè)是最后確定的語(yǔ)音識(shí)別結(jié)果', str)
// that.setData({
// contentTxt: str//這個(gè)是最后確定的語(yǔ)音識(shí)別結(jié)果
// })
//console.log('WebSocket連接已關(guān)閉!')
})
},
//錄音和停止錄音操作
recordHandle(e) {
let oactivityMaterials = this.data.activityMaterials
let parentIndex = e.currentTarget.dataset.idx
this.setData({ //獲取父級(jí)的下標(biāo) 后面錄音結(jié)束后給對(duì)應(yīng)的模塊賦值
parentIndex: parentIndex
})
//改成點(diǎn)擊事件
if (!oactivityMaterials[parentIndex].recordState) {
wx.showToast({
title: '開(kāi)始錄音',
icon: 'none',
duration: 1000
})
//兄弟節(jié)點(diǎn)的錄音按鈕改成灰色
if (oactivityMaterials.length > 1) {
for (let i in oactivityMaterials) {
oactivityMaterials[i].recordState = false
}
this.setData({
activityMaterials: oactivityMaterials
})
}
oactivityMaterials[parentIndex].recordState = true
this.setData({
activityMaterials: oactivityMaterials //錄音狀態(tài)
})
wx.getSetting({ //查看用戶有沒(méi)有開(kāi)啟語(yǔ)音權(quán)限
success(res) {
if (res.authSetting['scope.record']) {
wx.authorize({
scope: 'scope.record',
success() {
var xfurl = "";
wx.request({ //請(qǐng)求接口 獲取訊飛語(yǔ)音鑒權(quán)
url: BASE_URL + 'assistant/url',
method: "get",
header: {
'content-type': 'application/json' // 默認(rèn)值
},
success: function (res) {
//console.log('鑒權(quán)結(jié)果start:');
//console.log(res);
if (res.statusCode == "200" && res.data) {
xfurl = res.data;
wxst = wx.connectSocket({ // 開(kāi)啟websocket連接
url: xfurl,
method: 'GET',
success: function (res) {
recorderManager.start(searchoptions); //開(kāi)始錄音
}
});
} else {
wx.showToast({
title: '獲取語(yǔ)音鑒權(quán)失敗',
icon: 'none',
mask: true,
duration: 3000
})
}
},
fail: function () {
wx.showToast({
title: '獲取語(yǔ)音鑒權(quán)失敗',
icon: 'none',
mask: true,
duration: 3000
})
}
})
},
fail() {
wx.showModal({
title: '微信授權(quán)',
content: '您當(dāng)前未開(kāi)啟語(yǔ)音權(quán)限,請(qǐng)?jiān)谟疑辖窃O(shè)置(···)中開(kāi)啟“錄音功能”',
showCancel: false,
success(res) {
if (res.confirm) {
//console.log('用戶點(diǎn)擊確定')
}
}
})
}
})
} else {
wx.showModal({
title: '微信授權(quán)',
content: '您當(dāng)前未開(kāi)啟語(yǔ)音權(quán)限,請(qǐng)?jiān)谟疑辖窃O(shè)置(···)中開(kāi)啟“錄音功能”',
showCancel: false,
success(res) {
if (res.confirm) {
//console.log('用戶點(diǎn)擊確定')
}
}
})
}
}
})
} else {
oactivityMaterials[parentIndex].recordState = false
this.setData({
activityMaterials: oactivityMaterials
})
recorderManager.stop();
}
},
//播放操作
playHandle(e) {
const that = this
let idx = e.currentTarget.dataset.idx
let pidx = e.currentTarget.dataset.pidx
//recordArr的字段有url/txt/time/played/showTxt: false,//語(yǔ)音的文字部分是否展示showTip: false,//Tooltip 文字提示是否展示directionUp: false,//Tooltip的方向是向上還是向下
let activityMaterials = this.data.activityMaterials
let orecordArr = activityMaterials[pidx].recordArr[idx]
innerAudioContext.src = orecordArr.url
if (!orecordArr.played) {
//查找兄弟節(jié)點(diǎn) 把所有的played狀態(tài)改成false
for (let i in activityMaterials) {
for (let j in activityMaterials[i].recordArr) {
activityMaterials[i].recordArr[j].played = false
}
}
// if(activityMaterials && activityMaterials.length > 1){
// that.setData({
// activityMaterials: activityMaterials
// })
// }
//播放
orecordArr.played = true
innerAudioContext.play() // 播放
innerAudioContext.onEnded(() => {
//console.log('語(yǔ)音播放結(jié)束');
orecordArr.played = false
that.setData({
activityMaterials: activityMaterials
})
});
} else {
//關(guān)閉
orecordArr.played = false
innerAudioContext.stop() // 停止
}
this.setData({
activityMaterials: activityMaterials
})
},
onLongPress(e) {
//console.log(e)
//const listItem = e.currentTarget;
let activityMaterials = this.data.activityMaterials
let pidx = e.currentTarget.dataset.pidx //父級(jí)下標(biāo)
let idx = e.currentTarget.dataset.idx //子級(jí)下標(biāo)
//console.log(e.touches[0].clientY)
let oClientY = e.touches[0].clientY * 2 //點(diǎn)擊的位置和Y軸頂部的距離
//隱藏所有語(yǔ)音列表的tip
//console.log(activityMaterials)
for (let i in activityMaterials) {
for (let j in activityMaterials[i].recordArr) {
activityMaterials[i].recordArr[j].showTip = false
}
}
this.setData({
activityMaterials: activityMaterials
})
//判斷只要距離Y軸頂部的距離 大于220rpx 一律往上面冒泡
if (oClientY > 220) {
activityMaterials[pidx].recordArr[idx].directionUp = true
} else {
activityMaterials[pidx].recordArr[idx].directionUp = false
}
activityMaterials[pidx].recordArr[idx].showTip = true
this.setData({
activityMaterials: activityMaterials,
maskShow: true
})
},
txtRecordHandle(e) {
let activityMaterials = this.data.activityMaterials
let pidx = e.currentTarget.dataset.pidx //父級(jí)下標(biāo)
let idx = e.currentTarget.dataset.idx //子級(jí)下標(biāo)
activityMaterials[pidx].recordArr[idx].showTxt = true
activityMaterials[pidx].recordArr[idx].showTip = false
this.setData({
activityMaterials: activityMaterials
})
},
delRecordHandle(e) {
let activityMaterials = this.data.activityMaterials
let pidx = e.currentTarget.dataset.pidx //父級(jí)下標(biāo)
let idx = e.currentTarget.dataset.idx //子級(jí)下標(biāo)
activityMaterials[pidx].recordArr.splice(idx, 1)
this.setData({
activityMaterials: activityMaterials,
maskShow: false
})
},
closeTipHandle() {
let activityMaterials = this.data.activityMaterials
//隱藏所有語(yǔ)音列表的tip
//console.log(activityMaterials)
for (let i in activityMaterials) {
for (let j in activityMaterials[i].recordArr) {
activityMaterials[i].recordArr[j].showTip = false
}
}
this.setData({
activityMaterials: activityMaterials,
maskShow: false
})
},
onUnload: function () {
innerAudioContext.stop() // 停止
},
onShareAppMessage() {},
recordAiHandle(e) {
let oactivityMaterials = this.data.activityMaterials
let parentIndex = e ? e.currentTarget.dataset.idx : this.data.aiParentIndex
let params = {
docstyle: 3, //如果觀察記錄有值輸入3 沒(méi)值輸入1
content: {
'level1': this.data.observeSceneList[this.data.observeParentIndex].expenseItem,
'level2': this.data.childArray[this.data.observeChildIndex].expenseItem,
},
text: oactivityMaterials[parentIndex].content
}
wx.showLoading({
title: '加載中...'
});
util.request('https://ai.keeko.ai/docgeneration', params, 'POST', 'application/json').then(res => {
wx.hideLoading();
if (res.result == 1) {
this.setData({
aiPolish: res.data.text,
aistyle: e ? e.currentTarget.dataset.aistyle : this.data.aistyle,
aiParentIndex: parentIndex
})
if (!this.data.showPolish) {
this.setData({
showPolish: true
})
}
} else {
wx.showToast({
title: '尚在學(xué)習(xí)中',
icon: 'none',
mask: true,
duration: 3000
})
}
});
},
//Ai續(xù)寫(xiě) 觀察目的
aimAiHandle(e) {
let observe = this.data.observe
let params = {
docstyle: !observe ? 1 : 2, //如果目的有值輸入2 沒(méi)值輸入1
content: {
'level1': this.data.observeSceneList[this.data.observeParentIndex].expenseItem,
'level2': this.data.childArray[this.data.observeChildIndex].expenseItem,
},
text: observe
}
wx.showLoading({
title: '加載中...'
});
util.request('https://ai.keeko.ai/docgeneration', params, 'POST', 'application/json').then(res => {
wx.hideLoading();
if (res.result == 1) {
this.setData({
aiPolish: res.data.text,
aistyle: e ? e.currentTarget.dataset.aistyle : this.data.aistyle
})
//aiAgain 重寫(xiě)的時(shí)候不刷新彈窗狀態(tài)
if (!this.data.showPolish) {
this.setData({
showPolish: true
})
}
} else {
wx.showToast({
title: '尚在學(xué)習(xí)中',
icon: 'none',
mask: true,
duration: 3000
})
}
});
},
//判斷是不是空對(duì)象
isEmptyObject(obj) {
return Object.keys(obj).length === 0;
},
saveDocconfirm() {
let observe = this.data.observe
let level1 = this.data.observeSceneList[this.data.observeParentIndex].expenseItem
let level2 = this.data.childArray[this.data.observeChildIndex].expenseItem
let observeParams = {}
if (observe) {
observeParams = {
docstyle: 2, //2代表觀察目的
content: {
'level1': level1,
'level2': level2,
},
title: '觀察目的',
text: this.data.aimAiKeyword,
doctext: this.data.aimAiPolish
}
//console.log(observeParams)
}
//先過(guò)濾無(wú)值的項(xiàng)
let activityArr = []
if (this.data.activityMaterials.length > 0 && this.data.activityMaterials[0].content) {
activityArr = this.data.activityMaterials.map(function (item) {
if (item.recordAiPolish) {
return {
docstyle: 3, //2代表觀察目的
content: {
'level1': level1,
'level2': level2,
},
title: '觀察記錄',
text: item.aiKeyword,
doctext: item.recordAiPolish
}
}
})
}
if (!this.isEmptyObject(observeParams)) {
activityArr.unshift(observeParams)
}
let params = {
doc: activityArr
}
if (activityArr.length == 0) return
util.request('https://ai.keeko.ai/docconfirm', params, 'POST', 'application/json').then(res => {
//console.log(res)
});
},
aiCancel() {
this.setData({
showPolish: false,
})
},
aiAgain() {
if (this.data.aistyle == '1') {
this.aimAiHandle()
} else {
this.recordAiHandle()
}
},
aiConfirm() {
if (this.data.aistyle == '1') {
let otxt = this.data.aiPolish
let value = (this.data.observe + otxt).replace(/\n\s*/g, '\n'); // 獲取輸入的文本內(nèi)容
if (value.length > 500) {
value = value.slice(0, 500);
}
this.setData({
aimAiPolish: otxt,
aimAiKeyword: this.data.observe, //關(guān)鍵詞
observe: value,
observeNumber: value.length,
showPolish: false,
})
} else {
let oactivityMaterials = this.data.activityMaterials
let parentIndex = this.data.aiParentIndex
let otxt = this.data.aiPolish
let value = (oactivityMaterials[parentIndex].content + otxt).replace(/\n\s*/g, '\n'); // 獲取輸入的文本內(nèi)容
if (value.length > 500) {
value = value.slice(0, 500);
}
oactivityMaterials[parentIndex].aiKeyword = oactivityMaterials[parentIndex].content
oactivityMaterials[parentIndex].content = value
oactivityMaterials[parentIndex].recordAiPolish = otxt
this.setData({
activityMaterials: oactivityMaterials,
showPolish: false,
})
}
},
monitorPopInput(e) {
this.setData({
aiPolish: e.detail.value
})
},
})
.wrap{ padding: 30rpx 30rpx 100rpx 30rpx;}
.header-tab{ display: flex; overflow-x: scroll;}
.tab-list{ position: relative; margin-right: 20rpx; padding: 0; background: #fff; text-align: center;border-radius: 16rpx; opacity: 0.3;}
.tab-list:last-child{ margin-right: 0;}
.icon-daily{ margin: 0 auto; display: block; width: 225rpx; height: 178rpx; border-radius: 10rpx;}
.tab-list .v1{ position: absolute; bottom: 0; left: 0; width: 100%; height: 50rpx; line-height: 50rpx; background: #33a9ff; color: #fff; font-size: 28rpx; border-radius: 0 0 10rpx 10rpx; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;}
.tab-list.active{ opacity: 1;}
.title-box{ display: flex; align-items: center; font-size: 26rpx; font-weight: bold;}
.warn{ margin-top: 100rpx; text-align: center;}
.icon-add{ margin-left: 15rpx; display: block; width: 124rpx; height: 124rpx;}
.student-item{ display: flex; flex-wrap: wrap;}
.student-list{ position: relative;}
.student-list .v1{ margin-top: 10rpx; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 22rpx; color: #777;}
.student-photo{ margin: 0 auto; display: block; width: 124rpx; height: 124rpx; border-radius: 50%;}
.student-box{ padding: 30rpx 0 45rpx 0; display: grid; grid-template-columns: repeat(4, 1fr); grid-gap: 20rpx 0;}
.record-white-box{ margin-top: 30rpx; padding: 22rpx}
.title-box,.title-txt-part{ display: flex; align-items: center;}
.icon-close-black{ display: block; width: 28rpx; height: 16rpx;}
.icon-close-black2{ display: block; width: 28rpx; height: 28rpx;}
.icon-edit{ margin-left: 10rpx; width: 31rpx; height: 30rpx;}
.yellow-fence{ margin-right: 10rpx; width: 6rpx; height: 30rpx; background: #33a9ff; border-radius: 3rpx;}
.title-txt-part{ flex: 1; font-size: 28rpx; font-weight: bold;}
.title-input{ padding-left: 16rpx; width: 360rpx; height: 60rpx; border:1rpx solid #ddd; border-radius: 10rpx; font-size: 26rpx;}
.material-box{ margin-top: 22rpx; display: flex; justify-content: flex-start; flex-wrap: wrap;}
.upload-box{ margin: 0 25rpx 25rpx 0; padding: 0; display: flex; justify-content: center; align-items: center; width: 310rpx; height: 186rpx; background: #f0f0f0; font-size: 25rpx; color: #111; border: 0; border-radius: 22rpx;}
button::after {border: none;}
.icon-photo{ margin-right: 10rpx; display: block; width: 93rpx; height: 85rpx;}
.material-list{ position: relative; margin: 0 25rpx 25rpx 0; width: 295rpx; height: 186rpx;}
.material-list-m2{ width: 100%; height: 100%; border-radius: 22rpx;}
.icon-close{ position: absolute; top: 10rpx; right: 10rpx; z-index: 999; display: block; width: 50rpx; height: 50rpx;}
.add-box{ margin-top: 30rpx; display: flex; justify-content: center; align-items: center; display: flex; font-size: 28rpx; color: #33a9ff;}
.save-btn{ margin: 100rpx auto 0 auto; width: 330rpx; height: 84rpx; text-align: center; line-height: 84rpx; background: #33a9ff; font-size: 30rpx; color: #111; font-weight: bold; border-radius: 42rpx;}
.textarea-box-wrap{ position: relative; margin-top: 22rpx; padding: 22rpx 22rpx 100rpx 22rpx; background: #f0f0f0; border-radius: 10rpx;}
.textarea-box{ width: 100%; height: 300rpx; box-sizing: border-box; font-size: 25rpx; color: #111;}
.voice-box{ margin-bottom: 20rpx; box-sizing: border-box; background: #f0f0f0; font-size: 25rpx; color: #111;}
.videoBtn {width: 50%;}
.videoBtn text{color:#fff;}
.videoBtnBg {background: #bdb4b4;}
.icon-record{ display: block; width: 70rpx; height: 70rpx;}
.textarea-box-footer{ position: absolute; bottom: 0; left: 0; display: flex; justify-content: center; align-items: center; width: 100%; height: 100rpx;}
.record-btn{ margin: 0; padding: 0; width: 70rpx; height: 70rpx; background: transparent; border-radius: 50%;}
button::after{border: none;}
.record-list{ padding-left: 18rpx; display: flex; align-items: center; box-sizing: border-box; width: 640rpx; height: 74rpx; background: #fff; color: #19b2ff; border-radius: 18rpx;}
.icon-video{ display: block; width: 56rpx; height: 55rpx;}
.record-list .t1{ margin: 0 22rpx;}
.record-txt{ padding:10rpx 10rpx 0 10rpx; font-size: 24rpx; color: #19b2ff;}
.record-item{ margin-bottom: 22rpx;}
.record-item:last-child{ margin-bottom: 0;}
.icon-txt{ display: block; width: 60rpx; height: 61rpx;}
.icon-del{ margin-top: 10rpx; display: block; width: 41rpx; height: 53rpx;}
.pos-box{ position: absolute; left: 50%; z-index: 999; transform: translateX(-50%); display: flex; align-items: center; width: 300rpx; height: 140rpx; background: #19b2ff; border-radius: 14rpx;}
.pos-box-lef,.pos-box-rig{ flex: 1; height: 140rpx; display: flex; flex-direction: column; justify-content: center; align-items: center; font-size: 24rpx; color: #fff;}
.pos-box-lef .t1,.pos-box-rig .t1{ margin-top: 6rpx;}
.icon-arrow-up,.icon-arrow-down{ display: block; width: 28rpx; height: 19rpx;}
.icon-arrow-down{ position: absolute; bottom: -19rpx; left: 50%; transform: translateX(-50%);}
.icon-arrow-up{ position: absolute; top: -19rpx; left: 50%; transform: translateX(-50%);}
.mask{ position: fixed; z-index: 99; top: 0; right: 0; bottom: 0; left: 0; background: transparent}
.icon-check{display: block; width: 42rpx; height: 42rpx;}
.icon-check{ position: absolute; top: 0; right: 0;}
.icon-arrow-down{ display: block; width: 24rpx; height: 24rpx;}
.close-box{ width: 40rpx; height: 40rpx; display: flex; justify-content: center; align-items: center;}
.no-graphs{ padding: 30rpx 20rpx; font-size: 24rpx; color: #666;}
.observe-txt{ white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 26rpx; color: #666;}
.textarea-box2{ padding: 20rpx; width: 100%; height: 300rpx; box-sizing: border-box; background: #f0f0f0; font-size: 26rpx; border-radius: 10rpx;}
.textarea-foot{ padding: 10rpx 10rpx 0 10rpx; display: flex; justify-content: space-between; font-size: 22rpx; color: #777;}
.check-list{ margin: 25rpx 0 10rpx 0; display: flex; justify-content: space-between;}
.check-list-lef{ font-size: 26rpx; color: #333;}
.check-list-rig{ display: flex; font-size: 28rpx; color: #777;}
.theme-list{ display: flex; align-items: center; height: 80rpx; border-bottom: 1rpx dashed #ddd;}
.icon-checkbox{ display: block; width: 40rpx; height: 40rpx;}
.theme-list .v1{ margin: 0 20rpx; width: 300rpx; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 28rpx; font-weight: bold; color: #333;}
.theme-list .v2{ font-size: 26rpx; color: #666;}
.theme-list:last-child{ border-bottom: 0;}
.scroll-box{ margin-top: 20rpx; white-space: nowrap;}
.domain-first,.domain-second-list{ margin-right: 10rpx; padding: 0 30rpx; height: 60rpx; line-height: 60rpx; white-space: nowrap; border-radius: 12rpx; background: rgba(51,169,255, 0.3); font-size: 26rpx; color: #333;}
.domain-first.active,.domain-second-list.active{background: rgba(51,169,255, 1); color: #fff;}
.domain-first{ position: relative; overflow: hidden; display: inline-block;}
.corner-mark{ position: absolute; bottom: 0; right: 0; width: 35rpx; height: 33rpx;}
.domain-second-list{ background: rgba(51,169,255, 0.1);}
.domain-second-list.active{background: rgba(51,169,255, 0.7)}
.domain-second{ margin-top: 30rpx; padding: 20rpx 0 0 0; display: flex; flex-wrap: wrap; border-top: 1px solid #eee;}
.domain-second-list{ margin-bottom: 10rpx;}
.domain-three-item{ margin-top: 20rpx;}
.domain-three-title{ margin-bottom: 20rpx; padding: 0 20rpx; display: flex; justify-content: space-between; align-items: center; height: 70rpx; line-height: 70rpx; border: 1px solid #eee; border-radius: 12rpx;}
.domain-three-title .v1{ font-size: 26rpx; color: #333;}
.domain-three-title .v2{ font-size: 24rpx; color: #999;}
.domain-three-list{ margin-bottom: 20rpx; display: flex;}
.domain-three-list .v1{ margin: 0 10rpx; width: 100rpx; line-height: 40rpx; font-size: 24rpx; color: #666;}
.domain-three-list .v2{ margin-left:20rpx; width: 0; flex: 1; line-height: 36rpx; font-size: 24rpx; color: #666;}
.domain-three-list .v2.active{ color: rgb(0, 0, 99); font-weight: bold;}
.close-box-str{ padding: 40rpx 20rpx; font-size: 26rpx; color: #666; white-space: nowrap; text-overflow: ellipsis; overflow: hidden;}
.package-footer{ margin-top: 20rpx; text-align: center; font-size: 24rpx; color: #999;}
.ones-aline{ margin: 0 15rpx;}
.footer{ display: flex; justify-content: space-evenly;}
.footer .v1,.footer .v2,.footer .v3{ margin: 0 25rpx; flex: 1; height: 80rpx; text-align: center; line-height: 80rpx; font-size: 30rpx; border-radius: 50rpx;}
.footer .v1,.footer .v3{ background: #b1b2b9; color: #fff;}
.footer .v2{ background: #33a9ff; color: #fff;}
.record-footer{ margin-top: 30rpx; padding: 20rpx 0;}
.picker{ text-decoration: underline;}
.student-number{ margin-left: 20rpx; font-weight: 400; font-size: 26rpx; color: #777;}
.up-box{ display: flex; justify-content: center; align-items: center; height: 50rpx; background: #fff; border-radius: 10rpx;}
.up-box .icon-close-black{ width: 28rpx; height: 16rpx;}
.student-list2{ position: relative; min-height: 140rpx;}
.student-list2 .v1{ margin-top: 10rpx; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 20rpx; color: #111;}
.student-photo2{ margin: 0 auto; display: block; width: 100rpx; height: 100rpx; border-radius: 50%;}
.more-box{ width: 100%; height: 100%; display: flex; justify-content: center; align-items: center;}
.scroll-class-box{ margin: 20rpx 0; white-space: nowrap;}
.scroll-class-list{ margin-right: 10rpx; padding: 0 30rpx; display: inline-block; height: 60rpx; line-height: 60rpx; white-space: nowrap; border-radius: 12rpx; background: rgba(25, 178, 255, 0.3); font-size: 26rpx; color: #333;}
.scroll-class-list.active{background: rgba(25, 178, 255, 1); color: #fff;}
.icon-add-txt{ margin-right: 14rpx; width: 45rpx; height: 45rpx; background: #33a9ff; text-align: center; line-height: 45rpx; font-size: 28rpx; color: #fff; border-radius: 50%;}
.only-box{display: flex; justify-content: space-between;}
.mt-20{ margin-top: 20rpx;}
.icon-ai{ display: block; width: 60rpx; height: 60rpx;}
.ai-wrap .v1,.ai-box .v1{ font-size: 20rpx; color: #33a9ff;}
.ai-wrap{ padding-bottom: 8rpx; display: flex; flex-direction: column; justify-content: center; align-items: center; background: #f0f0f0; border-radius: 0 0 10rpx 10rpx;}
.ai-box{ margin-right: 60rpx;}
.icon-add2{ margin-right: 14rpx; display: block; width: 44rpx; height: 45rpx;}
.ai-mask{ position: fixed; z-index: 99; left: 0; bottom:0; width: 750rpx; height: 100vh; background: rgba(0, 0, 0, 0.3);}
.ai-pop{ position: fixed; top: 50%; left: 30rpx; z-index: 100; transform: translateY(-50%); width: 690rpx; min-height: 400rpx; background: #fff; border-radius: 10rpx;}
.ai-pop-cont{ margin: 29rpx 0 0 30rpx; width: 630rpx; height: 300rpx; border-radius: 10rpx;}
.ai-pop-footer{ padding: 20rpx 0; display: flex; justify-content: center;}
.ai-pop-footer .v1,.ai-pop-footer .v2,.ai-pop-footer .v3{ margin: 0 25rpx; flex: 1; height: 60rpx; text-align: center; line-height: 60rpx; font-size: 30rpx; border-radius: 30rpx;}
.ai-pop-footer .v1{ background: #b1b2b9; color: #fff;}
.ai-pop-footer .v2,.ai-pop-footer .v3{ background: #33a9ff; color: #fff;}
個(gè)人記錄項(xiàng)目使用的 想使用的同學(xué)自己扣代碼吧文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-857997.html
到了這里,關(guān)于微信小程序 訊飛錄音 點(diǎn)擊按鈕錄音內(nèi)容轉(zhuǎn)文字的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!