index.vue 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <template>
  2. <view class="eva-body">
  3. <!-- 页头step -->
  4. <view class="step">
  5. <view class="step1">
  6. <image :src="require('../../../static/1..png')" alt="">
  7. <view class="span">提交车辆故障信息</view>
  8. </view>
  9. <image :src="require('../../../static/tiaozhuan.png')" alt="">
  10. <view class="step2">
  11. <image :src="require('../../../static/2..png')" alt="">
  12. <view class="span">专业师傅评估报价</view>
  13. </view>
  14. </view>
  15. <!-- 选择车辆 -->
  16. <navigator url="/pages/preCarWash/chooseCar/index" class="chooseCar">
  17. <view class="carsMsg">
  18. <image :src="cardMsg.brandLogo?baseImagePath+cardMsg.brandLogo: carImg" alt="">
  19. <view v-if="cardMsg.brandLogo" class="carNa">
  20. {{cardMsg.brandName}} {{cardMsg.carSeriesName}}
  21. </view>
  22. <view v-else class="carNa" style="color: #666666;">
  23. {{carTitle}}
  24. </view>
  25. </view>
  26. <image :src="require('../../../static/choose.png')" alt="">
  27. </navigator>
  28. <!-- 描述详情 -->
  29. <view
  30. style="background-color: #FFFFFF;width: 710rpx;position: relative;left: calc(50% - 355rpx);border-radius: 8px;">
  31. <view class="eva-detail">
  32. <textarea class="textarea" :value="textData" @input="textInput" placeholder="请输入车辆遇到的问题/状况描述"
  33. placeholder-class="classTextarea" maxlength="-1"></textarea>
  34. </view>
  35. <!-- 上传图片 -->
  36. <view class="uploadFile">
  37. <view class="uploadView" v-for="(item, index) in uploadFileList" :key="index">
  38. <image @click="del(index)" class="uploadDelete" :src="require('../../../static/uploadDelete.png')"
  39. alt="">
  40. <image class="uploadImg" :src="item" alt="">
  41. </view>
  42. <view class="uploadView">
  43. <image @click="upload" class="uploadImg" :src="require('../../../static/upload-pic.png')" alt="">
  44. </view>
  45. </view>
  46. <!-- 上传视频 -->
  47. <view class="uploadFile" style="padding-bottom: 46rpx;">
  48. <view class="uploadView">
  49. <image v-if="videoFilePath!=''" @click="delvideo()" class="uploadDelete"
  50. :src="require('../../../static/uploadDelete.png')" alt="">
  51. <image v-if="videoFilePath==''" @click="chooseVideo" class="uploadImg"
  52. :src="require('../../../static/upload-video.png')" alt="">
  53. <video v-else class="uploadImg" :src="videoFilePath"></video>
  54. </view>
  55. </view>
  56. </view>
  57. <!-- 提交 -->
  58. <view class="submit" @click="submit()">
  59. 提交
  60. </view>
  61. <!-- 历史估价记录 -->
  62. <view @click="topath()" class="history">
  63. 历史估价记录
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import {
  69. getUserCar
  70. } from "@/api/shop.js"
  71. import {
  72. setEvaluationAdd
  73. } from "@/api/maintain.js"
  74. export default {
  75. data: function() {
  76. return {
  77. carImg: require("../../../static/morentu.png"),
  78. carTitle: "请选择车辆",
  79. carData: {
  80. id: 1,
  81. carImg: require("../../../static/qiche.png"),
  82. carTitle: "奥迪a6l 2017款 30 fsi 技术型 fsi 技术型"
  83. },
  84. baseImagePath: this.baseImagePath,
  85. textData: "",
  86. uploadFileList: [
  87. ],
  88. imgUrls: "",
  89. videoUrl: "",
  90. videoFilePath: "",
  91. cardMsg: {}
  92. }
  93. },
  94. onLoad() {
  95. this.getUserCar()
  96. },
  97. onShow: function() { //option为object类型,会序列化上个页面传递的参数
  98. let that = this;
  99. uni.$on('chooseCar', function(data) {
  100. that.cardMsg = data;
  101. })
  102. },
  103. methods: {
  104. getUserCar() {
  105. console.log('-------------------------------------------------------------');
  106. getUserCar().then(res => {
  107. console.log(res, '返回');
  108. this.cardMsg = res.data;
  109. })
  110. },
  111. textInput(e) {
  112. this.textData = e.detail.value;
  113. },
  114. topath() {
  115. this.$yrouter.push({
  116. path: "/pages/maintenance/evaluate/history/index"
  117. });
  118. },
  119. submit() {
  120. if (!this.carData.id) {
  121. uni.showToast({
  122. icon: "none",
  123. title: '请选择您的车辆'
  124. })
  125. } else if (!this.textData) {
  126. uni.showToast({
  127. icon: "none",
  128. title: '请输入估计内容'
  129. })
  130. } else if (!this.imgUrls) {
  131. uni.showToast({
  132. icon: "none",
  133. title: '请输至少上传一张图片'
  134. })
  135. } else {
  136. setEvaluationAdd({
  137. carId: this.carData.id,
  138. describes: this.textData,
  139. imgUrls: this.imgUrls,
  140. videoUrl: this.videoUrl
  141. }).then(res => {
  142. if (res.code == "00000") {
  143. uni.showToast({
  144. title: '预约成功',
  145. icon: 'none',
  146. duration: 3000
  147. });
  148. setTimeout(res => {
  149. uni.navigateBack({
  150. delta: 1 //返回两层页面
  151. });
  152. }, 3000)
  153. }
  154. })
  155. }
  156. },
  157. upload() {
  158. let that = this;
  159. uni.chooseImage({
  160. count: 9, //默认9
  161. sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
  162. sourceType: ['album'], //从相册选择
  163. loop: true,
  164. success: res => {
  165. if (res.tempFilePaths.length != 0) {
  166. this.uploadFileList.push(res.tempFilePaths[0]);
  167. }
  168. var tempFilePaths = res.tempFilePaths;
  169. var tempFiles = res.tempFiles;
  170. uni.uploadFile({
  171. url: 'https://api.biaodianfuhao.net/api/common/sysFileInfo/upload',
  172. fileType: 'image',
  173. filePath: tempFilePaths[0],
  174. file: tempFiles[0],
  175. name: 'file',
  176. success: uploadFileRes => {
  177. let uploadRes = JSON.parse(uploadFileRes.data);
  178. if (that.imgUrls == "") {
  179. that.imgUrls = uploadRes.data;
  180. } else {
  181. that.imgUrls = that.imgUrls + "," + uploadRes.data
  182. }
  183. },
  184. fail(err) {
  185. console.log(err);
  186. }
  187. });
  188. }
  189. });
  190. },
  191. chooseVideo() {
  192. let that = this;
  193. // 上传视频
  194. uni.chooseVideo({
  195. maxDuration: 60,
  196. count: 1,
  197. camera: 'back',
  198. sourceType: ['album', 'camera'],
  199. success: (responent) => {
  200. this.videoFilePath = responent.tempFilePath;
  201. let videoFile = responent.tempFile;
  202. uni.uploadFile({
  203. url: 'https://api.biaodianfuhao.net/api/common/sysFileInfo/upload',
  204. fileType: 'video',
  205. filePath: this.videoFilePath,
  206. file: videoFile,
  207. name: 'file',
  208. success: uploadFileRes => {
  209. let uploadRes = JSON.parse(uploadFileRes.data);
  210. that.videoUrl = uploadRes.data;
  211. },
  212. fail(err) {
  213. console.log(err);
  214. }
  215. });
  216. // this.src = responent.tempFilePath; //头条
  217. }
  218. })
  219. },
  220. // 删除图片
  221. del(index) {
  222. this.uploadFileList.splice(index, 1);
  223. console.log(this.uploadFileList);
  224. },
  225. delvideo() {
  226. this.videoFilePath = "";
  227. }
  228. }
  229. }
  230. </script>
  231. <style lang="less">
  232. page {
  233. background: #F5F5F5;
  234. }
  235. .history {
  236. width: 600rpx;
  237. height: 90rpx;
  238. background: #FFFFFF;
  239. border: 1px solid #0063FF;
  240. border-radius: 45rpx;
  241. font-size: 32rpx;
  242. font-family: PingFang SC;
  243. font-weight: 500;
  244. color: #0063FF;
  245. text-align: center;
  246. line-height: 90rpx;
  247. margin: 50rpx 75rpx 0 75rpx;
  248. }
  249. .submit {
  250. width: 600rpx;
  251. height: 90rpx;
  252. background: linear-gradient(0deg, #005AFF 0%, #0078FF 100%);
  253. border-radius: 45rpx;
  254. font-size: 32rpx;
  255. font-family: PingFang SC;
  256. font-weight: 500;
  257. color: #FFFFFF;
  258. text-align: center;
  259. line-height: 90rpx;
  260. margin: 60rpx 75rpx 0 75rpx;
  261. }
  262. .uploadFile {
  263. width: 630rpx;
  264. height: 146rpx;
  265. display: flex;
  266. background: #ffffff;
  267. overflow-x: auto;
  268. padding: 0 40rpx 21rpx 40rpx;
  269. .uploadView {
  270. position: relative;
  271. .uploadImg {
  272. width: 146rpx;
  273. height: 146rpx;
  274. background: #FFFFFF;
  275. border-radius: 8px;
  276. margin-right: 17rpx;
  277. margin-bottom: 21rpx;
  278. }
  279. .uploadDelete {
  280. width: 26rpx;
  281. height: 26rpx;
  282. border-radius: 0 8px 0 0;
  283. position: absolute;
  284. top: 0;
  285. right: 17rpx;
  286. z-index: 9;
  287. }
  288. }
  289. }
  290. .eva-body {
  291. .step {
  292. width: 100%;
  293. height: 70rpx;
  294. background: #E9F3FF;
  295. display: flex;
  296. justify-content: space-around;
  297. align-items: center;
  298. .step1 {
  299. display: flex;
  300. align-items: baseline;
  301. image {
  302. width: 24rpx;
  303. height: 27rpx;
  304. }
  305. .span {
  306. margin-left: 14rpx;
  307. font-size: 26rpx;
  308. font-family: PingFang SC;
  309. font-weight: 500;
  310. color: #006AFF;
  311. line-height: 31rpx;
  312. }
  313. }
  314. image {
  315. width: 11rpx;
  316. height: 19rpx;
  317. }
  318. .step2 {
  319. display: flex;
  320. align-items: baseline;
  321. image {
  322. width: 24rpx;
  323. height: 27rpx;
  324. }
  325. .span {
  326. margin-left: 14rpx;
  327. font-size: 26rpx;
  328. font-family: PingFang SC;
  329. font-weight: 500;
  330. color: #006AFF;
  331. line-height: 31rpx;
  332. }
  333. }
  334. }
  335. }
  336. .chooseCar {
  337. width: 710rpx;
  338. height: 170rpx;
  339. background: #FFFFFF;
  340. border-radius: 10rpx;
  341. margin-top: 15rpx;
  342. margin-left: 20rpx;
  343. display: flex;
  344. align-items: center;
  345. justify-content: space-between;
  346. .carsMsg {
  347. display: flex;
  348. align-items: center;
  349. image {
  350. width: 118rpx;
  351. height: 118rpx;
  352. padding-left: 26rpx;
  353. }
  354. .carNa {
  355. font-size: 32rpx;
  356. font-family: PingFang SC;
  357. font-weight: 500;
  358. color: #333333;
  359. line-height: 42rpx;
  360. padding: 0 33rpx 0 33rpx;
  361. }
  362. }
  363. image {
  364. width: 15rpx;
  365. height: 27rpx;
  366. padding-right: 28rpx;
  367. }
  368. }
  369. .eva-detail {
  370. width: 710rpx;
  371. background: #FFFFFF;
  372. border-radius: 10rpx 10rpx 0 0;
  373. margin: 20rpx 20rpx 0 0rpx;
  374. .textarea {
  375. width: 630rpx;
  376. height: 150rpx;
  377. padding: 40rpx;
  378. }
  379. }
  380. .classTextarea {
  381. font-size: 28rpx;
  382. font-family: PingFang SC;
  383. font-weight: 500;
  384. color: #BFBFBF;
  385. line-height: 34rpx
  386. }
  387. </style>