ReportHiddenDanger.vue 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015
  1. <template>
  2. <view style="position: relative;">
  3. <form @submit="onSubmit">
  4. <scroll-view scroll-y class="container">
  5. <div class="helpBox">
  6. <semp-notice-bar scrollable showType="slider" icon="sound" setIconColor="#eb9064" round bgColor="#fff" iconSize="40" textFontSize="36rpx" :strText="helpTips" @tap="onOperateIllustrateTo"></semp-notice-bar>
  7. </div>
  8. <view class="formBox">
  9. <view class="hiddenDangerBox">
  10. <view class="hiddenDangerItemBox" style="margin-top: 0px;">
  11. <view class="hiddenDangerHeader">线索信息</view>
  12. <view class="hiddenDangerBody">
  13. <view class="hiddenDangerItem">
  14. <view class="hiddenDangerItemHeader">
  15. <text class="mustTips">*</text>
  16. <text class="itemHeaderText">地点</text>
  17. </view>
  18. <view class="hiddenDangerItemBody">
  19. <view class="fway-form-item" style="position: relative;">
  20. <view class="fway-form-input-inline" @tap="onMapTo">
  21. <input type="text" disabled class="fway-form-input" placeholder="请标记事发地点" v-model="data.address" />
  22. </view>
  23. <view class="fway-form-input-inline" v-if="data.address">
  24. <input type="text" class="fway-form-input" placeholder="请填写详细地址" v-model="data.fullAddress" @tap="inputTap" data-focus="fullAddress" :focus="focusID == 'fullAddress' ? true : false" />
  25. </view>
  26. </view>
  27. </view>
  28. </view>
  29. <view class="hiddenDangerItem">
  30. <view class="hiddenDangerItemHeader">
  31. <text class="mustTips">*</text>
  32. <text class="itemHeaderText" style="width: 248rpx;">事件描述</text>
  33. <view class="fway-form-lable-block hiddenDangerHeaderBtn">
  34. <view class="fway-form-lable-btn" style="width: 100%;height: 56rpx;">
  35. <view class="vioceBox">
  36. <nb-voice-record v-if="vioceList.length == 0" :btnStyle="vioceBtnStyle" popupFixBottom="400" isShowRecordTime popupTitle="正在录制音频,要求录音时长不低于10s" @startRecord="OnVioceStart" @endRecord="OnVioceEnd" @cancelRecord="OnVioceCancel" :btnIconShow="true" btnIconSrc="/static/img/write/record.png" :btnIconStyle="vioceBtnIconStyle" btnDefaultText="长按开始录音"></nb-voice-record>
  37. <view v-if="vioceList.length > 0" class="vioceListBox">
  38. <view class="vioceItemBox" v-for="(item, index) in vioceList" :key="index">
  39. <view class="vioceItemImgBox" @tap="onPlayVioce(item.tempFilePath)">
  40. <view class="vioceItemBG" :style="'width: '+ vioceItemBGWidth + '%'"></view>
  41. <image class="vioceItemImg" src="/static/img/write/bofang.png" v-if="!item.isPlay"></image>
  42. <image class="vioceItemImg" src="/static/img/write/zanting.png" v-else></image>
  43. <text class="vioceItemDuration">{{Math.round(item.duration / 1000)}}s</text>
  44. </view>
  45. <view class="vioceItemDelete" @tap="onDeleteVioce(item.tempFilePath)">删除
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="hiddenDangerItemBody">
  54. <view class="fway-form-item" style="position: relative;">
  55. <view class="fway-form-input-inline">
  56. <textarea type="text" class="fway-form-textarea" placeholder="请告知具体情况,以便我们尽快处理" v-model="data.description" maxlength="2000" />
  57. </view>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="hiddenDangerItem">
  62. <view style="padding: 10rpx 0;">
  63. <text class="mustTips" style="display: inline-block;vertical-align: text-top;">*</text>
  64. <view style="display: inline-block;width: calc(100% - 30rpx);vertical-align: text-top;">
  65. <text class="itemHeaderText">现场图片/视频</text>
  66. <text class="itemHeaderTips" style="line-height: 40rpx;">(图片请采用近景、含参照物远景图,并保持清晰)</text>
  67. </view>
  68. </view>
  69. <view class="hiddenDangerItemBody">
  70. <view class="photoListBox">
  71. <view class="photoItemBox" v-for="(item, index) in photoList" :key="index" @tap="onPreviewImage" :data-url="item.tempFilePath">
  72. <image class="photoItemImg" :src="item.tempFilePath" mode="aspectFit"></image>
  73. <image class="closeBtn" src="/static/img/common/close.png" @tap.stop="onDelImg" :data-index="index"></image>
  74. </view>
  75. <view class="photoItemBoxsel" v-show="photoList.length < 4" @tap="onChooseImageVideo('image')">
  76. <image class="photoItemImgsel" src="/static/img/write/selPhoto.png"></image>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. <view class="hiddenDangerItem">
  82. <view class="hiddenDangerItemHeader">
  83. <text class="itemHeaderText">现场视频</text>
  84. </view>
  85. <view class="hiddenDangerItemBody">
  86. <view class="photoListBox">
  87. <view class="photoItemBox" v-for="(item, index) in videoList" :key="index">
  88. <video class="photoItemImg" :id="index" :src="item.tempFilePath"></video>
  89. <image class="closeBtn" src="/static/img/common/close.png" @tap.stop="onDelVideo" :data-index="index"></image>
  90. </view>
  91. <view class="photoItemBoxsel" v-show="videoList.length < 3" @tap="onChooseImageVideo('video')">
  92. <image class="photoItemImgsel" src="/static/img/write/selVideo.png"></image>
  93. </view>
  94. </view>
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <view class="hiddenDangerItemBox reportPersonBox">
  100. <view class="hiddenDangerHeader">上报人信息</view>
  101. <view class="hiddenDangerBody">
  102. <view class="hiddenDangerItem" style="margin-bottom: 0;">
  103. <view class="hiddenDangerItemBody">
  104. <view class="fway-form-item">
  105. <view class="fway-form-lable"><text class="mustTips">*</text>姓名</view>
  106. <view class="fway-form-input-inline">
  107. <input type="text" class="fway-form-input" placeholder="请录入上报人姓名" v-model="data.name" @tap="inputTap" data-focus="name" :focus="focusID == 'name' ? true : false" />
  108. </view>
  109. </view>
  110. <view class="fway-form-item">
  111. <view class="fway-form-lable"><text class="mustTips">*</text>联系方式</view>
  112. <view class="fway-form-input-inline">
  113. <input type="number" class="fway-form-input" placeholder="请录入上报人的联系电话" v-model="data.phoneNumber" @tap="inputTap" data-focus="phoneNumber" :focus="focusID == 'phoneNumber' ? true : false" />
  114. </view>
  115. </view>
  116. <view class="fway-form-item" style="border: none;padding: 10rpx 0 0;">
  117. <view class="fway-form-lable" style="color: #000;"><text class="mustTips">*</text>是否保密</view>
  118. <view class="fway-form-input-inline" style="padding: 10rpx 0 10rpx 20rpx;width: calc(100% - 220rpx);">
  119. <radio-group @change="onIsSecretChange">
  120. <label class="fway-form-radioBox">
  121. <radio class="fway-form-radio" style="transform:scale(1)" value="1" color="#3e6ffd" :checked="data.isSecret == true" />保密
  122. </label>
  123. <label class="fway-form-radioBox">
  124. <radio class="fway-form-radio" style="transform:scale(1)" value="0" color="#3e6ffd" :checked="data.isSecret == false" />不保密
  125. </label>
  126. </radio-group>
  127. </view>
  128. </view>
  129. </view>
  130. </view>
  131. </view>
  132. </view>
  133. </view>
  134. </view>
  135. </scroll-view>
  136. <view class="fway-btnBox">
  137. <button class="fway-btn" formType="submit">立即上报</button>
  138. </view>
  139. </form>
  140. </view>
  141. </template>
  142. <script>
  143. const innerAudioContext = uni.createInnerAudioContext();
  144. var qqMap = require('@/static/js/qqmap-wx-jssdk.min.js');
  145. var qqMapsdk;
  146. var that;
  147. export default {
  148. data() {
  149. return {
  150. data: {
  151. longitude: '',
  152. latitude: '',
  153. areaCode: '',
  154. province: '',
  155. city: '',
  156. county: '',
  157. town: '',
  158. street: '',
  159. address: '',
  160. fullAddress: '',
  161. industryId: '',
  162. jobType: null,
  163. businessUnitType: '',
  164. workplace: '',
  165. workplaceName: '',
  166. workArea: '',
  167. workAreaId: '',
  168. startWorkTime: '',
  169. endWorkTime: '',
  170. name: '',
  171. phoneNumber: '',
  172. isSecret: null,
  173. description: '',
  174. companyName: '',
  175. files: []
  176. },
  177. photoList: [],
  178. videoList: [],
  179. vioceList: [],
  180. vioceBtnIconStyle:{
  181. width: '40rpx',
  182. height: '40rpx',
  183. marginRight: '10rpx'
  184. },
  185. vioceBtnStyle: {
  186. width: '240rpx',
  187. height: '56rpx',
  188. borderRadius: '60rpx',
  189. backgroundColor: '#3e6ffd',
  190. fontSize: "32rpx",
  191. color: '#fff',
  192. border: 'none',
  193. padding: '0 10rpx',
  194. permisionState: false
  195. },
  196. vioceItemBGWidth: 0,
  197. focusID: '',
  198. fileSize: 40, // 单位M
  199. helpID: '',
  200. helpTips: '',
  201. }
  202. },
  203. onLoad(option) {
  204. that = this;
  205. that.data.industryId = decodeURIComponent(option.id);
  206. qqMapsdk = new qqMap({
  207. key: 'TE4BZ-ZFEAT-45CX3-VPZ3R-GOLS6-EGF54'
  208. });
  209. that.onGetBaseData();
  210. },
  211. onShow() {
  212. that.data.phoneNumber = that.data.phoneNumber ? that.data.phoneNumber : uni.getStorageSync('userInfo').userTel || '';
  213. that.data.name = that.data.name ? that.data.name : uni.getStorageSync('userInfo').userName || '';
  214. },
  215. methods: {
  216. // 获取作业类型数据
  217. onGetBaseData(fun){
  218. that.$admin.req({
  219. method: 'GET',
  220. url: '/api/v1/Snapshot/industry/base/' + that.data.industryId
  221. }).then(res => {
  222. if (res) {
  223. // that.data.IndustryName = res.industry.name;
  224. that.helpID = res.bulletinId;
  225. that.helpTips = res.industry.txtHelpRemarks || '填报有疑问?点击查看更详细的操作指引';
  226. } else {
  227. that.$util.msg('服务异常,请稍后重试!');
  228. }
  229. typeof fun === 'function' && fun();
  230. })
  231. },
  232. // 监听input框点击设置焦点
  233. inputTap(e) {
  234. if(that.focusID != e.currentTarget.dataset.focus){
  235. uni.hideKeyboard();
  236. setTimeout(function() {
  237. that.focusID = e.currentTarget.dataset.focus
  238. }, 200)
  239. }
  240. },
  241. onIsSecretChange(e) {
  242. that.data.isSecret = e.detail.value == '1' ? true : false
  243. },
  244. // 验证地理位置是否在自贡市
  245. onGetAddress(latitude, longitude, fun) {
  246. qqMapsdk.reverseGeocoder({
  247. location: {
  248. latitude: latitude,
  249. longitude: longitude
  250. },
  251. success(res) {
  252. // 地址信息
  253. if (res.result.address_component.city != '自贡市') {
  254. typeof fun === 'function' && fun(false);
  255. } else {
  256. typeof fun === 'function' && fun(res.result);
  257. }
  258. },
  259. fail: function(error) {
  260. console.error(error);
  261. typeof fun === 'function' && fun(false);
  262. }
  263. });
  264. },
  265. onMapTo() {
  266. // 判断微信位置是否开启
  267. let appAuthorizeSetting = uni.getAppAuthorizeSetting();
  268. if (appAuthorizeSetting.locationAuthorized != 'authorized') {
  269. that.$util.msg("定位失败,请在手机设置中打开微信位置权限");
  270. return;
  271. }
  272. uni.chooseLocation({
  273. success: function(res) {
  274. if (res.name) {
  275. that.onGetAddress(res.latitude, res.longitude, function(data) {
  276. if (data) {
  277. console.log(data);
  278. that.data.longitude = res.longitude;
  279. that.data.latitude = res.latitude;
  280. that.data.areaCode = data.ad_info.adcode;
  281. that.data.province = data.address_component.province;
  282. that.data.city = data.address_component.city;
  283. that.data.county = data.address_component.district;
  284. that.data.town = data.address_reference.town.title;
  285. that.data.street = data.address_component.street;
  286. // that.data.address = data.address;
  287. if (res.address) {
  288. let address = res.address;
  289. try {
  290. address = address.replace('四川省自贡市', '');
  291. that.data.address = res.name + '(' + address + ')';
  292. } catch (d) {
  293. that.data.address = res.name + '(' + address + ')';
  294. }
  295. } else {
  296. that.data.address = res.name;
  297. }
  298. } else {
  299. that.$util.msg("选择的地点不属于自贡市行政管辖范围,请重新确认事发地点");
  300. }
  301. })
  302. } else {
  303. that.$util.msg("事发地点定位失败,请重新选择");
  304. }
  305. },
  306. fail() {
  307. that.$util.msg("事发地点定位失败,请重新选择");
  308. }
  309. });
  310. },
  311. OnVioceStart() {
  312. // 开始录音
  313. },
  314. OnVioceEnd(e) {
  315. if (e.duration / 1000 < 10) {
  316. that.$util.msg('您的录音不足10s,请重新点击开始录音');
  317. return;
  318. }
  319. if (e.fileSize * 1 > that.fileSize * 1024 * 1024) {
  320. that.$util.msg('您的录音超过了系统文件限制大小,请重新点击开始录音');
  321. return;
  322. }
  323. that.vioceList.push({
  324. tempFilePath: e.tempFilePath,
  325. duration: e.duration,
  326. fileSize: e.fileSize,
  327. fileType: 'vioce',
  328. isPlay: false
  329. });
  330. // 结束录音并处理得到的录音文件
  331. // event中,app端仅有tempFilePath字段,微信小程序还有duration和fileSize两个字段
  332. },
  333. OnVioceCancel() {
  334. // 用户取消录音
  335. that.$util.msg('您已取消录音');
  336. },
  337. onPlayVioce(src) {
  338. if (src) {
  339. let indexVioce = '';
  340. that.vioceList.forEach((item, index) => {
  341. if (item.tempFilePath == src) {
  342. indexVioce = index;
  343. that.vioceList[index].isPlay = true;
  344. that.$set(that.vioceList, index, that.vioceList[index]);
  345. }
  346. })
  347. innerAudioContext.src = src;
  348. let vioceInterval = '';
  349. let vioceTime = 0;
  350. innerAudioContext.play();
  351. innerAudioContext.onPlay(function() {
  352. // 定时器设置背景色宽度
  353. vioceInterval = setInterval(() => {
  354. vioceTime += 100;
  355. let numTime = (vioceTime / that.vioceList[indexVioce].duration).toFixed(3) *
  356. 100;
  357. that.vioceItemBGWidth = numTime > 100 ? 100 : numTime
  358. }, 100)
  359. })
  360. innerAudioContext.onEnded(function() {
  361. that.vioceList[indexVioce].isPlay = false;
  362. that.$set(that.vioceList, indexVioce, that.vioceList[indexVioce]);
  363. clearInterval(vioceInterval);
  364. that.vioceItemBGWidth = 0
  365. })
  366. }
  367. },
  368. onDeleteVioce(src) {
  369. let isPlay = false;
  370. that.vioceList.forEach((item, index) => {
  371. if (item.tempFilePath == src) {
  372. if (that.vioceList[index].isPlay == true){
  373. isPlay = true;
  374. }
  375. }
  376. });
  377. if (isPlay){
  378. that.$util.msg('录音正在播放,请稍后删除!');
  379. return;
  380. }
  381. uni.showModal({
  382. content: '确定要删除吗?',
  383. confirmText: '确定',
  384. confirmColor: '#3e6ffd',
  385. success: res => {
  386. if (res.confirm) {
  387. let deleteIndex = -1;
  388. that.vioceList.forEach((item, index) => {
  389. if (item.tempFilePath == src) {
  390. deleteIndex = index;
  391. }
  392. })
  393. that.vioceList.splice(deleteIndex, 1);
  394. }
  395. }
  396. });
  397. },
  398. // 选择图片和视频
  399. onChooseImageVideo(type) {
  400. // 附件类型
  401. let mediaType = type;
  402. // 图片、视频数量限制剩余数量
  403. let remainPhotoNum = 4 - that.photoList.length;
  404. let remainVideoNum = 3 - that.videoList.length;
  405. // 选择限制数量
  406. // let count = remainPhotoNum + remainVideoNum;
  407. let count = 0;
  408. if (type == 'image'){
  409. count = remainPhotoNum;
  410. }else if (type == 'video'){
  411. count = remainVideoNum;
  412. }
  413. // if (remainPhotoNum > 0 && remainVideoNum > 0) {
  414. // mediaType = ['mix'];
  415. // } else {
  416. // if (remainPhotoNum > 0) {
  417. // mediaType = ['image'];
  418. // }
  419. // if (remainVideoNum > 0) {
  420. // mediaType = ['video'];
  421. // }
  422. // }
  423. if (count > 0) {
  424. uni.chooseMedia({
  425. count: count, //默认9
  426. mediaType: mediaType,
  427. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  428. sourceType: ['album', 'camera'], //从相册选择
  429. success: (res) => {
  430. let arrPhotoData = [];
  431. let arrVideoData = [];
  432. let strPhotoErrorIndex = '';
  433. let strVideoErrorIndex = '';
  434. let strVideoErrorSizeIndex = '';
  435. res.tempFiles.forEach((item, index) => {
  436. if (item.fileType == 'image') {
  437. arrPhotoData.push(item)
  438. } else if (item.fileType == 'video') {
  439. arrVideoData.push(item)
  440. }
  441. });
  442. let strErrorTips = '';
  443. // 判断图片是否满足条件
  444. let rightPhotoData = [];
  445. arrPhotoData.forEach((item, index) => {
  446. if (item.size > 0 && item.size <= that.fileSize * 1024 * 1024) {
  447. rightPhotoData.push(item)
  448. } else {
  449. if (strPhotoErrorIndex == '') {
  450. strPhotoErrorIndex = (index + 1)
  451. } else {
  452. strPhotoErrorIndex += ',' + (index + 1)
  453. }
  454. }
  455. });
  456. if (strPhotoErrorIndex != '') {
  457. if (strErrorTips != "") {
  458. strErrorTips += '\n';
  459. }
  460. strErrorTips += '您上传的第' + strPhotoErrorIndex + '张图片超过系统文件限制大小,请重新选择上传。'
  461. }
  462. if (rightPhotoData.length > remainPhotoNum) {
  463. if (strErrorTips != "") {
  464. strErrorTips += '\n';
  465. }
  466. strErrorTips += '您选择的图片超出数量限制,仅按顺序保留。'
  467. rightPhotoData.splice(remainPhotoNum, (rightPhotoData.length - remainPhotoNum))
  468. }
  469. // 判断视频是否满足条件
  470. let rightVideoData = [];
  471. arrVideoData.forEach((item, index) => {
  472. if (item.duration > 0 && item.duration <= 60) {
  473. if (item.size > 0 && item.size <= that.fileSize * 1024 * 1024) {
  474. rightVideoData.push(item)
  475. } else {
  476. if (strVideoErrorSizeIndex == '') {
  477. strVideoErrorSizeIndex = (index + 1)
  478. } else {
  479. strVideoErrorSizeIndex += ',' + (index + 1)
  480. }
  481. }
  482. } else {
  483. if (strVideoErrorIndex == '') {
  484. strVideoErrorIndex = (index + 1)
  485. } else {
  486. strVideoErrorIndex += ',' + (index + 1)
  487. }
  488. }
  489. });
  490. if (strVideoErrorIndex != '') {
  491. if (strErrorTips != "") {
  492. strErrorTips += '\n';
  493. }
  494. strErrorTips += '您上传的第' + strVideoErrorIndex + '个视频超过支持的最大时长60s,请重新上传。'
  495. }
  496. if (strVideoErrorSizeIndex != '') {
  497. if (strErrorTips != "") {
  498. strErrorTips += '\n';
  499. }
  500. strErrorTips += '您上传的第' + strVideoErrorSizeIndex + '个视频超过系统文件限制大小,请重新选择上传。'
  501. }
  502. if (rightVideoData.length > remainVideoNum) {
  503. if (strErrorTips != "") {
  504. strErrorTips += '\n';
  505. }
  506. strErrorTips += '您选择的满足条件的视频超出数量限制,仅按顺序保留。'
  507. rightVideoData.splice(remainVideoNum, rightVideoData.length - remainVideoNum);
  508. }
  509. // 保存
  510. if (rightPhotoData.length > 0) {
  511. if (that.photoList.length != 0) {
  512. that.photoList = that.photoList.concat(rightPhotoData)
  513. } else {
  514. that.photoList = rightPhotoData
  515. }
  516. }
  517. if (rightVideoData.length > 0) {
  518. if (that.videoList.length != 0) {
  519. that.videoList = that.videoList.concat(rightVideoData)
  520. } else {
  521. that.videoList = rightVideoData
  522. }
  523. }
  524. if (strErrorTips != "") {
  525. uni.showModal({
  526. title: '提示',
  527. content: strErrorTips,
  528. showCancel: false,
  529. confirmText: '确定',
  530. confirmColor: '#3e6ffd'
  531. })
  532. }
  533. }
  534. });
  535. } else {
  536. that.$util.msg('最多上传4张图片和3段视频!');
  537. }
  538. },
  539. onPreviewImage(e) {
  540. let arrStrPhoto = [];
  541. that.photoList.forEach((item, index) => {
  542. arrStrPhoto.push(item.tempFilePath)
  543. })
  544. uni.previewImage({
  545. urls: arrStrPhoto,
  546. current: e.currentTarget.dataset.url
  547. });
  548. },
  549. onDelImg(e) {
  550. uni.showModal({
  551. content: '确定要删除吗?',
  552. confirmText: '确定',
  553. confirmColor: '#3e6ffd',
  554. success: res => {
  555. if (res.confirm) {
  556. that.photoList.splice(e.currentTarget.dataset.index, 1)
  557. }
  558. }
  559. })
  560. },
  561. onDelVideo(e) {
  562. uni.showModal({
  563. content: '确定要删除吗?',
  564. confirmText: '确定',
  565. confirmColor: '#3e6ffd',
  566. success: res => {
  567. if (res.confirm) {
  568. that.videoList.splice(e.currentTarget.dataset.index, 1)
  569. }
  570. }
  571. })
  572. },
  573. // 操作指引
  574. onOperateIllustrateTo() {
  575. uni.navigateTo({
  576. url: '/pagesCare/Home/OperatingInstructions?helpID=' + encodeURIComponent(that.helpID)
  577. })
  578. },
  579. // 附件上传
  580. onUploadFiles(fun) {
  581. uni.showLoading({
  582. title: '上传中,请稍后',
  583. mask: true
  584. })
  585. let files = that.photoList;
  586. // 组装数据
  587. if (that.videoList.length > 0) {
  588. files = files.concat(that.videoList)
  589. }
  590. if (that.vioceList.length > 0) {
  591. files = files.concat(that.vioceList)
  592. }
  593. let pArr = [];
  594. if (files && files.length > 0) {
  595. files.forEach((file, i, array) => {
  596. pArr.push(new Promise(function(resolve, reject) {
  597. that.onUpLoadSingleFile(file, "uploadkey" + i, resolve, reject);
  598. }))
  599. });
  600. Promise.all(pArr).then(res => {
  601. uni.hideLoading();
  602. typeof fun === 'function' && fun(res);
  603. }, err => {
  604. uni.hideLoading();
  605. that.$util.msg(err.msg);
  606. })
  607. } else {
  608. uni.hideLoading();
  609. typeof fun === 'function' && fun();
  610. }
  611. },
  612. // 单个附件上传
  613. onUpLoadSingleFile(file, key, resolve, reject) {
  614. let fileObj = {
  615. fileType: file.fileType,
  616. msg: ''
  617. };
  618. switch (fileObj.fileType) {
  619. case 'vioce':
  620. fileObj.msg = '录音上传失败';
  621. break;
  622. case 'image':
  623. fileObj.msg = '图片上传失败';
  624. break;
  625. case 'video':
  626. fileObj.msg = '视频上传失败';
  627. break;
  628. default:
  629. break;
  630. }
  631. uni.uploadFile({
  632. url: that.$admin.config.upfileurl + '?source=hotline',
  633. filePath: file.tempFilePath,
  634. name: 'fileData',
  635. timeout: 10000,
  636. success: res => {
  637. if (res.statusCode == 200) {
  638. try {
  639. let data = JSON.parse(res.data);
  640. let obj = {
  641. additionId: data.result.id,
  642. duration: file.duration || 0,
  643. fileName: data.result.fileName,
  644. path: data.result.path
  645. };
  646. return resolve(obj);
  647. } catch (d) {
  648. return reject(fileObj)
  649. }
  650. } else {
  651. return reject(fileObj)
  652. }
  653. },
  654. fail: res => {
  655. return reject(fileObj)
  656. },
  657. })
  658. },
  659. // 表单验证
  660. formValidation() {
  661. if (!that.data.address) {
  662. that.$util.msg("请选择事发地点!");
  663. return false;
  664. }
  665. if (that.data.fullAddress) {
  666. if (escape(that.data.fullAddress).indexOf("%u") == -1) {
  667. that.$util.msg("请输入正确的地址信息!");
  668. return false;
  669. }
  670. }
  671. if (!that.data.description) {
  672. that.$util.msg("请输入问题描述!");
  673. return false;
  674. }
  675. if (that.photoList.length == 0 && that.videoList.length == 0) {
  676. that.$util.msg("请上传现场图片或者视频!");
  677. return false;
  678. }
  679. if (!that.data.name) {
  680. that.$util.msg("请输入姓名!");
  681. return false;
  682. }
  683. if (!that.data.phoneNumber) {
  684. that.$util.msg("请输入手机号码!");
  685. return false;
  686. }
  687. if (that.$util.e_checkPhone(that.data.phoneNumber) === false) {
  688. that.$util.msg('手机号码格式不正确!');
  689. return false;
  690. }
  691. if (that.data.isSecret == null) {
  692. that.$util.msg("请选择是否保密!");
  693. return false;
  694. }
  695. return true;
  696. },
  697. // 表单提交
  698. onSubmit(e) {
  699. if (!that.formValidation()) {
  700. return;
  701. }
  702. let params = that.data;
  703. that.onUploadFiles(function(arr) {
  704. params.files = arr || [];
  705. console.log(params);
  706. that.$admin.req({
  707. method: 'POST',
  708. url: '/api/v1/Snapshot/order',
  709. data: params
  710. }).then(res => {
  711. console.log(res);
  712. if (res) {
  713. if (res.no && res.password) {
  714. uni.showModal({
  715. title: "您的诉求已上报成功! ",
  716. content: '工单编号:' + res.no + '\r\n查询密码:' + res.password,
  717. showCancel: false,
  718. confirmText: '确定',
  719. confirmColor: '#3e6ffd',
  720. success: res => {
  721. let obj = uni.getStorageSync('userInfo');
  722. obj.userName = that.data.name;
  723. uni.setStorageSync('userInfo', obj);
  724. uni.switchTab({
  725. url: "/pages/Index/Mine"
  726. })
  727. }
  728. })
  729. } else {
  730. that.$util.msg(res.msg || "对不起,提交失败,请稍后重试!");
  731. }
  732. } else {
  733. that.$util.msg("对不起,提交失败,请稍后重试!");
  734. }
  735. });
  736. });
  737. },
  738. }
  739. }
  740. </script>
  741. <style lang="less">
  742. .container {
  743. background-color: #f7f7f7;
  744. font-size: 0;
  745. }
  746. .helpBox {
  747. padding: 20rpx;
  748. }
  749. .formBox {
  750. margin: 0;
  751. padding-bottom: 140rpx;
  752. }
  753. .fway-btnBox{
  754. position: absolute;
  755. bottom: 0;
  756. width: 100%;
  757. padding: 20rpx 0 30rpx;
  758. background-color: #f7f7f7;
  759. z-index: 99;
  760. }
  761. .fway-btn{
  762. height: 80rpx;
  763. line-height: 80rpx;
  764. font-size: 40rpx;
  765. }
  766. .hiddenDangerBox {
  767. padding: 0 20rpx;
  768. }
  769. .hiddenDangerItemBox {
  770. padding: 0;
  771. background-color: #fff;
  772. margin-top: 20rpx;
  773. box-shadow: 0rpx 5rpx 12rpx 0rpx #c7c7c7;
  774. border-radius: 10rpx;
  775. }
  776. .hiddenDangerHeader {
  777. padding: 30rpx 20rpx 20rpx;
  778. font-size: 44rpx;
  779. font-weight: bold;
  780. color: #000;
  781. }
  782. .hiddenDangerBody {
  783. padding: 0 20rpx 10rpx;
  784. }
  785. .hiddenDangerItem {
  786. margin-bottom: 20rpx;
  787. }
  788. .hiddenDangerItemHeader {
  789. padding: 10rpx 0;
  790. display: flex;
  791. justify-content: left;
  792. align-items: center;
  793. }
  794. .mustTips {
  795. width: 30rpx;
  796. font-size: 40rpx;
  797. font-weight: bold;
  798. color: #fd0101;
  799. }
  800. .itemHeaderText {
  801. color: #000;
  802. font-size: 36rpx;
  803. }
  804. .itemHeaderTips {
  805. font-size: 28rpx;
  806. color: #777;
  807. }
  808. .hiddenDangerItemBody {
  809. padding: 0;
  810. }
  811. .hiddenDangerHeaderBtn {
  812. width: calc(100% - 288rpx);
  813. display: inline-block;
  814. vertical-align: middle;
  815. text-align: right;
  816. }
  817. .reportPersonBox .fway-form-item {
  818. border-bottom: 2rpx #eaeaea solid;
  819. }
  820. .reportPersonBox .fway-form-lable {
  821. padding: 10rpx 0;
  822. width: 200rpx;
  823. color: #777;
  824. font-size: 36rpx;
  825. }
  826. .reportPersonBox .fway-form-input-inline {
  827. width: calc(100% - 200rpx);
  828. padding: 10rpx 0 0;
  829. }
  830. .reportPersonBox .fway-form-input {
  831. background-color: #fff;
  832. }
  833. .photoListBox {
  834. width: calc(100% - 20rpx);
  835. padding: 10rpx 10rpx;
  836. display: flex;
  837. justify-content: left;
  838. align-items: start;
  839. flex-wrap: wrap;
  840. align-content: start;
  841. }
  842. .photoItemBox {
  843. width: calc(25% - 20rpx);
  844. height: 130rpx;
  845. position: relative;
  846. border: 2rpx #E5E5E5 solid;
  847. border-radius: 10rpx;
  848. }
  849. .photoItemBox + .photoItemBox{
  850. margin-left: 20rpx;
  851. }
  852. .photoItemBox + .photoItemBoxsel{
  853. margin-left: 20rpx;
  854. }
  855. .photoItemBoxsel {
  856. width: calc(25% - 20rpx);
  857. height: 130rpx;
  858. position: relative;
  859. background-color: #f7f7f7;
  860. border-radius: 10rpx;
  861. display: flex;
  862. justify-content: center;
  863. align-items: center;
  864. }
  865. .photoItemImg {
  866. width: 100%;
  867. height: 100%;
  868. }
  869. .photoItemImgsel{
  870. width: 60rpx;
  871. height: 60rpx;
  872. }
  873. .closeBtn {
  874. background-color: #00000060;
  875. width: 30rpx;
  876. height: 30rpx;
  877. position: absolute;
  878. padding: 10rpx;
  879. top: 0;
  880. right: 0;
  881. }
  882. .vioceBox {
  883. display: inline-block;
  884. height: 100%;
  885. }
  886. .vioceListBox {
  887. height: 100%;
  888. }
  889. .vioceItemBox {
  890. height: 100%;
  891. width: 240rpx;
  892. }
  893. .vioceItemImgBox {
  894. display: inline-table;
  895. vertical-align: middle;
  896. width: 120rpx;
  897. padding: 6rpx 10rpx;
  898. background-color: #fff;
  899. color: #999999;
  900. border: 2rpx #ccc solid;
  901. border-radius: 10rpx;
  902. position: relative;
  903. }
  904. .vioceItemDelete {
  905. font-size: 32rpx;
  906. color: #3e6ffd;
  907. display: inline-table;
  908. vertical-align: middle;
  909. text-align: right;
  910. width: 80rpx;
  911. }
  912. .vioceItemBG {
  913. background-color: #bfbfbf;
  914. width: 0;
  915. position: absolute;
  916. left: 0;
  917. top: 0;
  918. height: 48rpx;
  919. border-radius: 10rpx;
  920. z-index: 0;
  921. }
  922. .isPlay {
  923. background-color: #F6F7F8;
  924. color: #000;
  925. }
  926. .vioceItemImg {
  927. width: 36rpx;
  928. height: 36rpx;
  929. display: inline-block;
  930. vertical-align: middle;
  931. margin-right: 20rpx;
  932. position: relative;
  933. z-index: 99;
  934. }
  935. .vioceItemDuration {
  936. color: #515151;
  937. display: inline-block;
  938. vertical-align: middle;
  939. position: relative;
  940. z-index: 99;
  941. font-size: 32rpx;
  942. }
  943. .fway-form-item {
  944. padding: 0 10rpx;
  945. }
  946. .fway-form-input {
  947. width: calc(100% - 40rpx);
  948. padding: 0 20rpx;
  949. height: 80rpx;
  950. line-height: 80rpx;
  951. font-size: 36rpx;
  952. }
  953. .fway-form-textarea {
  954. width: calc(100% - 40rpx);
  955. padding: 20rpx;
  956. height: 180rpx;
  957. font-size: 36rpx;
  958. line-height: 46rpx;
  959. }
  960. .fway-form-item .fway-form-input-select {
  961. width: auto;
  962. }
  963. .fway-form-tips {
  964. padding: 10rpx 0;
  965. }
  966. .fway-form-radioBox{
  967. font-size: 36rpx;
  968. }
  969. </style>