ReportHiddenDanger.vue 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991
  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" 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% - 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. success: (res) => {
  424. let arrPhotoData = [];
  425. let arrVideoData = [];
  426. let strPhotoErrorIndex = '';
  427. let strVideoErrorIndex = '';
  428. let strVideoErrorSizeIndex = '';
  429. res.tempFiles.forEach((item, index) => {
  430. if (item.fileType == 'image') {
  431. arrPhotoData.push(item)
  432. } else if (item.fileType == 'video') {
  433. arrVideoData.push(item)
  434. }
  435. });
  436. let strErrorTips = '';
  437. // 判断图片是否满足条件
  438. let rightPhotoData = [];
  439. arrPhotoData.forEach((item, index) => {
  440. if (item.size > 0 && item.size <= that.fileSize * 1024 * 1024) {
  441. rightPhotoData.push(item)
  442. } else {
  443. if (strPhotoErrorIndex == '') {
  444. strPhotoErrorIndex = (index + 1)
  445. } else {
  446. strPhotoErrorIndex += ',' + (index + 1)
  447. }
  448. }
  449. });
  450. if (strPhotoErrorIndex != '') {
  451. if (strErrorTips != "") {
  452. strErrorTips += '\n';
  453. }
  454. strErrorTips += '您上传的第' + strPhotoErrorIndex + '张图片超过系统文件限制大小,请重新选择上传。'
  455. }
  456. if (rightPhotoData.length > remainPhotoNum) {
  457. if (strErrorTips != "") {
  458. strErrorTips += '\n';
  459. }
  460. strErrorTips += '您选择的图片超出数量限制,仅按顺序保留。'
  461. rightPhotoData.splice(remainPhotoNum, (rightPhotoData.length - remainPhotoNum))
  462. }
  463. // 判断视频是否满足条件
  464. let rightVideoData = [];
  465. arrVideoData.forEach((item, index) => {
  466. if (item.duration > 0 && item.duration <= 60) {
  467. if (item.size > 0 && item.size <= that.fileSize * 1024 * 1024) {
  468. rightVideoData.push(item)
  469. } else {
  470. if (strVideoErrorSizeIndex == '') {
  471. strVideoErrorSizeIndex = (index + 1)
  472. } else {
  473. strVideoErrorSizeIndex += ',' + (index + 1)
  474. }
  475. }
  476. } else {
  477. if (strVideoErrorIndex == '') {
  478. strVideoErrorIndex = (index + 1)
  479. } else {
  480. strVideoErrorIndex += ',' + (index + 1)
  481. }
  482. }
  483. });
  484. if (strVideoErrorIndex != '') {
  485. if (strErrorTips != "") {
  486. strErrorTips += '\n';
  487. }
  488. strErrorTips += '您上传的第' + strVideoErrorIndex + '个视频超过支持的最大时长60s,请重新上传。'
  489. }
  490. if (strVideoErrorSizeIndex != '') {
  491. if (strErrorTips != "") {
  492. strErrorTips += '\n';
  493. }
  494. strErrorTips += '您上传的第' + strVideoErrorSizeIndex + '个视频超过系统文件限制大小,请重新选择上传。'
  495. }
  496. if (rightVideoData.length > remainVideoNum) {
  497. if (strErrorTips != "") {
  498. strErrorTips += '\n';
  499. }
  500. strErrorTips += '您选择的满足条件的视频超出数量限制,仅按顺序保留。'
  501. rightVideoData.splice(remainVideoNum, rightVideoData.length - remainVideoNum);
  502. }
  503. // 保存
  504. if (rightPhotoData.length > 0) {
  505. if (that.photoList.length != 0) {
  506. that.photoList = that.photoList.concat(rightPhotoData)
  507. } else {
  508. that.photoList = rightPhotoData
  509. }
  510. }
  511. if (rightVideoData.length > 0) {
  512. if (that.videoList.length != 0) {
  513. that.videoList = that.videoList.concat(rightVideoData)
  514. } else {
  515. that.videoList = rightVideoData
  516. }
  517. }
  518. if (strErrorTips != "") {
  519. uni.showModal({
  520. title: '提示',
  521. content: strErrorTips,
  522. showCancel: false,
  523. confirmText: '确定',
  524. confirmColor: '#3e6ffd'
  525. })
  526. }
  527. }
  528. });
  529. } else {
  530. that.$util.msg('最多上传4张图片和3段视频!');
  531. }
  532. },
  533. onPreviewImage(e) {
  534. let arrStrPhoto = [];
  535. that.photoList.forEach((item, index) => {
  536. arrStrPhoto.push(item.tempFilePath)
  537. })
  538. uni.previewImage({
  539. urls: arrStrPhoto,
  540. current: e.currentTarget.dataset.url
  541. });
  542. },
  543. onDelImg(e) {
  544. uni.showModal({
  545. content: '确定要删除吗?',
  546. confirmText: '确定',
  547. confirmColor: '#3e6ffd',
  548. success: res => {
  549. if (res.confirm) {
  550. that.photoList.splice(e.currentTarget.dataset.index, 1)
  551. }
  552. }
  553. })
  554. },
  555. onDelVideo(e) {
  556. uni.showModal({
  557. content: '确定要删除吗?',
  558. confirmText: '确定',
  559. confirmColor: '#3e6ffd',
  560. success: res => {
  561. if (res.confirm) {
  562. that.videoList.splice(e.currentTarget.dataset.index, 1)
  563. }
  564. }
  565. })
  566. },
  567. // 操作指引
  568. onOperateIllustrateTo() {
  569. uni.navigateTo({
  570. url: '/pagesBase/Home/OperatingInstructions?helpID=' + encodeURIComponent(that.helpID)
  571. })
  572. },
  573. // 附件上传
  574. onUploadFiles(fun) {
  575. uni.showLoading({
  576. title: '上传中,请稍后',
  577. mask: true
  578. })
  579. let files = that.photoList;
  580. // 组装数据
  581. if (that.videoList.length > 0) {
  582. files = files.concat(that.videoList)
  583. }
  584. if (that.vioceList.length > 0) {
  585. files = files.concat(that.vioceList)
  586. }
  587. let pArr = [];
  588. if (files && files.length > 0) {
  589. files.forEach((file, i, array) => {
  590. pArr.push(new Promise(function(resolve, reject) {
  591. that.onUpLoadSingleFile(file, "uploadkey" + i, resolve, reject);
  592. }))
  593. });
  594. Promise.all(pArr).then(res => {
  595. uni.hideLoading();
  596. typeof fun === 'function' && fun(res);
  597. }, err => {
  598. uni.hideLoading();
  599. that.$util.msg(err.msg);
  600. })
  601. } else {
  602. uni.hideLoading();
  603. typeof fun === 'function' && fun();
  604. }
  605. },
  606. // 单个附件上传
  607. onUpLoadSingleFile(file, key, resolve, reject) {
  608. let fileObj = {
  609. fileType: file.fileType,
  610. msg: ''
  611. };
  612. switch (fileObj.fileType) {
  613. case 'vioce':
  614. fileObj.msg = '录音上传失败';
  615. break;
  616. case 'image':
  617. fileObj.msg = '图片上传失败';
  618. break;
  619. case 'video':
  620. fileObj.msg = '视频上传失败';
  621. break;
  622. default:
  623. break;
  624. }
  625. uni.uploadFile({
  626. url: that.$admin.config.upfileurl + '?source=hotline',
  627. filePath: file.tempFilePath,
  628. name: 'fileData',
  629. timeout: 10000,
  630. success: res => {
  631. if (res.statusCode == 200) {
  632. try {
  633. let data = JSON.parse(res.data);
  634. let obj = {
  635. additionId: data.result.id,
  636. duration: file.duration || 0,
  637. fileName: data.result.fileName,
  638. path: data.result.path
  639. };
  640. return resolve(obj);
  641. } catch (d) {
  642. return reject(fileObj)
  643. }
  644. } else {
  645. return reject(fileObj)
  646. }
  647. },
  648. fail: res => {
  649. return reject(fileObj)
  650. },
  651. })
  652. },
  653. // 表单验证
  654. formValidation() {
  655. if (!that.data.address) {
  656. that.$util.msg("请选择事发地点!");
  657. return false;
  658. }
  659. if (that.data.fullAddress) {
  660. if (escape(that.data.fullAddress).indexOf("%u") == -1) {
  661. that.$util.msg("请输入正确的地址信息!");
  662. return false;
  663. }
  664. }
  665. if (!that.data.description) {
  666. that.$util.msg("请输入问题描述!");
  667. return false;
  668. }
  669. if (that.photoList.length == 0 && that.videoList.length == 0) {
  670. that.$util.msg("请上传现场图片或者视频!");
  671. return false;
  672. }
  673. if (!that.data.name) {
  674. that.$util.msg("请输入姓名!");
  675. return false;
  676. }
  677. if (!that.data.phoneNumber) {
  678. that.$util.msg("请输入手机号码!");
  679. return false;
  680. }
  681. if (that.$util.e_checkPhone(that.data.phoneNumber) === false) {
  682. that.$util.msg('手机号码格式不正确!');
  683. return false;
  684. }
  685. if (that.data.isSecret == null) {
  686. that.$util.msg("请选择是否保密!");
  687. return false;
  688. }
  689. return true;
  690. },
  691. // 表单提交
  692. onSubmit(e) {
  693. if (!that.formValidation()) {
  694. return;
  695. }
  696. let params = that.data;
  697. that.onUploadFiles(function(arr) {
  698. params.files = arr || [];
  699. // console.log(params);
  700. that.$admin.req({
  701. method: 'POST',
  702. url: '/api/v1/Snapshot/order',
  703. data: params
  704. }).then(res => {
  705. if (res) {
  706. if (res.no && res.password) {
  707. uni.showModal({
  708. title: "您的诉求已上报成功! ",
  709. content: '工单编号:' + res.no + '\r\n查询密码:' + res.password,
  710. showCancel: false,
  711. confirmText: '确定',
  712. confirmColor: '#3e6ffd',
  713. success: res => {
  714. let obj = uni.getStorageSync('userInfo');
  715. obj.userName = that.data.name;
  716. uni.setStorageSync('userInfo', obj);
  717. uni.switchTab({
  718. url: "/pages/Index/Mine"
  719. })
  720. }
  721. })
  722. } else {
  723. that.$util.msg(res.msg || "对不起,提交失败,请稍后重试!");
  724. }
  725. } else {
  726. that.$util.msg("对不起,提交失败,请稍后重试!");
  727. }
  728. });
  729. });
  730. },
  731. }
  732. }
  733. </script>
  734. <style lang="less">
  735. .container {
  736. background-color: #f7f7f7;
  737. font-size: 0;
  738. }
  739. .helpBox {
  740. padding: 20rpx;
  741. }
  742. .formBox {
  743. margin: 0;
  744. padding-bottom: 140rpx;
  745. }
  746. .fway-btnBox{
  747. position: absolute;
  748. bottom: 0;
  749. width: 100%;
  750. padding: 20rpx 0 30rpx;
  751. background-color: #f7f7f7;
  752. z-index: 99;
  753. }
  754. .hiddenDangerBox {
  755. padding: 0 20rpx;
  756. }
  757. .hiddenDangerItemBox {
  758. padding: 0;
  759. background-color: #fff;
  760. margin-top: 20rpx;
  761. box-shadow: 0rpx 5rpx 12rpx 0rpx #c7c7c7;
  762. border-radius: 10rpx;
  763. }
  764. .hiddenDangerHeader {
  765. padding: 30rpx 20rpx 20rpx;
  766. font-size: 30rpx;
  767. font-weight: bold;
  768. color: #000;
  769. }
  770. .hiddenDangerBody {
  771. padding: 0 20rpx 10rpx;
  772. }
  773. .hiddenDangerItem {
  774. margin-bottom: 20rpx;
  775. }
  776. .hiddenDangerItemHeader {
  777. padding: 10rpx 0;
  778. display: flex;
  779. justify-content: left;
  780. align-items: center;
  781. height: 32rpx;
  782. }
  783. .mustTips {
  784. width: 30rpx;
  785. font-size: 32rpx;
  786. font-weight: bold;
  787. color: #fd0101;
  788. }
  789. .itemHeaderText {
  790. color: #000;
  791. font-size: 28rpx;
  792. }
  793. .itemHeaderTips {
  794. font-size: 24rpx;
  795. color: #777;
  796. }
  797. .hiddenDangerItemBody {
  798. padding: 0;
  799. }
  800. .hiddenDangerHeaderBtn {
  801. width: calc(100% - 288rpx);
  802. display: inline-block;
  803. vertical-align: middle;
  804. text-align: right;
  805. }
  806. .reportPersonBox .fway-form-item {
  807. border-bottom: 2rpx #eaeaea solid;
  808. }
  809. .reportPersonBox .fway-form-lable {
  810. padding: 10rpx 0;
  811. width: 150rpx;
  812. color: #777;
  813. }
  814. .reportPersonBox .fway-form-input-inline {
  815. width: calc(100% - 150rpx);
  816. padding: 10rpx 0 0;
  817. }
  818. .reportPersonBox .fway-form-input {
  819. background-color: #fff;
  820. }
  821. .photoListBox {
  822. width: calc(100% - 20rpx);
  823. padding: 10rpx 10rpx;
  824. display: flex;
  825. justify-content: left;
  826. align-items: start;
  827. flex-wrap: wrap;
  828. align-content: start;
  829. }
  830. .photoItemBox {
  831. width: calc(25% - 20rpx);
  832. height: 130rpx;
  833. position: relative;
  834. border: 2rpx #E5E5E5 solid;
  835. border-radius: 10rpx;
  836. }
  837. .photoItemBox + .photoItemBox{
  838. margin-left: 20rpx;
  839. }
  840. .photoItemBox + .photoItemBoxsel{
  841. margin-left: 20rpx;
  842. }
  843. .photoItemBoxsel {
  844. width: calc(25% - 20rpx);
  845. height: 130rpx;
  846. position: relative;
  847. background-color: #f7f7f7;
  848. border-radius: 10rpx;
  849. display: flex;
  850. justify-content: center;
  851. align-items: center;
  852. }
  853. .photoItemImg {
  854. width: 100%;
  855. height: 100%;
  856. }
  857. .photoItemImgsel{
  858. width: 60rpx;
  859. height: 60rpx;
  860. }
  861. .closeBtn {
  862. background-color: #00000060;
  863. width: 30rpx;
  864. height: 30rpx;
  865. position: absolute;
  866. padding: 10rpx;
  867. top: 0;
  868. right: 0;
  869. }
  870. .vioceBox {
  871. display: inline-block;
  872. height: 100%;
  873. }
  874. .vioceListBox {
  875. height: 100%;
  876. }
  877. .vioceItemBox {
  878. height: 100%;
  879. width: 220rpx;
  880. }
  881. .vioceItemImgBox {
  882. display: inline-table;
  883. vertical-align: middle;
  884. width: 100rpx;
  885. padding: 6rpx 10rpx;
  886. background-color: #fff;
  887. color: #999999;
  888. border: 2rpx #ccc solid;
  889. border-radius: 10rpx;
  890. position: relative;
  891. }
  892. .vioceItemDelete {
  893. font-size: 28rpx;
  894. color: #3e6ffd;
  895. display: inline-table;
  896. vertical-align: middle;
  897. text-align: right;
  898. width: 80rpx;
  899. }
  900. .vioceItemBG {
  901. background-color: #bfbfbf;
  902. width: 0;
  903. position: absolute;
  904. left: 0;
  905. top: 0;
  906. height: 44rpx;
  907. border-radius: 10rpx;
  908. z-index: 0;
  909. }
  910. .isPlay {
  911. background-color: #F6F7F8;
  912. color: #000;
  913. }
  914. .vioceItemImg {
  915. width: 32rpx;
  916. height: 32rpx;
  917. display: inline-block;
  918. vertical-align: middle;
  919. margin-right: 20rpx;
  920. position: relative;
  921. z-index: 99;
  922. }
  923. .vioceItemDuration {
  924. color: #515151;
  925. display: inline-block;
  926. vertical-align: middle;
  927. position: relative;
  928. z-index: 99;
  929. }
  930. .fway-form-item {
  931. padding: 0 10rpx;
  932. }
  933. .fway-form-input {
  934. width: calc(100% - 40rpx);
  935. padding: 0 20rpx;
  936. }
  937. .fway-form-textarea {
  938. width: calc(100% - 40rpx);
  939. padding: 20rpx;
  940. height: 120rpx;
  941. }
  942. .fway-form-item .fway-form-input-select {
  943. width: auto;
  944. }
  945. .fway-form-tips {
  946. padding: 10rpx 0;
  947. }
  948. </style>