123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465 |
- <template>
- <view><web-view @message="onmessage" src="/hybrid/html/video.html"></web-view></view>
- </template>
- <script>
- import { clzConfirm, saveBase64ToAliOss, saveImgToAliOss } from '@/libs/tools';
- import { taskStart, submitTask, updateTaskItem, getTaskDetail } from '@/api/task';
- import { getTaskItem, delTaskItem } from '@/api/taskItem';
- import { taskTargetSave, taskCommentsSave } from '@/api/taskTarget';
- import { photoPaiZhao, getVideoUrl } from '@/api/store';
- export default {
- data() {
- return {
- wv: null,
- isClose: false,
- isEditImg: false,
- showPz: false,
- types: 'video',
- restart: '',
- taskId: '',
- storeId: '',
- assessSchemeId: ''
- };
- },
- methods: {
-
- onmessage(event) {
- let data = event.detail.data[0];
-
- if (data.action == 'toast') {
- uni.showToast({
- icon: 'none',
- title: data.msg
- });
- }
-
- if (data.action == 'getWinStatus') {
- let d = JSON.parse(data.msg);
- this[d.key] = d.val;
- }
-
- if (data.action == 'getVideoUrl') {
- this.getStoreVideoUrl(JSON.parse(data.msg));
- }
-
- if (data.action == 'takePhotos') {
- console.log('takePhotos');
-
- if (this.types == 'video') {
- this.takePhotos(JSON.parse(data.msg));
- }
-
- if (this.types == 'scene') {
- console.log('camerPhotos');
- this.camerPhotos();
- }
- }
-
- if (data.action == 'saveEditImg') {
- this.uploadImg(data.msg);
- }
-
- if (data.action == 'delImgs') {
- this.delImgs(data.msg);
- }
-
- if (data.action == 'previewImg') {
- this.previewImg(data.msg)
- }
-
- if (data.action == 'delKpItem') {
- this.delKpItem(data.msg);
- }
-
- if (data.action == 'selZbResult') {
- this.saveZbResult(JSON.parse(data.msg));
- }
-
- if (data.action == 'saveZbPlImgs') {
- this.saveZbPlImgs(JSON.parse(data.msg));
- }
-
- if (data.action == 'updateKpTj') {
- this.getTaskDetail();
- }
-
- if (data.action == 'submitTask') {
- this.submitTask();
- }
-
- if (data.action == 'nextStep') {
- this.nextStep();
- }
- },
-
- saveZbPlImgs(data) {
- let params = {
- id: data.id,
- comments: data.comments,
- taskTargetPhotoList: []
- };
- data.taskTargetPhotoList.map(item => {
- params.taskTargetPhotoList.push({
- photoPath: item.photoPath
- });
- });
- console.log(params, 'saveZbPlImgs');
- taskCommentsSave(params).then(res => {
- console.log(res);
- if (res.status == 200) {
- this.wv.evalJS('vm.saveZbPlImgsSuccess()');
- }
- uni.showToast({
- icon: 'none',
- title: res.message
- });
- });
- },
-
- saveZbResult(data) {
- console.log(data, 'saveZbResult');
- taskTargetSave(data).then(res => {
- if (res.status == 200) {
- this.wv.evalJS("vm.saveZbResultSuccess('" + JSON.stringify(data) + "')");
- }
- uni.showToast({
- icon: 'none',
- title: res.message
- });
- });
- },
-
- previewImg(path){
- uni.previewImage({
- urls:[path]
- })
- },
-
- takePhotos(data) {
- if (data.videoPlayerStatus == 'playing') {
- uni.showLoading({
- mask: true,
- title: '正在抓拍图片...'
- });
- photoPaiZhao({ streamId: data.streamId }).then(res => {
- console.log(res);
- if (res.data) {
- this.wv.evalJS("vm.takePhotoSuccess('" + res.data.url + "')");
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message || '拍照截图失败,稍后重试'
- });
- }
- uni.hideLoading();
- });
- } else {
- uni.showToast({
- icon: 'none',
- title: '开始播放视频后才可以拍照截图'
- });
- }
- },
-
- camerPhotos() {
- const _this = this;
- uni.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['camera'],
- success: function(res) {
-
- uni.showLoading({
- title:'正在保存图片...',
- mask: true
- })
- saveImgToAliOss(res.tempFilePaths[0], function(ret) {
- _this.wv.evalJS("vm.takePhotoSuccess('" + ret.data + "')");
- uni.hideLoading()
- });
- }
- });
- },
-
- delImgs(index) {
- const _this = this;
- clzConfirm({
- title: '提示',
- content: '确定删除此图片,删除后无法恢复?',
- success: function(res) {
- if (res.confirm || res.index == 0) {
- _this.wv.evalJS('vm.delImgsSuccess(' + index + ')');
- }
- }
- });
- },
-
- delKpItem(id) {
- const _this = this;
- clzConfirm({
- title: '提示',
- content: '确定删除此考评项,删除后无法恢复?',
- success: function(res) {
- if (res.confirm || res.index == 0) {
- delTaskItem({ id: id }).then(ret => {
- if (ret.status == 200) {
- _this.wv.evalJS('vm.delKpItemSuccess(' + id + ')');
- }
- uni.showToast({
- icon: 'none',
- title: ret.message
- });
- });
- }
- }
- });
- },
-
- uploadImg(formData) {
- const _this = this;
- saveBase64ToAliOss(formData, function(res) {
-
-
- _this.wv.evalJS('vm.closeImgsEdit()');
-
- _this.wv.evalJS("vm.updateItemImg('" + res.data + "')");
- });
- },
-
- creatTask(isNew) {
-
- let parms = {
- storeId: this.storeId,
- type: this.types == 'video' ? 'VIDEO_INSPECTION' : 'SPOT_INSPECTION'
- };
-
- if (isNew) {
- parms.id = this.taskId;
- }
-
- if (this.types == 'scene') {
- let signin = this.$store.state.vuex_sceneTaskSignIn;
- parms.inspectorPositionAddr = signin.inspectorPositionAddr;
- parms.inspectorPositionPhotoPath = signin.inspectorPositionPhotoPath;
- }
- console.log(parms,'taskStart')
- taskStart(parms).then(res => {
- if (res.status == 200) {
- this.taskId = res.data.id;
-
- this.getTaskDetail();
- this.getTaskItem();
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message
- });
- }
- });
- },
-
- getTaskDetail() {
- getTaskDetail({ id: this.taskId }).then(res => {
- this.assessSchemeId = res.data.assessSchemeId;
- this.wv.evalJS("vm.getTaskDetail('" + JSON.stringify(res.data) + "')");
- });
- },
-
- getTaskItem() {
- getTaskItem({ id: this.taskId }).then(res => {
-
- let str = JSON.stringify(res.data)
- str = str.replace(/\\t|\\n|\\r|\\s/g,'')
- this.wv.evalJS("vm.getTaskItem('" + str + "')");
- });
- },
-
- updateTaskItem(row) {
- console.log(row);
-
- if(row.id == this.assessSchemeId){
- return
- }
- updateTaskItem({
- id: this.taskId,
- assessSchemeId: row.id,
- assessSchemeName: row.name
- }).then(res => {
- console.log(res, 'updateTaskItem');
- if (res.status == 200) {
-
- this.wv.evalJS('vm.resetPage()');
- this.getTaskDetail();
- this.getTaskItem();
- } else {
- uni.showToast({
- icon: 'none',
- title: res.message
- });
- }
- });
- },
-
- getVideoList() {
- let list = this.$store.state.vuex_storeVideoList;
- this.wv.evalJS("vm.setVideoList('" + JSON.stringify(list) + "')");
- },
-
- getStoreVideoUrl(item) {
- let _this = this
- getVideoUrl({ streamId: item.streamId, outProtocol: 'hls' }).then(res => {
- console.log(res);
- if (res.status == 200 && res.data) {
- this.wv.evalJS("vm.getVideoUrlSuccess('" + res.data.url + "')");
- } else {
- this.wv.evalJS("vm.getVideoUrlError('error')");
- uni.showToast({
- icon: 'none',
- title: '加载视频失败'
- });
- }
- });
- },
-
- submitTask() {
- const _this = this;
- clzConfirm({
- title: '提示',
- content: '确定提交本次巡店?',
- success: function(res) {
- console.log(res, '--------');
- if (res.confirm || res.index == 0) {
- submitTask({
- id: _this.taskId
- }).then(ret => {
- console.log(ret);
- if (ret.status == 200) {
- _this.isClose = true;
-
- uni.redirectTo({
- url: '/pages/shopTourCompleted/shopTourCompleted?taskId=' + _this.taskId
- });
- } else {
- _this.isClose = false;
- }
- uni.showToast({
- icon: 'none',
- title: ret.message
- });
- });
- }
- }
- });
- },
-
- nextStep() {
- uni.navigateTo({
- url: '/pages/shopTourOver/shopTourOver?taskId=' + this.taskId
- });
- }
- },
- onLoad(options) {
- console.log(options, 'options');
-
- this.types = options.types;
- this.taskId = options.taskId;
- this.storeId = options.storeId;
- this.restart = options.restart;
- },
- onUnload() {
- uni.$off('resetTaskKpItem');
- uni.$off('closeTour');
- },
- onReady() {
- let _this = this;
- _this.isClose = false;
-
-
- var currentWebview = this.$mp.page.$getAppWebview();
-
- setTimeout(function() {
- _this.wv = currentWebview.children()[0];
- _this.wv.evalJS("vm.setTyps('" + _this.types + "')");
-
- if (_this.types == 'video') {
- _this.getVideoList();
- }
- if (_this.restart == 1) {
-
- _this.creatTask(1);
- } else if (_this.restart == 0) {
-
-
- _this.getTaskDetail();
- _this.getTaskItem();
- } else {
-
- _this.creatTask(0);
- }
- }, 500);
-
-
- uni.$on('resetTaskKpItem', row => {
- _this.updateTaskItem(row);
- });
-
- uni.$on('closeTour', flag => {
- if (flag == 1) {
- this.isClose = true;
- uni.navigateBack();
- }
- });
- },
-
- onBackPress() {
- console.log(this.isEditImg, 'onBackPress');
- let _this = this;
- if (!_this.isClose) {
-
- if (this.isEditImg) {
-
- _this.wv.evalJS('vm.closeImgsEdit()');
- }
-
- else if (this.showPz) {
-
- _this.wv.evalJS('vm.onClosePz()');
- } else {
- clzConfirm({
- title: '提示',
- content: '巡店还未完成,确定退出吗?',
- success: function(res) {
- if (res.confirm || res.index == 0) {
- _this.isClose = true;
- uni.navigateBack({
- delta: 1
- });
- }
- }
- });
- }
- return true;
- }
- },
-
- onNavigationBarButtonTap(e) {
-
- if (e.index == 0 && !this.isEditImg) {
- uni.navigateTo({
- url: '/pages/evaluatePlan/evaluatePlan?id=' + this.assessSchemeId + '&types='+this.types
- });
- } else {
- uni.showToast({
- icon: 'none',
- title: '正在编辑图片,不能选择考评方案'
- });
- }
- }
- };
- </script>
- <style></style>
|