popup.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  1. <template>
  2. <view>
  3. <!-- 弹窗 -->
  4. <view class="bgbox" @click="getClose" v-if="type"></view>
  5. <!-- 指派 -->
  6. <view v-if="type=='assign'" class="assignbox">
  7. </view>
  8. </view>
  9. </template>
  10. <script>
  11. import config from '@/config'
  12. const baseUrl = config.baseUrl
  13. import { getToken } from '@/utils/auth'
  14. import {uploadmore} from '@/utils/common.js'
  15. export default{
  16. components:{},
  17. props:{
  18. type: {
  19. type: String,
  20. default () {
  21. return ''
  22. }
  23. },
  24. finshtype:{
  25. type: [String,Number],
  26. default () {
  27. return ''
  28. }
  29. }
  30. },
  31. data(){
  32. return{
  33. //附件
  34. option: {
  35. // 上传服务器地址,需要替换为你的接口地址
  36. url: baseUrl+'/common/uploadNew', // 该地址非真实路径,需替换为你项目自己的接口地址
  37. // 上传附件的key
  38. name: 'file',
  39. // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
  40. header: {
  41. // 示例参数可删除
  42. 'Authorization': 'Bearer ' + getToken(),
  43. },
  44. // 根据你接口需求自定义body参数
  45. formData: {
  46. loanApplicationNumber:'',
  47. loanApplicationId:'',
  48. }
  49. },
  50. // 借据上传
  51. jjoption: {
  52. // 上传服务器地址,需要替换为你的接口地址
  53. url: baseUrl+'/common/uploadNewOcr', // 该地址非真实路径,需替换为你项目自己的接口地址
  54. // 上传附件的key
  55. name: 'file',
  56. // 根据你接口需求自定义请求头,默认不要写content-type,让浏览器自适配
  57. header: {
  58. // 示例参数可删除
  59. 'Authorization': 'Bearer ' + getToken(),
  60. },
  61. // 根据你接口需求自定义body参数
  62. formData: {
  63. loanApplicationNumber:'',
  64. loanApplicationId:'',
  65. }
  66. },
  67. // 选择文件后是否立即自动上传,true=选择后立即上传
  68. instantly: true,
  69. // 必传宽高且宽高应与slot宽高保持一致
  70. width: '',
  71. height: '40rpx',
  72. // 限制允许上传的格式,空串=不限制,默认为空
  73. formats: 'doc,docx,xls,xlsx,ppt,txt,pdf,zip,rar,word,png,jpg,jpeg',
  74. // 文件上传大小限制
  75. size: 100,
  76. // 文件数量限制 默认10
  77. count: 5,
  78. // 文件回显列表
  79. files: new Map(),
  80. // 微信小程序Map对象for循环不显示,所以转成普通数组,不要问为什么,我也不知道
  81. wxFiles: [],
  82. // 是否打印日志
  83. debug: false,
  84. filelist:[],
  85. // filico:require('@/work/static/filico.png'),
  86. // fdelimg:require('@/work/static/fjdel.png'),
  87. baseUrl:config.baseUrl,
  88. // closeimg:require("@/static/images/close.png"),
  89. syqxidx:'',
  90. datainfo:{
  91. iszc:""
  92. },
  93. sexs: [{
  94. text: '男',
  95. value: 0
  96. }, {
  97. text: '女',
  98. value: 1
  99. }],
  100. peoval:0,
  101. peolist:[]
  102. }
  103. },
  104. mounted() {
  105. this.baseUrl=baseUrl
  106. },
  107. watch:{
  108. loanApplicationNumber(val){
  109. this.option.formData.loanApplicationNumber=val
  110. this.jjoption.formData.loanApplicationNumber=val
  111. },
  112. loanApplicationId(val){
  113. this.option.formData.loanApplicationId=val
  114. this.jjoption.formData.loanApplicationId=val
  115. },
  116. type(val){
  117. // this.filelist=[];
  118. // this.shtext='';
  119. // this.isty='2';
  120. // this.phofile=[];
  121. }
  122. },
  123. methods:{
  124. bindDateChange(){
  125. var val=e.detail.value;
  126. },
  127. getClose(){
  128. this.$emit('getClose')
  129. },
  130. getSure(){
  131. this.$emit('getSure')
  132. },
  133. getChose(val){
  134. this.peoval=val
  135. },
  136. getPreviewImage(arr,idx){
  137. var newArr=[];
  138. arr.forEach(ite=>{
  139. var ds=this.baseUrl+ite
  140. newArr.push(ds)
  141. })
  142. uni.previewImage({
  143. urls: newArr,
  144. current:idx,
  145. success: function(data) {
  146. },
  147. fail: function(err) {
  148. }
  149. });
  150. },
  151. // 上传
  152. onuploadEnd(item,fileVal,bigType) {
  153. var newobj={}
  154. var responseText=JSON.parse(item.responseText)
  155. if(responseText.code==200){
  156. if(fileVal=='qtfj'){
  157. newobj.name=responseText.originalFilename;
  158. }else{
  159. newobj.name=responseText.newFileName;
  160. }
  161. newobj.oldName=responseText.originalFilename;
  162. newobj.url=responseText.fileName;
  163. newobj.type=fileVal;
  164. newobj.bigType=bigType;
  165. newobj.loanApplicationId=this.loanApplicationId;
  166. newobj.loanApplicationNumber=this.loanApplicationNumber;
  167. this.filelist.push(newobj)
  168. }else{
  169. this.$toast(responseText.msg)
  170. }
  171. },
  172. getDelFj(idx){
  173. var that=this;
  174. uni.showModal({
  175. title: '确认删除',
  176. content: "是否确认删除",
  177. cancelText: '取消',
  178. confirmText: '确认',
  179. success: function(res) {
  180. if (res.confirm) {
  181. that.filelist.splice(idx,1)
  182. } else if (res.cancel) {
  183. }
  184. }
  185. });
  186. },
  187. getDown(path,name){
  188. console.log(path,name)
  189. // #ifdef APP-PLUS
  190. self.getFilePermissions(function(res){
  191. if(res==1){
  192. uni.showLoading({
  193. title: '加载中'
  194. });
  195. var url = baseUrl + path;
  196. let dtask = plus.downloader.createDownload(url, {
  197. filename: 'file://storage/emulated/0/'+baseName+'/' + name
  198. }, (d, status) => {
  199. //d为下载的文件对象
  200. if (status == 200) {
  201. uni.hideLoading();
  202. uni.showToast({
  203. icon: 'none',
  204. mask: true,
  205. title: '已保存到文件夹:/'+baseName+'/'+ name, //保存路径
  206. duration: 3000,
  207. });
  208. //下载成功,d.filename是文件在保存在本地的相对路径,使用下面的API可转为平台绝对路径
  209. let fileSaveUrl = plus.io.convertLocalFileSystemURL(d.filename);
  210. setTimeout(() => {
  211. plus.runtime.openFile(d.filename); //选择软件打开文件
  212. }, 1500)
  213. } else {
  214. //下载失败
  215. uni.hideLoading();
  216. plus.downloader.clear(); //清除下载任务
  217. uni.showToast({
  218. icon: 'none',
  219. mask: true,
  220. title: '下载失败,请稍后重试',
  221. });
  222. }
  223. })
  224. dtask.start();
  225. }else{
  226. uni.hideLoading();
  227. uni.showToast({
  228. title: '无法获取权限,文件下载将出错!',
  229. icon: 'none',
  230. })
  231. }
  232. })
  233. // #endif
  234. // #ifndef APP-PLUS
  235. this.getDownloader(path)
  236. // #endif
  237. },
  238. getDownloader(e){
  239. uni.showLoading({
  240. title: '加载中'
  241. });
  242. var url=baseUrl+e;
  243. let index1 = e.lastIndexOf("."); // 得到一个索引值
  244. let index2 = e.length;
  245. let type = e.substring(index1, index2);
  246. if ((type.indexOf('jpg') > -1 || type.indexOf('jpeg') > -1 || type.indexOf('png') > -1)) {
  247. uni.previewImage({
  248. current: 0,
  249. urls: [url],
  250. // background: '#ffffff'
  251. });
  252. uni.hideLoading();
  253. } else {
  254. uni.downloadFile({
  255. url: url,//文件的下载路径
  256. success(result) {
  257. uni.hideLoading()
  258. var filePath = result.tempFilePath;
  259. uni.openDocument({
  260. filePath: filePath,
  261. showMenu: true,
  262. success: function (res) {
  263. // console.log('打开文档成功');
  264. }
  265. });
  266. },
  267. fail(res) {uni.hideLoading()}
  268. })
  269. }
  270. },
  271. getDelFn(){
  272. var that=this;
  273. uni.showModal({
  274. title: '确认删除',
  275. content: "是否确认删除",
  276. cancelText: '取消',
  277. confirmText: '确认',
  278. success: function(res) {
  279. if (res.confirm) {
  280. // that.filelist.splice(idx,1)
  281. } else if (res.cancel) {
  282. }
  283. }
  284. });
  285. },
  286. getaddImage(e){
  287. let that = this;
  288. let file =[],count=9
  289. uni.chooseImage({
  290. count: 1,
  291. success:function(res){
  292. let img= res.tempFilePaths;
  293. if(img.length + file.length > count){
  294. uni.showToast({
  295. title: '最多上传'+count+'张图片',
  296. icon: 'none',
  297. duration: 2000
  298. })
  299. }else{
  300. let imglen = res.tempFilePaths.length;
  301. var fuwufile = [];
  302. uploadmore('/common/upload',img,0,0,0,imglen,fuwufile,function(rs){
  303. var resurl=rs[0];
  304. // if(e=='front'){
  305. // that.datainfo.front=resurl.fileName;
  306. // }else{
  307. // that.datainfo.back=resurl.fileName;
  308. // }
  309. })
  310. }
  311. }
  312. });
  313. },
  314. }
  315. }
  316. </script>
  317. <style lang="scss" scoped>
  318. // 指派
  319. .assignbox{background: #FFFFFF;border-radius: 20rpx;position: fixed;left:56rpx;right:54rpx;z-index: 10;top: 50%;transform: translateY(-50%);padding: 32rpx 38rpx 36rpx;
  320. .assbox{max-height: calc(100vh - 300rpx);overflow: auto;}
  321. .asstit{font-weight: bold;font-size: 30rpx;color: #272727;text-align: center;padding-left: 16rpx;margin-bottom: 28rpx;}
  322. .rimg{width: 16rpx;height: 28rpx;flex: 0 0 auto;margin-left: 20rpx;
  323. image{width: 100%;height: 100%;}
  324. }
  325. .asline{border-bottom: 2rpx solid #E5E5E5;padding: 30rpx 0;margin-bottom: 40rpx;}
  326. .tabtit{font-weight: bold;font-size: 26rpx;color: #272727;line-height: 36rpx;margin-bottom: 24rpx;padding-left: 14rpx;}
  327. .asslists{display: flex;flex-wrap: wrap;
  328. .asslist{width: 252rpx;height: 76rpx;border-radius: 20rpx;border: 2rpx solid #DADADA;position: relative;display: flex;align-items: center;box-sizing: border-box;padding: 0 22rpx;margin: 0 14rpx 24rpx 14rpx;overflow: hidden;
  329. &.act{border-color: #0256FD;
  330. .altit{color: #0256FD;}
  331. }
  332. image{position: absolute;right: -2rpx;bottom: -2rpx;width: 34rpx;height: 32rpx;}
  333. .altit{font-weight: bold;font-size: 26rpx;color: #666666;flex: 1;}
  334. .altxt{font-weight: bold;font-size: 22rpx;flex: 0 0 auto;}
  335. }
  336. }
  337. // 上传图片
  338. &.pra{left: 100rpx;right: 100rpx;}
  339. .assadd{display: flex;flex-direction: column;align-items: center;justify-content: center;border-radius: 10rpx;height: 192rpx;
  340. border: 2rpx dashed #A7A7A7;box-sizing: border-box;margin-bottom: 32rpx;
  341. image{width:48rpx;height: 40rpx;margin-bottom: 16rpx;}
  342. view{font-weight: bold;font-size: 26rpx;color: #272727;}
  343. }
  344. .assimgs{display: flex;align-items: center;flex-wrap: wrap;margin-bottom: 8rpx;
  345. .assimg{width: 140rpx;height: 140rpx;position: relative;overflow: hidden;margin: 0 24rpx 24rpx 0;
  346. &:nth-of-type(3n){margin-right: 0;}
  347. .img{width: 100%;height: 100%;}
  348. .delimg{width: 24rpx;height: 24rpx;position: absolute;right: 0;top: 0;}
  349. }
  350. }
  351. }
  352. .voice{font-weight: 500;display: flex;justify-content:flex-end;align-items: center;margin-top: 40rpx;
  353. font-size: 24rpx;
  354. color: #45CB99;
  355. image{width: 24rpx;height: 24rpx;margin-right: 8rpx;}
  356. }
  357. // 附件
  358. .fjlists {display: flex;align-items: flex-start;justify-content: space-between;margin-bottom: 20rpx;
  359. &:last-child{margin-bottom: 0;}
  360. .imgl{width: 40rpx;height: 40rpx;display: flex;align-items: center;flex: 0 0 auto;
  361. image{width: 26rpx;height: 24rpx;}
  362. }
  363. .tit{font-size: 26rpx;color: #222327;font-weight: 500;margin-top: 4rpx;word-break: break-all;}
  364. .delimg{width: 40rpx;height:40rpx;margin-left: 16rpx;display: flex;align-items: center;justify-content: center;flex: 0 0 auto;
  365. image{width: 24rpx;height: 24rpx;}
  366. }
  367. .txta{color: #28C529;font-weight: 500;line-height: 40rpx;flex: 0 0 auto;margin-left: 18rpx;padding: 0 6rpx;}
  368. }
  369. .closeimg{width: 32rpx;height: 32rpx;position: absolute;bottom: -62rpx;left: 50%;margin-left: -16rpx;}
  370. </style>