addafter.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. if(this.deviceid && this.adddata.type_id!=''&&this.phoneTF){
  192. this.getaddafter(obj)
  193. }else{
  194. console.log(1)
  195. uni.showToast({
  196. title: '设备ID和设备类型不能为空',
  197. duration: 2000,
  198. icon:"none"
  199. });
  200. }
  201. },
  202. actionSheetCallback(index) {//选择器选择
  203. this.adddata.type = this.actionSheetList[index].text;
  204. this.adddata.type_id=index+2
  205. },
  206. iphone(){//检测手机
  207. if(!/^1[23456789]\d{9}$/.test(this.adddata.phone)){
  208. uni.showToast({
  209. title: '手机号格式不正确',
  210. duration: 2000,
  211. icon:'none'
  212. });
  213. this.phoneTF=false
  214. }
  215. },
  216. addID(){
  217. this.getID(this.adddata.id)
  218. }
  219. }
  220. }
  221. </script>
  222. <style lang="scss">
  223. .addafter_con{
  224. width: 100%;
  225. padding: 110rpx 0;
  226. background-color: #71CD9A;
  227. .addafter_con_top{
  228. width: 90%;
  229. margin: 0 auto;
  230. background-color: #FFFFFF;
  231. padding: 16rpx 30rpx 36rpx;
  232. border-radius: 20rpx;
  233. p{
  234. text-align: center;
  235. font-size: 30rpx;
  236. color: #62BF89;
  237. }
  238. input{
  239. margin-top: 20rpx;
  240. background-color: #F1FAF5;
  241. color: #62BF89;
  242. font-size:26rpx;
  243. padding: 8rpx 26rpx;
  244. border-radius: 20rpx;
  245. }
  246. }
  247. .addafter_con_connect{
  248. width: 90%;
  249. margin: -20rpx auto;
  250. display: flex;
  251. justify-content: space-between;
  252. padding: 0 16rpx;
  253. image{
  254. width: 20rpx;
  255. height: 60rpx;
  256. }
  257. }
  258. .addafter_con_bot{
  259. width: 90%;
  260. margin: 0 auto;
  261. background-color: #FFFFFF;
  262. padding: 30rpx;
  263. border-radius: 20rpx;
  264. .addafter_con_bot_title{
  265. text-align: center;
  266. font-size: 30rpx;
  267. color: #62BF89;
  268. }
  269. .textarea{
  270. width: 94%;
  271. height: 240rpx;
  272. padding: 20rpx;
  273. background-color: #F1FAF5;
  274. margin-top: 20rpx;
  275. font-size: 26rpx;
  276. border-radius: 20rpx;
  277. color: #62BF89;
  278. }
  279. }
  280. .imgvideo{
  281. width: 100%;
  282. margin-top: 20rpx;
  283. background-color: #FFFFFF;
  284. display: flex;
  285. justify-content: space-around;
  286. flex-wrap: wrap;
  287. .imgvideo_img,.imgvideo_video{
  288. width: 30%;
  289. height: 160rpx;
  290. border: 2rpx dashed #A3DABD;
  291. text-align: center;
  292. line-height: 160rpx;
  293. margin-bottom: 20rpx;
  294. position: relative;
  295. image{
  296. width: 40rpx;
  297. height: 32rpx;
  298. }
  299. .uploading{
  300. width: 100%;
  301. height: 160rpx;
  302. position: absolute;
  303. top: 0;
  304. left: 0;
  305. .delete{
  306. position: absolute;
  307. top: -12rpx;
  308. right: -12rpx;
  309. font-size: 12rpx;
  310. background-color: #FE0000;
  311. border-radius: 50%;
  312. color: #ffffff;
  313. z-index: 50;
  314. }
  315. }
  316. }
  317. }
  318. button{
  319. width: 100%;
  320. height: 60rpx;
  321. font-size: 30rpx;
  322. line-height: 60rpx;
  323. color: #FFFFFF;
  324. background-color: #50CE87;
  325. margin-top: 40rpx;
  326. }
  327. }
  328. </style>