ddvideo.html 13 KB

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