index.vue 8.4 KB

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