index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. <template>
  2. <view class="container">
  3. <view class="status_bar"></view>
  4. <!-- 轮播图 start -->
  5. <swiper class="top-swiper" autoplay="true" duration="400" interval="5000" @change="swiperChange">
  6. <swiper-item v-for="(item, index) in carouselList" :key="index" class="carousel-item"
  7. @click="bannerNavToUrl(item)">
  8. <image :src="item.pic" />
  9. </swiper-item>
  10. </swiper>
  11. <!-- 轮播图 end -->
  12. <!-- 认证提示 statr-->
  13. <view class="rznow flex" v-if="userInfo && userInfo.is_real == 0">
  14. <view class="rztit">
  15. 您尚未完成身份认证,前往认证>>
  16. </view>
  17. <view class="rzbtn" @click="navTo('/pages/shop/attestation')">
  18. 立即认证
  19. </view>
  20. </view>
  21. <!-- 认证提示 ed-->
  22. <!-- 功能区 start-->
  23. <view class="gn-wrap flex">
  24. <view class="gn-icon flex">
  25. <image src="../../static/icon/in1.png" mode="heightFix"></image>
  26. </view>
  27. <view class="gn-tit">
  28. <view class="">
  29. 租电
  30. </view>
  31. <view class="tit-jj">
  32. 信用免押
  33. </view>
  34. </view>
  35. <view class="gn-btn" @click="navTo('/pages/shop/rent',1)">
  36. 立即租电
  37. </view>
  38. </view>
  39. <view class="gn-wrap flex">
  40. <view class="gn-icon flex">
  41. <image src="../../static/icon/in2.png" mode="heightFix"></image>
  42. </view>
  43. <view class="gn-tit">
  44. <view class="">
  45. 租车
  46. </view>
  47. <view class="tit-jj">
  48. 信用免押
  49. </view>
  50. </view>
  51. <view class="gn-btn" @click="navTo('/pages/shop/accessory')">
  52. 立即租车
  53. </view>
  54. </view>
  55. <!-- 功能区 ed-->
  56. <!-- 附近门店 start -->
  57. <view class="fjmd" @click="navTo('/pages/shop/shopTab')">
  58. <image src="../../static/img/md.png" mode=""></image>
  59. </view>
  60. <!-- 附近门店 end -->
  61. <!-- 使用攻略 start -->
  62. <view class="sygl">
  63. <view class="sy-top">
  64. <image src="../../static/icon/gl-top.png" mode=""></image>
  65. <view class="top-tit">
  66. 使用攻略
  67. </view>
  68. </view>
  69. <view class="sy-content flex">
  70. <view class="content-item flex">
  71. <image src="../../static/icon/sy1.png" mode="" class="sy-icon"></image>
  72. <view class="">
  73. 注册账号
  74. </view>
  75. </view>
  76. <image src="../../static/icon/jt.png" mode="" class="jt"></image>
  77. <view class="content-item flex">
  78. <image src="../../static/icon/sy2.png" mode="" class="sy-icon"></image>
  79. <view class="">
  80. 实名认证
  81. </view>
  82. </view>
  83. <image src="../../static/icon/jt.png" mode="" class="jt"></image>
  84. <view class="content-item flex">
  85. <image src="../../static/icon/sy3.png" mode="" class="sy-icon"></image>
  86. <view class="">
  87. 租电/租车
  88. </view>
  89. </view>
  90. <image src="../../static/icon/jt.png" mode="" class="jt"></image>
  91. <view class="content-item flex">
  92. <image src="../../static/icon/sy4.png" mode="" class="sy-icon"></image>
  93. <view class="">
  94. 开始使用
  95. </view>
  96. </view>
  97. </view>
  98. </view>
  99. <!-- 使用攻略 ed-->
  100. </view>
  101. </template>
  102. <script>
  103. // #ifdef MP-WEIXIN
  104. import {
  105. openMap
  106. } from '@/utils/rocessor.js';
  107. // #endif
  108. import {
  109. saveUrl,
  110. interceptor
  111. } from '@/utils/loginUtils.js';
  112. import {
  113. loadIndexs
  114. } from '@/api/index.js'
  115. import {
  116. mapState,
  117. mapMutations
  118. } from "vuex"
  119. export default {
  120. data() {
  121. return {
  122. carouselList: [], //轮播图
  123. };
  124. },
  125. computed: {
  126. ...mapState('user', ['userInfo', 'hasLogin']),
  127. },
  128. // 切换或显示后变动tabbar颜色
  129. onHide() {
  130. },
  131. onLoad: function(option) {
  132. // #ifndef MP
  133. if (option.spread) {
  134. // 存储其他邀请人
  135. uni.setStorageSync('spread', option.spread);
  136. }
  137. // #endif
  138. // #ifdef MP
  139. if (option.scene) {
  140. // 存储小程序邀请人
  141. uni.setStorage({
  142. key: 'spread_code',
  143. data: option.scene
  144. });
  145. }
  146. // #endif
  147. // 获取定位数据
  148. this.getlocation();
  149. },
  150. onShow() {
  151. this.getIndex()
  152. },
  153. onReady() {
  154. },
  155. // #ifdef MP
  156. onShareAppMessage(options) {
  157. // 设置菜单中的转发按钮触发转发事件时的转发内容
  158. let pages = getCurrentPages(); //获取加载的页面
  159. let currentPage = pages[pages.length - 1]; //获取当前页面的对象
  160. let url = currentPage.route; //当前页面url
  161. let item = currentPage.options; //如果要获取url中所带的参数可以查看options
  162. let shareObj = {
  163. title: '租电', // 默认是小程序的名称(可以写slogan等)
  164. path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
  165. imageUrl: '',
  166. desc: '',
  167. success: function(res) {
  168. // 转发成功之后的回调
  169. if (res.errMsg == 'shareAppMessage:ok') {}
  170. },
  171. fail: function() {
  172. // 转发失败之后的回调
  173. if (res.errMsg == 'shareAppMessage:fail cancel') {
  174. // 用户取消转发
  175. } else if (res.errMsg == 'shareAppMessage:fail') {
  176. // 转发失败,其中 detail message 为详细失败信息
  177. }
  178. }
  179. };
  180. // 判断是否可以邀请
  181. // if (this.userInfo.uid) {
  182. // shareObj.path += '&spread=' + this.userInfo.uid;
  183. // }
  184. return shareObj;
  185. },
  186. // #endif
  187. methods: {
  188. ...mapMutations('user',['setAddress']),
  189. getIndex() {
  190. loadIndexs().then(res => {
  191. this.carouselList = res.data.banner
  192. })
  193. },
  194. navTo(url, ind = 0) {
  195. if (ind == 1) {
  196. if (!this.hasLogin) {
  197. // 保存地址
  198. saveUrl();
  199. // 登录拦截
  200. interceptor();
  201. } else {
  202. if (this.userInfo.is_real == 1) {
  203. uni.navigateTo({
  204. url,
  205. fail(e) {
  206. console.log(e);
  207. }
  208. });
  209. } else {
  210. uni.showModal({
  211. title: '提示',
  212. content: '您当前未进行实名认证,是否立即实名认证?',
  213. complete(res) {
  214. if (res.confirm) {
  215. uni.navigateTo({
  216. url: '/pages/shop/attestation'
  217. })
  218. }
  219. }
  220. })
  221. }
  222. }
  223. } else {
  224. if (url.indexOf('http') != -1) {
  225. window.location.href = url
  226. } else {
  227. uni.navigateTo({
  228. url,
  229. fail() {
  230. uni.switchTab({
  231. url
  232. })
  233. }
  234. })
  235. }
  236. }
  237. },
  238. // 获取经纬度
  239. getlocation() {
  240. let obj = this;
  241. // #ifdef H5 || APP
  242. uni.getLocation({
  243. type: 'gcj02',
  244. success(e) {
  245. obj.getlocationSetInit(e)
  246. },
  247. fail(e) {
  248. if(e.errCode==22){
  249. uni.showModal({
  250. title: '定位开启错误',
  251. content: '请查看是否已经开启定位服务',
  252. showCancel: false,
  253. });
  254. }
  255. console.log(e, 'cw');
  256. }
  257. })
  258. // #endif
  259. // #ifdef MP-WEIXIN
  260. openMap().then((e) => {
  261. console.log("授权");
  262. wx.getLocation({
  263. type: 'gcj02',
  264. success: (e) => {
  265. console.log(e);
  266. // 调用鉴定位置变化事件
  267. this.getlocationSetInit(e)
  268. },
  269. fail() {
  270. }
  271. })
  272. })
  273. // #endif
  274. },
  275. // 获取经纬度完毕后回调处理
  276. getlocationSetInit(data) {
  277. const obj = this;
  278. try {
  279. console.log(data, '位置数据');
  280. // 保存当前经纬度
  281. obj.setAddress({
  282. latitude: data.latitude,
  283. longitude: data.longitude
  284. })
  285. } catch (e) {
  286. console.log(e, 'cww');
  287. }
  288. },
  289. }
  290. };
  291. </script>
  292. <style lang="scss">
  293. page {
  294. background: #ffff;
  295. min-height: 100%;
  296. height: auto;
  297. }
  298. // 顶部搜索
  299. .top-search {
  300. height: 80rpx;
  301. padding: 0 20rpx;
  302. background-color: #fff;
  303. .top-logo {
  304. width: 50rpx;
  305. // height: 50rpx;
  306. margin-right: 10rpx;
  307. image {
  308. width: 48rpx;
  309. }
  310. }
  311. .search-box {
  312. justify-content: center;
  313. width: 698rpx;
  314. height: 60rpx;
  315. background: #EEEEEE;
  316. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  317. border-radius: 30rpx;
  318. .search {
  319. width: 34rpx;
  320. height: 34rpx;
  321. }
  322. .search-font {
  323. margin-left: 14rpx;
  324. font-size: 28rpx;
  325. font-family: PingFang SC;
  326. font-weight: 500;
  327. color: #CBCBCB;
  328. }
  329. }
  330. }
  331. // 顶部轮播图
  332. .top-swiper {
  333. width: 750rpx;
  334. height: 473rpx;
  335. // margin: 20rpx 0 0;
  336. image {
  337. width: 750rpx;
  338. height: 473rpx;
  339. }
  340. }
  341. .jg {
  342. height: 20rpx;
  343. background: #F8F8F8;
  344. }
  345. // 分类
  346. .cate-section {
  347. justify-content: space-around;
  348. background-color: #fff;
  349. padding: 0rpx 0 30rpx;
  350. .cate-item {
  351. flex-grow: 0;
  352. width: 20%;
  353. flex-direction: column;
  354. text-align: center;
  355. align-items: center;
  356. justify-content: center;
  357. .img-wrapper {
  358. width: 112rpx;
  359. height: 112rpx;
  360. border-radius: 20rpx;
  361. position: relative;
  362. image {
  363. width: 112rpx;
  364. height: 112rpx;
  365. position: absolute;
  366. left: 50%;
  367. top: 50%;
  368. transform: translate(-50%, -50%);
  369. }
  370. }
  371. .item-title {
  372. margin-top: 15rpx;
  373. font-size: 26rpx;
  374. font-weight: 500;
  375. color: #666666;
  376. }
  377. }
  378. }
  379. .rznow {
  380. font-weight: 500;
  381. font-size: 26rpx;
  382. color: #FFFFFF;
  383. background-color: #78797a;
  384. height: 74rpx;
  385. padding: 0 42rpx 0 52rpx;
  386. .rztit {
  387. line-height: 74rpx;
  388. }
  389. .rzbtn {
  390. width: 127rpx;
  391. height: 47rpx;
  392. text-align: center;
  393. line-height: 47rpx;
  394. background: #35d9b7;
  395. border-radius: 24rpx;
  396. font-size: 22rpx;
  397. }
  398. }
  399. .gn-wrap {
  400. margin: 45rpx auto;
  401. width: 670rpx;
  402. height: 219rpx;
  403. background: #FFFFFF;
  404. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  405. border-radius: 30rpx;
  406. padding-right: 47rpx;
  407. .gn-icon {
  408. flex-shrink: 0;
  409. width: 210rpx;
  410. height: 100%;
  411. justify-content: center;
  412. image {
  413. height: 112rpx;
  414. }
  415. }
  416. .gn-tit {
  417. flex-grow: 1;
  418. font-weight: bold;
  419. color: #333333;
  420. font-size: 36rpx;
  421. flex-direction: column;
  422. justify-content: center;
  423. align-items: flex-start;
  424. .tit-jj {
  425. font-size: 25rpx;
  426. font-weight: 500;
  427. color: #666666;
  428. padding-top: 32rpx;
  429. }
  430. }
  431. .gn-btn {
  432. flex-shrink: 0;
  433. width: 127rpx;
  434. border: 1px solid $base-color;
  435. border-radius: 28rpx;
  436. font-size: 25rpx;
  437. font-weight: 500;
  438. color: $base-color;
  439. line-height: 55rpx;
  440. text-align: center;
  441. }
  442. }
  443. .fjmd {
  444. width: 708rpx;
  445. height: 233rpx;
  446. margin: 20rpx auto;
  447. image {
  448. width: 100%;
  449. height: 100%;
  450. }
  451. }
  452. .sygl {
  453. .sy-top {
  454. position: relative;
  455. height: 100rpx;
  456. image {
  457. width: 369rpx;
  458. height: 8rpx;
  459. position: absolute;
  460. top: 0;
  461. bottom: 0;
  462. left: 0;
  463. right: 0;
  464. margin: auto;
  465. }
  466. .top-tit {
  467. font-size: 32rpx;
  468. font-weight: bold;
  469. color: #4A2723;
  470. text-align: center;
  471. line-height: 100rpx;
  472. }
  473. }
  474. .sy-content {
  475. padding: 0 10rpx 65rpx;
  476. .content-item {
  477. flex-grow: 1;
  478. flex-direction: column;
  479. justify-content: center;
  480. align-items: center;
  481. font-size: 22rpx;
  482. font-weight: 500;
  483. color: #4A2723;
  484. }
  485. .sy-icon {
  486. width: 90rpx;
  487. height: 90rpx;
  488. margin-bottom: 15rpx;
  489. }
  490. .jt {
  491. flex-shrink: 0;
  492. width: 14rpx;
  493. height: 15rpx;
  494. margin-top: 40rpx;
  495. align-self: flex-start;
  496. }
  497. }
  498. }
  499. </style>