addafter.vue 13 KB

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