index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  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="line"></view>
  27. <view class="mesView">
  28. <view class="leftTitle">车牌号</view>
  29. <view class="rightView" v-if="!memberCar">
  30. <view class="plateNumber noSelectColor">请添加您的爱车</view>
  31. <view class="changeCarBg" @click="addCar()">
  32. <image src="../../static/img/icon_tianjia.png"
  33. style="width: 32rpx; height: 34rpx; margin-right: 5rpx;"></image>
  34. <view style="color: #FF2400; font-size: 28rpx;">添加</view>
  35. </view>
  36. </view>
  37. <view class="rightView" v-else>
  38. <view class="plateNumber selectColor">{{memberCar.plateNumber}}</view>
  39. <view class="changeCarBg" @click="goCarList()">
  40. <image src="../../static/img/icon_change.png"
  41. style="width: 32rpx; height: 34rpx; margin-right: 5rpx;"></image>
  42. <view style="color: #FF2400; font-size: 28rpx;">换车</view>
  43. </view>
  44. </view>
  45. </view>
  46. <view class="line"></view>
  47. <view class="mesView">
  48. <view class="leftTitle">车型</view>
  49. <view class="carModBtn selectColor carMod" v-if="memberCar">{{memberCar.carModel}}</view>
  50. <view class="carModBtn noSelectColor" v-else>车型</view>
  51. </view>
  52. <view class="line"></view>
  53. <view class="mesView">
  54. <view class="leftTitle">行驶里程</view>
  55. <input class="mileageInput selectColor" type="number" v-model="mileage" placeholder="请输入"
  56. placeholder-style="color:#999999" @input="upMileage" />
  57. <view class="kmStr">km</view>
  58. </view>
  59. </view>
  60. <view class="look4s" @click="gomodule">查看4S店保养价格</view>
  61. </view>
  62. </template>
  63. <script>
  64. export default {
  65. data() {
  66. return {
  67. imgData: [],
  68. uid: '',
  69. cityName: '',
  70. cityCode: '',
  71. memberCar: '',
  72. locationCity: {
  73. cityName: '',
  74. cityCode: '',
  75. lng: '',
  76. lat: '',
  77. },
  78. time: '',
  79. mileage: '',
  80. autoplay: true,
  81. interval: 2000,
  82. duration: 500,
  83. brand:'',
  84. cityRole:'',
  85. }
  86. },
  87. onLoad() {
  88. },
  89. onShow() {
  90. var that = this;
  91. that.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  92. that.uid = uni.getStorageSync("logodata").uid;
  93. var selectCity = uni.getStorageSync("selectCity");
  94. if (selectCity) {
  95. //有选择的城市
  96. that.cityName = selectCity.city
  97. that.cityCode = selectCity.code
  98. } else{
  99. //定位到的城市
  100. var nowCity = uni.getStorageSync("locationCity");
  101. if (nowCity) {
  102. that.cityName = nowCity.cityName
  103. that.cityCode = nowCity.cityCode
  104. if (that.uid) {
  105. that.queryHomeDetail();
  106. }
  107. } else {
  108. // 重新去定位城市
  109. that.getLocation()
  110. }
  111. }
  112. if (that.uid) {
  113. that.queryHomeDetail();
  114. }
  115. },
  116. methods: {
  117. upMileage(){
  118. this.$http('worldKeepCar/worldHome/updateTMemberCarByHome', {
  119. id: this.memberCar.id,
  120. milage: this.mileage?this.mileage:0,
  121. }, 'POST').then(res => {
  122. uni.hideLoading();
  123. console.log(res);
  124. if (res.code == 0) {
  125. var cardata = uni.getStorageSync("maintainCarData")
  126. if (cardata) {
  127. cardata.milage = this.mileage
  128. uni.setStorage({
  129. key: 'maintainCarData',
  130. data: cardata,
  131. success: function () {
  132. }
  133. });
  134. }
  135. }
  136. })
  137. },
  138. getLocation() {
  139. const that = this
  140. uni.getLocation({
  141. type: 'gcj02',
  142. success: function(res) {
  143. console.log('定位', res)
  144. that.locationCity.lng = res.longitude
  145. that.locationCity.lat = res.latitude
  146. that.getAdress();
  147. },
  148. fail(err) {
  149. console.log(err)
  150. }
  151. });
  152. },
  153. getAdress() {
  154. // 根据经纬度 逆城市地理编码 获取城市信息
  155. var location = this.locationCity.lng + ',' + this.locationCity.lat
  156. uni.request({
  157. url: 'https://restapi.amap.com/v3/geocode/regeo',
  158. data: {
  159. key: '389a059efa3f499d9145eb84b1c3248d',
  160. location: location,
  161. types: "190000",
  162. extensions: "all",
  163. radius: 100
  164. },
  165. dataType: "json",
  166. success: (res) => {
  167. console.log('定位城市', res);
  168. if(res.data.regeocode){
  169. let cityname = res.data.regeocode.addressComponent.city;
  170. var cityCode = res.data.regeocode.addressComponent.adcode
  171. cityCode = cityCode.slice(0, -2)
  172. cityCode = cityCode + '00'
  173. this.locationCity.cityName = cityname
  174. this.locationCity.cityCode = cityCode
  175. uni.setStorage({
  176. key: 'locationCity',
  177. data: this.locationCity,
  178. success: function() {
  179. console.log('定位城市,保存成功');
  180. }
  181. })
  182. this.cityName = this.locationCity.cityName
  183. this.cityCode = this.locationCity.cityCode
  184. }else{
  185. this.cityName=''
  186. this.cityCode=''
  187. }
  188. }
  189. });
  190. },
  191. showCity(){
  192. uni.navigateTo({
  193. url:'../chooseCity/chooseCity'
  194. })
  195. },
  196. goLonIn(){
  197. uni.navigateTo({
  198. url:'../login/login'
  199. })
  200. },
  201. queryHomeDetail() {
  202. uni.showLoading({
  203. title: '加载中'
  204. })
  205. this.$http('worldKeepCar/worldHome/queryHomeDetail', {
  206. cityCode: this.cityCode
  207. }, 'GET').then(res => {
  208. uni.hideLoading();
  209. this.cityRole = res.data.cityRole
  210. this.imgData = res.data.banners
  211. this.memberCar = res.data.memberCar
  212. if (res.data.memberCar) {
  213. this.mileage = res.data.memberCar.milage
  214. }
  215. else {
  216. this.mileage =''
  217. }
  218. this.brand = res.data.memberCar.brand
  219. var cardata = uni.getStorageSync("maintainCarData")
  220. if (cardata) {
  221. this.memberCar = cardata
  222. if (cardata) {
  223. this.mileage = this.memberCar.milage
  224. }
  225. else {
  226. this.mileage =''
  227. }
  228. this.brand = this.memberCar.brand
  229. }else{
  230. uni.setStorage({
  231. key: 'maintainCarData',
  232. data: this.memberCar,
  233. success: function () {
  234. }
  235. });
  236. }
  237. })
  238. },
  239. gomodule() {
  240. if (!this.uid) {
  241. this.goLonIn();
  242. }
  243. if (!this.cityCode) {
  244. uni.showToast({
  245. title:'请选择城市',
  246. icon:'none',
  247. duration: 3000,
  248. })
  249. return
  250. }
  251. if (!this.memberCar) {
  252. uni.showToast({
  253. title:'请选择车辆',
  254. icon:'none',
  255. duration: 3000,
  256. })
  257. return
  258. }
  259. if (this.cityRole == 0) {
  260. uni.showToast({
  261. title:'所选城市暂时不支持保养,我们正在努力开通哦~',
  262. icon:'none',
  263. duration: 3000,
  264. })
  265. return
  266. }
  267. uni.navigateTo({
  268. url: '../module/maintain?brand='+this.brand
  269. })
  270. },
  271. goCarList() {
  272. if (this.uid) {
  273. uni.navigateTo({
  274. url: 'cailist?type=1'
  275. })
  276. }
  277. },
  278. addCar() {
  279. if (!this.uid) {
  280. this.goLonIn();
  281. }
  282. uni.navigateTo({
  283. url: 'addCar'
  284. })
  285. },
  286. bindChange(e) {
  287. console.log(e);
  288. this.time = e.target.value
  289. },
  290. },
  291. onShareAppMessage:function() {
  292. },
  293. }
  294. </script>
  295. <style>
  296. .content {
  297. min-height: 100vh;
  298. background-color: #F4F5F7;
  299. }
  300. .bBannerList {
  301. width: 100%;
  302. height: 100%;
  303. background-color: #F4F5F7;
  304. }
  305. .swpImg {
  306. width: 100%;
  307. height: 300rpx;
  308. }
  309. .carMessage {
  310. margin: 24rpx 24rpx 40rpx;
  311. padding-top: 10rpx;
  312. height: 500rpx;
  313. background-color: #FFFFFF;
  314. border-radius: 10rpx;
  315. }
  316. .look4s {
  317. margin: 40rpx 24rpx;
  318. height: 88rpx;
  319. line-height: 88rpx;
  320. text-align: center;
  321. background-color: #FD5300;
  322. border-radius: 10rpx;
  323. color: #FFFFFF;
  324. font-weight: bold;
  325. font-size: 30rpx;
  326. }
  327. .mesView {
  328. display: flex;
  329. align-items: center;
  330. width: 100%;
  331. height: 120rpx;
  332. background-color: #FFFFFF;
  333. }
  334. .leftTitle {
  335. margin: 28rpx;
  336. width: 120rpx;
  337. font-size: 28rpx;
  338. color: #666666;
  339. }
  340. .noSelectColor {
  341. color: #999999;
  342. }
  343. .selectColor {
  344. color: #333333;
  345. }
  346. .carMod{
  347. text-overflow: -o-ellipsis-lastline;
  348. overflow: hidden;
  349. text-overflow: ellipsis;
  350. display: -webkit-box;
  351. -webkit-line-clamp: 2;
  352. line-clamp: 2;
  353. -webkit-box-orient: vertical;
  354. }
  355. .rightArrow {
  356. margin-right: 28rpx;
  357. width: 14rpx;
  358. height: 23rpx;
  359. }
  360. .cityBtn {
  361. width: 65%;
  362. font-size: 28rpx;
  363. }
  364. .rightView {
  365. display: flex;
  366. justify-content: space-between;
  367. width: 80%;
  368. }
  369. .plateNumber {
  370. font-size: 28rpx;
  371. }
  372. .carModBtn {
  373. width: 65%;
  374. font-size: 28rpx;
  375. }
  376. .timeBtn {
  377. width: 65%;
  378. font-size: 28rpx;
  379. }
  380. .mileageInput {
  381. width: 20%;
  382. font-size: 28rpx;
  383. }
  384. .kmStr {
  385. font-size: 28rpx;
  386. color: #333333;
  387. }
  388. .changeCarBg {
  389. display: flex;
  390. /* justify-content: flex-start; */
  391. align-items: center;
  392. width: 120rpx;
  393. margin-right: 28rpx;
  394. }
  395. .line{
  396. margin: 0 28rpx;
  397. height: 2rpx;
  398. background-color: #EEEEEE;
  399. }
  400. </style>