index.vue 7.9 KB

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