addafter.vue 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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="BASE_URL+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. BASE_URL: 'http://182.92.193.64:8002',
  57. adddata:{//设备参数
  58. id:'',
  59. name:'',
  60. phone:'',
  61. text:'',
  62. site:'',
  63. type:'',
  64. type_id:''
  65. },
  66. imageList:[],//图片链接
  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. imageFile:[],
  96. phoneTF:true//手机号判断
  97. }
  98. },
  99. methods: {
  100. clickLeft(){//返回
  101. uni.navigateTo({
  102. url:"./index"
  103. })
  104. },
  105. gainimg(index){//添加图片
  106. uni.chooseImage({
  107. count: 1, //默认9
  108. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  109. sourceType: ['album','camera'], //从相册选择
  110. success: (res)=> {
  111. uni.uploadFile({
  112. url: 'http://182.92.193.64:8002/api/api_gateway?method=base.bases.base_photo', //仅为示例,非真实的接口地址
  113. filePath: res.tempFilePaths[0],
  114. name: 'img_file',
  115. formData: {
  116. 'user': 'test'
  117. },
  118. success: (uploadFileRes) => {
  119. this.imageList[index]=JSON.parse(uploadFileRes.data).data.src
  120. this.$forceUpdate() //强制刷新视图
  121. this.uploadingTF[index]=true
  122. }
  123. });
  124. }
  125. });
  126. },
  127. gainvideo(index){//添加视频
  128. uni.chooseVideo({
  129. count: 1,
  130. mediaType:['video'],
  131. success:(res)=> {
  132. uni.uploadFile({
  133. url: 'http://182.92.193.64:8002/api/api_gateway?method=after_sale.after_sale_manage.video_upload', //仅为示例,非真实的接口地址
  134. file: res.tempFile,
  135. name: 'upload',
  136. formData: {
  137. 'user': 'test'
  138. },
  139. success: (uploadFileRes) => {
  140. this.selfList[index]=JSON.parse(uploadFileRes.data).data.data.src
  141. this.$forceUpdate() //强制刷新视图
  142. this.uploadingTF[index+3]=true
  143. }
  144. });
  145. }
  146. });
  147. },
  148. deletes(index){//删除
  149. this.uploadingTF[index]=false
  150. this.$forceUpdate() //强制刷新视图
  151. },
  152. async getaddafter(data) {//提交数据
  153. const res = await this.$myRequest({
  154. url: '/api/api_gateway?method=after_sale.after_sale_manage.aftersale_apply',
  155. data:{
  156. device_id:data.id,
  157. d_type:data.type,
  158. errordesc:data.text,
  159. errorimg:data.imageList,
  160. errorvideo:data.selfList,
  161. addr:data.site,
  162. user:data.name,
  163. userphone:data.phone,
  164. is_pc:0
  165. }
  166. })
  167. },
  168. async getID(data) {
  169. const res = await this.$myRequest({
  170. url: '/api/api_gateway?method=after_sale.after_sale_manage.device_check',
  171. data:{
  172. device_id:data
  173. }
  174. })
  175. if(res!=''){
  176. this.deviceid=true
  177. }else{
  178. this.deviceid=false
  179. }
  180. },
  181. btn(){//提交按钮
  182. let obj ={}
  183. obj.id=this.adddata.id
  184. obj.type=this.adddata.type_id
  185. obj.text=this.adddata.text
  186. obj.imageList=JSON.stringify(this.imageList)
  187. obj.site=this.adddata.site
  188. obj.name=this.adddata.name
  189. obj.phone=this.adddata.phone
  190. obj.selfList=JSON.stringify(this.selfList)
  191. console.log(obj.imageList)
  192. if(this.deviceid && this.adddata.type_id!=''&&this.phoneTF){
  193. this.getaddafter(obj)
  194. }else{
  195. console.log(1)
  196. uni.showToast({
  197. title: '设备ID和设备类型不能为空',
  198. duration: 2000,
  199. icon:"none"
  200. });
  201. }
  202. },
  203. actionSheetCallback(index) {//选择器选择
  204. this.adddata.type = this.actionSheetList[index].text;
  205. this.adddata.type_id=index+2
  206. },
  207. iphone(){//检测手机
  208. if(!/^1[23456789]\d{9}$/.test(this.adddata.phone)){
  209. uni.showToast({
  210. title: '手机号格式不正确',
  211. duration: 2000,
  212. icon:'none'
  213. });
  214. this.phoneTF=false
  215. }
  216. },
  217. addID(){
  218. this.getID(this.adddata.id)
  219. }
  220. }
  221. }
  222. </script>
  223. <style lang="scss">
  224. .addafter_con{
  225. width: 100%;
  226. padding: 110rpx 0;
  227. background-color: #71CD9A;
  228. .addafter_con_top{
  229. width: 90%;
  230. margin: 0 auto;
  231. background-color: #FFFFFF;
  232. padding: 16rpx 30rpx 36rpx;
  233. border-radius: 20rpx;
  234. p{
  235. text-align: center;
  236. font-size: 30rpx;
  237. color: #62BF89;
  238. }
  239. input{
  240. margin-top: 20rpx;
  241. background-color: #F1FAF5;
  242. color: #62BF89;
  243. font-size:26rpx;
  244. padding: 8rpx 26rpx;
  245. border-radius: 20rpx;
  246. }
  247. }
  248. .addafter_con_connect{
  249. width: 90%;
  250. margin: -20rpx auto;
  251. display: flex;
  252. justify-content: space-between;
  253. padding: 0 16rpx;
  254. image{
  255. width: 20rpx;
  256. height: 60rpx;
  257. }
  258. }
  259. .addafter_con_bot{
  260. width: 90%;
  261. margin: 0 auto;
  262. background-color: #FFFFFF;
  263. padding: 30rpx;
  264. border-radius: 20rpx;
  265. .addafter_con_bot_title{
  266. text-align: center;
  267. font-size: 30rpx;
  268. color: #62BF89;
  269. }
  270. .textarea{
  271. width: 94%;
  272. height: 240rpx;
  273. padding: 20rpx;
  274. background-color: #F1FAF5;
  275. margin-top: 20rpx;
  276. font-size: 26rpx;
  277. border-radius: 20rpx;
  278. color: #62BF89;
  279. }
  280. }
  281. .imgvideo{
  282. width: 100%;
  283. margin-top: 20rpx;
  284. background-color: #FFFFFF;
  285. display: flex;
  286. justify-content: space-around;
  287. flex-wrap: wrap;
  288. .imgvideo_img,.imgvideo_video{
  289. width: 30%;
  290. height: 160rpx;
  291. border: 2rpx dashed #A3DABD;
  292. text-align: center;
  293. line-height: 160rpx;
  294. margin-bottom: 20rpx;
  295. position: relative;
  296. image{
  297. width: 40rpx;
  298. height: 32rpx;
  299. }
  300. .uploading{
  301. width: 100%;
  302. height: 160rpx;
  303. position: absolute;
  304. top: 0;
  305. left: 0;
  306. .delete{
  307. position: absolute;
  308. top: -12rpx;
  309. right: -12rpx;
  310. font-size: 12rpx;
  311. background-color: #FE0000;
  312. border-radius: 50%;
  313. color: #ffffff;
  314. z-index: 50;
  315. }
  316. }
  317. }
  318. }
  319. button{
  320. width: 100%;
  321. height: 60rpx;
  322. font-size: 30rpx;
  323. line-height: 60rpx;
  324. color: #FFFFFF;
  325. background-color: #50CE87;
  326. margin-top: 40rpx;
  327. }
  328. }
  329. </style>