ddvideo.html 14 KB

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