addafter.vue 13 KB

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