addCar.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  1. <template>
  2. <view class="content">
  3. <!-- 填写车辆信息 -->
  4. <view class="carMessage">
  5. <view class="mesView">
  6. <view class="leftTitle">车牌号</view>
  7. <input class="plateNumber" placeholder-style="color:#999999" placeholder="请输入车牌号" disabled="true"
  8. @tap="plateShow=true" v-model.trim="plateNo" />
  9. <plate-input v-if="plateShow" :plate="plateNo" @export="setPlate" @close="plateShow=false" />
  10. </view>
  11. <view class="mesView" @click="goCarModel()">
  12. <view class="leftTitle">车型</view>
  13. <view class="carModBtn noSelectColor" v-if="!carModelInfo.title">请选择车型</view>
  14. <view class="carModBtn selectColor" v-else>{{carModelInfo.title}}</view>
  15. <image src="../../static/img/rightArrow.png" class="rightArrow"></image>
  16. </view>
  17. <view class="mesView">
  18. <view class="leftTitle">购车时间</view>
  19. <picker class="timeBtn" @change="bindChange" mode="date">
  20. <view class="uni-input selectColor" v-if="time">{{time}}</view>
  21. <view class="uni-input noSelectColor" v-else>请选择您的购车时间</view>
  22. </picker>
  23. <image src="../../static/img/rightArrow.png" class="rightArrow"></image>
  24. </view>
  25. <view class="mesView">
  26. <view class="leftTitle">行驶里程</view>
  27. <input class="mileageInput selectColor" type="number" v-model="mileage" placeholder="请输入"
  28. placeholder-style="color:#999999" />
  29. <view class="kmStr">km</view>
  30. </view>
  31. </view>
  32. <view class="bottomView">
  33. <view class="saveCar" @click="saveCar()">
  34. <image src="../../static/img/icon_tianjiacheliang.png" mode="" style="width: 44rpx; height: 36rpx; margin-right: 10rpx;"></image>
  35. <view>保存爱车</view>
  36. </view>
  37. </view>
  38. </view>
  39. </template>
  40. <script>
  41. import plateInput from "@/components/uni-plate-input/uni-plate-input.vue"
  42. export default {
  43. components: {
  44. plateInput
  45. },
  46. data() {
  47. return {
  48. plateNo: '',
  49. plateShow: false,
  50. carModelInfo: '',
  51. time: '',
  52. mileage: '',
  53. carId: '',
  54. isEditCar: false,
  55. }
  56. },
  57. onLoad(opt) {
  58. var carModelInfo = uni.getStorageSync("carModelInfo");
  59. if (carModelInfo) {
  60. this.carModelInfo = carModelInfo;
  61. }
  62. console.log(opt);
  63. this.isEditCar = opt.isEditCar
  64. this.carId = opt.id
  65. if (this.isEditCar == 'true') {
  66. this.getEditData()
  67. }
  68. },
  69. onShow() {
  70. var carModelInfo = uni.getStorageSync("carModelInfo");
  71. if (carModelInfo) {
  72. this.carModelInfo = carModelInfo;
  73. }
  74. },
  75. methods: {
  76. getEditData() {
  77. uni.showLoading({});
  78. var carModelInfo = {
  79. carModelInfo: {
  80. }
  81. }
  82. this.$http('worldKeepCar/worldHome/queryMyTMemberCarDetail', {
  83. id: this.carId
  84. }, 'GET').then(res => {
  85. uni.hideLoading();
  86. carModelInfo.carModelInfo.logo = res.data.brandLogo;
  87. carModelInfo.carModelInfo.brand = res.data.brand;
  88. carModelInfo.carModelInfo.carSeries = res.data.series;
  89. carModelInfo.carModelInfo.displacement = res.data.displacement;
  90. carModelInfo.carModelInfo.transmissionType = res.data.transmissionType;
  91. carModelInfo.carModelInfo.modelYear = res.data.annualmoney;
  92. carModelInfo.carModelInfo.carModel = res.data.carModel;
  93. carModelInfo.carModelInfo.guidePrice = res.data.guidePrice;
  94. // 展示时
  95. this.plateNo = res.data.plateNumber;
  96. carModelInfo.title = res.data.carModel;
  97. this.time = res.data.createTime.slice(0,res.data.createTime.length-8);
  98. this.mileage = res.data.milage;
  99. this.carModelInfo = carModelInfo;
  100. })
  101. },
  102. goCarModel() {
  103. uni.navigateTo({
  104. url: 'carModel'
  105. })
  106. },
  107. setPlate(plate) {
  108. if (plate.length >= 7) this.plateNo = plate;
  109. this.plateShow = false;
  110. },
  111. bindChange(e) {
  112. console.log(e);
  113. this.time = e.target.value
  114. },
  115. saveCar() {
  116. uni.showLoading({});
  117. if (this.plateNo == '') {
  118. uni.showToast({
  119. title: '请填写车牌号',
  120. icon: 'none',
  121. duration: 3000
  122. });
  123. return false;
  124. }
  125. if (this.carModelInfo == '') {
  126. uni.showToast({
  127. title: '请选择车型',
  128. icon: 'none',
  129. duration: 3000
  130. });
  131. return false;
  132. }
  133. if (this.time == '') {
  134. uni.showToast({
  135. title: '请选择购车时间',
  136. icon: 'none',
  137. duration: 3000
  138. });
  139. return false;
  140. }
  141. if (this.mileage == '') {
  142. uni.showToast({
  143. title: '请输入行驶里程',
  144. icon: 'none',
  145. duration: 3000
  146. });
  147. return false;
  148. }
  149. if (this.isEditCar == 'true') {
  150. this.updateTMemberCar()
  151. }
  152. else {
  153. this.addTMemberCar()
  154. }
  155. },
  156. addTMemberCar(){
  157. this.$http('worldKeepCar/worldHome/addTMemberCar', {
  158. plateNumber: this.plateNo,
  159. milage: this.mileage,
  160. brand: this.carModelInfo.carModelInfo.brand,
  161. displacement: this.carModelInfo.carModelInfo.displacement,
  162. series: this.carModelInfo.carModelInfo.carSeries,
  163. annualmoney: this.carModelInfo.carModelInfo.productionYear,
  164. carModel: this.carModelInfo.title,
  165. salesName: this.carModelInfo.carModelInfo.salesName,
  166. transmissionType: this.carModelInfo.carModelInfo.transmissionType,
  167. model: this.carModelInfo.carModelInfo.carModel,
  168. nLevelID: this.carModelInfo.carModelInfo.nLevelID,
  169. engineType: this.carModelInfo.carModelInfo.engineModel,
  170. brandLogo: this.carModelInfo.carModelInfo.logo,
  171. AcarTime: this.time,
  172. guidePrice: this.carModelInfo.carModelInfo.guidePrice,
  173. }, 'POST').then(res => {
  174. uni.hideLoading();
  175. if (res.code == 0) {
  176. uni.showToast({
  177. title: '保存成功',
  178. icon: 'none',
  179. duration: 3000
  180. });
  181. uni.removeStorageSync('carModelInfo');
  182. setTimeout(function() {
  183. uni.navigateBack({
  184. })
  185. }, 3000);
  186. } else {
  187. uni.showToast({
  188. title: res.msg,
  189. icon: 'none',
  190. duration: 3000
  191. });
  192. }
  193. })
  194. },
  195. updateTMemberCar(){
  196. this.$http('worldKeepCar/worldHome/updateTMemberCar', {
  197. plateNumber: this.plateNo,
  198. milage: this.mileage,
  199. brand: this.carModelInfo.carModelInfo.brand,
  200. displacement: this.carModelInfo.carModelInfo.displacement,
  201. series: this.carModelInfo.carModelInfo.carSeries,
  202. annualmoney: this.carModelInfo.carModelInfo.productionYear,
  203. carModel: this.carModelInfo.title,
  204. salesName: this.carModelInfo.carModelInfo.salesName,
  205. transmissionType: this.carModelInfo.carModelInfo.transmissionType,
  206. model: this.carModelInfo.carModelInfo.carModel,
  207. nLevelID: this.carModelInfo.carModelInfo.nLevelID,
  208. engineType: this.carModelInfo.carModelInfo.engineModel,
  209. brandLogo: this.carModelInfo.carModelInfo.logo,
  210. AcarTime: this.time,
  211. guidePrice: this.carModelInfo.carModelInfo.guidePrice,
  212. id: this.carId,
  213. }, 'POST').then(res => {
  214. uni.hideLoading();
  215. if (res.code == 0) {
  216. uni.showToast({
  217. title: '保存成功',
  218. icon: 'none',
  219. duration: 3000
  220. });
  221. uni.removeStorageSync('carModelInfo');
  222. setTimeout(function() {
  223. uni.navigateBack({
  224. })
  225. }, 3000);
  226. } else {
  227. uni.showToast({
  228. title: res.msg,
  229. icon: 'none',
  230. duration: 3000
  231. });
  232. }
  233. })
  234. },
  235. }
  236. }
  237. </script>
  238. <style>
  239. .content {
  240. min-height: 100vh;
  241. background-color: #F4F5F7;
  242. padding-top: 20rpx;
  243. }
  244. .carMessage {
  245. margin: 0rpx 24rpx 40rpx;
  246. padding-top: 20rpx;
  247. height: 500rpx;
  248. background-color: #FFFFFF;
  249. border-radius: 10rpx;
  250. }
  251. .mesView {
  252. display: flex;
  253. align-items: center;
  254. width: 100%;
  255. height: 120rpx;
  256. background-color: #FFFFFF;
  257. }
  258. .leftTitle {
  259. margin: 28rpx;
  260. width: 120rpx;
  261. font-size: 28rpx;
  262. color: #666666;
  263. }
  264. .noSelectColor {
  265. color: #999999;
  266. }
  267. .selectColor {
  268. color: #333333;
  269. }
  270. .rightArrow {
  271. margin-right: 28rpx;
  272. width: 14rpx;
  273. height: 23rpx;
  274. }
  275. .cityBtn {
  276. width: 65%;
  277. font-size: 28rpx;
  278. }
  279. .plateNumber {
  280. width: 55%;
  281. font-size: 28rpx;
  282. }
  283. .carModBtn {
  284. width: 65%;
  285. font-size: 28rpx;
  286. }
  287. .timeBtn {
  288. width: 65%;
  289. font-size: 28rpx;
  290. }
  291. .mileageInput {
  292. width: 20%;
  293. font-size: 28rpx;
  294. }
  295. .kmStr {
  296. font-size: 28rpx;
  297. color: #333333;
  298. }
  299. .bottomView {
  300. background-color: #FFFFFF;
  301. width: 100%;
  302. height: 120rpx;
  303. position: fixed;
  304. bottom: 0rpx;
  305. }
  306. .saveCar {
  307. background: linear-gradient(135deg, #FD5300 0%, #FF270A 100%);
  308. margin: 23rpx 30rpx;
  309. height: 74rpx;
  310. border-radius: 37rpx;
  311. color: #FFFFFF;
  312. font-size: 30rpx;
  313. font-weight: bold;
  314. align-items: center;
  315. display: flex;
  316. justify-content: center;
  317. }
  318. </style>