video.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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.id"> {{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 class="checkWork-head-row">
  73. <div>
  74. <div>进度:{{kptj.finishedTargetCount}}/{{kptj.totalTargetCount}}</div>
  75. <div>耗时:{{kptj.haoshi}}</div>
  76. <!-- <div>得分:{{kptj.getScore}}/{{kptj.totalScore}}</div> -->
  77. </div>
  78. <div>
  79. <div>不适用:{{kptj.notWorkTargetCount}}</div>
  80. <div>不合格:{{kptj.notPassTargetCount}}</div>
  81. <div>合格:{{kptj.passTargetCount}}</div>
  82. </div>
  83. </div>
  84. </div>
  85. <!-- 打分 -->
  86. <div class="checkWork-body">
  87. <div class="checkWork-body-tabs">
  88. <div class="tabs-items" :class="activeIndex==index?'active':''" v-for="(item,index) in kpItem" @click="getKpItemZb(index)"
  89. :key="item.id">
  90. <div v-if="isDelItem">
  91. <a-icon @click.stop="confirmDelKpx(item.id)" class="aicon" type="close" />
  92. </div>
  93. <div>{{item.assessItemName}}</div>
  94. <div>{{item.finishedTargetCount}}/{{item.totalTargetCount}}</div>
  95. </div>
  96. <div class="tabs-items" v-if="kpItem.length>1">
  97. <div class="edit" v-if="!isDelItem" @click="isDelItem=true">编辑</div>
  98. <div class="edit" @click="isDelItem=false" v-else>取消编辑</div>
  99. </div>
  100. </div>
  101. <div class="checkWork-body-tabCons">
  102. <div class="tabCons-items" v-for="(zb,zbIndex) in zbItem" :key="zb.id">
  103. <div>
  104. <div><b>{{zb.assessTargetName}}</b></div>
  105. <!-- 点击打开拍照 -->
  106. <div @click="openCamera(zbIndex)">
  107. <a-icon type="camera" style="font-size: 30px;" />
  108. </div>
  109. </div>
  110. <!-- 拍照图片 -->
  111. <div class="photos">
  112. <div v-for="(photo,pindex) in zb.taskTargetPhotoVOList" :key="photo.id">
  113. <a-avatar :size="40" shape="square" :src="photo.photoPath" />
  114. </div>
  115. </div>
  116. <!-- 评论 -->
  117. <div class="remarks">
  118. 评论:{{zb.comments}}
  119. </div>
  120. <!-- 评分 -->
  121. <div>
  122. <div>
  123. <!-- 分值:{{zb.getScore}} <a-icon @click="openEditFs" type="edit" style="font-size: 20px;margin-left: 10px;"/> -->
  124. </div>
  125. <div>
  126. <!-- 不适用 -->
  127. <a-icon @click="selZbResult(0,zb)" type="minus-circle" :class="zb.result=='NOT_WORK'?'choose-bsy':''" />
  128. </div>
  129. <div>
  130. <!-- 不合格 -->
  131. <a-icon @click="selZbResult(1,zb)" type="close-circle" :class="zb.result=='NOT_PASS'?'choose-bhg':''" />
  132. </div>
  133. <div>
  134. <!-- 合格 -->
  135. <a-icon @click="selZbResult(2,zb)" type="check-circle" :class="zb.result=='PASS'?'choose-hg':''" />
  136. </div>
  137. </div>
  138. </div>
  139. <div v-if="!zbItem" style="text-align: center;padding-top: 50px;">
  140. 暂无数据
  141. </div>
  142. </div>
  143. </div>
  144. <!-- 提交按钮-->
  145. <div class="checkWork-button" v-if="kptj&&kptj.finishedTargetCount==kptj.totalTargetCount">
  146. <div v-if="xdType=='video'" @click="submitTask">提交本次巡店</div>
  147. <div v-if="xdType=='scene'" @click="nextStep">下一步</div>
  148. </div>
  149. </div>
  150. <!-- 拍照弹框 -->
  151. <a-drawer title="快拍" placement="bottom" :closable="true" :visible="showPz" @close="onClosePz" :height="360">
  152. <div class="pzPopus">
  153. <!-- 评论 -->
  154. <div class="pz-pinglun">
  155. <div class="remarks">
  156. <a-textarea placeholder="请填写备注内容(选填)" v-model="curZbItem.comments" :rows="4" />
  157. </div>
  158. <div class="icons">
  159. <a-icon class="aicon" type="camera" />
  160. </div>
  161. </div>
  162. <!-- 图片列表 -->
  163. <div class="imglist">
  164. <div v-for="(photo,pindex) in curZbItem.taskTargetPhotoVOList" :key="photo.id">
  165. <img @click="editImgs(photo.photoPath,activeZbIndex,pindex)" :src="photo.photoPath">
  166. <a-icon @click.stop="delImgs(pindex)" class="aicon" type="close" />
  167. </div>
  168. </div>
  169. <!-- 提交 -->
  170. <div class="f-btns">
  171. <a-button size="large" @click="saveZbPlImgs" type="primary" block> 提交 </a-button>
  172. </div>
  173. </div>
  174. </a-drawer>
  175. <!-- 加载条 -->
  176. <div v-if="showLoading" class="loading">
  177. <a-spin />
  178. </div>
  179. </div>
  180. <script>
  181. // 初始化vm 实例
  182. var vm = new Vue({
  183. el: '#app',
  184. data: {
  185. xdType: 'video', // 巡店类型
  186. player: null, // 播放器对象
  187. videoList: [], // 播放通道
  188. curVideo: null, // 当前播放的视频
  189. showYt: false, // 显示云台控制
  190. showYtbtns: false,
  191. showPz: false, // 显示拍照弹框
  192. isDelItem: false, // 是否显示考评项删除按钮
  193. showLoading: true, // 页面加载条
  194. isEditImg: false, // 是否编辑图片
  195. PED: null, // 图片编辑对象
  196. hsID: null, // 耗时计时器id
  197. activeIndex: 0, // 当前选择的考评项
  198. activeZbIndex: 0, //当前编辑的指标index
  199. activeZbPhoto: 0, //当前编辑的指标图片index
  200. curZbItem: {
  201. comments: '',
  202. taskTargetPhotoVOList: []
  203. }, // 当前编辑的指标评论图片对象
  204. // 考评统计
  205. kptj: {
  206. haoshi: '0时0分'
  207. },
  208. // 考评项
  209. kpItem: [],
  210. zbItem: []
  211. },
  212. mounted() {
  213. let _this = this
  214. moment.locale('zh-cn');
  215. // 耗时计算
  216. this.hsID = setInterval(function() {
  217. _this.haoshi()
  218. }, 60000)
  219. },
  220. destroyed() {
  221. clearInterval(this.hsID)
  222. },
  223. methods: {
  224. // 重置页面
  225. resetPage() {
  226. this.activeIndex = 0
  227. this.activeZbIndex = 0
  228. this.activeZbPhoto = 0
  229. this.curZbItem = {
  230. comments: '',
  231. taskTargetPhotoVOList: []
  232. }
  233. this.isDelItem = false
  234. this.showPz = false
  235. },
  236. // 设置巡店类型
  237. setTyps(type) {
  238. console.log(type)
  239. this.xdType = type
  240. // 设置标题
  241. document.title = type == 'video' ? '远程巡店' : '现场巡店'
  242. },
  243. // 设置视频列表
  244. setVideoList(data) {
  245. this.videoList = JSON.parse(data)
  246. this.curVideo = this.videoList[0]
  247. this.videoInit()
  248. },
  249. // 获取任务详情
  250. getTaskDetail(data) {
  251. this.kptj = JSON.parse(data)
  252. this.haoshi()
  253. },
  254. // 获取任务考评项
  255. getTaskItem(data) {
  256. this.kpItem = JSON.parse(data)
  257. this.zbItem = this.kpItem.length ? this.kpItem[this.activeIndex].taskTargetVOList : [],
  258. this.showLoading = false
  259. },
  260. // 选择机位
  261. onVideoListClick({
  262. key
  263. }) {
  264. let v = this.videoList.find(item => item.id == key)
  265. if (v) {
  266. this.curVideo = v
  267. // 重置播放器
  268. this.showYt = false
  269. this.showYtbtns = false
  270. this.player.dispose()
  271. this.videoInit()
  272. }
  273. },
  274. // 初始化播放器
  275. videoInit() {
  276. const _this = this
  277. const videoSrc = this.curVideo.videoSrc
  278. // 初始化播放器
  279. _this.player = new Aliplayer({
  280. 'id': 'player-con',
  281. 'source': videoSrc,
  282. 'width': '100%',
  283. 'height': '240px',
  284. 'autoplay': false,
  285. 'isLive': true,
  286. 'rePlay': true,
  287. 'playsinline': true,
  288. 'preload': true,
  289. 'language': 'zh-cn',
  290. 'useH5Prism': true,
  291. 'extraInfo': {
  292. 'crossOrigin': 'anonymous'
  293. },
  294. 'skinLayout': [{
  295. 'name': 'bigPlayButton',
  296. 'align': 'cc'
  297. },
  298. {
  299. 'name': 'errorDisplay',
  300. 'align': 'tlabs',
  301. 'x': 0,
  302. 'y': 0
  303. },
  304. {
  305. 'name': 'infoDisplay'
  306. },
  307. {
  308. 'name': 'controlBar',
  309. 'align': 'blabs',
  310. 'x': 0,
  311. 'y': 0,
  312. 'children': [{
  313. 'name': 'fullScreenButton',
  314. 'align': 'tr',
  315. 'x': 15,
  316. 'y': 10
  317. },
  318. {
  319. 'name': 'volume',
  320. 'align': 'tr',
  321. 'x': 15,
  322. 'y': 8
  323. },
  324. {
  325. 'name': 'liveDisplay',
  326. 'align': 'tl',
  327. 'x': 15,
  328. 'y': 2
  329. }
  330. ]
  331. }
  332. ]
  333. }, function(player) {
  334. _this.sendMsg('message', 'The player is created')
  335. })
  336. // 控制栏
  337. _this.player.on('playing', function() {
  338. _this.showYt = true
  339. })
  340. _this.player.on('error', function(e) {
  341. console.log(JSON.stringify(e), 'error')
  342. })
  343. },
  344. // 耗时计算
  345. haoshi() {
  346. let s = this.kptj.startTime
  347. this.kptj.haoshi = moment().diff(s, 'hours') + '时' + moment().diff(s, 'minutes') % 60 + '分'
  348. },
  349. // 发送消息给app 页面
  350. sendMsg(action, msg) {
  351. uni.postMessage({
  352. data: {
  353. action: action,
  354. msg: msg
  355. }
  356. })
  357. },
  358. // 显示云台控制按钮
  359. openYt() {
  360. this.showYtbtns = !this.showYtbtns
  361. },
  362. // 控制云台
  363. kzYt(index) {
  364. const cmd = ['left', 'right', 'up', 'down']
  365. this.sendMsg('kzyt', '控制云台' + cmd[index - 1])
  366. },
  367. // 打开抓拍照片弹框
  368. openCamera(index) {
  369. this.showPz = true
  370. this.activeZbIndex = index
  371. this.sendMsg('getWinStatus', JSON.stringify({
  372. key: 'showPz',
  373. val: true
  374. }))
  375. // 当前查看的指标对象
  376. let obj = this.zbItem[this.activeZbIndex]
  377. this.curZbItem = JSON.parse(JSON.stringify(obj))
  378. },
  379. // 关闭抓拍弹框
  380. onClosePz() {
  381. this.showPz = false
  382. this.sendMsg('getWinStatus', JSON.stringify({
  383. key: 'showPz',
  384. val: false
  385. }))
  386. },
  387. // 删除图片
  388. delImgs(index) {
  389. this.sendMsg('delImgs', index)
  390. },
  391. delImgsSuccess(index) {
  392. this.curZbItem.taskTargetPhotoVOList.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.taskTargetPhotoVOList
  427. photoList[this.activeZbPhoto].photoPath = path
  428. },
  429. // 更新已完成考评数
  430. updateKpFinish() {
  431. let kpItem = this.kpItem[this.activeIndex]
  432. let a = 0
  433. this.zbItem.map(item => {
  434. if (item.result) {
  435. a++
  436. }
  437. })
  438. kpItem.finishedTargetCount = a
  439. // 更新总进度
  440. this.sendMsg('updateKpTj', '')
  441. },
  442. // 删除考评项
  443. confirmDelKpx(id) {
  444. this.sendMsg('delKpItem', id)
  445. },
  446. // 删除考评项成功
  447. delKpItemSuccess(id) {
  448. let index = this.kpItem.findIndex(item => item.id == id)
  449. if (index >= 0) {
  450. this.kpItem.splice(index, 1)
  451. this.getKpItemZb(0)
  452. // 更新总进度
  453. this.sendMsg('updateKpTj', '')
  454. }
  455. },
  456. // 切换考评项对应的指标
  457. getKpItemZb(index) {
  458. this.activeIndex = index
  459. this.zbItem = this.kpItem[index].taskTargetVOList
  460. },
  461. // 评分,0 不适用,1 不合格,2 合格
  462. selZbResult(type, zb) {
  463. let {
  464. id,
  465. taskItemId,
  466. taskId
  467. } = zb
  468. let result = ['NOT_WORK', 'NOT_PASS', 'PASS']
  469. this.sendMsg('selZbResult', JSON.stringify({
  470. result: result[type],
  471. id: id,
  472. taskItemId: taskItemId,
  473. taskId: taskId
  474. }))
  475. },
  476. // 保存指标结果成功
  477. saveZbResultSuccess(data) {
  478. let {
  479. id,
  480. result
  481. } = JSON.parse(data)
  482. console.log(id, result)
  483. let zb = this.zbItem.find(item => item.id == id)
  484. if (zb) {
  485. zb.result = result
  486. // 更新考评项已完成指标数
  487. this.updateKpFinish()
  488. }
  489. },
  490. // 保存指标评论及图片
  491. saveZbPlImgs() {
  492. this.sendMsg('saveZbPlImgs', JSON.stringify(this.curZbItem))
  493. },
  494. // 更新指标评论及图片成功
  495. saveZbPlImgsSuccess() {
  496. this.zbItem.splice(this.activeZbIndex, 1, this.curZbItem)
  497. this.onClosePz()
  498. },
  499. // 提交此次任务
  500. submitTask() {
  501. this.sendMsg('submitTask', '')
  502. },
  503. // 现场巡店下一步签字
  504. nextStep() {
  505. this.sendMsg('nextStep', '')
  506. }
  507. }
  508. })
  509. </script>
  510. </body>
  511. </html>