index.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491
  1. <template>
  2. <view class="content">
  3. <!-- 轮播图 -->
  4. <view class="bBannerList">
  5. <swiper class="swiper" :autoplay="autoplay" :interval="interval" :duration="duration" :circular="true">
  6. <swiper-item v-for="(item,index) in imgData" @click="carBswpClick(item)" v-if="!shopId">
  7. <view class="swiper-item uni-bg-red">
  8. <image :src="item.logo" mode="" class="swpImg"></image>
  9. </view>
  10. </swiper-item>
  11. <swiper-item v-for="(item,index) in imgData" @click="carBswpClickshop(item)" v-if="shopId">
  12. <view class="swiper-item uni-bg-red">
  13. <image :src="item.logo" mode="" class="swpImg"></image>
  14. </view>
  15. </swiper-item>
  16. </swiper>
  17. </view>
  18. <!-- 填写车辆信息 -->
  19. <view class="carMessage">
  20. <view class="mesView">
  21. <view class="leftTitle">城市</view>
  22. <view class="cityBtn noSelectColor" v-if="!cityName" @click="showCity">请选择</view>
  23. <view class="cityBtn selectColor" v-else @click="showCity">{{cityName}}</view>
  24. <image src="../../static/img/rightArrow.png" class="rightArrow"></image>
  25. </view>
  26. <view class="line"></view>
  27. <view class="mesView">
  28. <view class="leftTitle">车牌号</view>
  29. <view class="rightView" v-if="!memberCar">
  30. <view class="plateNumber noSelectColor">请添加您的爱车</view>
  31. <view class="changeCarBg" @click="addCar()">
  32. <image src="../../static/img/icon_tianjia.png"
  33. style="width: 32rpx; height: 34rpx; margin-right: 5rpx;"></image>
  34. <view style="color: #FF2400; font-size: 28rpx;">添加</view>
  35. </view>
  36. </view>
  37. <view class="rightView" v-else>
  38. <view class="plateNumber selectColor">{{memberCar.plateNumber}}</view>
  39. <view class="changeCarBg" @click="goCarList()">
  40. <image src="../../static/img/icon_change.png"
  41. style="width: 32rpx; height: 34rpx; margin-right: 5rpx;"></image>
  42. <view style="color: #FF2400; font-size: 28rpx;">换车</view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="line"></view>
  47. <view class="mesView">
  48. <view class="leftTitle">车型</view>
  49. <view class="carModBtn selectColor carMod" v-if="memberCar">{{memberCar.carModel}}</view>
  50. <view class="carModBtn noSelectColor" v-else>车型</view>
  51. </view>
  52. <view class="line"></view>
  53. <view class="mesView">
  54. <view class="leftTitle">行驶里程</view>
  55. <input class="mileageInput selectColor" type="number" v-model="mileage" placeholder="请输入"
  56. placeholder-style="color:#999999" @input="upMileage" />
  57. <view class="kmStr">km</view>
  58. </view>
  59. </view>
  60. <view class="look4s" @click="gomodule">查看4S店保养价格</view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. data() {
  66. return {
  67. imgData: [],
  68. uid: '',
  69. cityName: '',
  70. cityCode: '',
  71. memberCar: '',
  72. locationCity: {
  73. cityName: '',
  74. cityCode: '',
  75. lng: '',
  76. lat: '',
  77. },
  78. time: '',
  79. mileage: '',
  80. autoplay: true,
  81. interval: 2000,
  82. duration: 500,
  83. brand:'',
  84. cityRole:'',
  85. }
  86. },
  87. onLoad() {
  88. },
  89. onShow() {
  90. var that = this;
  91. that.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  92. that.uid = uni.getStorageSync("logodata").uid;
  93. var selectCity = uni.getStorageSync("selectCity");
  94. if (selectCity) {
  95. //有选择的城市
  96. that.cityName = selectCity.city
  97. that.cityCode = selectCity.code
  98. } else{
  99. //定位到的城市
  100. var nowCity = uni.getStorageSync("locationCity");
  101. if (nowCity) {
  102. that.cityName = nowCity.cityName
  103. that.cityCode = nowCity.cityCode
  104. if (that.uid) {
  105. that.queryHomeDetail();
  106. }
  107. } else {
  108. // 重新去定位城市
  109. that.getLocation()
  110. }
  111. }
  112. if (that.uid) {
  113. that.queryHomeDetail();
  114. }
  115. },
  116. methods: {
  117. upMileage(){
  118. this.$http('worldKeepCar/worldHome/updateTMemberCarByHome', {
  119. id: this.memberCar.id,
  120. milage: this.mileage?this.mileage:0,
  121. }, 'POST').then(res => {
  122. uni.hideLoading();
  123. console.log(res);
  124. if (res.code == 0) {
  125. var cardata = uni.getStorageSync("maintainCarData")
  126. if (cardata) {
  127. cardata.milage = this.mileage
  128. uni.setStorage({
  129. key: 'maintainCarData',
  130. data: cardata,
  131. success: function () {
  132. }
  133. });
  134. }
  135. }
  136. })
  137. },
  138. getLocation() {
  139. const that = this
  140. uni.getLocation({
  141. type: 'gcj02',
  142. success: function(res) {
  143. console.log('定位', res)
  144. that.locationCity.lng = res.longitude
  145. that.locationCity.lat = res.latitude
  146. that.getAdress();
  147. },
  148. fail(err) {
  149. console.log(err)
  150. }
  151. });
  152. },
  153. getAdress() {
  154. // 根据经纬度 逆城市地理编码 获取城市信息
  155. var location = this.locationCity.lng + ',' + this.locationCity.lat
  156. uni.request({
  157. url: 'https://restapi.amap.com/v3/place/around',
  158. data: {
  159. key: '064b6a4a8ade55656edcde2f528876de',
  160. location: location,
  161. types: "190000",
  162. extensions: "all",
  163. radius: 100
  164. },
  165. dataType: "json",
  166. success: (res) => {
  167. console.log('定位城市', res);
  168. let cityname = res.data.pois[0].cityname;
  169. var cityCode = res.data.pois[0].adcode
  170. cityCode = cityCode.slice(0, -2)
  171. cityCode = cityCode + '00'
  172. this.locationCity.cityName = cityname
  173. this.locationCity.cityCode = cityCode
  174. uni.setStorage({
  175. key: 'locationCity',
  176. data: this.locationCity,
  177. success: function() {
  178. console.log('定位城市,保存成功');
  179. }
  180. })
  181. this.cityName = this.locationCity.cityName
  182. this.cityCode = this.locationCity.cityCode
  183. }
  184. });
  185. },
  186. showCity(){
  187. uni.navigateTo({
  188. url:'../chooseCity/chooseCity'
  189. })
  190. },
  191. goLonIn(){
  192. uni.navigateTo({
  193. url:'../login/login'
  194. })
  195. },
  196. queryHomeDetail() {
  197. uni.showLoading({
  198. title: '加载中'
  199. })
  200. this.$http('worldKeepCar/worldHome/queryHomeDetail', {
  201. cityCode: this.cityCode
  202. }, 'GET').then(res => {
  203. uni.hideLoading();
  204. this.cityRole = res.data.cityRole
  205. this.imgData = res.data.banners
  206. this.memberCar = res.data.memberCar
  207. if (res.data.memberCar) {
  208. this.mileage = res.data.memberCar.milage
  209. }
  210. else {
  211. this.mileage =''
  212. }
  213. this.brand = res.data.memberCar.brand
  214. var cardata = uni.getStorageSync("maintainCarData")
  215. if (cardata) {
  216. this.memberCar = cardata
  217. if (cardata) {
  218. this.mileage = this.memberCar.milage
  219. }
  220. else {
  221. this.mileage =''
  222. }
  223. this.brand = this.memberCar.brand
  224. }else{
  225. uni.setStorage({
  226. key: 'maintainCarData',
  227. data: this.memberCar,
  228. success: function () {
  229. }
  230. });
  231. }
  232. })
  233. },
  234. gomodule() {
  235. if (!this.uid) {
  236. this.goLonIn();
  237. }
  238. if (!this.cityCode) {
  239. uni.showToast({
  240. title:'请选择城市',
  241. icon:'none',
  242. duration: 3000,
  243. })
  244. return
  245. }
  246. if (!this.memberCar) {
  247. uni.showToast({
  248. title:'请选择车辆',
  249. icon:'none',
  250. duration: 3000,
  251. })
  252. return
  253. }
  254. if (this.cityRole == 0) {
  255. uni.showToast({
  256. title:'所选城市暂时不支持保养,我们正在努力开通哦~',
  257. icon:'none',
  258. duration: 3000,
  259. })
  260. return
  261. }
  262. uni.navigateTo({
  263. url: '../module/maintain?brand='+this.brand
  264. })
  265. },
  266. goCarList() {
  267. if (this.uid) {
  268. uni.navigateTo({
  269. url: 'cailist?type=1'
  270. })
  271. }
  272. },
  273. addCar() {
  274. if (!this.uid) {
  275. this.goLonIn();
  276. }
  277. uni.navigateTo({
  278. url: 'addCar'
  279. })
  280. },
  281. bindChange(e) {
  282. console.log(e);
  283. this.time = e.target.value
  284. },
  285. },
  286. onShareAppMessage:function() {
  287. },
  288. }
  289. </script>
  290. <style>
  291. .content {
  292. min-height: 100vh;
  293. background-color: #F4F5F7;
  294. }
  295. .bBannerList {
  296. width: 100%;
  297. height: 100%;
  298. background-color: #F4F5F7;
  299. }
  300. .swpImg {
  301. width: 100%;
  302. height: 300rpx;
  303. }
  304. .carMessage {
  305. margin: 24rpx 24rpx 40rpx;
  306. padding-top: 10rpx;
  307. height: 500rpx;
  308. background-color: #FFFFFF;
  309. border-radius: 10rpx;
  310. }
  311. .look4s {
  312. margin: 40rpx 24rpx;
  313. height: 88rpx;
  314. line-height: 88rpx;
  315. text-align: center;
  316. background-color: #FD5300;
  317. border-radius: 10rpx;
  318. color: #FFFFFF;
  319. font-weight: bold;
  320. font-size: 30rpx;
  321. }
  322. .mesView {
  323. display: flex;
  324. align-items: center;
  325. width: 100%;
  326. height: 120rpx;
  327. background-color: #FFFFFF;
  328. }
  329. .leftTitle {
  330. margin: 28rpx;
  331. width: 120rpx;
  332. font-size: 28rpx;
  333. color: #666666;
  334. }
  335. .noSelectColor {
  336. color: #999999;
  337. }
  338. .selectColor {
  339. color: #333333;
  340. }
  341. .carMod{
  342. text-overflow: -o-ellipsis-lastline;
  343. overflow: hidden;
  344. text-overflow: ellipsis;
  345. display: -webkit-box;
  346. -webkit-line-clamp: 2;
  347. line-clamp: 2;
  348. -webkit-box-orient: vertical;
  349. }
  350. .rightArrow {
  351. margin-right: 28rpx;
  352. width: 14rpx;
  353. height: 23rpx;
  354. }
  355. .cityBtn {
  356. width: 65%;
  357. font-size: 28rpx;
  358. }
  359. .rightView {
  360. display: flex;
  361. justify-content: space-between;
  362. width: 80%;
  363. }
  364. .plateNumber {
  365. font-size: 28rpx;
  366. }
  367. .carModBtn {
  368. width: 65%;
  369. font-size: 28rpx;
  370. }
  371. .timeBtn {
  372. width: 65%;
  373. font-size: 28rpx;
  374. }
  375. .mileageInput {
  376. width: 20%;
  377. font-size: 28rpx;
  378. }
  379. .kmStr {
  380. font-size: 28rpx;
  381. color: #333333;
  382. }
  383. .changeCarBg {
  384. display: flex;
  385. /* justify-content: flex-start; */
  386. align-items: center;
  387. width: 120rpx;
  388. margin-right: 28rpx;
  389. }
  390. .line{
  391. margin: 0 28rpx;
  392. height: 2rpx;
  393. background-color: #EEEEEE;
  394. }
  395. </style>