index.vue 7.9 KB

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