index.vue 9.1 KB

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