addafter.vue 13 KB

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