addafter.vue 18 KB

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