addafter.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view>
  3. <view style="position: fixed;z-index: 100;">
  4. <uni-nav-bar @clickLeft="clickLeft" left-icon="back" left-text="返回" title="设备报修"></uni-nav-bar>
  5. </view>
  6. <view class="addafter_con">
  7. <view class="addafter_con_top">
  8. <p>基本信息</p>
  9. <input type="number" v-model="adddata.id" placeholder="请填写设备ID" placeholder-style="color: #62BF89;font-size:24rpx"
  10. @blur="addID" />
  11. <input type="select" v-model="adddata.type" placeholder="请选择设备类型" placeholder-style="color: #62BF89;font-size:24rpx"
  12. @click="show = true" disabled />
  13. <input type="text" v-model="adddata.name" placeholder="请填写联系人名称" placeholder-style="color: #62BF89;font-size:24rpx" />
  14. <input type="number" v-model="adddata.phone" placeholder="请填写联系人电话" placeholder-style="color: #62BF89;font-size:24rpx"
  15. @blur="iphone" />
  16. <input type="text" v-model="adddata.site" placeholder="请填写联系人地址" placeholder-style="color: #62BF89;font-size:24rpx" />
  17. <u-action-sheet :list="actionSheetList" v-model="show" @click="actionSheetCallback"></u-action-sheet>
  18. </view>
  19. <view class="addafter_con_connect">
  20. <image src="../../static/image/afterSale/5d9b8db91f11175aa5277fef40581ab.png" mode=""></image>
  21. <image src="../../static/image/afterSale/5d9b8db91f11175aa5277fef40581ab.png" mode=""></image>
  22. </view>
  23. <view class="addafter_con_bot">
  24. <p class="addafter_con_bot_title">保修详情</p>
  25. <textarea v-model="adddata.text" placeholder="请描述设备问题" class="textarea" placeholder-style="color: #62BF89;font-size:26rpx" />
  26. <p style="color: #808080;font-size: 24rpx;">{{adddata.text.length}}/140</p>
  27. <view class="imgvideo">
  28. <view class="imgvideo_img" v-for="(item,index) in 3">
  29. <view @click="gainimg(index)">
  30. <image src="../../static/image/afterSale/eee1e84bb85f6f6ff5c5866a3a42779.png" mode="" v-if="!uploadingTF[index]"></image>
  31. </view>
  32. <view class="uploading" v-if="uploadingTF[index]">
  33. <u-icon name="close" class="delete" @click="deletes(index)"></u-icon>
  34. <image :src="imageList[index]" mode="" class="uploading"></image>
  35. </view>
  36. </view>
  37. <view class="imgvideo_video" v-for="(item,index) in 3">
  38. <view @click="gainvideo(index)">
  39. <image src="../../static/image/afterSale/80314eaa07c32e9c76537a8a8224130.png" mode="" v-if="!uploadingTF[index+3]"></image>
  40. </view>
  41. <view class="uploading" v-if="uploadingTF[index+3]">
  42. <u-icon name="close" class="delete" @click="deletes(index+3)"></u-icon>
  43. <video :src="selfList[index]" controls class="uploading"></video>
  44. </view>
  45. </view>
  46. </view>
  47. <button @click="btn" :disabled="btnisTorF">提 交</button>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. adddata:{//设备参数
  57. id:'',
  58. name:'',
  59. phone:'',
  60. text:'',
  61. site:'',
  62. type:'',
  63. type_id:''
  64. },
  65. imageList:[],//图片链接
  66. // postimageList:[],
  67. uploadingTF:[false,false,false,false,false,false],//图片的删除
  68. selfList:[],//视频链接
  69. actionSheetList: [//设备选项
  70. {
  71. text: '杀虫灯'
  72. },
  73. {
  74. text: '测报灯'
  75. },
  76. {
  77. text: '智能性诱'
  78. },
  79. {
  80. text: '环境检测'
  81. },
  82. {
  83. text: '监控设备'
  84. },
  85. {
  86. text: '孢子仪'
  87. },
  88. {
  89. text: '性诱设备'
  90. },
  91. ],
  92. show:false,//选择器的显示
  93. btnisTorF:false,
  94. deviceid:false//设备号判断
  95. }
  96. },
  97. methods: {
  98. clickLeft(){//返回
  99. uni.navigateTo({
  100. url:"./index"
  101. })
  102. },
  103. gainimg(index){//添加图片
  104. uni.chooseImage({
  105. count: 1, //默认9
  106. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  107. sourceType: ['album','camera'], //从相册选择
  108. success: (res)=> {
  109. this.imageList[index]=res.tempFilePaths[0]
  110. this.$forceUpdate() //强制刷新视图
  111. this.uploadingTF[index]=true
  112. // this.postimageList[index]=res.tempFilePaths[0].slice(res.tempFilePaths[0].indexOf(":")+1)
  113. uni.getImageInfo({
  114. src: res.tempFilePaths[0],
  115. success:(image)=>{
  116. console.log(image);
  117. }
  118. });
  119. }
  120. });
  121. },
  122. gainvideo(index){//添加视频
  123. uni.chooseVideo({
  124. count: 1,
  125. mediaType:['video'],
  126. success:(res)=> {
  127. console.log(res)
  128. this.selfList[index]= res.tempFilePath;
  129. this.$forceUpdate() //强制刷新视图
  130. this.uploadingTF[index+3]=true
  131. }
  132. });
  133. },
  134. deletes(index){//删除
  135. this.uploadingTF[index]=false
  136. this.$forceUpdate() //强制刷新视图
  137. },
  138. async getaddafter(data) {
  139. const res = await this.$myRequest({
  140. url: '/api/api_gateway?method=after_sale.after_sale_manage.aftersale_apply',
  141. data:{
  142. device_id:data.id,
  143. d_type:data.type,
  144. errordesc:data.text,
  145. errorimg:data.imageList,
  146. addr:data.site,
  147. user:data.name,
  148. userphone:data.phone,
  149. is_pc:0
  150. }
  151. })
  152. },
  153. async getaddvideo(data) {
  154. const res = await this.$myRequest({
  155. url: '/api/api_gateway?method=after_sale.after_sale_manage.video_upload',
  156. data:{
  157. upload:data
  158. }//after_sale.after_sale_manage.device_check
  159. })
  160. },
  161. async getID(data) {
  162. const res = await this.$myRequest({
  163. url: '/api/api_gateway?method=after_sale.after_sale_manage.device_check',
  164. data:{
  165. device_id:data
  166. }
  167. })
  168. if(res!=''){
  169. this.deviceid=true
  170. }else{
  171. this.deviceid=false
  172. }
  173. },
  174. btn(){//提交按钮
  175. let obj ={}
  176. obj.id=this.adddata.id
  177. obj.type=this.adddata.type_id
  178. obj.text=this.adddata.text
  179. obj.imageList=JSON.stringify(this.imageList)
  180. console.log(obj.imageList)
  181. obj.site=this.adddata.site
  182. obj.name=this.adddata.name
  183. obj.phone=this.adddata.phone
  184. // if(this.deviceid==false && this.adddata.type_id==''){
  185. // uni.showToast({
  186. // title: '设备ID和设备类型不能为空',
  187. // duration: 2000,
  188. // icon:'none'
  189. // });
  190. // }else{
  191. // this.getaddafter(obj)
  192. // if(this.selfList.length!=0){
  193. // // this.getaddvideo(this.selfList)
  194. // }
  195. // }
  196. },
  197. actionSheetCallback(index) {//选择器选择
  198. this.adddata.type = this.actionSheetList[index].text;
  199. this.adddata.type_id=index+2
  200. },
  201. iphone(){//检测手机
  202. if(!/^1[23456789]\d{9}$/.test(this.adddata.phone)){
  203. uni.showToast({
  204. title: '手机号格式不正确',
  205. duration: 2000,
  206. icon:'none'
  207. });
  208. }
  209. },
  210. addID(){
  211. this.getID(this.adddata.id)
  212. }
  213. }
  214. }
  215. </script>
  216. <style lang="scss">
  217. .addafter_con{
  218. width: 100%;
  219. padding: 110rpx 0;
  220. background-color: #71CD9A;
  221. .addafter_con_top{
  222. width: 90%;
  223. margin: 0 auto;
  224. background-color: #FFFFFF;
  225. padding: 16rpx 30rpx 36rpx;
  226. border-radius: 20rpx;
  227. p{
  228. text-align: center;
  229. font-size: 30rpx;
  230. color: #62BF89;
  231. }
  232. input{
  233. margin-top: 20rpx;
  234. background-color: #F1FAF5;
  235. color: #62BF89;
  236. font-size:26rpx;
  237. padding: 8rpx 26rpx;
  238. border-radius: 20rpx;
  239. }
  240. }
  241. .addafter_con_connect{
  242. width: 90%;
  243. margin: -20rpx auto;
  244. display: flex;
  245. justify-content: space-between;
  246. padding: 0 16rpx;
  247. image{
  248. width: 20rpx;
  249. height: 60rpx;
  250. }
  251. }
  252. .addafter_con_bot{
  253. width: 90%;
  254. margin: 0 auto;
  255. background-color: #FFFFFF;
  256. padding: 30rpx;
  257. border-radius: 20rpx;
  258. .addafter_con_bot_title{
  259. text-align: center;
  260. font-size: 30rpx;
  261. color: #62BF89;
  262. }
  263. .textarea{
  264. width: 94%;
  265. height: 240rpx;
  266. padding: 20rpx;
  267. background-color: #F1FAF5;
  268. margin-top: 20rpx;
  269. font-size: 26rpx;
  270. border-radius: 20rpx;
  271. color: #62BF89;
  272. }
  273. }
  274. .imgvideo{
  275. width: 100%;
  276. margin-top: 20rpx;
  277. background-color: #FFFFFF;
  278. display: flex;
  279. justify-content: space-around;
  280. flex-wrap: wrap;
  281. .imgvideo_img,.imgvideo_video{
  282. width: 30%;
  283. height: 160rpx;
  284. border: 2rpx dashed #A3DABD;
  285. text-align: center;
  286. line-height: 160rpx;
  287. margin-bottom: 20rpx;
  288. position: relative;
  289. image{
  290. width: 40rpx;
  291. height: 32rpx;
  292. }
  293. .uploading{
  294. width: 100%;
  295. height: 160rpx;
  296. position: absolute;
  297. top: 0;
  298. left: 0;
  299. .delete{
  300. position: absolute;
  301. top: -12rpx;
  302. right: -12rpx;
  303. font-size: 12rpx;
  304. background-color: #FE0000;
  305. border-radius: 50%;
  306. color: #ffffff;
  307. z-index: 50;
  308. }
  309. }
  310. }
  311. }
  312. button{
  313. width: 100%;
  314. height: 60rpx;
  315. font-size: 30rpx;
  316. line-height: 60rpx;
  317. color: #FFFFFF;
  318. background-color: #50CE87;
  319. margin-top: 40rpx;
  320. }
  321. }
  322. </style>