addafter.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513
  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="'http://www.hnyfwlw.com:8006/bigdata_app'+'/image/afterSale/5d9b8db91f11175aa5277fef40581ab.png'" mode=""></image>
  38. <image :src="'http://www.hnyfwlw.com:8006/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="'http://www.hnyfwlw.com:8006/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="'http://www.hnyfwlw.com:8006/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. show:false,//选择器的显示
  141. btnisTorF:false,
  142. deviceid:false,//设备号判断
  143. imageFile:[],
  144. phoneTF:true,//手机号判断
  145. imgs:'',
  146. imgindex:null,
  147. videoindex:0,
  148. videoshow:false
  149. }
  150. },
  151. onLoad(option) {
  152. if(option.device_id){
  153. console.log(option)
  154. this.adddata.id = option.device_id
  155. var typedata = this.actionSheetList.filter((item)=>{
  156. return item.id == Number(option.device_type)
  157. })
  158. console.log(typedata)
  159. this.adddata.type = typedata[0].text
  160. this.adddata.type_id = typedata[0].id
  161. }
  162. },
  163. methods: {
  164. clickLeft(){//返回
  165. uni.navigateBack({
  166. delta:1
  167. })
  168. },
  169. gainimg(index){//添加图片
  170. this.imgindex = index
  171. uni.chooseImage({
  172. count: 1, //默认9
  173. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  174. sourceType: ['album','camera'], //从相册选择
  175. success: (res)=> {
  176. this.imgs = res.tempFilePaths[0]
  177. this.loding = true
  178. }
  179. });
  180. },
  181. gainvideo(index){//添加视频
  182. uni.chooseVideo({
  183. count: 1,
  184. sourceType:['album', 'camera'],
  185. success:(res)=> {
  186. console.log(res)
  187. uni.uploadFile({
  188. url: 'http://8.136.98.49:8002/api/api_gateway?method=after_sale.after_sale_manage.video_upload', //仅为示例,非真实的接口地址
  189. filePath: res.tempFilePath,
  190. name: 'upload',
  191. fileType:"video",
  192. formData: {
  193. 'user': 'test'
  194. },
  195. success: (uploadFileRes) => {
  196. console.log(uploadFileRes)
  197. if(uploadFileRes.statusCode == 200){
  198. this.selfList=JSON.parse(uploadFileRes.data).data.data.src
  199. this.$forceUpdate() //强制刷新视图
  200. this.uploadingTF[index+3] = true
  201. }else{
  202. uni.showToast({
  203. title: '请将视频压缩后上传!',
  204. duration: 2000,
  205. icon:"none"
  206. });
  207. }
  208. }
  209. });
  210. }
  211. });
  212. },
  213. deletes(index){//删除
  214. this.uploadingTF[index]=false
  215. if(index==3){
  216. this.selfList = ""
  217. }else{
  218. this.imageList.splice(index,1)
  219. }
  220. this.$forceUpdate() //强制刷新视图
  221. },
  222. async getaddafter(data) {//提交数据
  223. const res = await this.$myRequest({
  224. url: '/api/api_gateway?method=after_sale.after_sale_manage.aftersale_apply',
  225. data:{
  226. device_id:data.id,
  227. d_type:data.type,
  228. errordesc:data.text,
  229. errorimg:data.imageList,
  230. errorvideo:data.selfList,
  231. addr:data.site,
  232. user:data.name,
  233. userphone:data.phone,
  234. is_pc:0
  235. }
  236. })
  237. console.log(res)
  238. if(res){
  239. uni.showToast({
  240. title: '提交成功',
  241. duration: 2000,
  242. });
  243. setTimeout(()=>{
  244. uni.navigateBack({
  245. delta:1
  246. })
  247. },1000)
  248. }else{
  249. uni.showToast({
  250. title: '提交失败',
  251. duration: 2000,
  252. icon:"none"
  253. });
  254. }
  255. },
  256. async getID(data) {
  257. const res = await this.$myRequest({
  258. url: '/api/api_gateway?method=after_sale.after_sale_manage.device_check',
  259. data:{
  260. device_id:data
  261. }
  262. })
  263. if(res!=''){
  264. this.deviceid=false
  265. }else{
  266. this.deviceid=true
  267. }
  268. },
  269. btn(){//提交按钮
  270. this.getID(this.adddata.id)
  271. let obj ={}
  272. obj.id=this.adddata.id
  273. obj.type=this.adddata.type_id
  274. obj.text=this.adddata.text
  275. if(this.imageList.length==0){
  276. obj.imageList=""
  277. }else{
  278. obj.imageList=JSON.stringify(this.imageList)
  279. }
  280. obj.site=this.adddata.site
  281. obj.name=this.adddata.name
  282. obj.phone=this.adddata.phone
  283. obj.selfList=this.selfList
  284. console.log(this.selfList)
  285. // 设备号错误
  286. if(this.deviceid){
  287. uni.showToast({
  288. title: '设备号错误',
  289. duration: 2000,
  290. icon:"none"
  291. });
  292. }else if(this.adddata.type_id ==''){
  293. uni.showToast({
  294. title: '设备类型不能为空',
  295. duration: 2000,
  296. icon:"none"
  297. });
  298. }else if(this.phoneTF){
  299. uni.showToast({
  300. title: '请输入正确的手机号',
  301. duration: 2000,
  302. icon:'none'
  303. });
  304. }else{
  305. console.log(obj)
  306. this.getaddafter(obj)
  307. }
  308. },
  309. actionSheetCallback(index) {//选择器选择
  310. this.adddata.type = this.actionSheetList[index].text;
  311. this.adddata.type_id = this.actionSheetList[index].id
  312. },
  313. iphone(){//检测手机
  314. if(!/^1[23456789]\d{9}$/.test(this.adddata.phone)){
  315. uni.showToast({
  316. title: '手机号格式不正确',
  317. duration: 2000,
  318. icon:'none'
  319. });
  320. this.phoneTF=true
  321. }else{
  322. this.phoneTF=false
  323. }
  324. },
  325. addID(){
  326. this.getID(this.adddata.id)
  327. },
  328. examine(url) {
  329. var imgarr =[]
  330. imgarr.push(url)
  331. console.log(imgarr)
  332. uni.previewImage({
  333. urls: imgarr
  334. });
  335. },
  336. onok(ev){
  337. uni.uploadFile({
  338. url: 'http://8.136.98.49:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  339. filePath: ev.path,
  340. name: 'img_file',
  341. formData: {
  342. 'user': 'test'
  343. },
  344. success: (uploadFileRes) => {
  345. this.imageList[this.imgindex]=JSON.parse(uploadFileRes.data).data.src
  346. this.$forceUpdate() //强制刷新视图
  347. this.uploadingTF[this.imgindex]=true
  348. this.loding = false
  349. }
  350. });
  351. this.imgs = ""
  352. },
  353. oncancle(){
  354. this.imgs = ""
  355. },
  356. yulan(index){
  357. this.videoindex = index
  358. this.videoshow = !this.videoshow
  359. }
  360. }
  361. }
  362. </script>
  363. <style lang="scss">
  364. page{
  365. background-color: #71CD9A;
  366. }
  367. .addafter_con{
  368. width: 100%;
  369. position: absolute;
  370. top: 54px;
  371. .addafter_con_top{
  372. width: 90%;
  373. margin: 0 auto;
  374. background-color: #FFFFFF;
  375. padding: 16rpx 30rpx 36rpx;
  376. border-radius: 20rpx;
  377. box-sizing: border-box;
  378. p{
  379. text-align: center;
  380. font-size: 30rpx;
  381. color: #62BF89;
  382. }
  383. input{
  384. width: 95%;
  385. background-color: #F1FAF5;
  386. color: #62BF89;
  387. font-size:26rpx;
  388. padding: 8rpx 26rpx;
  389. border-radius: 20rpx;
  390. }
  391. }
  392. .addafter_con_connect{
  393. width: 90%;
  394. margin: -20rpx auto;
  395. display: flex;
  396. justify-content: space-between;
  397. padding: 0 16rpx;
  398. box-sizing: border-box;
  399. image{
  400. width: 20rpx;
  401. height: 60rpx;
  402. }
  403. }
  404. .addafter_con_bot{
  405. width: 90%;
  406. margin: 0 auto;
  407. background-color: #FFFFFF;
  408. padding: 30rpx;
  409. border-radius: 20rpx;
  410. box-sizing: border-box;
  411. .addafter_con_bot_title{
  412. text-align: center;
  413. font-size: 30rpx;
  414. color: #62BF89;
  415. }
  416. .textarea{
  417. width: 94%;
  418. height: 240rpx;
  419. padding: 20rpx;
  420. background-color: #F1FAF5;
  421. margin-top: 20rpx;
  422. font-size: 26rpx;
  423. border-radius: 20rpx;
  424. color: #62BF89;
  425. }
  426. }
  427. .imgvideo{
  428. width: 100%;
  429. margin-top: 20rpx;
  430. background-color: #FFFFFF;
  431. display: flex;
  432. flex-wrap: wrap;
  433. .imgvideo_img,.imgvideo_video{
  434. width: 30%;
  435. height: 160rpx;
  436. border: 2rpx dashed #A3DABD;
  437. text-align: center;
  438. line-height: 160rpx;
  439. margin:0 8rpx 20rpx 8rpx;
  440. position: relative;
  441. image{
  442. width: 40rpx;
  443. height: 32rpx;
  444. }
  445. .sim_info_loding{
  446. width: 100%;
  447. height: 160rpx;
  448. position: absolute;
  449. top: 0;
  450. left: 0;
  451. image{
  452. width: 100%;
  453. height: 100%;
  454. }
  455. }
  456. .uploading{
  457. width: 100%;
  458. height: 160rpx;
  459. position: absolute;
  460. top: 0;
  461. left: 0;
  462. }
  463. .delete{
  464. position: absolute;
  465. top: -12rpx;
  466. right: -12rpx;
  467. font-size: 36rpx;
  468. background-color: #FE0000;
  469. border-radius: 50%;
  470. color: #ffffff;
  471. z-index: 50;
  472. }
  473. .deletes{
  474. width: 80%;
  475. height: 50rpx;
  476. margin-left: 110%;
  477. font-size: 24rpx;
  478. background-color: #FE0000;
  479. color: #FFFDEF;
  480. line-height: 50rpx;
  481. }
  482. .yulan{
  483. width: 80%;
  484. height: 50rpx;
  485. margin: 0 0 20rpx 110%;
  486. font-size: 24rpx;
  487. background-color: #62BF89;
  488. color: #FFFDEF;
  489. line-height: 50rpx;
  490. }
  491. }
  492. }
  493. button{
  494. width: 100%;
  495. height: 60rpx;
  496. font-size: 30rpx;
  497. line-height: 60rpx;
  498. color: #FFFFFF;
  499. background-color: #50CE87;
  500. margin-top: 60rpx;
  501. }
  502. }
  503. .model {
  504. width: 90%;
  505. .model_box {
  506. width: 90%;
  507. margin: 40rpx auto 48rpx;
  508. display: flex;
  509. justify-content: center;
  510. }
  511. }
  512. </style>