addafter.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415
  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. <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="../../static/image/afterSale/5d9b8db91f11175aa5277fef40581ab.png" mode=""></image>
  23. <image src="../../static/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="../../static/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="../../static/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. },
  91. {
  92. text: '测报灯'
  93. },
  94. {
  95. text: '智能性诱'
  96. },
  97. {
  98. text: '环境检测'
  99. },
  100. {
  101. text: '监控设备'
  102. },
  103. {
  104. text: '孢子仪'
  105. },
  106. {
  107. text: '性诱设备'
  108. },
  109. ],
  110. show:false,//选择器的显示
  111. btnisTorF:false,
  112. deviceid:false,//设备号判断
  113. imageFile:[],
  114. phoneTF:true,//手机号判断
  115. imgs:'',
  116. imgindex:null,
  117. videoindex:0,
  118. videoshow:false
  119. }
  120. },
  121. methods: {
  122. clickLeft(){//返回
  123. uni.navigateTo({
  124. url:"./index"
  125. })
  126. },
  127. gainimg(index){//添加图片
  128. this.imgindex = index
  129. uni.chooseImage({
  130. count: 1, //默认9
  131. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  132. sourceType: ['album','camera'], //从相册选择
  133. success: (res)=> {
  134. this.imgs = res.tempFilePaths[0]
  135. }
  136. });
  137. },
  138. gainvideo(index){//添加视频
  139. uni.chooseVideo({
  140. count: 1,
  141. sourceType:['album', 'camera'],
  142. success:(res)=> {
  143. console.log(res)
  144. uni.uploadFile({
  145. url: 'http://182.92.193.64:8002/api/api_gateway?method=after_sale.after_sale_manage.video_upload', //仅为示例,非真实的接口地址
  146. filePath: res.tempFilePath,
  147. name: 'upload',
  148. fileType:"video",
  149. formData: {
  150. 'user': 'test'
  151. },
  152. success: (uploadFileRes) => {
  153. console.log(uploadFileRes)
  154. if(uploadFileRes.statusCode == 200){
  155. this.selfList=JSON.parse(uploadFileRes.data).data.data.src
  156. this.$forceUpdate() //强制刷新视图
  157. this.uploadingTF[index+3] = true
  158. }else{
  159. uni.showToast({
  160. title: '请将视频压缩后上传!',
  161. duration: 2000,
  162. icon:"none"
  163. });
  164. }
  165. }
  166. });
  167. }
  168. });
  169. },
  170. deletes(index){//删除
  171. this.uploadingTF[index]=false
  172. this.$forceUpdate() //强制刷新视图
  173. },
  174. async getaddafter(data) {//提交数据
  175. const res = await this.$myRequest({
  176. url: '/api/api_gateway?method=after_sale.after_sale_manage.aftersale_apply',
  177. data:{
  178. device_id:data.id,
  179. d_type:data.type,
  180. errordesc:data.text,
  181. errorimg:data.imageList,
  182. errorvideo:data.selfList,
  183. addr:data.site,
  184. user:data.name,
  185. userphone:data.phone,
  186. is_pc:0
  187. }
  188. })
  189. },
  190. async getID(data) {
  191. const res = await this.$myRequest({
  192. url: '/api/api_gateway?method=after_sale.after_sale_manage.device_check',
  193. data:{
  194. device_id:data
  195. }
  196. })
  197. if(res!=''){
  198. this.deviceid=true
  199. }else{
  200. this.deviceid=false
  201. }
  202. },
  203. btn(){//提交按钮
  204. let obj ={}
  205. obj.id=this.adddata.id
  206. obj.type=this.adddata.type_id
  207. obj.text=this.adddata.text
  208. obj.imageList=JSON.stringify(this.imageList)
  209. obj.site=this.adddata.site
  210. obj.name=this.adddata.name
  211. obj.phone=this.adddata.phone
  212. obj.selfList=JSON.stringify(this.selfList)
  213. console.log(obj.imageList)
  214. if(this.deviceid && this.adddata.type_id!=''&&this.phoneTF){
  215. this.getaddafter(obj)
  216. }else{
  217. console.log(1)
  218. uni.showToast({
  219. title: '设备ID和设备类型不能为空',
  220. duration: 2000,
  221. icon:"none"
  222. });
  223. }
  224. },
  225. actionSheetCallback(index) {//选择器选择
  226. this.adddata.type = this.actionSheetList[index].text;
  227. this.adddata.type_id=index+2
  228. },
  229. iphone(){//检测手机
  230. if(!/^1[23456789]\d{9}$/.test(this.adddata.phone)){
  231. uni.showToast({
  232. title: '手机号格式不正确',
  233. duration: 2000,
  234. icon:'none'
  235. });
  236. this.phoneTF=false
  237. }
  238. },
  239. addID(){
  240. this.getID(this.adddata.id)
  241. },
  242. examine(url) {
  243. var imgarr =[]
  244. imgarr.push(url)
  245. console.log(imgarr)
  246. uni.previewImage({
  247. urls: imgarr
  248. });
  249. },
  250. onok(ev){
  251. uni.uploadFile({
  252. url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  253. filePath: ev.path,
  254. name: 'img_file',
  255. formData: {
  256. 'user': 'test'
  257. },
  258. success: (uploadFileRes) => {
  259. this.imageList[this.imgindex]=JSON.parse(uploadFileRes.data).data.src
  260. this.$forceUpdate() //强制刷新视图
  261. this.uploadingTF[this.imgindex]=true
  262. }
  263. });
  264. this.imgs = ""
  265. },
  266. oncancle(){
  267. this.imgs = ""
  268. },
  269. yulan(index){
  270. this.videoindex = index
  271. this.videoshow = !this.videoshow
  272. }
  273. }
  274. }
  275. </script>
  276. <style lang="scss">
  277. page{
  278. background-color: #71CD9A;
  279. }
  280. .addafter_con{
  281. width: 100%;
  282. position: absolute;
  283. top: 54px;
  284. .addafter_con_top{
  285. width: 90%;
  286. margin: 0 auto;
  287. background-color: #FFFFFF;
  288. padding: 16rpx 30rpx 36rpx;
  289. border-radius: 20rpx;
  290. box-sizing: border-box;
  291. p{
  292. text-align: center;
  293. font-size: 30rpx;
  294. color: #62BF89;
  295. }
  296. input{
  297. margin-top: 20rpx;
  298. background-color: #F1FAF5;
  299. color: #62BF89;
  300. font-size:26rpx;
  301. padding: 8rpx 26rpx;
  302. border-radius: 20rpx;
  303. }
  304. }
  305. .addafter_con_connect{
  306. width: 90%;
  307. margin: -20rpx auto;
  308. display: flex;
  309. justify-content: space-between;
  310. padding: 0 16rpx;
  311. box-sizing: border-box;
  312. image{
  313. width: 20rpx;
  314. height: 60rpx;
  315. }
  316. }
  317. .addafter_con_bot{
  318. width: 90%;
  319. margin: 0 auto;
  320. background-color: #FFFFFF;
  321. padding: 30rpx;
  322. border-radius: 20rpx;
  323. box-sizing: border-box;
  324. .addafter_con_bot_title{
  325. text-align: center;
  326. font-size: 30rpx;
  327. color: #62BF89;
  328. }
  329. .textarea{
  330. width: 94%;
  331. height: 240rpx;
  332. padding: 20rpx;
  333. background-color: #F1FAF5;
  334. margin-top: 20rpx;
  335. font-size: 26rpx;
  336. border-radius: 20rpx;
  337. color: #62BF89;
  338. }
  339. }
  340. .imgvideo{
  341. width: 100%;
  342. margin-top: 20rpx;
  343. background-color: #FFFFFF;
  344. display: flex;
  345. flex-wrap: wrap;
  346. .imgvideo_img,.imgvideo_video{
  347. width: 30%;
  348. height: 160rpx;
  349. border: 2rpx dashed #A3DABD;
  350. text-align: center;
  351. line-height: 160rpx;
  352. margin:0 10rpx 20rpx 8rpx;
  353. position: relative;
  354. image{
  355. width: 40rpx;
  356. height: 32rpx;
  357. }
  358. .uploading{
  359. width: 100%;
  360. height: 160rpx;
  361. position: absolute;
  362. top: 0;
  363. left: 0;
  364. }
  365. .delete{
  366. position: absolute;
  367. top: -12rpx;
  368. right: -12rpx;
  369. font-size: 36rpx;
  370. background-color: #FE0000;
  371. border-radius: 50%;
  372. color: #ffffff;
  373. z-index: 50;
  374. }
  375. .deletes{
  376. width: 80%;
  377. height: 50rpx;
  378. margin-left: 110%;
  379. font-size: 24rpx;
  380. background-color: #FE0000;
  381. color: #FFFDEF;
  382. line-height: 50rpx;
  383. }
  384. .yulan{
  385. width: 80%;
  386. height: 50rpx;
  387. margin: 0 0 20rpx 110%;
  388. font-size: 24rpx;
  389. background-color: #62BF89;
  390. color: #FFFDEF;
  391. line-height: 50rpx;
  392. }
  393. }
  394. }
  395. button{
  396. width: 100%;
  397. height: 60rpx;
  398. font-size: 30rpx;
  399. line-height: 60rpx;
  400. color: #FFFFFF;
  401. background-color: #50CE87;
  402. margin-top: 60rpx;
  403. }
  404. }
  405. .model {
  406. width: 90%;
  407. .model_box {
  408. width: 90%;
  409. margin: 40rpx auto 48rpx;
  410. display: flex;
  411. justify-content: center;
  412. }
  413. }
  414. </style>