123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- <template>
- <view>
- <web-view @message="onmessage" src="/hybrid/html/video.html"></web-view>
- </view>
- </template>
- <script>
- import { clzConfirm,saveBase64ToAliOss } from '@/libs/tools'
- import {taskStart,submitTask,updateTaskItem,getTaskDetail} from '@/api/task'
- import {getTaskItem,delTaskItem} from '@/api/taskItem'
- import {taskTargetSave,taskCommentsSave} from '@/api/taskTarget'
- import {findVsDeviceChannels} from '@/api/store'
- export default {
- data() {
- return {
- wv: null,
- isClose: false, // 是否关闭当前窗口
- isEditImg: false, // 是否正在编辑图片
- showPz: false, // 是否正在拍照
- types: 'video', // 巡店类型,video,scene
- restart: '', // 是否重新巡店
- taskId: '', // 任务id
- storeId: '', // 门店id
- assessSchemeId: '', // 方案id
- };
- },
- methods: {
- // 监听html页面事件
- onmessage(event) {
- let data = event.detail.data[0]
- // console.log(data)
- // webview 窗口传过来的页面状态
- if(data.action == 'getWinStatus'){
- let d = JSON.parse(data.msg)
- this[d.key] = d.val
- }
- // 保存编辑后的图片
- if(data.action == 'saveEditImg'){
- this.uploadImg(data.msg)
- }
- // 删除图片
- if(data.action == 'delImgs'){
- this.delImgs(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()
- }
- },
- //指标评论,图片更新保存
- saveZbPlImgs(data){
- taskCommentsSave(data).then(res=>{
- if(res.status == 200){
- this.wv.evalJS("vm.saveZbPlImgsSuccess()")
- }
- uni.showToast({
- icon:'none',
- title: res.message
- })
- })
- },
- // 保存指标结果
- saveZbResult(data){
- taskTargetSave(data).then(res=>{
- if(res.status == 200){
- this.wv.evalJS("vm.saveZbResultSuccess("+data.id+",'"+data.result+"')")
- }
- uni.showToast({
- icon:'none',
- title: res.message
- })
- })
- },
- // 删除图片
- 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(res=>{
- if(res.status == 200){
- _this.wv.evalJS("vm.delKpItemSuccess("+id+")")
- }
- uni.showToast({
- icon:'none',
- title: res.message
- })
- })
- }
- }
- });
- },
- // 上传编辑后的图片到阿里云
- uploadImg(formData) {
- const _this = this;
- saveBase64ToAliOss(formData,function(res){
- // console.log(res);
- // 关闭编辑图片
- _this.wv.evalJS("vm.closeImgsEdit()")
- // 更新编辑后的图片
- _this.wv.evalJS("vm.updateItemImg('"+res.data+"')")
- })
- },
- // 开始巡店(重新开始),isNew 0 新建,1 重新开始
- creatTask(isNew){
- // 新建任务,只传门店id
- let parms = {
- storeId:this.storeId
- }
- // 重新开始,要传任务id
- if(isNew){
- parms.taskId = this.taskId
- }
- taskStart(parms).then(res => {
- if(res.status == 200){
- // 创建成功,查询任务明细
- this.getTaskDetail()
- this.getTaskItem()
- }else{
- uni.showToast({
- icon:'none',
- title: res.message
- })
- }
- })
- },
- // 查询任务明细
- getTaskDetail(){
- getTaskDetail({id:this.taskId}).then(res => {
- this.assessSchemeId = res.data.assessSchemeId // 方案id
- this.wv.evalJS("vm.getTaskDetail('"+JSON.stringify(res.data)+"')")
- })
- },
- // 任务考评项目明细
- getTaskItem(){
- getTaskItem({id:this.taskId}).then(res => {
- this.wv.evalJS("vm.getTaskItem('"+JSON.stringify(res.data)+"')")
- })
- },
- // 更新方案项目
- updateTaskItem(schemeId){
- console.log(schemeId)
- updateTaskItem({schemeId,taskId:this.taskId}).then(res=>{
- if(res.status==200){
- // 重置页面
- this.wv.evalJS("vm.resetPage()")
- this.getTaskDetail()
- this.getTaskItem()
- }else{
- uni.showToast({
- icon:'none',
- title: res.message
- })
- }
- })
- },
- // 获取视频列表
- getVideoList(){
- findVsDeviceChannels({storeId:this.storeId}).then(res=>{
- if(res.status==200){
- this.wv.evalJS("vm.setVideoList('"+JSON.stringify(res.data)+"')")
- }
- })
- },
- // 提交本次任务
- submitTask(){
- const _this = this;
- clzConfirm({
- title: '提示',
- content: '确定提交本次巡店?',
- success: function(res) {
- if (res.confirm || res.index == 0) {
- submitTask({storeId:this.storeId}).then(res=>{
- if(res.status == 200){
- uni.navigateBack()
- }
- uni.showToast({
- icon:'none',
- title: res.message
- })
- })
- }
- }
- });
- },
- // 现场巡店下一步签字
- nextStep(){
- uni.navigateTo({
- url:"/pages/shopTourOver/shopTourOver?storeId="+this.storeId
- })
- }
- },
- onLoad(options) {
- // 巡店类型,视频还时现场
- this.types = options.types
- this.taskId = options.taskId
- this.storeId = options.storeId
- this.restart = options.restart
- },
- onReady() {
- let _this = this
- // #ifdef APP-PLUS
- //获取当前页面的webview对象
- 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()
- }else{
- // 首次新建
- _this.creatTask(0)
- }
- }, 500);
- // #endif
-
- // 监听选择方案后事件,schemeId 方案id
- uni.$on("resetTaskKpItem",(schemeId)=>{
- _this.updateTaskItem(schemeId)
- })
- },
- // 监听返回键
- 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
- })
- }else{
- uni.showToast({
- icon:"none",
- title:"正在编辑图片,不能选择考评方案"
- })
- }
- },
- }
- </script>
- <style>
- </style>
|