ddvideo.html 15 KB

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