index.vue 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  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 homeData.bBannerList" @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 homeData.bBannerList" @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. <input class="plateNumber" placeholder-style="color:#999999" placeholder="请输入车牌号" disabled="true" @tap="plateShow=true"
  29. v-model.trim="plateNo" />
  30. <plate-input v-if="plateShow" :plate="plateNo" @export="setPlate" @close="plateShow=false" />
  31. <view class="changeCarBg" @click="changeCar" v-show="!joinFirst">
  32. <image src="../../static/img/icon_change.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="mesView">
  38. <view class="leftTitle">车型</view>
  39. <view class="carModBtn noSelectColor" v-if="!carMod">请添加您的爱车</view>
  40. <view class="carModBtn selectColor" v-else>{{carMod}}</view>
  41. <image src="../../static/img/rightArrow.png" class="rightArrow"></image>
  42. </view>
  43. <view class="mesView">
  44. <view class="leftTitle">购车时间</view>
  45. <picker class="timeBtn" @change="bindChange" mode="date">
  46. <view class="uni-input selectColor" v-if="time">{{time}}</view>
  47. <view class="uni-input noSelectColor" v-else>请选择您的购车时间</view>
  48. </picker>
  49. <image src="../../static/img/rightArrow.png" class="rightArrow"></image>
  50. </view>
  51. <view class="mesView">
  52. <view class="leftTitle">行驶里程</view>
  53. <input class="mileageInput selectColor" type="number" v-model="mileage" placeholder="请输入"
  54. placeholder-style="color:#999999" />
  55. <view class="kmStr">km</view>
  56. </view>
  57. </view>
  58. <view class="look4s">查看4S店保养价格</view>
  59. <chose-city @selectCity="selectCity" v-if="showCity" @closeModal="closeModal"></chose-city>
  60. </view>
  61. </template>
  62. <script>
  63. import choseCity from "@/components/chose-city/chose-city"
  64. import plateInput from "@/components/uni-plate-input/uni-plate-input.vue"
  65. export default {
  66. components: {
  67. choseCity,
  68. plateInput
  69. },
  70. data() {
  71. return {
  72. homeData: '',
  73. shopId: '',
  74. cityname: '',
  75. showCity: false,
  76. location: '',
  77. cityCode: '',
  78. plateNo: '',
  79. plateShow: false,
  80. joinFirst: false,
  81. carMod: '',
  82. time: '',
  83. mileage: '',
  84. }
  85. },
  86. onLoad() {
  87. console.log('index-----onLoad')
  88. var that = this;
  89. this.iStatusBarHeight = uni.getSystemInfoSync().statusBarHeight;
  90. //#ifdef H5
  91. var logodata = {
  92. uid: 'E4416E30-C82A-4136-81B7-6B424DDE4847',
  93. token: "39F6A2FB48D841FA9A3AA149532917CE",
  94. memberInfo: {
  95. nickName: '布克',
  96. name: '66',
  97. headUrl: 'https://thirdwx.qlogo.cn/mmopen/vi_32/PHgdyF2l1fvicOPTicZlAdhuK65E6VFnNJIhA9QWFCUwftgc9hySDltLEEWic27eMLkiaoQG9emzqg0s87JaW28HFQ/132'
  98. }
  99. }
  100. var obj = {
  101. cityname: "济南市",
  102. lat: 36.68013,
  103. lng: 117.06533,
  104. cityCode: 370100
  105. }
  106. uni.setStorage({
  107. key: 'location',
  108. data: obj,
  109. success: function() {}
  110. });
  111. uni.setStorage({
  112. key: 'logodata',
  113. data: logodata,
  114. success: function() {}
  115. });
  116. var wxOpend = {
  117. openid: "oqeJ-5Lsmi-vM1Oirso6z9-MrD3g",
  118. session_key: "sxV2xbqNvOkk+p7i/KosiQ=="
  119. }
  120. uni.setStorage({
  121. key: 'wxOpendata',
  122. data: wxOpend,
  123. success: function() {}
  124. });
  125. that.queryHomeDetail();
  126. that.getqueryMemberCarShop()
  127. // #endif
  128. this.uid = uni.getStorageSync("logodata").uid;
  129. this.shopId = uni.getStorageSync("shopData").shopId;
  130. console.log(this.shopId)
  131. this.location = uni.getStorageSync("location");
  132. if (this.location) {
  133. this.lng = this.location.lng;
  134. this.lat = this.location.lat;
  135. this.cityname = this.location.cityname;
  136. this.cityCode = this.location.cityCode;
  137. //that.queryHomeDetail();
  138. if (that.uid) {
  139. that.getqueryMemberCarShop()
  140. } else {
  141. that.queryHomeDetail();
  142. }
  143. } else {
  144. uni.getLocation({
  145. type: 'gcj02',
  146. success: function(res) {
  147. console.log(res)
  148. that.lng = res.longitude
  149. that.lat = res.latitude
  150. that.getAdress();
  151. //登录状态下获取车辆信息
  152. if (that.uid) {
  153. that.getqueryMemberCarShop()
  154. } else {
  155. that.queryHomeDetail();
  156. }
  157. },
  158. fail(err) {
  159. console.log(err)
  160. that.queryHomeDetail();
  161. //登录状态下获取车辆信息
  162. if (that.uid) {
  163. that.getqueryMemberCarShop()
  164. }
  165. }
  166. });
  167. }
  168. },
  169. methods: {
  170. selectCity(item) {
  171. console.log('-您选择的城市-', item)
  172. this.location.cityname = item.name;
  173. this.location.cityCode = item.citycode;
  174. this.cityname = item.name;
  175. console.log(this.location)
  176. uni.setStorage({
  177. key: 'location',
  178. data: this.location,
  179. success: function() {}
  180. });
  181. this.showCity = false;
  182. },
  183. closeModal() {
  184. this.showCity = false
  185. },
  186. setPlate(plate) {
  187. if (plate.length >= 7) this.plateNo = plate;
  188. this.plateShow = false;
  189. },
  190. changeCar() {
  191. },
  192. bindChange(e) {
  193. console.log(e);
  194. this.time = e.target.value
  195. },
  196. getAdress() {
  197. var location = this.lng + ',' + this.lat
  198. uni.request({
  199. url: 'https://restapi.amap.com/v3/place/around', //仅为示例,并非真实接口地址。
  200. data: {
  201. key: '064b6a4a8ade55656edcde2f528876de',
  202. location: location,
  203. types: "190000",
  204. extensions: "all",
  205. radius: 100
  206. },
  207. dataType: "json",
  208. success: (res) => {
  209. console.log(res);
  210. this.cityname = res.data.pois[0].cityname;
  211. var cityCode = res.data.pois[0].adcode
  212. cityCode = cityCode.slice(0, -2)
  213. cityCode = cityCode + '00'
  214. var obj = {
  215. cityname: this.cityname,
  216. lng: this.lng,
  217. lat: this.lat,
  218. cityCode: cityCode
  219. }
  220. uni.setStorage({
  221. key: 'location',
  222. data: obj,
  223. success: function() {}
  224. });
  225. }
  226. });
  227. },
  228. }
  229. }
  230. </script>
  231. <style>
  232. .content {
  233. min-height: 100vh;
  234. background-color: #F4F5F7;
  235. }
  236. .bBannerList {
  237. width: 100%;
  238. height: 300rpx;
  239. background-color: #3F536E;
  240. }
  241. .swpImg {
  242. width: 100%;
  243. height: 300rpx;
  244. }
  245. .carMessage {
  246. margin: 24rpx 24rpx 40rpx;
  247. height: 600rpx;
  248. background-color: #FFFFFF;
  249. border-radius: 10rpx;
  250. }
  251. .look4s {
  252. margin: 40rpx 24rpx;
  253. height: 88rpx;
  254. line-height: 88rpx;
  255. text-align: center;
  256. background-color: #FD5300;
  257. border-radius: 10rpx;
  258. color: #FFFFFF;
  259. font-weight: bold;
  260. font-size: 30rpx;
  261. }
  262. .mesView {
  263. display: flex;
  264. align-items: center;
  265. width: 100%;
  266. height: 120rpx;
  267. background-color: #FFFFFF;
  268. }
  269. .leftTitle {
  270. margin: 28rpx;
  271. width: 120rpx;
  272. font-size: 28rpx;
  273. color: #666666;
  274. }
  275. .noSelectColor {
  276. color: #999999;
  277. }
  278. .selectColor {
  279. color: #333333;
  280. }
  281. .rightArrow {
  282. margin-right: 28rpx;
  283. width: 14rpx;
  284. height: 23rpx;
  285. }
  286. .cityBtn {
  287. width: 65%;
  288. font-size: 28rpx;
  289. }
  290. .plateNumber {
  291. width: 55%;
  292. font-size: 28rpx;
  293. }
  294. .carModBtn {
  295. width: 65%;
  296. font-size: 28rpx;
  297. }
  298. .timeBtn {
  299. width: 65%;
  300. font-size: 28rpx;
  301. }
  302. .mileageInput {
  303. width: 20%;
  304. font-size: 28rpx;
  305. }
  306. .kmStr {
  307. font-size: 28rpx;
  308. color: #333333;
  309. }
  310. .changeCarBg {
  311. display: flex;
  312. /* justify-content: flex-start; */
  313. align-items: center;
  314. width: 120rpx;
  315. margin-right: 28rpx;
  316. }
  317. </style>