addafter.vue 9.2 KB

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