addafter.vue 12 KB

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