video.html 18 KB

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