index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395
  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_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>
  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 (this.uid) {
  93. that.queryHomeDetail();
  94. }
  95. if (location) {
  96. this.lng = location.lng;
  97. this.lat = location.lat;
  98. this.cityname = location.cityname;
  99. this.cityCode = location.cityCode;
  100. this.location=location
  101. if (this.uid) {
  102. that.queryHomeDetail();
  103. }
  104. } else {
  105. /* uni.showToast({
  106. title: '请选择城市'
  107. }) */
  108. uni.getLocation({
  109. type: 'gcj02',
  110. success: function (res) {
  111. console.log(res)
  112. that.lng=res.longitude
  113. that.lat=res.latitude
  114. that.getAdress();
  115. },
  116. fail(err) {
  117. }
  118. });
  119. }
  120. },
  121. methods: {
  122. goLonIn(){
  123. uni.navigateTo({
  124. url:'../login/login'
  125. })
  126. },
  127. queryHomeDetail() {
  128. uni.showLoading({
  129. title: '加载中'
  130. })
  131. this.$http('worldKeepCar/worldHome/queryHomeDetail', {
  132. cityCode: this.cityCode
  133. }, 'GET').then(res => {
  134. uni.hideLoading();
  135. this.imgData = res.data.banners
  136. this.memberCar = res.data.memberCar
  137. if (res.data.memberCar) {
  138. this.mileage = res.data.memberCar.milage
  139. }
  140. else {
  141. this.mileage =''
  142. }
  143. var cardata = uni.getStorageSync("maintainCarData")
  144. if (cardata) {
  145. this.memberCar = cardata
  146. }else{
  147. uni.setStorage({
  148. key: 'maintainCarData',
  149. data: this.memberCar,
  150. success: function () {
  151. }
  152. });
  153. }
  154. })
  155. },
  156. gomodule() {
  157. if (!this.uid) {
  158. this.goLonIn();
  159. }
  160. uni.navigateTo({
  161. url: '../module/maintain'
  162. })
  163. },
  164. goCarList() {
  165. if (this.uid) {
  166. uni.navigateTo({
  167. url: 'cailist?type=1'
  168. })
  169. }
  170. },
  171. addCar() {
  172. if (!this.uid) {
  173. this.goLonIn();
  174. }
  175. uni.navigateTo({
  176. url: 'addCar'
  177. })
  178. },
  179. selectCity(item) {
  180. console.log('-您选择的城市-', item)
  181. console.log(this.location)
  182. this.location.cityname = item.name;
  183. this.location.cityCode = item.citycode;
  184. this.cityname = item.name;
  185. console.log(this.location)
  186. uni.setStorage({
  187. key: 'location',
  188. data: this.location,
  189. success: function() {}
  190. });
  191. this.showCity = false;
  192. },
  193. closeModal() {
  194. this.showCity = false
  195. },
  196. bindChange(e) {
  197. console.log(e);
  198. this.time = e.target.value
  199. },
  200. getAdress(){
  201. var location=this.lng+','+this.lat
  202. uni.request({
  203. url: 'https://restapi.amap.com/v3/place/around', //仅为示例,并非真实接口地址。
  204. data: {
  205. key: '064b6a4a8ade55656edcde2f528876de',
  206. location: location,
  207. types:"190000",
  208. extensions:"all",
  209. radius:100
  210. },
  211. dataType: "json",
  212. success: (res) => {
  213. console.log(res);
  214. this.cityname=res.data.pois[0].cityname;
  215. var cityCode=res.data.pois[0].adcode
  216. cityCode=cityCode.slice(0, -2)
  217. cityCode=cityCode+'00'
  218. this.cityCode=cityCode
  219. var obj={
  220. cityname:this.cityname,
  221. lng:this.lng,
  222. lat:this.lat,
  223. cityCode:cityCode
  224. }
  225. uni.setStorage({
  226. key: 'location',
  227. data: obj,
  228. success: function () {}
  229. });
  230. if (this.uid) {
  231. that.queryHomeDetail();
  232. }
  233. }
  234. });
  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: 300rpx;
  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>