LivelihoodFacts.vue 28 KB

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