video.html 15 KB

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