video.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
  6. <title>--</title>
  7. <script src="js/vue@2.6.11"></script>
  8. <script src="js/uni.webview.1.5.2.js"></script>
  9. <!-- antd ui -->
  10. <script type="text/javascript" charset="utf-8" src="js/moment.min.js"></script>
  11. <script type="text/javascript" charset="utf-8" src="js/moment-with-locales.min.js"></script>
  12. <link rel="stylesheet" href="antd/antd.min.css" />
  13. <script type="text/javascript" charset="utf-8" src="antd/antd.min.js"></script>
  14. <!-- 编辑图片 -->
  15. <script type="text/javascript" charset="utf-8" src="imgEdit/ped.min.js"></script>
  16. <!-- 播放器 -->
  17. <link rel="stylesheet" href="aliplayer/aliplayer-min.css" />
  18. <script type="text/javascript" charset="utf-8" src="aliplayer/aliplayer-h5-min.js"></script>
  19. <!-- 页面样式 -->
  20. <link rel="stylesheet" href="css/styles.css" />
  21. </head>
  22. <body>
  23. <div class="storeCheck" id="app">
  24. <!-- 播放器 -->
  25. <div class="videoPlay" v-if="xdType=='video'&&!videoStatus">
  26. <!-- 云台控制 -->
  27. <div class="control-yt" v-show="showYt&&!showYtbtns" @click="openYt"></div>
  28. <div class="control-yt-close" v-show="showYtbtns" @click="openYt"></div>
  29. <div v-show="showYtbtns" @click="kzYt(1)" class="ytBtns yt-left"></div>
  30. <div v-show="showYtbtns" @click="kzYt(2)" class="ytBtns yt-right"></div>
  31. <div v-show="showYtbtns" @click="kzYt(3)" class="ytBtns yt-top"></div>
  32. <div v-show="showYtbtns" @click="kzYt(4)" class="ytBtns yt-bottom"></div>
  33. <!-- 加载条 -->
  34. <div v-if="showVideoLoading" class="videoloading">
  35. <a-spin size="large" tip="加载中..."/>
  36. </div>
  37. <!-- 播放器 -->
  38. <div class="prism-player" id="player-con"></div>
  39. </div>
  40. <div class="videoPlay errorVideo" v-if="xdType=='video'&&videoStatus">
  41. <div @click='getVideoUrl'>点击重新加载视频</div>
  42. </div>
  43. <!-- 工作区 -->
  44. <div class="checkWork">
  45. <!-- 统计及摄像头切换 -->
  46. <div class="checkWork-head">
  47. <div class="checkWork-head-row" v-if="xdType=='video'">
  48. <!-- 机位 -->
  49. <div>
  50. <div>机位:</div>
  51. <div></div>
  52. <div>
  53. <a-dropdown>
  54. <a-menu selectable slot="overlay" @click="onVideoListClick">
  55. <a-menu-item v-for="item in videoList" :key="item.gbId"> {{item.name}} </a-menu-item>
  56. </a-menu>
  57. <a class="ant-dropdown-link" @click="e => e.preventDefault()">
  58. {{curVideo&&curVideo.name}}
  59. <a-icon type="down" />
  60. </a>
  61. </a-dropdown>
  62. </div>
  63. </div>
  64. <!-- 预置位 -->
  65. <!-- <div>
  66. <div>预置位:</div>
  67. <div>
  68. <a-dropdown>
  69. <a-menu slot="overlay">
  70. <a-menu-item key="1"> 预置位1 </a-menu-item>
  71. <a-menu-item key="2"> 预置位2 </a-menu-item>
  72. <a-menu-item key="3"> 预置位3 </a-menu-item>
  73. </a-menu>
  74. <a-button block> 请选择 <a-icon type="down" /> </a-button>
  75. </a-dropdown>
  76. </div>
  77. </div> -->
  78. </div>
  79. <div class="checkWork-head-row">
  80. <div>
  81. <div>进度:{{kptj.finishedTargetCount}}/{{kptj.totalTargetCount}}</div>
  82. <div>耗时:{{kptj.haoshi}}</div>
  83. <!-- <div>得分:{{kptj.getScore}}/{{kptj.totalScore}}</div> -->
  84. </div>
  85. <div>
  86. <div>不适用:{{kptj.notWorkTargetCount}}</div>
  87. <div>不合格:{{kptj.notPassTargetCount}}</div>
  88. <div>合格:{{kptj.passTargetCount}}</div>
  89. </div>
  90. </div>
  91. </div>
  92. <!-- 打分 -->
  93. <div class="checkWork-body">
  94. <div class="checkWork-body-tabs">
  95. <div class="tabs-items" :class="activeIndex==index?'active':''" v-for="(item,index) in kpItem" @click="getKpItemZb(index)"
  96. :key="item.id">
  97. <div v-if="isDelItem&&kpItem.length>1">
  98. <a-icon @click.stop="confirmDelKpx(item.id)" class="aicon" type="close" />
  99. </div>
  100. <div>{{item.assessItemName}}</div>
  101. <div>{{item.finishedTargetCount}}/{{item.totalTargetCount}}</div>
  102. </div>
  103. <div class="tabs-items" v-if="kpItem.length>1">
  104. <div class="edit" v-if="!isDelItem" @click="isDelItem=true">删除</div>
  105. <div class="edit" @click="isDelItem=false" v-else>取消删除</div>
  106. </div>
  107. <div style="text-align: center;padding-top: 50px;" v-if='kpItem.length==0'>
  108. <div>暂无指标项目</div>
  109. </div>
  110. </div>
  111. <div class="checkWork-body-tabCons">
  112. <div class="tabCons-items" v-for="(zb,zbIndex) in zbItem" :key="zb.id">
  113. <div>
  114. <div><b>{{zb.assessTargetName}}</b></div>
  115. <!-- 点击打开拍照 -->
  116. <div @click="openCamera(zbIndex)">
  117. <a-icon type="camera" theme="twoTone" style="font-size: 30px;" />
  118. </div>
  119. </div>
  120. <!-- 拍照图片 -->
  121. <div class="photos">
  122. <div v-for="(photo,pindex) in zb.taskTargetPhotoList" :key="photo.id">
  123. <a-avatar @click="previewImg(photo.photoPath)" :size="60" shape="square" :src="photo.photoPath+'?x-oss-process=image/resize,m_pad,h_60,w_60,color_ffffff'" />
  124. </div>
  125. </div>
  126. <!-- 评论 -->
  127. <div class="remarks" v-if="zb.comments">
  128. 评论:{{zb.comments}}
  129. </div>
  130. <!-- 评分 -->
  131. <div>
  132. <div>
  133. <!-- 分值:{{zb.getScore}} <a-icon @click="openEditFs" type="edit" style="font-size: 20px;margin-left: 10px;"/> -->
  134. </div>
  135. <div>
  136. <!-- 不适用 -->
  137. <a-icon @click="selZbResult(0,zb)" :theme="zb.result=='NOT_WORK'?'filled':''" type="minus-circle" :class="zb.result=='NOT_WORK'?'choose-bsy':''" />
  138. </div>
  139. <div>
  140. <!-- 不合格 -->
  141. <a-icon @click="selZbResult(1,zb)" :theme="zb.result=='NOT_PASS'?'filled':''" type="close-circle" :class="zb.result=='NOT_PASS'?'choose-bhg':''" />
  142. </div>
  143. <div>
  144. <!-- 合格 -->
  145. <a-icon @click="selZbResult(2,zb)" :theme="zb.result=='PASS'?'filled':''" type="check-circle" :class="zb.result=='PASS'?'choose-hg':''" />
  146. </div>
  147. </div>
  148. </div>
  149. <div v-if="!zbItem||zbItem.length==0" style="text-align: center;padding-top: 50px;">
  150. 暂无指标
  151. </div>
  152. </div>
  153. </div>
  154. <!-- 提交按钮-->
  155. <div class="checkWork-button" v-if="kptj&&kptj.finishedTargetCount==kptj.totalTargetCount&&kptj.totalTargetCount!=0">
  156. <div v-if="xdType=='video'" @click="submitTask">保存本次巡店</div>
  157. <div v-if="xdType=='scene'" @click="nextStep">下一步</div>
  158. </div>
  159. <div class="checkWork-button-disabled" v-else>
  160. <div v-if="xdType=='video'">保存本次巡店</div>
  161. <div v-if="xdType=='scene'">下一步</div>
  162. </div>
  163. </div>
  164. <!-- 拍照弹框 -->
  165. <a-drawer title="快拍" placement="bottom" :closable="true" :visible="showPz" @close="onClosePz" :height="360">
  166. <div class="pzPopus">
  167. <!-- 评论 -->
  168. <div class="pz-pinglun">
  169. <div class="remarks">
  170. <a-textarea :maxlength="500" placeholder="请填写备注内容(最多500个字符)" v-model="curZbItem.comments" :rows="4" />
  171. </div>
  172. <div class="icons" @click="takePhotos(2)">
  173. <a-icon class="aicon" type="camera" />
  174. </div>
  175. </div>
  176. <!-- 图片列表 -->
  177. <div class="imglist">
  178. <div v-for="(photo,pindex) in curZbItem.taskTargetPhotoList" :key="pindex">
  179. <img @click="editImgs(photo.photoPath,activeZbIndex,pindex)" :src="photo.photoPath+'?x-oss-process=image/resize,m_pad,h_60,w_60,color_ffffff'">
  180. <a-icon @click.stop="delImgs(pindex)" class="aicon" type="close" />
  181. </div>
  182. </div>
  183. <!-- 提交 -->
  184. <div class="f-btns">
  185. <a-button size="large" @click="saveZbPlImgs" type="primary" block> 保存 </a-button>
  186. </div>
  187. </div>
  188. </a-drawer>
  189. <!-- 加载条 -->
  190. <div v-if="showLoading" class="loading">
  191. <a-spin />
  192. </div>
  193. </div>
  194. <script>
  195. // 初始化vm 实例
  196. var vm = new Vue({
  197. el: '#app',
  198. data: {
  199. xdType: 'video', // 巡店类型
  200. showVideoLoading: false, // 视频加载进度
  201. videoStatus: false, // 获取视频失败
  202. player: null, // 播放器对象
  203. videoPlayerStatus:'',// 视频播放状态
  204. videoList: [], // 播放通道
  205. curVideo: null, // 当前播放的视频
  206. showYt: false, // 显示云台控制
  207. showYtbtns: false,
  208. showPz: false, // 显示拍照弹框
  209. isDelItem: false, // 是否显示考评项删除按钮
  210. showLoading: true, // 页面加载条
  211. isEditImg: false, // 是否编辑图片
  212. PED: null, // 图片编辑对象
  213. hsID: null, // 耗时计时器id
  214. activeIndex: 0, // 当前选择的考评项
  215. activeZbIndex: 0, //当前编辑的指标index
  216. activeZbPhoto: 0, //当前编辑的指标图片index
  217. curZbItem: {
  218. comments: '',
  219. taskTargetPhotoList: []
  220. }, // 当前编辑的指标评论图片对象
  221. // 考评统计
  222. kptj: {
  223. haoshi: '0时0分'
  224. },
  225. // 考评项
  226. kpItem: [],
  227. zbItem: []
  228. },
  229. mounted() {
  230. let _this = this
  231. moment.locale('zh-cn');
  232. // 耗时计算
  233. this.hsID = setInterval(function() {
  234. _this.haoshi()
  235. }, 60000)
  236. },
  237. destroyed() {
  238. clearInterval(this.hsID)
  239. },
  240. methods: {
  241. // 重置页面
  242. resetPage() {
  243. this.activeIndex = 0
  244. this.activeZbIndex = 0
  245. this.activeZbPhoto = 0
  246. this.curZbItem = {
  247. comments: '',
  248. taskTargetPhotoList: []
  249. }
  250. this.isDelItem = false
  251. this.showPz = false
  252. },
  253. // 设置巡店类型
  254. setTyps(type) {
  255. console.log(type)
  256. this.xdType = type
  257. // 设置标题
  258. document.title = type == 'video' ? '视频巡店' : '现场巡店'
  259. },
  260. // 设置视频列表
  261. setVideoList(data) {
  262. this.videoList = JSON.parse(data)
  263. this.curVideo = this.videoList[0]
  264. this.getVideoUrl()
  265. },
  266. // 获取任务详情
  267. getTaskDetail(data) {
  268. this.kptj = JSON.parse(data)
  269. this.haoshi()
  270. },
  271. // 获取任务考评项
  272. getTaskItem(data) {
  273. this.kpItem=JSON.parse(data)
  274. this.zbItem = this.kpItem.length ? this.kpItem[this.activeIndex].taskTargetVOList : []
  275. this.showLoading = false
  276. },
  277. // 选择机位
  278. onVideoListClick({key}) {
  279. this.videoPlayerStatus = ''
  280. let v = this.videoList.find(item => item.gbId == key)
  281. if (v) {
  282. this.curVideo = v
  283. this.getVideoUrl()
  284. }
  285. },
  286. // 获取当前设备流地址
  287. getVideoUrl(){
  288. this.sendMsg('getVideoUrl', JSON.stringify(this.curVideo))
  289. },
  290. // 获取视频地址成功
  291. getVideoUrlSuccess(url){
  292. // 重置播放器
  293. this.showYt = false
  294. this.showYtbtns = false
  295. this.showVideoLoading = true
  296. if(this.player){
  297. // this.player.dispose()
  298. // document.getElementById('player-con').innerHTML = ""
  299. this.player.loadByUrl(url)
  300. }else{
  301. this.videoInit(url)
  302. }
  303. },
  304. // 获取视频地址失败
  305. getVideoUrlError(err){
  306. this.videoStatus = true
  307. },
  308. // 初始化播放器
  309. videoInit(videoSrc) {
  310. const _this = this
  311. _this.videoStatus = false
  312. // 初始化播放器
  313. _this.player = new Aliplayer({
  314. 'id': 'player-con',
  315. 'source': videoSrc,
  316. 'width': '100%',
  317. 'height': '240px',
  318. 'autoplay': true,
  319. 'isLive': true,
  320. 'rePlay': true,
  321. 'playsinline': false,
  322. 'showBuffer': true,
  323. 'preload': false,
  324. 'language': 'zh-cn',
  325. 'useH5Prism': true,
  326. 'extraInfo': {
  327. 'crossOrigin': 'anonymous'
  328. },
  329. 'skinLayout': [
  330. {
  331. 'name': 'bigPlayButton',
  332. 'align': 'cc'
  333. },
  334. {
  335. 'name': 'errorDisplay',
  336. 'align': 'tlabs',
  337. 'x': 0,
  338. 'y': 0
  339. },
  340. {
  341. 'name': 'infoDisplay',
  342. 'align': 'cc'
  343. },
  344. {
  345. 'name': 'controlBar',
  346. 'align': 'blabs',
  347. 'x': 0,
  348. 'y': 0,
  349. 'children': [{
  350. 'name': 'fullScreenButton',
  351. 'align': 'tr',
  352. 'x': 15,
  353. 'y': 10
  354. },
  355. {
  356. 'name': 'volume',
  357. 'align': 'tr',
  358. 'x': 15,
  359. 'y': 8
  360. },
  361. {
  362. 'name': 'liveDisplay',
  363. 'align': 'tl',
  364. 'x': 15,
  365. 'y': 2
  366. }
  367. ]
  368. }
  369. ]
  370. }, function(player) {
  371. _this.sendMsg('message', 'The player is created')
  372. })
  373. // 控制栏
  374. _this.player.on('playing', function() {
  375. console.log('playing')
  376. // _this.showYt = true
  377. _this.videoPlayerStatus = 'playing'
  378. _this.showVideoLoading = false
  379. })
  380. _this.player.on('error', function(e) {
  381. console.log(JSON.stringify(e), 'error')
  382. _this.player.loadByUrl(videoSrc)
  383. })
  384. // 全屏时设置横屏
  385. _this.player.on('requestFullScreen', function(e) {
  386. plus.screen.lockOrientation('landscape-primary')
  387. })
  388. _this.player.on('cancelFullScreen', function(e) {
  389. plus.screen.lockOrientation('portrait-primary')
  390. })
  391. },
  392. // 耗时计算
  393. haoshi() {
  394. let s = this.kptj.startTime
  395. let times = moment().diff(s, 'hours') + '时' + moment().diff(s, 'minutes') % 60 + '分'
  396. this.$set(this.kptj,'haoshi',times)
  397. },
  398. // 发送消息给app 页面
  399. sendMsg(action, msg) {
  400. uni.postMessage({
  401. data: {
  402. action: action,
  403. msg: msg
  404. }
  405. })
  406. },
  407. // 显示云台控制按钮
  408. openYt() {
  409. this.showYtbtns = !this.showYtbtns
  410. },
  411. // 控制云台
  412. kzYt(index) {
  413. const cmd = ['left', 'right', 'up', 'down']
  414. this.sendMsg('kzyt', '控制云台' + cmd[index - 1])
  415. },
  416. // 打开抓拍照片弹框
  417. openCamera(index) {
  418. // 显示弹框
  419. this.showPz = true
  420. this.activeZbIndex = index
  421. this.sendMsg('getWinStatus', JSON.stringify({
  422. key: 'showPz',
  423. val: true
  424. }))
  425. // 当前查看的指标对象
  426. let obj = this.zbItem[this.activeZbIndex]
  427. this.curZbItem = Object.assign({
  428. comments: '',
  429. taskTargetPhotoList: []
  430. },JSON.parse(JSON.stringify(obj)))
  431. // 抓拍
  432. this.takePhotos(1)
  433. },
  434. // 抓拍
  435. takePhotos(type){
  436. if(!this.curZbItem.taskTargetPhotoList||this.curZbItem.taskTargetPhotoList.length<5){
  437. this.sendMsg('takePhotos',JSON.stringify({
  438. streamId: this.curVideo&&this.curVideo.streamId,
  439. videoPlayerStatus: this.videoPlayerStatus,
  440. type: type
  441. }))
  442. }else{
  443. this.sendMsg('toast','最多抓拍5张图片')
  444. }
  445. },
  446. // 拍照成功后,返回图片地址
  447. takePhotoSuccess(url){
  448. let obj = {
  449. photoPath: url
  450. }
  451. if(!this.curZbItem.hasOwnProperty('taskTargetPhotoList')){
  452. this.curZbItem.taskTargetPhotoList = [obj]
  453. }else{
  454. this.curZbItem.taskTargetPhotoList.push(obj)
  455. this.curZbItem.taskTargetPhotoList.splice()
  456. }
  457. },
  458. // 关闭抓拍弹框
  459. onClosePz() {
  460. this.showPz = false
  461. this.sendMsg('getWinStatus', JSON.stringify({
  462. key: 'showPz',
  463. val: false
  464. }))
  465. },
  466. // 删除图片
  467. delImgs(index) {
  468. this.sendMsg('delImgs', index)
  469. },
  470. delImgsSuccess(index) {
  471. console.log(index,'delImgsSuccess')
  472. this.curZbItem.taskTargetPhotoList.splice(index, 1)
  473. },
  474. // 预览编辑图片
  475. editImgs(url, index, pindex) {
  476. let _this = this
  477. _this.activeZbIndex = index
  478. _this.activeZbPhoto = pindex
  479. _this.sendMsg('getWinStatus', JSON.stringify({
  480. key: 'isEditImg',
  481. val: true
  482. }))
  483. console.log('editImgs',url)
  484. this.PED = new window.PED.imageInfo(
  485. url,
  486. function(data) {
  487. console.log('saveEditImg')
  488. // 保存图片编辑
  489. _this.sendMsg('saveEditImg', data)
  490. },
  491. function() {
  492. _this.sendMsg('getWinStatus', JSON.stringify({
  493. key: 'isEditImg',
  494. val: false
  495. }))
  496. })
  497. },
  498. // 关闭图片编辑
  499. closeImgsEdit() {
  500. this.PED.hidePED()
  501. this.sendMsg('getWinStatus', JSON.stringify({
  502. key: 'isEditImg',
  503. val: false
  504. }))
  505. },
  506. // 更新编辑后的图片
  507. updateItemImg(path) {
  508. let photoList = this.curZbItem.taskTargetPhotoList
  509. photoList[this.activeZbPhoto].photoPath = path
  510. },
  511. // 查看大图
  512. previewImg(path){
  513. this.sendMsg('previewImg', path)
  514. },
  515. // 更新已完成考评数
  516. updateKpFinish() {
  517. let kpItem = this.kpItem[this.activeIndex]
  518. let a = 0
  519. this.zbItem.map(item => {
  520. if (item.result) {
  521. a++
  522. }
  523. })
  524. kpItem.finishedTargetCount = a
  525. // 更新总进度
  526. this.sendMsg('updateKpTj', '')
  527. },
  528. // 删除考评项
  529. confirmDelKpx(id) {
  530. this.sendMsg('delKpItem', id)
  531. },
  532. // 删除考评项成功
  533. delKpItemSuccess(id) {
  534. let index = this.kpItem.findIndex(item => item.id == id)
  535. if (index >= 0) {
  536. this.kpItem.splice(index, 1)
  537. this.getKpItemZb(0)
  538. // 更新总进度
  539. this.sendMsg('updateKpTj', '')
  540. }
  541. if(this.kpItem.length==1){
  542. this.sendMsg('toast','至少保留一个考评项目')
  543. }
  544. },
  545. // 切换考评项对应的指标
  546. getKpItemZb(index) {
  547. this.activeIndex = index
  548. this.zbItem = this.kpItem[index].taskTargetVOList
  549. },
  550. // 评分,0 不适用,1 不合格,2 合格
  551. selZbResult(type, zb) {
  552. let {
  553. id,
  554. taskItemId,
  555. taskId
  556. } = zb
  557. let result = ['NOT_WORK', 'NOT_PASS', 'PASS']
  558. this.sendMsg('selZbResult', JSON.stringify({
  559. result: result[type],
  560. id: id,
  561. taskItemId: taskItemId,
  562. taskId: taskId
  563. }))
  564. },
  565. // 保存指标结果成功
  566. saveZbResultSuccess(data) {
  567. let {
  568. id,
  569. result
  570. } = JSON.parse(data)
  571. console.log(id, result)
  572. let zb = this.zbItem.find(item => item.id == id)
  573. if (zb) {
  574. zb.result = result
  575. // 更新考评项已完成指标数
  576. this.updateKpFinish()
  577. }
  578. },
  579. // 保存指标评论及图片
  580. saveZbPlImgs() {
  581. this.sendMsg('saveZbPlImgs', JSON.stringify(this.curZbItem))
  582. },
  583. // 更新指标评论及图片成功
  584. saveZbPlImgsSuccess() {
  585. this.zbItem.splice(this.activeZbIndex, 1, this.curZbItem)
  586. this.onClosePz()
  587. },
  588. // 提交此次任务
  589. submitTask() {
  590. this.sendMsg('submitTask', '')
  591. },
  592. // 现场巡店下一步签字
  593. nextStep() {
  594. this.sendMsg('nextStep', '')
  595. }
  596. }
  597. })
  598. </script>
  599. </body>
  600. </html>