repair.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <template>
  2. <view>
  3. <image src="/static/icon/background.png" mode="" class="background"></image>
  4. <view style="padding-top: 100rpx;">
  5. <view class="align-items">
  6. <back></back>
  7. </view>
  8. <view class="project-content">
  9. <view class="font-forty-eight blue">
  10. 项目名称:{{name}}
  11. </view>
  12. <view class="font-forty-eight blue">
  13. 项目地址:{{address}}
  14. </view>
  15. </view>
  16. <view>
  17. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('xiaoqu')">
  18. {{house ? house :'选择小区'}}
  19. <u-popup v-model="pop" mode="bottom" height="1000rpx">
  20. <view style="margin: 20rpx;">
  21. <u-search placeholder="请输入搜索内容" v-model="keyword" :action-style="{'font-size':'40rpx'}" @custom="searchinfo(selectType)"></u-search>
  22. </view>
  23. <view>
  24. <scroll-view scroll-y="true" style="height: 600rpx; text-align: center;">
  25. <view v-for="(item,index) in chooseHouseList" :key="item.value" >
  26. <view :class="current === index ? 'active' : '' " style="color: #000000;" @click="active(item,index)">
  27. {{item.label}}
  28. </view>
  29. </view>
  30. </scroll-view>
  31. <view class="">
  32. <button type="default" class="font-fifty-six" @click="search(selectType)">确定</button>
  33. </view>
  34. <view class="">
  35. <button type="default" @click="pop = false;" class="font-fifty-six">取消</button>
  36. </view>
  37. </view>
  38. </u-popup>
  39. </view>
  40. </view>
  41. <view>
  42. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('louyu')">
  43. {{bulid ? bulid : '选择楼宇'}}
  44. </view>
  45. </view>
  46. <view>
  47. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('danyuan')">
  48. {{unit ? unit : '选择单元'}}
  49. </view>
  50. </view>
  51. <view>
  52. <view class="font-fifty-six SourceHanSansCN choose" @click="openHouse('menpai')">
  53. {{houseNumber ? houseNumber : '选择门牌'}}
  54. </view>
  55. </view>
  56. <!-- <view v-if="photo.length >= 1">
  57. <view class="flex" v-for="(item,index) in photo" :key="index">
  58. <image :src="item" mode="" class="project-img"></image>
  59. </view>
  60. </view> -->
  61. <view class="upload">
  62. <text class="font-forty SourceHanSansCN">备注:</text>
  63. <textarea value="" placeholder="请输入备注" v-model="remark"/>
  64. </view>
  65. <view class="" style="display: flex; flex-wrap: wrap; margin: 0 55rpx;">
  66. <image src="/static/icon/chooseimg.png" mode="" style="width: 190rpx; height: 190rpx; margin: 0 12rpx; "
  67. @click="choose()"></image>
  68. <view v-for="(item,index) in imgArr" :key="index" style="position: relative;">
  69. <view v-if="item.substring(item.length - 3) == 'png' || item.substring(item.length - 3) == 'jpg' ">
  70. <image :src="item" mode=""
  71. style="width: 190rpx; height: 190rpx; margin: 0 20rpx;" @click="showPhoto(index)">
  72. </image>
  73. </view>
  74. <view v-else>
  75. <video :src="item"
  76. style="width: 190rpx; height: 190rpx; margin: 0 20rpx;"></video>
  77. </view>
  78. <view @click="remove(index)" style="position: absolute; top: 0; right: 14rpx; border-radius: 50%; background-color: #FF0000;">
  79. <u-icon name="close" color="#FFFFFF" size="35" ></u-icon>
  80. </view>
  81. </view>
  82. </view>
  83. <view class="project background-color1 font-sixty-four white" @click="updatePhoto()">
  84. 确定上传
  85. </view>
  86. </view>
  87. </view>
  88. </template>
  89. <script>
  90. import service from '@/api/index.js'
  91. export default {
  92. data() {
  93. return {
  94. action: this.$HTTP.webUrl + `/obs`,
  95. headers: {
  96. MAuthorization: "wxBearer " + uni.getStorageSync('token')
  97. },
  98. url: [],
  99. id: 0,
  100. name: '',
  101. address: '',
  102. photo: [],
  103. uploading: false,
  104. imgArr: [],
  105. progress: 0 ,//图片或视频上传百分比
  106. pop:false,
  107. housename:'',
  108. houseid:0,
  109. buildid:0,
  110. unitid:0,
  111. numberid:0,
  112. houseShow: false,
  113. current:-1,
  114. chooseHouseList: [],
  115. house: '选择小区',
  116. bulid: '选择楼宇',
  117. unit: '选择单元',
  118. houseNumber: '选择门牌',
  119. serviceType:'',
  120. housedata:0,
  121. remark:'',
  122. keyword:'',
  123. loading:false
  124. }
  125. },
  126. onLoad(e) {
  127. console.log(e)
  128. this.id = e.id;
  129. this.name = e.name;
  130. this.address = e.address
  131. // this.getEngineDetail();
  132. },
  133. methods: {
  134. showPhoto(index){
  135. uni.previewImage({
  136. current:index,
  137. urls:this.imgArr,
  138. })
  139. },
  140. updatePhoto() {
  141. if (this.housedata == 0 || this.housedata == null) {
  142. this.$UTILS.showPrompt('请选择门牌号!')
  143. return
  144. }
  145. if(this.imgArr.length <= 0) {
  146. this.$UTILS.showPrompt('请上传照片!')
  147. return
  148. }
  149. if(this.loading == false) {
  150. this.$UTILS.showPrompt('照片或视频未上传完毕,无法提交!')
  151. return
  152. }
  153. let param = {
  154. // photo: this.imgArr,
  155. picUrl: this.imgArr,
  156. serviceType: this.id,
  157. houseId: this.housedata,
  158. remark:this.remark
  159. }
  160. console.log('param', param)
  161. // this.$UTILS.showPrompt('提交成功!')
  162. service.submitOrder(param).then(res => {
  163. this.$UTILS.showPrompt('提交成功!')
  164. this.houseNumber = null;
  165. this.imgArr = null;
  166. }).catch(e => {
  167. this.$UTILS.showPrompt('提交失败!')
  168. console.error(e)
  169. })
  170. },
  171. //获取小区
  172. getArea() {
  173. service.getArea().then(res => {
  174. this.chooseHouseList = [];
  175. res.forEach((item, index) => {
  176. this.chooseHouseList.push({
  177. value: item.id,
  178. label: item.name,
  179. selectType:'xiaoqu'
  180. })
  181. })
  182. })
  183. },
  184. searchinfo(selectType){
  185. if(selectType == 'xiaoqu'){
  186. console.log('ssss',this.selectType)
  187. service.getArea({name:this.keyword}).then(res => {
  188. this.chooseHouseList = [];
  189. res.forEach((item, index) => {
  190. this.chooseHouseList.push({
  191. value: item.id,
  192. label: item.name,
  193. selectType:'xiaoqu'
  194. })
  195. })
  196. })
  197. this.keyword = '';
  198. }else if(selectType == 'louyu'){
  199. console.log('ssss',this.selectType)
  200. service.getBuilding({areaId: this.houseid,name:this.keyword}).then(res => {
  201. this.chooseHouseList = [];
  202. res.forEach((item, index) => {
  203. this.chooseHouseList.push({
  204. value: item.id,
  205. label: item.name,
  206. selectType:'louyu'
  207. })
  208. })
  209. })
  210. this.keyword = '';
  211. }else if(selectType == 'danyuan'){
  212. console.log('ssss',this.selectType)
  213. service.getUnit({buildingId: this.buildid,name:this.keyword}).then(res => {
  214. this.chooseHouseList = [];
  215. res.forEach((item, index) => {
  216. this.chooseHouseList.push({
  217. value: item.id,
  218. label: item.name,
  219. selectType:'danyuan'
  220. })
  221. })
  222. })
  223. this.keyword = '';
  224. }else if(selectType == 'menpai'){
  225. console.log('ssss',this.selectType)
  226. service.getAllHouse({unitId: this.unitid,name:this.keyword}).then(res => {
  227. this.chooseHouseList = [];
  228. res.forEach((item, index) => {
  229. this.chooseHouseList.push({
  230. value: item.id,
  231. label: item.name,
  232. selectType:'menpai'
  233. })
  234. })
  235. })
  236. this.keyword = '';
  237. }
  238. },
  239. openHouse(selectType) {
  240. if(selectType === 'xiaoqu'){
  241. //选择小区
  242. this.selectType = 'xiaoqu'
  243. this.getArea();
  244. }else if(selectType === 'louyu'){
  245. //选择楼宇
  246. this.selectType = 'louyu'
  247. this.housename = null;
  248. this.buildid = 0;
  249. service.getBuilding({areaId: this.houseid}).then(res => {
  250. this.chooseHouseList = [];
  251. res.forEach(item => {
  252. this.chooseHouseList.push({
  253. value: item.id,
  254. label: item.name,
  255. selectType:'louyu'
  256. })
  257. })
  258. })
  259. }else if(selectType === 'danyuan'){
  260. //选择单元
  261. this.selectType = 'danyuan'
  262. this.housename = null;
  263. this.unitid = 0;
  264. service.getUnit({buildingId: this.buildid}).then(res => {
  265. this.chooseHouseList = [];
  266. res.forEach(item => {
  267. this.chooseHouseList.push({
  268. value: item.id,
  269. label: item.name,
  270. selectType:'danyuan'
  271. })
  272. })
  273. })
  274. }else if(selectType === 'menpai'){
  275. //选择门牌
  276. console.log('menpai',this.numberid)
  277. this.selectType = 'menpai'
  278. this.housename = null;
  279. this.numberid = null;
  280. service.getAllHouse({unitId: this.unitid}).then(res => {
  281. this.chooseHouseList = [];
  282. res.forEach(item => {
  283. this.chooseHouseList.push({
  284. value: item.id,
  285. label: item.name,
  286. selectType:'menpai'
  287. })
  288. })
  289. })
  290. }
  291. this.pop = !this.pop;
  292. },
  293. active(item,index){
  294. this.current = index;
  295. this.housename = item.label;
  296. if(item.selectType == 'xiaoqu'){
  297. this.houseid = item.value;
  298. }else if(item.selectType == 'louyu'){
  299. this.buildid = item.value;
  300. }else if(item.selectType == 'danyuan'){
  301. this.unitid = item.value;
  302. }else if(item.selectType == 'menpai'){
  303. this.numberid = item.value
  304. }
  305. this.selectType = item.selectType;
  306. },
  307. search(selectType){
  308. if(selectType == 'xiaoqu'){
  309. this.house = this.housename;
  310. service.getBuilding({areaId: this.houseid}).then(res => {
  311. this.chooseHouseList = [];
  312. res.forEach(item => {
  313. this.chooseHouseList.push({
  314. value: item.id,
  315. label: item.name,
  316. selectType:'louyu'
  317. })
  318. })
  319. })
  320. this.current = -1;
  321. this.bulid = null;
  322. this.unit = null;
  323. this.houseNumber = null;
  324. }else if(selectType == 'louyu'){
  325. this.bulid = this.housename;
  326. service.getUnit({buildingId: this.buildid}).then(res => {
  327. this.chooseHouseList = [];
  328. res.forEach(item => {
  329. this.chooseHouseList.push({
  330. value: item.id,
  331. label: item.name,
  332. selectType:'danyuan'
  333. })
  334. })
  335. })
  336. this.unit = null;
  337. this.houseNumber = null;
  338. this.current = -1;
  339. }else if(selectType == 'danyuan'){
  340. this.unit = this.housename;
  341. service.getAllHouse({unitId: this.unitid}).then(res => {
  342. this.chooseHouseList = [];
  343. res.forEach(item => {
  344. this.chooseHouseList.push({
  345. value: item.id,
  346. label: item.name,
  347. selectType:'menpai'
  348. })
  349. })
  350. })
  351. this.houseNumber = null;
  352. this.current = -1;
  353. }else if(selectType == 'menpai'){
  354. this.houseNumber = this.housename;
  355. this.housedata = this.numberid;
  356. console.log('this.housedata',this.housedata)
  357. this.current = -1;
  358. }
  359. this.pop = false;
  360. },
  361. // getEngineDetail() {
  362. // service.getEngineDetail({
  363. // id: this.id
  364. // }).then(res => {
  365. // this.photo = res.photo
  366. // })
  367. // },
  368. choose() {
  369. let _this = this;
  370. uni.showActionSheet({
  371. title: '上传',
  372. itemList: ['图片', '视频'],
  373. success: (res) => {
  374. // console.log(res)
  375. if (res.tapIndex == 0) {
  376. this.chooseimage()
  377. } else {
  378. this.choosevideo()
  379. }
  380. }
  381. })
  382. },
  383. chooseimage() {
  384. console.log('图片')
  385. let _this = this;
  386. uni.chooseImage({
  387. sizeType: ['album', 'camera'],
  388. success(resp) {
  389. console.log('res--uni.chooseMedia', resp);
  390. resp.tempFiles.forEach((item, index) => {
  391. const task = uni.uploadFile({
  392. url: _this.$HTTP.webUrl + `/obs`,
  393. filePath: item.path,
  394. name: 'file',
  395. formData: {},
  396. header: _this.headers,
  397. success: res => {
  398. // 判断是否json字符串,将其转为json格式
  399. let data = _this.$u.test.jsonString(res
  400. .data) ? JSON.parse(res.data) : res.data;
  401. if (![200, 201, 204].includes(res.statusCode)) {
  402. // this.uploadError(index, data);
  403. _this.$UTILS.showPrompt('上传失败!')
  404. } else {
  405. // 上传成功
  406. // this.lists[index].response = data;
  407. // this.lists[index].progress = 100;
  408. // this.lists[index].error = false;
  409. // this.$emit('on-success', data, index, this.lists, this
  410. // .index);
  411. if (_this.progress === 100) {
  412. // console.log('_this.progress', _this.progress)
  413. // console.log('data----', data)
  414. // console.log('res--', res)
  415. _this.imgArr.push(data.data.url)
  416. // console.log('imgArr', _this.imgArr)
  417. _this.$UTILS.showPrompt('上传成功!')
  418. }
  419. }
  420. },
  421. fail: e => {
  422. _this.$UTILS.showPrompt('上传失败!')
  423. this.uploadError(index, e);
  424. },
  425. complete: res => {
  426. _this.uploading = false;
  427. // _this.uploadFile(index + 1);
  428. // this.$emit('on-change', res, index, this.lists, this
  429. // .index);
  430. }
  431. });
  432. task.onProgressUpdate(res => {
  433. // if (res.progress > 0) {
  434. // this.lists[index].progress = res.progress;
  435. // this.$emit('on-progress', res, index, this.lists, this.index);
  436. // }
  437. _this.progress = res.progress;
  438. console.log('onProgressUpdate', res)
  439. uni.showLoading({
  440. title: '上传中'
  441. })
  442. if(_this.progress != 100){
  443. _this.loading = false
  444. console.log('_this.loading false', _this.loading)
  445. }else {
  446. _this.loading = true
  447. console.log('_this.loading true', _this.loading)
  448. }
  449. });
  450. })
  451. },
  452. })
  453. },
  454. choosevideo() {
  455. let _this = this;
  456. console.log('视频')
  457. uni.chooseVideo({
  458. sourceType: ['album','camera'],
  459. maxDuration: 30,
  460. success(resp) {
  461. const task = uni.uploadFile({
  462. url: _this.$HTTP.webUrl + `/obs`,
  463. filePath: resp.tempFilePath,
  464. name: 'file',
  465. formData: {},
  466. header: _this.headers,
  467. success: res => {
  468. // 判断是否json字符串,将其转为json格式
  469. let data = _this.$u.test.jsonString(res
  470. .data) ? JSON.parse(res.data) : res.data;
  471. if (![200, 201, 204].includes(res.statusCode)) {
  472. this.uploadError(index, data);
  473. } else {
  474. // 上传成功
  475. // this.lists[index].response = data;
  476. // this.lists[index].progress = 100;
  477. // this.lists[index].error = false;
  478. // this.$emit('on-success', data, index, this.lists, this
  479. // .index);
  480. if (_this.progress === 100) {
  481. console.log('_this.progress', _this.progress)
  482. console.log('data----', data)
  483. console.log('res--', res)
  484. _this.imgArr.push(data.data.url)
  485. console.log('imgArr', _this.imgArr)
  486. _this.$UTILS.showPrompt('上传成功!')
  487. }
  488. }
  489. },
  490. fail: e => {
  491. _this.$UTILS.showPrompt('上传失败!')
  492. this.uploadError(index, e);
  493. },
  494. complete: res => {
  495. uni.hideLoading();
  496. _this.uploading = false;
  497. // _this.uploadFile(index + 1);
  498. // this.$emit('on-change', res, index, this.lists, this
  499. // .index);
  500. }
  501. });
  502. task.onProgressUpdate(res => {
  503. // if (res.progress > 0) {
  504. // this.lists[index].progress = res.progress;
  505. // this.$emit('on-progress', res, index, this.lists, this.index);
  506. // }
  507. _this.progress = res.progress;
  508. console.log('onProgressUpdate', res)
  509. uni.showLoading({
  510. title: '上传中'
  511. })
  512. if(_this.progress != 100){
  513. _this.loading = false
  514. console.log('_this.loading false', _this.loading)
  515. }else {
  516. _this.loading = true
  517. console.log('_this.loading true', _this.loading)
  518. }
  519. });
  520. },
  521. })
  522. },
  523. remove(index) {
  524. uni.showModal({
  525. title: '提示',
  526. content: '是否删除该图片或视频?',
  527. success: (res) => {
  528. if (res.confirm) {
  529. this.imgArr.splice(index, 1)
  530. console.log('this.imgarr',this.imgArr)
  531. }
  532. }
  533. })
  534. },
  535. }
  536. }
  537. </script>
  538. <style lang="scss" scoped>
  539. .background {
  540. z-index: -1;
  541. position: fixed;
  542. width: 100%;
  543. height: 100%;
  544. background-size: 100% 100%;
  545. }
  546. .choose {
  547. text-align: center;
  548. padding: 20rpx;
  549. margin: 30rpx;
  550. color: #FFFFFF;
  551. background: #43CEB1;
  552. border-radius: 64rpx;
  553. }
  554. .upload {
  555. margin: 30rpx;
  556. padding: 30rpx 20rpx;
  557. border: 2rpx solid #3857F3;
  558. border-radius: 48rpx;
  559. }
  560. .active{
  561. background-color: #1890FF;
  562. }
  563. .project-content {
  564. border: 4rpx solid #3857F3;
  565. margin: 80rpx 55rpx 30rpx;
  566. padding: 30rpx 20rpx;
  567. border-radius: 48rpx;
  568. }
  569. .project {
  570. border-radius: 72rpx;
  571. padding: 25rpx 0;
  572. text-align: center;
  573. margin: 60rpx 55rpx 0;
  574. }
  575. .project-img {
  576. width: 300rpx;
  577. height: 168rpx;
  578. margin: 20rpx auto;
  579. }
  580. </style>