<template> <view > <cu-custom bgColor="bg-gradual-blueness" :isBack="true"> <block slot="backText">返回</block> <block slot="content">更新签字信息</block> </cu-custom> <scroll-view scroll-y="false" > <view class="form"> <view class="wui-form-list"> <view class="wui-sign"> <view class="title">用户</view> <button class="cu-btn bg-green shadow" @tap="showModal" data-target="Modal">手写签字</button> </view> <view class="wui-sign-box" v-show="(imgList && imgList.length > 0) || (initImgList && initImgList.length > 0)"> <view class="sign-title"> 签字照片: </view> <view class="wui-sign-cotent" v-if="imgList && imgList.length > 0"> <view class="sign-img" v-for="(item,index) in imgList" :key="index" @tap="ViewImage" data-type="0" :data-url="imgList[index].filePath"> <image :src="imgList[index].filePath" mode="aspectFit"></image> </view> </view> <view class="wui-sign-cotent" v-else-if="initImgList && initImgList.length > 0"> <view class="sign-img" v-for="(item,index) in initImgList" :key="index" @tap="ViewImage" data-type="0" :data-url="initImgList[index].filePath"> <image :src="initImgList[index].filePath" mode="aspectFit"></image> </view> </view> </view> <view class="cu-modal" :class="modalName=='Modal'?'show':''"> <writing-board @confirm="subCanvas" @cancel="hideModal"></writing-board> </view> </view> </view> <view class="cu-bar btn-group" style="margin-top: 30upx;"> <button class="cu-btn bg-green margin-tb-sm lg" @click="$noMultipleClicks(goSubmit)">确 认</button> </view> <view class="padding flex flex-direction"> </view> </scroll-view> </view> </template> <script> import { basePath,corpinfoId,deptId,loginUser,formatDate,loginSession,baseImgPath } from '@/common/tool.js'; import writingBoard from "@/components/writing-board/writing-board.vue" export default { components: { writingBoard }, data() { return { baseImgPath:baseImgPath, imgList:[], initImgList:[], modalName:null, noClick:true, } }, onLoad(event){ this.getData(); loginSession(); }, methods: { getData() { var _this = this; uni.showLoading({ title: '请稍候' }) uni.request({ url: basePath + '/app/user/geUserInfoSign', method: 'POST', header: { 'Content-type': 'application/x-www-form-urlencoded' }, data: { CORPINFO_ID:loginUser.CORPINFO_ID, USER_ID:loginUser.USER_ID, }, success: (res) => { if ("success" == res.data.result) { uni.hideLoading(); _this.pd = res.data.pd; //参数map if(res.data.IMGURL && res.data.IMGURL != '' && res.data.IMGURL != undefined && res.data.IMGURL != 'undefined'){ var initImg = {} initImg.filePath = baseImgPath + res.data.IMGURL console.info(baseImgPath) console.info(res.data.IMGURL) _this.initImgList.push(initImg) } } else if ("exception" == data.result) { uni.showToast({ title: '错误', duration: 2000 }); } } }); }, goSubmit(STATUS){ var _this = this; uni.showLoading({ title: '请稍候' }) if (_this.imgList.length <= 0) { uni.showToast({ icon: 'none', title: '请签字', duration: 1500 }); return; } const formData={} formData.USER_ID=loginUser.USER_ID formData.CORPINFO_ID = loginUser.CORPINFO_ID uni.uploadFile({ url: basePath+'/app/user/updateUserSign', filePath: _this.imgList[0].filePath, name: 'FFILE', formData:formData, success: (res) => { uni.showToast({ icon:'none', title: '保存成功', duration: 2000 }); _this.goback() }, fail: (err) => { uni.hideLoading(); uni.showModal({ content: err.errMsg, showCancel: false }); } }) }, /* *手写板 */ showModal(e) { this.modalName = e.currentTarget.dataset.target }, hideModal(e) { this.modalName = null }, //完成 subCanvas(e) { this.imgList.splice(0,this.imgList.length); this.imgList.push(e); this.hideModal() }, ViewImage(e) { let files =[]; files.push(e.currentTarget.dataset.url) uni.previewImage({ urls: files, current: e.currentTarget.dataset.url }); }, goback(){ var pages = getCurrentPages(); // 获取当前页面栈 var prePage = pages[pages.length - 2]; // 上二级页面 prePage.$vm.initflag = true; // A 页面 init方法 为true uni.navigateBack({delta: 1}); uni.hideLoading(); }, } } </script> <style> </style>