addafter.vue 18 KB

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