LivelihoodFacts.vue 28 KB

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