addafter.vue 14 KB

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