index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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=true">请选择</view>
  23. <view class="cityBtn selectColor" v-else @click="showCity=true">{{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_change.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>
  49. <view class="mesView">
  50. <view class="leftTitle">行驶里程</view>
  51. <input class="mileageInput selectColor" type="number" v-model="mileage" placeholder="请输入"
  52. placeholder-style="color:#999999" />
  53. <view class="kmStr">km</view>
  54. </view>
  55. </view>
  56. <view class="look4s" @click="gomodule">查看4S店保养价格</view>
  57. <chose-city @selectCity="selectCity" v-if="showCity" @closeModal="closeModal"></chose-city>
  58. </view>
  59. </template>
  60. <script>
  61. import choseCity from "@/components/chose-city/chose-city"
  62. export default {
  63. components: {
  64. choseCity
  65. },
  66. data() {
  67. return {
  68. imgData: [],
  69. uid: '',
  70. cityname: '',
  71. showCity: false,
  72. memberCar: '',
  73. location: {
  74. lng:'',
  75. lat:'',
  76. cityname:'',
  77. cityCode:'',
  78. },
  79. cityCode: '',
  80. time: '',
  81. mileage: '',
  82. autoplay:true,
  83. }
  84. },
  85. onLoad() {
  86. },
  87. onShow() {
  88. var that = this;
  89. this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  90. this.uid = uni.getStorageSync("logodata").uid;
  91. var location = uni.getStorageSync("location");
  92. if (location) {
  93. this.lng = location.lng;
  94. this.lat = location.lat;
  95. this.cityname = location.cityname;
  96. this.cityCode = location.cityCode;
  97. this.location=location
  98. that.queryHomeDetail();
  99. } else {
  100. /* uni.showToast({
  101. title: '请选择城市'
  102. }) */
  103. uni.getLocation({
  104. type: 'gcj02',
  105. success: function (res) {
  106. console.log(res)
  107. that.lng=res.longitude
  108. that.lat=res.latitude
  109. that.getAdress();
  110. },
  111. fail(err) {
  112. }
  113. });
  114. }
  115. },
  116. methods: {
  117. queryHomeDetail() {
  118. uni.showLoading({
  119. title: '加载中'
  120. })
  121. this.$http('worldKeepCar/worldHome/queryHomeDetail', {
  122. cityCode: this.cityCode
  123. }, 'GET').then(res => {
  124. uni.hideLoading();
  125. this.imgData = res.data.banners
  126. this.memberCar = res.data.memberCar
  127. this.mileage = res.data.memberCar.milage
  128. var cardata = uni.getStorageSync("maintainCarData")
  129. if (cardata) {
  130. this.memberCar = cardata
  131. }else{
  132. uni.setStorage({
  133. key: 'maintainCarData',
  134. data: this.memberCar,
  135. success: function () {
  136. }
  137. });
  138. }
  139. })
  140. },
  141. gomodule() {
  142. uni.navigateTo({
  143. url: '../module/maintain'
  144. })
  145. },
  146. goCarList() {
  147. if (this.uid) {
  148. uni.navigateTo({
  149. url: 'cailist?type=1'
  150. })
  151. }
  152. },
  153. addCar() {
  154. uni.navigateTo({
  155. url: 'addCar'
  156. })
  157. },
  158. selectCity(item) {
  159. console.log('-您选择的城市-', item)
  160. console.log(this.location)
  161. this.location.cityname = item.name;
  162. this.location.cityCode = item.citycode;
  163. this.cityname = item.name;
  164. console.log(this.location)
  165. uni.setStorage({
  166. key: 'location',
  167. data: this.location,
  168. success: function() {}
  169. });
  170. this.showCity = false;
  171. },
  172. closeModal() {
  173. this.showCity = false
  174. },
  175. bindChange(e) {
  176. console.log(e);
  177. this.time = e.target.value
  178. },
  179. getAdress(){
  180. var location=this.lng+','+this.lat
  181. uni.request({
  182. url: 'https://restapi.amap.com/v3/place/around', //仅为示例,并非真实接口地址。
  183. data: {
  184. key: '064b6a4a8ade55656edcde2f528876de',
  185. location: location,
  186. types:"190000",
  187. extensions:"all",
  188. radius:100
  189. },
  190. dataType: "json",
  191. success: (res) => {
  192. console.log(res);
  193. this.cityname=res.data.pois[0].cityname;
  194. var cityCode=res.data.pois[0].adcode
  195. cityCode=cityCode.slice(0, -2)
  196. cityCode=cityCode+'00'
  197. this.cityCode=cityCode
  198. var obj={
  199. cityname:this.cityname,
  200. lng:this.lng,
  201. lat:this.lat,
  202. cityCode:cityCode
  203. }
  204. uni.setStorage({
  205. key: 'location',
  206. data: obj,
  207. success: function () {}
  208. });
  209. this.queryHomeDetail();
  210. }
  211. });
  212. },
  213. }
  214. }
  215. </script>
  216. <style>
  217. .content {
  218. min-height: 100vh;
  219. background-color: #F4F5F7;
  220. }
  221. .bBannerList {
  222. width: 100%;
  223. height: 300rpx;
  224. background-color: #F4F5F7;
  225. }
  226. .swpImg {
  227. width: 100%;
  228. height: 300rpx;
  229. }
  230. .carMessage {
  231. margin: 24rpx 24rpx 40rpx;
  232. padding-top: 10rpx;
  233. height: 500rpx;
  234. background-color: #FFFFFF;
  235. border-radius: 10rpx;
  236. }
  237. .look4s {
  238. margin: 40rpx 24rpx;
  239. height: 88rpx;
  240. line-height: 88rpx;
  241. text-align: center;
  242. background-color: #FD5300;
  243. border-radius: 10rpx;
  244. color: #FFFFFF;
  245. font-weight: bold;
  246. font-size: 30rpx;
  247. }
  248. .mesView {
  249. display: flex;
  250. align-items: center;
  251. width: 100%;
  252. height: 120rpx;
  253. background-color: #FFFFFF;
  254. }
  255. .leftTitle {
  256. margin: 28rpx;
  257. width: 120rpx;
  258. font-size: 28rpx;
  259. color: #666666;
  260. }
  261. .noSelectColor {
  262. color: #999999;
  263. }
  264. .selectColor {
  265. color: #333333;
  266. }
  267. .rightArrow {
  268. margin-right: 28rpx;
  269. width: 14rpx;
  270. height: 23rpx;
  271. }
  272. .cityBtn {
  273. width: 65%;
  274. font-size: 28rpx;
  275. }
  276. .rightView {
  277. display: flex;
  278. justify-content: space-between;
  279. width: 80%;
  280. }
  281. .plateNumber {
  282. font-size: 28rpx;
  283. }
  284. .carModBtn {
  285. width: 65%;
  286. font-size: 28rpx;
  287. }
  288. .timeBtn {
  289. width: 65%;
  290. font-size: 28rpx;
  291. }
  292. .mileageInput {
  293. width: 20%;
  294. font-size: 28rpx;
  295. }
  296. .kmStr {
  297. font-size: 28rpx;
  298. color: #333333;
  299. }
  300. .changeCarBg {
  301. display: flex;
  302. /* justify-content: flex-start; */
  303. align-items: center;
  304. width: 120rpx;
  305. margin-right: 28rpx;
  306. }
  307. </style>