ddvideo.html 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448
  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+'?x-oss-process=image/resize,m_pad,h_40,w_40,color_000000'" />
  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+'?x-oss-process=image/resize,m_pad,h_50,w_50,color_000000'">
  139. <a-icon @click.stop="delImgs(pindex)" class="aicon" type="close" />
  140. </div>
  141. </div>
  142. <!-- 提交 -->
  143. <div class="f-btns">
  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. methods: {
  182. // 重置页面
  183. resetPage() {
  184. this.activeZbIndex = 0
  185. this.activeZbPhoto = 0
  186. this.curZbItem = {
  187. comments: '',
  188. taskTargetPhotoList: []
  189. }
  190. this.showPz = false
  191. },
  192. // 设置巡店类型及标题
  193. setTyps(type, storeName) {
  194. console.log(type)
  195. this.xdType = type
  196. // 设置标题
  197. document.title = storeName
  198. },
  199. // 设置视频列表
  200. setVideoList(data) {
  201. this.videoList = JSON.parse(data)
  202. this.curVideo = this.videoList[0]
  203. this.getVideoUrl()
  204. },
  205. // 设置任务项列表
  206. getTaskDetail(data) {
  207. this.zbItem = JSON.parse(data)
  208. this.showLoading = false
  209. },
  210. // 选择机位
  211. onVideoListClick({
  212. key
  213. }) {
  214. this.videoPlayerStatus = ''
  215. let v = this.videoList.find(item => item.gbId == key)
  216. if (v) {
  217. this.curVideo = v
  218. this.getVideoUrl()
  219. }
  220. },
  221. // 获取当前设备流地址
  222. getVideoUrl() {
  223. this.sendMsg('getVideoUrl', JSON.stringify(this.curVideo))
  224. },
  225. // 获取视频地址成功
  226. getVideoUrlSuccess(url) {
  227. // 重置播放器
  228. this.showYt = false
  229. this.showYtbtns = false
  230. if (this.player) {
  231. this.player.dispose()
  232. }
  233. this.videoInit(url)
  234. },
  235. // 初始化播放器
  236. videoInit(videoSrc) {
  237. const _this = this
  238. // 初始化播放器
  239. _this.player = new Aliplayer({
  240. 'id': 'player-con',
  241. 'source': videoSrc,
  242. 'width': '100%',
  243. 'height': '240px',
  244. 'autoplay': false,
  245. 'isLive': true,
  246. 'rePlay': true,
  247. 'playsinline': true,
  248. 'preload': true,
  249. 'language': 'zh-cn',
  250. 'useH5Prism': true,
  251. 'extraInfo': {
  252. 'crossOrigin': 'anonymous'
  253. },
  254. 'skinLayout': [{
  255. 'name': 'bigPlayButton',
  256. 'align': 'cc'
  257. },
  258. {
  259. 'name': 'errorDisplay',
  260. 'align': 'tlabs',
  261. 'x': 0,
  262. 'y': 0
  263. },
  264. {
  265. 'name': 'infoDisplay'
  266. },
  267. {
  268. 'name': 'controlBar',
  269. 'align': 'blabs',
  270. 'x': 0,
  271. 'y': 0,
  272. 'children': [{
  273. 'name': 'fullScreenButton',
  274. 'align': 'tr',
  275. 'x': 15,
  276. 'y': 10
  277. },
  278. {
  279. 'name': 'volume',
  280. 'align': 'tr',
  281. 'x': 15,
  282. 'y': 8
  283. },
  284. {
  285. 'name': 'liveDisplay',
  286. 'align': 'tl',
  287. 'x': 15,
  288. 'y': 2
  289. }
  290. ]
  291. }
  292. ]
  293. }, function(player) {
  294. _this.sendMsg('message', 'The player is created')
  295. })
  296. // 控制栏
  297. _this.player.on('playing', function() {
  298. // _this.showYt = true
  299. _this.videoPlayerStatus = 'playing'
  300. })
  301. _this.player.on('error', function(e) {
  302. console.log(JSON.stringify(e), 'error')
  303. })
  304. },
  305. // 发送消息给app 页面
  306. sendMsg(action, msg) {
  307. uni.postMessage({
  308. data: {
  309. action: action,
  310. msg: msg
  311. }
  312. })
  313. },
  314. // 显示云台控制按钮
  315. openYt() {
  316. this.showYtbtns = !this.showYtbtns
  317. },
  318. // 控制云台
  319. kzYt(index) {
  320. const cmd = ['left', 'right', 'up', 'down']
  321. this.sendMsg('kzyt', '控制云台' + cmd[index - 1])
  322. },
  323. // 打开抓拍照片弹框
  324. openCamera(index) {
  325. // 显示弹框
  326. this.showPz = true
  327. this.activeZbIndex = index
  328. this.sendMsg('getWinStatus', JSON.stringify({
  329. key: 'showPz',
  330. val: true
  331. }))
  332. // 当前查看的指标对象
  333. let obj = this.zbItem[this.activeZbIndex]
  334. this.curZbItem = Object.assign({
  335. comments: '',
  336. taskTargetPhotoList: []
  337. }, JSON.parse(JSON.stringify(obj)))
  338. // 抓拍
  339. this.takePhotos(1)
  340. },
  341. // 抓拍
  342. takePhotos(type) {
  343. if (!this.curZbItem.taskTargetPhotoList || this.curZbItem.taskTargetPhotoList.length < 6) {
  344. let pd = JSON.stringify({
  345. streamId: this.curVideo && this.curVideo.streamId,
  346. videoPlayerStatus: this.videoPlayerStatus,
  347. type: type
  348. });
  349. this.sendMsg('takePhotos', this.xdType == 'video' ? pd : '')
  350. } else {
  351. this.sendMsg('toast', '最多抓拍6张图片')
  352. }
  353. },
  354. // 拍照成功后,返回图片地址
  355. takePhotoSuccess(url) {
  356. let obj = {
  357. photoPath: url
  358. }
  359. if (!this.curZbItem.hasOwnProperty('taskTargetPhotoList')) {
  360. this.curZbItem.taskTargetPhotoList = [obj]
  361. } else {
  362. this.curZbItem.taskTargetPhotoList.push(obj)
  363. this.curZbItem.taskTargetPhotoList.splice()
  364. }
  365. },
  366. // 关闭抓拍弹框
  367. onClosePz() {
  368. this.showPz = false
  369. this.sendMsg('getWinStatus', JSON.stringify({
  370. key: 'showPz',
  371. val: false
  372. }))
  373. },
  374. // 删除图片
  375. delImgs(index) {
  376. this.sendMsg('delImgs', index)
  377. },
  378. delImgsSuccess(index) {
  379. console.log(index, 'delImgsSuccess')
  380. this.curZbItem.taskTargetPhotoList.splice(index, 1)
  381. },
  382. // 预览编辑图片
  383. editImgs(url, index, pindex) {
  384. let _this = this
  385. _this.activeZbIndex = index
  386. _this.activeZbPhoto = pindex
  387. _this.sendMsg('getWinStatus', JSON.stringify({
  388. key: 'isEditImg',
  389. val: true
  390. }))
  391. this.PED = new window.PED.imageInfo(
  392. url,
  393. function(data) {
  394. // 保存图片编辑
  395. _this.sendMsg('saveEditImg', data)
  396. },
  397. function() {
  398. _this.sendMsg('getWinStatus', JSON.stringify({
  399. key: 'isEditImg',
  400. val: false
  401. }))
  402. })
  403. },
  404. // 关闭图片编辑
  405. closeImgsEdit() {
  406. this.PED.hidePED()
  407. this.sendMsg('getWinStatus', JSON.stringify({
  408. key: 'isEditImg',
  409. val: false
  410. }))
  411. },
  412. // 更新编辑后的图片
  413. updateItemImg(path) {
  414. let photoList = this.curZbItem.taskTargetPhotoList
  415. photoList[this.activeZbPhoto].photoPath = path
  416. },
  417. // 评分,0 不适用,1 不合格,2 合格
  418. selZbResult(type, zb, zbIndex) {
  419. let result = ['NOT_WORK', 'NOT_PASS', 'PASS']
  420. zb.result = result[type]
  421. this.zbItem.splice(zbIndex, 1, zb)
  422. },
  423. // 保存指标评论及图片
  424. saveZbPlImgs() {
  425. this.zbItem.splice(this.activeZbIndex, 1, this.curZbItem)
  426. this.onClosePz()
  427. },
  428. // 提交此次任务
  429. submitTask() {
  430. // 判断是否全部评分
  431. let allPf = []
  432. this.zbItem.map(item=>{
  433. if(item.result&&item.result!=''){
  434. allPf.push(true)
  435. }
  436. })
  437. if(allPf.length == this.zbItem.length){
  438. this.sendMsg('submitTask', JSON.stringify(this.zbItem))
  439. }else{
  440. this.sendMsg('toast', '请完成所有的项目')
  441. }
  442. },
  443. }
  444. })
  445. </script>
  446. </body>
  447. </html>