ReportHiddenDanger.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992
  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" :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%;">
  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" 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" disabled class="fway-form-input" placeholder="请录入上报人的联系电话" v-model="data.phoneNumber" />
  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% - 170rpx);">
  119. <radio-group @change="onIsSecretChange">
  120. <label class="fway-form-radioBox">
  121. <radio class="fway-form-radio" style="transform:scale(0.8)" 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(0.8)" 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. vioceBtnStyle: {
  181. width: '200rpx',
  182. height: '48rpx',
  183. borderRadius: '60rpx',
  184. backgroundColor: '#3e6ffd',
  185. color: '#fff',
  186. border: 'none',
  187. padding: '0 10rpx',
  188. permisionState: false
  189. },
  190. vioceItemBGWidth: 0,
  191. focusID: '',
  192. fileSize: 40, // 单位M
  193. helpID: '',
  194. helpTips: '',
  195. }
  196. },
  197. onLoad(option) {
  198. that = this;
  199. that.data.industryId = decodeURIComponent(option.id);
  200. qqMapsdk = new qqMap({
  201. key: 'TE4BZ-ZFEAT-45CX3-VPZ3R-GOLS6-EGF54'
  202. });
  203. that.onGetBaseData();
  204. },
  205. onShow() {
  206. that.data.phoneNumber = that.data.phoneNumber ? that.data.phoneNumber : uni.getStorageSync('userInfo').userTel || '';
  207. that.data.name = that.data.name ? that.data.name : uni.getStorageSync('userInfo').userName || '';
  208. },
  209. methods: {
  210. // 获取作业类型数据
  211. onGetBaseData(fun){
  212. that.$admin.req({
  213. method: 'GET',
  214. url: '/api/v1/Snapshot/industry/base/' + that.data.industryId
  215. }).then(res => {
  216. if (res) {
  217. // that.data.IndustryName = res.industry.name;
  218. that.helpID = res.bulletinId;
  219. that.helpTips = res.industry.txtHelpRemarks || '填报有疑问?点击查看更详细的操作指引';
  220. } else {
  221. that.$util.msg('服务异常,请稍后重试!');
  222. }
  223. typeof fun === 'function' && fun();
  224. })
  225. },
  226. // 监听input框点击设置焦点
  227. inputTap(e) {
  228. if(that.focusID != e.currentTarget.dataset.focus){
  229. uni.hideKeyboard();
  230. setTimeout(function() {
  231. that.focusID = e.currentTarget.dataset.focus
  232. }, 200)
  233. }
  234. },
  235. onIsSecretChange(e) {
  236. that.data.isSecret = e.detail.value == '1' ? true : false
  237. },
  238. // 验证地理位置是否在自贡市
  239. onGetAddress(latitude, longitude, fun) {
  240. qqMapsdk.reverseGeocoder({
  241. location: {
  242. latitude: latitude,
  243. longitude: longitude
  244. },
  245. success(res) {
  246. // 地址信息
  247. if (res.result.address_component.city != '自贡市') {
  248. typeof fun === 'function' && fun(false);
  249. } else {
  250. typeof fun === 'function' && fun(res.result);
  251. }
  252. },
  253. fail: function(error) {
  254. console.error(error);
  255. typeof fun === 'function' && fun(false);
  256. }
  257. });
  258. },
  259. onMapTo() {
  260. // 判断微信位置是否开启
  261. let appAuthorizeSetting = uni.getAppAuthorizeSetting();
  262. if (appAuthorizeSetting.locationAuthorized != 'authorized') {
  263. that.$util.msg("定位失败,请在手机设置中打开微信位置权限");
  264. return;
  265. }
  266. uni.chooseLocation({
  267. success: function(res) {
  268. if (res.name) {
  269. that.onGetAddress(res.latitude, res.longitude, function(data) {
  270. if (data) {
  271. console.log(data);
  272. that.data.longitude = res.longitude;
  273. that.data.latitude = res.latitude;
  274. that.data.areaCode = data.ad_info.adcode;
  275. that.data.province = data.address_component.province;
  276. that.data.city = data.address_component.city;
  277. that.data.county = data.address_component.district;
  278. that.data.town = data.address_reference.town.title;
  279. that.data.street = data.address_component.street;
  280. // that.data.address = data.address;
  281. if (res.address) {
  282. let address = res.address;
  283. try {
  284. address = address.replace('四川省自贡市', '');
  285. that.data.address = res.name + '(' + address + ')';
  286. } catch (d) {
  287. that.data.address = res.name + '(' + address + ')';
  288. }
  289. } else {
  290. that.data.address = res.name;
  291. }
  292. } else {
  293. that.$util.msg("选择的地点不属于自贡市行政管辖范围,请重新确认事发地点");
  294. }
  295. })
  296. } else {
  297. that.$util.msg("事发地点定位失败,请重新选择");
  298. }
  299. },
  300. fail() {
  301. that.$util.msg("事发地点定位失败,请重新选择");
  302. }
  303. });
  304. },
  305. OnVioceStart() {
  306. // 开始录音
  307. },
  308. OnVioceEnd(e) {
  309. if (e.duration / 1000 < 10) {
  310. that.$util.msg('您的录音不足10s,请重新点击开始录音');
  311. return;
  312. }
  313. if (e.fileSize * 1 > that.fileSize * 1024 * 1024) {
  314. that.$util.msg('您的录音超过了系统文件限制大小,请重新点击开始录音');
  315. return;
  316. }
  317. that.vioceList.push({
  318. tempFilePath: e.tempFilePath,
  319. duration: e.duration,
  320. fileSize: e.fileSize,
  321. fileType: 'vioce',
  322. isPlay: false
  323. });
  324. // 结束录音并处理得到的录音文件
  325. // event中,app端仅有tempFilePath字段,微信小程序还有duration和fileSize两个字段
  326. },
  327. OnVioceCancel() {
  328. // 用户取消录音
  329. that.$util.msg('您已取消录音');
  330. },
  331. onPlayVioce(src) {
  332. if (src) {
  333. let indexVioce = '';
  334. that.vioceList.forEach((item, index) => {
  335. if (item.tempFilePath == src) {
  336. indexVioce = index;
  337. that.vioceList[index].isPlay = true;
  338. that.$set(that.vioceList, index, that.vioceList[index]);
  339. }
  340. })
  341. innerAudioContext.src = src;
  342. let vioceInterval = '';
  343. let vioceTime = 0;
  344. innerAudioContext.play();
  345. innerAudioContext.onPlay(function() {
  346. // 定时器设置背景色宽度
  347. vioceInterval = setInterval(() => {
  348. vioceTime += 100;
  349. let numTime = (vioceTime / that.vioceList[indexVioce].duration).toFixed(3) *
  350. 100;
  351. that.vioceItemBGWidth = numTime > 100 ? 100 : numTime
  352. }, 100)
  353. })
  354. innerAudioContext.onEnded(function() {
  355. that.vioceList[indexVioce].isPlay = false;
  356. that.$set(that.vioceList, indexVioce, that.vioceList[indexVioce]);
  357. clearInterval(vioceInterval);
  358. that.vioceItemBGWidth = 0
  359. })
  360. }
  361. },
  362. onDeleteVioce(src) {
  363. let isPlay = false;
  364. that.vioceList.forEach((item, index) => {
  365. if (item.tempFilePath == src) {
  366. if (that.vioceList[index].isPlay == true){
  367. isPlay = true;
  368. }
  369. }
  370. });
  371. if (isPlay){
  372. that.$util.msg('录音正在播放,请稍后删除!');
  373. return;
  374. }
  375. uni.showModal({
  376. content: '确定要删除吗?',
  377. confirmText: '确定',
  378. confirmColor: '#3e6ffd',
  379. success: res => {
  380. if (res.confirm) {
  381. let deleteIndex = -1;
  382. that.vioceList.forEach((item, index) => {
  383. if (item.tempFilePath == src) {
  384. deleteIndex = index;
  385. }
  386. })
  387. that.vioceList.splice(deleteIndex, 1);
  388. }
  389. }
  390. });
  391. },
  392. // 选择图片和视频
  393. onChooseImageVideo(type) {
  394. // 附件类型
  395. let mediaType = type;
  396. // 图片、视频数量限制剩余数量
  397. let remainPhotoNum = 4 - that.photoList.length;
  398. let remainVideoNum = 3 - that.videoList.length;
  399. // 选择限制数量
  400. // let count = remainPhotoNum + remainVideoNum;
  401. let count = 0;
  402. if (type == 'image'){
  403. count = remainPhotoNum;
  404. }else if (type == 'video'){
  405. count = remainVideoNum;
  406. }
  407. // if (remainPhotoNum > 0 && remainVideoNum > 0) {
  408. // mediaType = ['mix'];
  409. // } else {
  410. // if (remainPhotoNum > 0) {
  411. // mediaType = ['image'];
  412. // }
  413. // if (remainVideoNum > 0) {
  414. // mediaType = ['video'];
  415. // }
  416. // }
  417. if (count > 0) {
  418. uni.chooseMedia({
  419. count: count, //默认9
  420. mediaType: mediaType,
  421. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  422. // sourceType: ['album', 'camera'], //从相册选择
  423. sourceType: ['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: '/pagesBase/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.address) {
  657. that.$util.msg("请选择事发地点!");
  658. return false;
  659. }
  660. if (that.data.fullAddress) {
  661. if (escape(that.data.fullAddress).indexOf("%u") == -1) {
  662. that.$util.msg("请输入正确的地址信息!");
  663. return false;
  664. }
  665. }
  666. if (!that.data.description) {
  667. that.$util.msg("请输入问题描述!");
  668. return false;
  669. }
  670. if (that.photoList.length == 0 && that.videoList.length == 0) {
  671. that.$util.msg("请上传现场图片或者视频!");
  672. return false;
  673. }
  674. if (!that.data.name) {
  675. that.$util.msg("请输入姓名!");
  676. return false;
  677. }
  678. if (!that.data.phoneNumber) {
  679. that.$util.msg("请输入手机号码!");
  680. return false;
  681. }
  682. if (that.$util.e_checkPhone(that.data.phoneNumber) === false) {
  683. that.$util.msg('手机号码格式不正确!');
  684. return false;
  685. }
  686. if (that.data.isSecret == null) {
  687. that.$util.msg("请选择是否保密!");
  688. return false;
  689. }
  690. return true;
  691. },
  692. // 表单提交
  693. onSubmit(e) {
  694. if (!that.formValidation()) {
  695. return;
  696. }
  697. let params = that.data;
  698. that.onUploadFiles(function(arr) {
  699. params.files = arr || [];
  700. // console.log(params);
  701. that.$admin.req({
  702. method: 'POST',
  703. url: '/api/v1/Snapshot/order',
  704. data: params
  705. }).then(res => {
  706. if (res) {
  707. if (res.no && res.password) {
  708. uni.showModal({
  709. title: "您的诉求已上报成功! ",
  710. content: '工单编号:' + res.no + '\r\n查询密码:' + res.password,
  711. showCancel: false,
  712. confirmText: '确定',
  713. confirmColor: '#3e6ffd',
  714. success: res => {
  715. let obj = uni.getStorageSync('userInfo');
  716. obj.userName = that.data.name;
  717. uni.setStorageSync('userInfo', obj);
  718. uni.switchTab({
  719. url: "/pages/Index/Mine"
  720. })
  721. }
  722. })
  723. } else {
  724. that.$util.msg(res.msg || "对不起,提交失败,请稍后重试!");
  725. }
  726. } else {
  727. that.$util.msg("对不起,提交失败,请稍后重试!");
  728. }
  729. });
  730. });
  731. },
  732. }
  733. }
  734. </script>
  735. <style lang="less">
  736. .container {
  737. background-color: #f7f7f7;
  738. font-size: 0;
  739. }
  740. .helpBox {
  741. padding: 20rpx;
  742. }
  743. .formBox {
  744. margin: 0;
  745. padding-bottom: 140rpx;
  746. }
  747. .fway-btnBox{
  748. position: absolute;
  749. bottom: 0;
  750. width: 100%;
  751. padding: 20rpx 0 30rpx;
  752. background-color: #f7f7f7;
  753. z-index: 99;
  754. }
  755. .hiddenDangerBox {
  756. padding: 0 20rpx;
  757. }
  758. .hiddenDangerItemBox {
  759. padding: 0;
  760. background-color: #fff;
  761. margin-top: 20rpx;
  762. box-shadow: 0rpx 5rpx 12rpx 0rpx #c7c7c7;
  763. border-radius: 10rpx;
  764. }
  765. .hiddenDangerHeader {
  766. padding: 30rpx 20rpx 20rpx;
  767. font-size: 30rpx;
  768. font-weight: bold;
  769. color: #000;
  770. }
  771. .hiddenDangerBody {
  772. padding: 0 20rpx 10rpx;
  773. }
  774. .hiddenDangerItem {
  775. margin-bottom: 20rpx;
  776. }
  777. .hiddenDangerItemHeader {
  778. padding: 10rpx 0;
  779. display: flex;
  780. justify-content: left;
  781. align-items: center;
  782. height: 32rpx;
  783. }
  784. .mustTips {
  785. width: 30rpx;
  786. font-size: 32rpx;
  787. font-weight: bold;
  788. color: #fd0101;
  789. }
  790. .itemHeaderText {
  791. color: #000;
  792. font-size: 28rpx;
  793. }
  794. .itemHeaderTips {
  795. font-size: 24rpx;
  796. color: #fd0101;
  797. }
  798. .hiddenDangerItemBody {
  799. padding: 0;
  800. }
  801. .hiddenDangerHeaderBtn {
  802. width: calc(100% - 288rpx);
  803. display: inline-block;
  804. vertical-align: middle;
  805. text-align: right;
  806. }
  807. .reportPersonBox .fway-form-item {
  808. border-bottom: 2rpx #eaeaea solid;
  809. }
  810. .reportPersonBox .fway-form-lable {
  811. padding: 10rpx 0;
  812. width: 150rpx;
  813. color: #777;
  814. }
  815. .reportPersonBox .fway-form-input-inline {
  816. width: calc(100% - 150rpx);
  817. padding: 10rpx 0 0;
  818. }
  819. .reportPersonBox .fway-form-input {
  820. background-color: #fff;
  821. }
  822. .photoListBox {
  823. width: calc(100% - 20rpx);
  824. padding: 10rpx 10rpx;
  825. display: flex;
  826. justify-content: left;
  827. align-items: start;
  828. flex-wrap: wrap;
  829. align-content: start;
  830. }
  831. .photoItemBox {
  832. width: calc(25% - 20rpx);
  833. height: 130rpx;
  834. position: relative;
  835. border: 2rpx #E5E5E5 solid;
  836. border-radius: 10rpx;
  837. }
  838. .photoItemBox + .photoItemBox{
  839. margin-left: 20rpx;
  840. }
  841. .photoItemBox + .photoItemBoxsel{
  842. margin-left: 20rpx;
  843. }
  844. .photoItemBoxsel {
  845. width: calc(25% - 20rpx);
  846. height: 130rpx;
  847. position: relative;
  848. background-color: #f7f7f7;
  849. border-radius: 10rpx;
  850. display: flex;
  851. justify-content: center;
  852. align-items: center;
  853. }
  854. .photoItemImg {
  855. width: 100%;
  856. height: 100%;
  857. }
  858. .photoItemImgsel{
  859. width: 60rpx;
  860. height: 60rpx;
  861. }
  862. .closeBtn {
  863. background-color: #00000060;
  864. width: 30rpx;
  865. height: 30rpx;
  866. position: absolute;
  867. padding: 10rpx;
  868. top: 0;
  869. right: 0;
  870. }
  871. .vioceBox {
  872. display: inline-block;
  873. height: 100%;
  874. }
  875. .vioceListBox {
  876. height: 100%;
  877. }
  878. .vioceItemBox {
  879. height: 100%;
  880. width: 220rpx;
  881. }
  882. .vioceItemImgBox {
  883. display: inline-table;
  884. vertical-align: middle;
  885. width: 100rpx;
  886. padding: 6rpx 10rpx;
  887. background-color: #fff;
  888. color: #999999;
  889. border: 2rpx #ccc solid;
  890. border-radius: 10rpx;
  891. position: relative;
  892. }
  893. .vioceItemDelete {
  894. font-size: 28rpx;
  895. color: #3e6ffd;
  896. display: inline-table;
  897. vertical-align: middle;
  898. text-align: right;
  899. width: 80rpx;
  900. }
  901. .vioceItemBG {
  902. background-color: #bfbfbf;
  903. width: 0;
  904. position: absolute;
  905. left: 0;
  906. top: 0;
  907. height: 44rpx;
  908. border-radius: 10rpx;
  909. z-index: 0;
  910. }
  911. .isPlay {
  912. background-color: #F6F7F8;
  913. color: #000;
  914. }
  915. .vioceItemImg {
  916. width: 32rpx;
  917. height: 32rpx;
  918. display: inline-block;
  919. vertical-align: middle;
  920. margin-right: 20rpx;
  921. position: relative;
  922. z-index: 99;
  923. }
  924. .vioceItemDuration {
  925. color: #515151;
  926. display: inline-block;
  927. vertical-align: middle;
  928. position: relative;
  929. z-index: 99;
  930. }
  931. .fway-form-item {
  932. padding: 0 10rpx;
  933. }
  934. .fway-form-input {
  935. width: calc(100% - 40rpx);
  936. padding: 0 20rpx;
  937. }
  938. .fway-form-textarea {
  939. width: calc(100% - 40rpx);
  940. padding: 20rpx;
  941. height: 120rpx;
  942. }
  943. .fway-form-item .fway-form-input-select {
  944. width: auto;
  945. }
  946. .fway-form-tips {
  947. padding: 10rpx 0;
  948. }
  949. </style>