ddvideo.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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>
  73. <!-- 打分 -->
  74. <div class="checkWork-body">
  75. <div style="width: 100%;" class="checkWork-body-tabCons">
  76. <div class="tabCons-items" v-for="(zb,zbIndex) in zbItem" :key="zb.id">
  77. <div>
  78. <div><b>{{zb.assessTargetName}}</b></div>
  79. <!-- 点击打开拍照 -->
  80. <div @click="openCamera(zbIndex)">
  81. <a-icon type="camera" style="font-size: 30px;" />
  82. </div>
  83. </div>
  84. <!-- 拍照图片 -->
  85. <div class="photos">
  86. <div v-for="(photo,pindex) in zb.taskTargetPhotoList" :key="photo.id">
  87. <a-avatar :size="40" shape="square" :src="photo.photoPath" />
  88. </div>
  89. </div>
  90. <!-- 评论 -->
  91. <div class="remarks">
  92. 评论:{{zb.comments}}
  93. </div>
  94. <!-- 评分 -->
  95. <div>
  96. <div>
  97. <!-- 分值:{{zb.getScore}} <a-icon @click="openEditFs" type="edit" style="font-size: 20px;margin-left: 10px;"/> -->
  98. </div>
  99. <div>
  100. <!-- 不适用 -->
  101. <a-icon @click="selZbResult(0,zb,zbIndex)" type="minus-circle" :class="zb.result=='NOT_WORK'?'choose-bsy':''" />
  102. </div>
  103. <div>
  104. <!-- 不合格 -->
  105. <a-icon @click="selZbResult(1,zb,zbIndex)" type="close-circle" :class="zb.result=='NOT_PASS'?'choose-bhg':''" />
  106. </div>
  107. <div>
  108. <!-- 合格 -->
  109. <a-icon @click="selZbResult(2,zb,zbIndex)" type="check-circle" :class="zb.result=='PASS'?'choose-hg':''" />
  110. </div>
  111. </div>
  112. </div>
  113. <div v-if="!zbItem" style="text-align: center;padding-top: 50px;">
  114. 暂无数据
  115. </div>
  116. </div>
  117. </div>
  118. <!-- 提交按钮 -->
  119. <div class="checkWork-button">
  120. <div v-if="xdType=='video'" @click="submitTask">提交</div>
  121. </div>
  122. </div>
  123. <!-- 拍照弹框 -->
  124. <a-drawer title="快拍" placement="bottom" :closable="true" :visible="showPz" @close="onClosePz" :height="360">
  125. <div class="pzPopus">
  126. <!-- 评论 -->
  127. <div class="pz-pinglun">
  128. <div class="remarks">
  129. <a-textarea placeholder="请填写备注内容(选填)" v-model="curZbItem.comments" :rows="4" />
  130. </div>
  131. <div class="icons" @click="takePhotos(2)">
  132. <a-icon class="aicon" type="camera" />
  133. </div>
  134. </div>
  135. <!-- 图片列表 -->
  136. <div class="imglist">
  137. <div v-for="(photo,pindex) in curZbItem.taskTargetPhotoList" :key="pindex">
  138. <img @click="editImgs(photo.photoPath,activeZbIndex,pindex)" :src="photo.photoPath">
  139. <a-icon @click.stop="delImgs(pindex)" class="aicon" type="close" />
  140. </div>
  141. </div>
  142. <!-- 提交 -->
  143. <div class="f-btns" v-if="allPf.length==zbItem.length">
  144. <a-button size="large" @click="saveZbPlImgs" type="primary" block> 提交 </a-button>
  145. </div>
  146. </div>
  147. </a-drawer>
  148. <!-- 加载条 -->
  149. <div v-if="showLoading" class="loading">
  150. <a-spin />
  151. </div>
  152. </div>
  153. <script>
  154. // 初始化vm 实例
  155. var vm = new Vue({
  156. el: '#app',
  157. data: {
  158. xdType: 'video', // 巡店类型
  159. player: null, // 播放器对象
  160. videoPlayerStatus: '', // 视频播放状态
  161. videoList: [], // 播放通道
  162. curVideo: null, // 当前播放的视频
  163. showYt: false, // 显示云台控制
  164. showYtbtns: false,
  165. showPz: false, // 显示拍照弹框
  166. showLoading: true, // 页面加载条
  167. isEditImg: false, // 是否编辑图片
  168. PED: null, // 图片编辑对象
  169. activeZbIndex: 0, //当前编辑的指标index
  170. activeZbPhoto: 0, //当前编辑的指标图片index
  171. curZbItem: {
  172. comments: '',
  173. taskTargetPhotoList: []
  174. }, // 当前编辑的指标评论图片对象
  175. zbItem: [], // 考评项
  176. },
  177. mounted() {
  178. let _this = this
  179. moment.locale('zh-cn');
  180. },
  181. computed: {
  182. // 判断是否全部评分
  183. finishPc() {
  184. let allPf = []
  185. this.zbItem.map(item=>{
  186. if(item.result&&item.result!=''){
  187. allPf.push(true)
  188. }
  189. })
  190. return allPf
  191. }
  192. },
  193. methods: {
  194. // 重置页面
  195. resetPage() {
  196. this.activeZbIndex = 0
  197. this.activeZbPhoto = 0
  198. this.curZbItem = {
  199. comments: '',
  200. taskTargetPhotoList: []
  201. }
  202. this.showPz = false
  203. },
  204. // 设置巡店类型及标题
  205. setTyps(type, storeName) {
  206. console.log(type)
  207. this.xdType = type
  208. // 设置标题
  209. document.title = storeName
  210. },
  211. // 设置视频列表
  212. setVideoList(data) {
  213. this.videoList = JSON.parse(data)
  214. this.curVideo = this.videoList[0]
  215. this.getVideoUrl()
  216. },
  217. // 设置任务项列表
  218. getTaskDetail(data) {
  219. this.zbItem = JSON.parse(data)
  220. this.showLoading = false
  221. },
  222. // 选择机位
  223. onVideoListClick({
  224. key
  225. }) {
  226. this.videoPlayerStatus = ''
  227. let v = this.videoList.find(item => item.gbId == key)
  228. if (v) {
  229. this.curVideo = v
  230. this.getVideoUrl()
  231. }
  232. },
  233. // 获取当前设备流地址
  234. getVideoUrl() {
  235. this.sendMsg('getVideoUrl', JSON.stringify(this.curVideo))
  236. },
  237. // 获取视频地址成功
  238. getVideoUrlSuccess(url) {
  239. // 重置播放器
  240. this.showYt = false
  241. this.showYtbtns = false
  242. if (this.player) {
  243. this.player.dispose()
  244. }
  245. this.videoInit(url)
  246. },
  247. // 初始化播放器
  248. videoInit(videoSrc) {
  249. const _this = this
  250. // 初始化播放器
  251. _this.player = new Aliplayer({
  252. 'id': 'player-con',
  253. 'source': videoSrc,
  254. 'width': '100%',
  255. 'height': '240px',
  256. 'autoplay': false,
  257. 'isLive': true,
  258. 'rePlay': true,
  259. 'playsinline': true,
  260. 'preload': true,
  261. 'language': 'zh-cn',
  262. 'useH5Prism': true,
  263. 'extraInfo': {
  264. 'crossOrigin': 'anonymous'
  265. },
  266. 'skinLayout': [{
  267. 'name': 'bigPlayButton',
  268. 'align': 'cc'
  269. },
  270. {
  271. 'name': 'errorDisplay',
  272. 'align': 'tlabs',
  273. 'x': 0,
  274. 'y': 0
  275. },
  276. {
  277. 'name': 'infoDisplay'
  278. },
  279. {
  280. 'name': 'controlBar',
  281. 'align': 'blabs',
  282. 'x': 0,
  283. 'y': 0,
  284. 'children': [{
  285. 'name': 'fullScreenButton',
  286. 'align': 'tr',
  287. 'x': 15,
  288. 'y': 10
  289. },
  290. {
  291. 'name': 'volume',
  292. 'align': 'tr',
  293. 'x': 15,
  294. 'y': 8
  295. },
  296. {
  297. 'name': 'liveDisplay',
  298. 'align': 'tl',
  299. 'x': 15,
  300. 'y': 2
  301. }
  302. ]
  303. }
  304. ]
  305. }, function(player) {
  306. _this.sendMsg('message', 'The player is created')
  307. })
  308. // 控制栏
  309. _this.player.on('playing', function() {
  310. // _this.showYt = true
  311. _this.videoPlayerStatus = 'playing'
  312. })
  313. _this.player.on('error', function(e) {
  314. console.log(JSON.stringify(e), 'error')
  315. })
  316. },
  317. // 发送消息给app 页面
  318. sendMsg(action, msg) {
  319. uni.postMessage({
  320. data: {
  321. action: action,
  322. msg: msg
  323. }
  324. })
  325. },
  326. // 显示云台控制按钮
  327. openYt() {
  328. this.showYtbtns = !this.showYtbtns
  329. },
  330. // 控制云台
  331. kzYt(index) {
  332. const cmd = ['left', 'right', 'up', 'down']
  333. this.sendMsg('kzyt', '控制云台' + cmd[index - 1])
  334. },
  335. // 打开抓拍照片弹框
  336. openCamera(index) {
  337. // 显示弹框
  338. this.showPz = true
  339. this.activeZbIndex = index
  340. this.sendMsg('getWinStatus', JSON.stringify({
  341. key: 'showPz',
  342. val: true
  343. }))
  344. // 当前查看的指标对象
  345. let obj = this.zbItem[this.activeZbIndex]
  346. this.curZbItem = Object.assign({
  347. comments: '',
  348. taskTargetPhotoList: []
  349. }, JSON.parse(JSON.stringify(obj)))
  350. // 抓拍
  351. this.takePhotos(1)
  352. },
  353. // 抓拍
  354. takePhotos(type) {
  355. if (!this.curZbItem.taskTargetPhotoList || this.curZbItem.taskTargetPhotoList.length < 6) {
  356. let pd = JSON.stringify({
  357. streamId: this.curVideo && this.curVideo.streamId,
  358. videoPlayerStatus: this.videoPlayerStatus,
  359. type: type
  360. });
  361. this.sendMsg('takePhotos', this.xdType == 'video' ? pd : '')
  362. } else {
  363. this.sendMsg('toast', '最多抓拍6张图片')
  364. }
  365. },
  366. // 拍照成功后,返回图片地址
  367. takePhotoSuccess(url) {
  368. let obj = {
  369. photoPath: url
  370. }
  371. if (!this.curZbItem.hasOwnProperty('taskTargetPhotoList')) {
  372. this.curZbItem.taskTargetPhotoList = [obj]
  373. } else {
  374. this.curZbItem.taskTargetPhotoList.push(obj)
  375. this.curZbItem.taskTargetPhotoList.splice()
  376. }
  377. },
  378. // 关闭抓拍弹框
  379. onClosePz() {
  380. this.showPz = false
  381. this.sendMsg('getWinStatus', JSON.stringify({
  382. key: 'showPz',
  383. val: false
  384. }))
  385. },
  386. // 删除图片
  387. delImgs(index) {
  388. this.sendMsg('delImgs', index)
  389. },
  390. delImgsSuccess(index) {
  391. console.log(index, 'delImgsSuccess')
  392. this.curZbItem.taskTargetPhotoList.splice(index, 1)
  393. },
  394. // 预览编辑图片
  395. editImgs(url, index, pindex) {
  396. let _this = this
  397. _this.activeZbIndex = index
  398. _this.activeZbPhoto = pindex
  399. _this.sendMsg('getWinStatus', JSON.stringify({
  400. key: 'isEditImg',
  401. val: true
  402. }))
  403. this.PED = new window.PED.imageInfo(
  404. url,
  405. function(data) {
  406. // 保存图片编辑
  407. _this.sendMsg('saveEditImg', data)
  408. },
  409. function() {
  410. _this.sendMsg('getWinStatus', JSON.stringify({
  411. key: 'isEditImg',
  412. val: false
  413. }))
  414. })
  415. },
  416. // 关闭图片编辑
  417. closeImgsEdit() {
  418. this.PED.hidePED()
  419. this.sendMsg('getWinStatus', JSON.stringify({
  420. key: 'isEditImg',
  421. val: false
  422. }))
  423. },
  424. // 更新编辑后的图片
  425. updateItemImg(path) {
  426. let photoList = this.curZbItem.taskTargetPhotoList
  427. photoList[this.activeZbPhoto].photoPath = path
  428. },
  429. // 评分,0 不适用,1 不合格,2 合格
  430. selZbResult(type, zb, zbIndex) {
  431. let result = ['NOT_WORK', 'NOT_PASS', 'PASS']
  432. zb.result = result[type]
  433. this.zbItem.splice(zbIndex, 1, zb)
  434. },
  435. // 保存指标评论及图片
  436. saveZbPlImgs() {
  437. this.zbItem.splice(this.activeZbIndex, 1, this.curZbItem)
  438. this.onClosePz()
  439. },
  440. // 提交此次任务
  441. submitTask() {
  442. this.sendMsg('submitTask', JSON.stringify(this.zbItem))
  443. },
  444. }
  445. })
  446. </script>
  447. </body>
  448. </html>