addafter.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  1. <template>
  2. <view class="service-sale">
  3. <view class="status_bar"></view>
  4. <view class="" style="position: relative; top: 44px">
  5. <view style="position: fixed; z-index: 100">
  6. <uni-nav-bar
  7. @clickLeft="clickLeft"
  8. left-icon="back"
  9. left-text="返回"
  10. title="设备报修"
  11. ></uni-nav-bar>
  12. </view>
  13. <view class="addafter_con">
  14. <view class="addafter_con_top">
  15. <p>基本信息</p>
  16. <view class="" style="display: flex; margin-top: 20rpx">
  17. <span style="color: #ff0000">*</span>
  18. <input
  19. type="number"
  20. v-model="adddata.id"
  21. placeholder="请填写设备ID"
  22. placeholder-style="color: #62BF89;font-size:24rpx"
  23. @blur="addID"
  24. />
  25. </view>
  26. <view class="" style="display: flex; margin-top: 20rpx" >
  27. <span style="color: #ff0000">*</span>
  28. <!-- <input
  29. type="select"
  30. v-model="adddata.type"
  31. placeholder="请选择设备类型"
  32. placeholder-style="color: #62BF89;font-size:24rpx"
  33. disabled
  34. style="width:100%"
  35. /> -->
  36. <view class="text-input" @click="show = true">{{adddata.type || '请选择设备类型'}}</view>
  37. </view>
  38. <view class="" style="display: flex; margin-top: 20rpx">
  39. <span style="color: #fff">*</span>
  40. <input
  41. type="text"
  42. v-model="adddata.name"
  43. placeholder="请填写联系人名称"
  44. placeholder-style="color: #62BF89;font-size:24rpx"
  45. />
  46. </view>
  47. <view class="" style="display: flex; margin-top: 20rpx">
  48. <span style="color: #ff0000">*</span>
  49. <input
  50. type="number"
  51. v-model="adddata.phone"
  52. placeholder="请填写联系人电话"
  53. placeholder-style="color: #62BF89;font-size:24rpx"
  54. @blur="iphone"
  55. />
  56. </view>
  57. <view class="" style="display: flex; margin-top: 20rpx">
  58. <span style="color: #fff">*</span>
  59. <input
  60. type="text"
  61. v-model="adddata.site"
  62. placeholder="请填写联系人地址"
  63. placeholder-style="color: #62BF89;font-size:24rpx"
  64. />
  65. </view>
  66. </view>
  67. <view class="addafter_con_connect">
  68. <image
  69. :src="
  70. $imageURL +
  71. '/bigdata_app/image/afterSale/5d9b8db91f11175aa5277fef40581ab.png'
  72. "
  73. mode=""
  74. ></image>
  75. <image
  76. :src="
  77. $imageURL +
  78. '/bigdata_app/image/afterSale/5d9b8db91f11175aa5277fef40581ab.png'
  79. "
  80. mode=""
  81. ></image>
  82. </view>
  83. <view class="addafter_con_bot">
  84. <p class="addafter_con_bot_title">报修详情</p>
  85. <textarea
  86. v-model="adddata.text"
  87. placeholder="请描述设备问题"
  88. class="textarea"
  89. placeholder-style="color: #62BF89;font-size:26rpx"
  90. />
  91. <p style="color: #808080; font-size: 24rpx">
  92. {{ adddata.text.length }}/140
  93. </p>
  94. <view class="imgvideo">
  95. <view class="imgvideo_img" v-for="(item, index) in 3">
  96. <view @click="gainimg(index)">
  97. <image
  98. :src="
  99. $imageURL +
  100. '/bigdata_app/image/afterSale/eee1e84bb85f6f6ff5c5866a3a42779.png'
  101. "
  102. mode=""
  103. v-if="!uploadingTF[index]"
  104. ></image>
  105. </view>
  106. <view class="sim_info_loding" v-if="loding">
  107. <image
  108. src="../../static/images/cb/6286299.gif"
  109. mode=""
  110. class="img"
  111. ></image>
  112. </view>
  113. <view class="uploading" v-if="uploadingTF[index]">
  114. <u-icon
  115. name="close"
  116. class="delete"
  117. @click="deletes(index)"
  118. ></u-icon>
  119. <image
  120. :src="imageList[index]"
  121. mode=""
  122. class="uploading"
  123. @click="examine(imageList[index])"
  124. ></image>
  125. </view>
  126. </view>
  127. <view class="imgvideo_video" v-for="(item, index) in 1">
  128. <view @click="gainvideo(index)">
  129. <image
  130. :src="
  131. $imageURL +
  132. '/bigdata_app/image/afterSale/80314eaa07c32e9c76537a8a8224130.png'
  133. "
  134. mode=""
  135. v-if="!uploadingTF[index + 3]"
  136. ></image>
  137. </view>
  138. <view class="uploading" v-if="uploadingTF[index + 3]">
  139. <video
  140. :src="BASE_URL + selfList"
  141. :controls="false"
  142. class="uploading"
  143. ></video>
  144. <view class="yulan" @click="yulan(index)"> 预览 </view>
  145. <view class="deletes" @click="deletes(index + 3)"> 删除 </view>
  146. </view>
  147. </view>
  148. </view>
  149. <button @click="btn" :disabled="btnisTorF">提 交</button>
  150. </view>
  151. </view>
  152. </view>
  153. <kps-image-cutter
  154. @ok="onok"
  155. @cancel="oncancle"
  156. :url="imgs"
  157. :fixed="false"
  158. :blob="false"
  159. :maxWidth="500"
  160. :maxHeight="500"
  161. ></kps-image-cutter>
  162. <u-modal
  163. v-model="videoshow"
  164. :mask-close-able="true"
  165. :show-confirm-button="false"
  166. title="视频预览"
  167. class="model"
  168. >
  169. <view class="model_box">
  170. <video
  171. :src="'https://web.hnyfwlw.com' + selfList"
  172. controls
  173. style="width: 90%"
  174. ></video>
  175. </view>
  176. </u-modal>
  177. <u-action-sheet
  178. :list="actionSheetList"
  179. v-model="show"
  180. @click="actionSheetCallback"
  181. ></u-action-sheet>
  182. </view>
  183. </template>
  184. <script>
  185. import kpsImageCutter from '@/components/ksp-image-cutter/ksp-image-cutter.vue';
  186. export default {
  187. components: {
  188. kpsImageCutter,
  189. },
  190. data() {
  191. return {
  192. BASE_URL: 'https://web.hnyfwlw.com',
  193. adddata: {
  194. //设备参数
  195. id: '',
  196. name: '',
  197. phone: '',
  198. text: '',
  199. site: '',
  200. type: '',
  201. type_id: '',
  202. },
  203. loding: false,
  204. imageList: [], //图片链接
  205. uploadingTF: [false, false, false, false, false, false], //图片的删除
  206. selfList: '', //视频链接
  207. actionSheetList: [
  208. //设备选项
  209. {
  210. text: '杀虫灯',
  211. id: 2,
  212. },
  213. {
  214. text: '测报灯',
  215. id: 3,
  216. },
  217. {
  218. text: '智能性诱',
  219. id: 4,
  220. },
  221. {
  222. text: '环境监测',
  223. id: 5,
  224. },
  225. {
  226. text: '监控设备',
  227. id: 6,
  228. },
  229. {
  230. text: '孢子仪',
  231. id: 7,
  232. },
  233. {
  234. text: '性诱2.0',
  235. id: 10,
  236. },
  237. {
  238. text: '水肥一体化',
  239. id: 13,
  240. },
  241. {
  242. text: '天牛监测设备',
  243. id: 32,
  244. },
  245. {
  246. text: '色诱测报设备2.0',
  247. id: 33,
  248. },
  249. {
  250. text: '色诱测报设备1.0',
  251. id: 34,
  252. },
  253. {
  254. text: '虫情测报设备5.0',
  255. id: 35,
  256. },
  257. ],
  258. show: false, //选择器的显示
  259. btnisTorF: false,
  260. deviceid: false, //设备号判断
  261. imageFile: [],
  262. phoneTF: true, //手机号判断
  263. imgs: '',
  264. imgindex: null,
  265. videoindex: 0,
  266. videoshow: false,
  267. };
  268. },
  269. onLoad(option) {
  270. if (option.device_id) {
  271. this.getDeviceTypeList().then(()=>{
  272. console.log(option);
  273. this.adddata.id = option.device_id;
  274. var typedata = this.actionSheetList.filter((item) => {
  275. return item.id == Number(option.device_type);
  276. });
  277. console.log(typedata);
  278. this.adddata.type = typedata[0].text;
  279. this.adddata.type_id = typedata[0].id;
  280. });
  281. }else{
  282. this.getDeviceTypeList();
  283. }
  284. },
  285. methods: {
  286. async getDeviceTypeList() {
  287. const res = await this.$myRequest({
  288. url: '/api/api_gateway?method=home.homes.user_device_type',
  289. });
  290. console.log(res);
  291. this.actionSheetList = (res || []).map((item) => {
  292. return {
  293. ...item,
  294. text: item.type_name,
  295. };
  296. });
  297. return res;
  298. },
  299. clickLeft() {
  300. //返回
  301. uni.navigateBack({
  302. delta: 1,
  303. });
  304. },
  305. gainimg(index) {
  306. //添加图片
  307. this.imgindex = index;
  308. uni.chooseImage({
  309. count: 1, //默认9
  310. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  311. sourceType: ['album', 'camera'], //从相册选择
  312. success: (res) => {
  313. this.imgs = res.tempFilePaths[0];
  314. this.loding = true;
  315. },
  316. });
  317. },
  318. gainvideo(index) {
  319. //添加视频
  320. uni.chooseVideo({
  321. count: 1,
  322. sourceType: ['album', 'camera'],
  323. success: (res) => {
  324. console.log(res);
  325. uni.uploadFile({
  326. url: 'https://web.hnyfwlw.com/api/api_gateway?method=after_sale.after_sale_manage.video_upload', //仅为示例,非真实的接口地址
  327. filePath: res.tempFilePath,
  328. name: 'upload',
  329. fileType: 'video',
  330. formData: {
  331. user: 'test',
  332. },
  333. success: (uploadFileRes) => {
  334. console.log(uploadFileRes);
  335. if (uploadFileRes.statusCode == 200) {
  336. this.selfList = JSON.parse(uploadFileRes.data).data.data.src;
  337. this.$forceUpdate(); //强制刷新视图
  338. this.uploadingTF[index + 3] = true;
  339. } else {
  340. uni.showToast({
  341. title: '请将视频压缩后上传!',
  342. duration: 2000,
  343. icon: 'none',
  344. });
  345. }
  346. },
  347. });
  348. },
  349. });
  350. },
  351. deletes(index) {
  352. //删除
  353. this.uploadingTF[index] = false;
  354. if (index == 3) {
  355. this.selfList = '';
  356. } else {
  357. this.imageList.splice(index, 1);
  358. }
  359. this.$forceUpdate(); //强制刷新视图
  360. },
  361. async getaddafter(data) {
  362. //提交数据
  363. const res = await this.$myRequest({
  364. url: '/api/api_gateway?method=after_sale.after_sale_manage.aftersale_apply',
  365. data: {
  366. device_id: data.id,
  367. d_type: data.type,
  368. errordesc: data.text,
  369. errorimg: data.imageList,
  370. errorvideo: data.selfList,
  371. addr: data.site,
  372. user: data.name,
  373. userphone: data.phone,
  374. is_pc: 0,
  375. },
  376. });
  377. console.log(res);
  378. if (res) {
  379. uni.showToast({
  380. title: '提交成功',
  381. duration: 2000,
  382. });
  383. setTimeout(() => {
  384. uni.navigateBack({
  385. delta: 1,
  386. });
  387. }, 1000);
  388. } else {
  389. uni.showToast({
  390. title: '提交失败',
  391. duration: 2000,
  392. icon: 'none',
  393. });
  394. }
  395. },
  396. async getID(data) {
  397. const res = await this.$myRequest({
  398. url: '/api/api_gateway?method=after_sale.after_sale_manage.device_check',
  399. data: {
  400. device_id: data,
  401. },
  402. });
  403. if (res != '') {
  404. this.deviceid = false;
  405. } else {
  406. this.deviceid = true;
  407. }
  408. },
  409. btn() {
  410. //提交按钮
  411. this.getID(this.adddata.id);
  412. let obj = {};
  413. obj.id = this.adddata.id;
  414. obj.type = this.adddata.type_id;
  415. obj.text = this.adddata.text;
  416. if (this.imageList.length == 0) {
  417. obj.imageList = '';
  418. } else {
  419. obj.imageList = JSON.stringify(this.imageList);
  420. }
  421. obj.site = this.adddata.site;
  422. obj.name = this.adddata.name;
  423. obj.phone = this.adddata.phone;
  424. obj.selfList = this.selfList;
  425. console.log(this.selfList);
  426. // 设备号错误
  427. if (this.deviceid) {
  428. uni.showToast({
  429. title: '设备号错误',
  430. duration: 2000,
  431. icon: 'none',
  432. });
  433. } else if (this.adddata.type_id == '') {
  434. uni.showToast({
  435. title: '设备类型不能为空',
  436. duration: 2000,
  437. icon: 'none',
  438. });
  439. } else if (this.phoneTF) {
  440. uni.showToast({
  441. title: '请输入正确的手机号',
  442. duration: 2000,
  443. icon: 'none',
  444. });
  445. } else {
  446. console.log(obj);
  447. this.getaddafter(obj);
  448. }
  449. },
  450. actionSheetCallback(index) {
  451. //选择器选择
  452. this.adddata.type = this.actionSheetList[index].text;
  453. this.adddata.type_id = this.actionSheetList[index].id;
  454. },
  455. iphone() {
  456. //检测手机
  457. if (!/^1[23456789]\d{9}$/.test(this.adddata.phone)) {
  458. uni.showToast({
  459. title: '手机号格式不正确',
  460. duration: 2000,
  461. icon: 'none',
  462. });
  463. this.phoneTF = true;
  464. } else {
  465. this.phoneTF = false;
  466. }
  467. },
  468. addID() {
  469. this.getID(this.adddata.id);
  470. },
  471. examine(url) {
  472. var imgarr = [];
  473. imgarr.push(url);
  474. console.log(imgarr);
  475. uni.previewImage({
  476. urls: imgarr,
  477. });
  478. },
  479. onok(ev) {
  480. uni.uploadFile({
  481. url: 'https://web.hnyfwlw.com/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  482. filePath: ev.path,
  483. name: 'img_file',
  484. formData: {
  485. user: 'test',
  486. },
  487. success: (uploadFileRes) => {
  488. this.imageList[this.imgindex] = JSON.parse(
  489. uploadFileRes.data,
  490. ).data.src;
  491. this.$forceUpdate(); //强制刷新视图
  492. this.uploadingTF[this.imgindex] = true;
  493. this.loding = false;
  494. },
  495. });
  496. this.imgs = '';
  497. },
  498. oncancle() {
  499. this.imgs = '';
  500. },
  501. yulan(index) {
  502. this.videoindex = index;
  503. this.videoshow = !this.videoshow;
  504. },
  505. },
  506. };
  507. </script>
  508. <style lang="scss" scoped>
  509. page {
  510. min-height: 100vh;
  511. background-color: #71cd9a;
  512. }
  513. .service-sale {
  514. // height: 100vh;
  515. }
  516. .addafter_con {
  517. width: 100%;
  518. position: absolute;
  519. top: 54px;
  520. .addafter_con_top {
  521. width: 90%;
  522. margin: 0 auto;
  523. background-color: #ffffff;
  524. padding: 16rpx 30rpx 36rpx;
  525. border-radius: 20rpx;
  526. box-sizing: border-box;
  527. p {
  528. text-align: center;
  529. font-size: 30rpx;
  530. color: #62bf89;
  531. }
  532. input {
  533. width: 95%;
  534. background-color: #f1faf5;
  535. color: #62bf89;
  536. font-size: 26rpx;
  537. padding: 8rpx 26rpx;
  538. border-radius: 20rpx;
  539. }
  540. .text-input {
  541. width: 95%;
  542. background-color: #f1faf5;
  543. color: #62bf89;
  544. font-size: 26rpx;
  545. padding: 8rpx 26rpx;
  546. border-radius: 20rpx;
  547. }
  548. }
  549. .addafter_con_connect {
  550. width: 90%;
  551. margin: -20rpx auto;
  552. display: flex;
  553. justify-content: space-between;
  554. padding: 0 16rpx;
  555. box-sizing: border-box;
  556. image {
  557. width: 20rpx;
  558. height: 60rpx;
  559. }
  560. }
  561. .addafter_con_bot {
  562. width: 90%;
  563. margin: 0 auto;
  564. background-color: #ffffff;
  565. padding: 30rpx;
  566. border-radius: 20rpx;
  567. box-sizing: border-box;
  568. .addafter_con_bot_title {
  569. text-align: center;
  570. font-size: 30rpx;
  571. color: #62bf89;
  572. }
  573. .textarea {
  574. width: 94%;
  575. height: 240rpx;
  576. padding: 20rpx;
  577. background-color: #f1faf5;
  578. margin-top: 20rpx;
  579. font-size: 26rpx;
  580. border-radius: 20rpx;
  581. color: #62bf89;
  582. }
  583. }
  584. .imgvideo {
  585. width: 100%;
  586. margin-top: 20rpx;
  587. background-color: #ffffff;
  588. display: flex;
  589. flex-wrap: wrap;
  590. .imgvideo_img,
  591. .imgvideo_video {
  592. width: 30%;
  593. height: 160rpx;
  594. border: 2rpx dashed #a3dabd;
  595. text-align: center;
  596. line-height: 160rpx;
  597. margin: 0 8rpx 20rpx 8rpx;
  598. position: relative;
  599. image {
  600. width: 40rpx;
  601. height: 32rpx;
  602. }
  603. .sim_info_loding {
  604. width: 100%;
  605. height: 160rpx;
  606. position: absolute;
  607. top: 0;
  608. left: 0;
  609. image {
  610. width: 100%;
  611. height: 100%;
  612. }
  613. }
  614. .uploading {
  615. width: 100%;
  616. height: 160rpx;
  617. position: absolute;
  618. top: 0;
  619. left: 0;
  620. }
  621. .delete {
  622. position: absolute;
  623. top: -12rpx;
  624. right: -12rpx;
  625. font-size: 36rpx;
  626. background-color: #fe0000;
  627. border-radius: 50%;
  628. color: #ffffff;
  629. z-index: 50;
  630. }
  631. .deletes {
  632. width: 80%;
  633. height: 50rpx;
  634. margin-left: 110%;
  635. font-size: 24rpx;
  636. background-color: #fe0000;
  637. color: #fffdef;
  638. line-height: 50rpx;
  639. }
  640. .yulan {
  641. width: 80%;
  642. height: 50rpx;
  643. margin: 0 0 20rpx 110%;
  644. font-size: 24rpx;
  645. background-color: #62bf89;
  646. color: #fffdef;
  647. line-height: 50rpx;
  648. }
  649. }
  650. }
  651. button {
  652. width: 100%;
  653. height: 60rpx;
  654. font-size: 30rpx;
  655. line-height: 60rpx;
  656. color: #ffffff;
  657. background-color: #50ce87;
  658. margin-top: 60rpx;
  659. }
  660. }
  661. .model {
  662. width: 90%;
  663. .model_box {
  664. width: 90%;
  665. margin: 40rpx auto 48rpx;
  666. display: flex;
  667. justify-content: center;
  668. }
  669. }
  670. ::v-deep .u-drawer {
  671. &__scroll-view {
  672. max-height: 80vh;
  673. height: auto;
  674. }
  675. }
  676. </style>