index.vue 8.1 KB

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