video.html 18 KB

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