addafter.vue 13 KB

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