index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  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. if(this.userInfo.payRules) {
  204. uni.showModal({
  205. title: '温馨提醒',
  206. content:'您已支付相同金额订单,请确认是否重新下单?',
  207. complete(res) {
  208. if(res.confirm) {
  209. uni.navigateTo({
  210. url,
  211. fail(e) {
  212. console.log(e);
  213. }
  214. });
  215. }
  216. }
  217. })
  218. }else {
  219. uni.navigateTo({
  220. url,
  221. fail(e) {
  222. console.log(e);
  223. }
  224. });
  225. }
  226. } else {
  227. uni.showModal({
  228. title: '提示',
  229. content: '您当前未进行实名认证,是否立即实名认证?',
  230. complete(res) {
  231. if (res.confirm) {
  232. uni.navigateTo({
  233. url: '/pages/shop/attestation'
  234. })
  235. }
  236. }
  237. })
  238. }
  239. }
  240. } else {
  241. if (url.indexOf('http') != -1) {
  242. window.location.href = url
  243. } else {
  244. uni.navigateTo({
  245. url,
  246. fail() {
  247. uni.switchTab({
  248. url
  249. })
  250. }
  251. })
  252. }
  253. }
  254. },
  255. // 获取经纬度
  256. getlocation() {
  257. let obj = this;
  258. // #ifdef H5 || APP
  259. uni.getLocation({
  260. type: 'gcj02',
  261. success(e) {
  262. obj.getlocationSetInit(e)
  263. },
  264. fail(e) {
  265. if(e.errCode==22){
  266. uni.showModal({
  267. title: '定位开启错误',
  268. content: '请查看是否已经开启定位服务',
  269. showCancel: false,
  270. });
  271. }
  272. console.log(e, 'cw');
  273. }
  274. })
  275. // #endif
  276. // #ifdef MP-WEIXIN
  277. openMap().then((e) => {
  278. console.log("授权");
  279. wx.getLocation({
  280. type: 'gcj02',
  281. success: (e) => {
  282. console.log(e);
  283. // 调用鉴定位置变化事件
  284. this.getlocationSetInit(e)
  285. },
  286. fail() {
  287. }
  288. })
  289. })
  290. // #endif
  291. },
  292. // 获取经纬度完毕后回调处理
  293. getlocationSetInit(data) {
  294. const obj = this;
  295. try {
  296. console.log(data, '位置数据');
  297. // 保存当前经纬度
  298. obj.setAddress({
  299. latitude: data.latitude,
  300. longitude: data.longitude
  301. })
  302. } catch (e) {
  303. console.log(e, 'cww');
  304. }
  305. },
  306. }
  307. };
  308. </script>
  309. <style lang="scss">
  310. page {
  311. background: #ffff;
  312. min-height: 100%;
  313. height: auto;
  314. }
  315. // 顶部搜索
  316. .top-search {
  317. height: 80rpx;
  318. padding: 0 20rpx;
  319. background-color: #fff;
  320. .top-logo {
  321. width: 50rpx;
  322. // height: 50rpx;
  323. margin-right: 10rpx;
  324. image {
  325. width: 48rpx;
  326. }
  327. }
  328. .search-box {
  329. justify-content: center;
  330. width: 698rpx;
  331. height: 60rpx;
  332. background: #EEEEEE;
  333. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  334. border-radius: 30rpx;
  335. .search {
  336. width: 34rpx;
  337. height: 34rpx;
  338. }
  339. .search-font {
  340. margin-left: 14rpx;
  341. font-size: 28rpx;
  342. font-family: PingFang SC;
  343. font-weight: 500;
  344. color: #CBCBCB;
  345. }
  346. }
  347. }
  348. // 顶部轮播图
  349. .top-swiper {
  350. width: 750rpx;
  351. height: 473rpx;
  352. // margin: 20rpx 0 0;
  353. image {
  354. width: 750rpx;
  355. height: 473rpx;
  356. }
  357. }
  358. .jg {
  359. height: 20rpx;
  360. background: #F8F8F8;
  361. }
  362. // 分类
  363. .cate-section {
  364. justify-content: space-around;
  365. background-color: #fff;
  366. padding: 0rpx 0 30rpx;
  367. .cate-item {
  368. flex-grow: 0;
  369. width: 20%;
  370. flex-direction: column;
  371. text-align: center;
  372. align-items: center;
  373. justify-content: center;
  374. .img-wrapper {
  375. width: 112rpx;
  376. height: 112rpx;
  377. border-radius: 20rpx;
  378. position: relative;
  379. image {
  380. width: 112rpx;
  381. height: 112rpx;
  382. position: absolute;
  383. left: 50%;
  384. top: 50%;
  385. transform: translate(-50%, -50%);
  386. }
  387. }
  388. .item-title {
  389. margin-top: 15rpx;
  390. font-size: 26rpx;
  391. font-weight: 500;
  392. color: #666666;
  393. }
  394. }
  395. }
  396. .rznow {
  397. font-weight: 500;
  398. font-size: 26rpx;
  399. color: #FFFFFF;
  400. background-color: #78797a;
  401. height: 74rpx;
  402. padding: 0 42rpx 0 52rpx;
  403. .rztit {
  404. line-height: 74rpx;
  405. }
  406. .rzbtn {
  407. width: 127rpx;
  408. height: 47rpx;
  409. text-align: center;
  410. line-height: 47rpx;
  411. background: #35d9b7;
  412. border-radius: 24rpx;
  413. font-size: 22rpx;
  414. }
  415. }
  416. .gn-wrap {
  417. margin: 45rpx auto;
  418. width: 670rpx;
  419. height: 219rpx;
  420. background: #FFFFFF;
  421. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  422. border-radius: 30rpx;
  423. padding-right: 47rpx;
  424. .gn-icon {
  425. flex-shrink: 0;
  426. width: 210rpx;
  427. height: 100%;
  428. justify-content: center;
  429. image {
  430. height: 112rpx;
  431. }
  432. }
  433. .gn-tit {
  434. flex-grow: 1;
  435. font-weight: bold;
  436. color: #333333;
  437. font-size: 36rpx;
  438. flex-direction: column;
  439. justify-content: center;
  440. align-items: flex-start;
  441. .tit-jj {
  442. font-size: 25rpx;
  443. font-weight: 500;
  444. color: #666666;
  445. padding-top: 32rpx;
  446. }
  447. }
  448. .gn-btn {
  449. flex-shrink: 0;
  450. width: 127rpx;
  451. border: 1px solid $base-color;
  452. border-radius: 28rpx;
  453. font-size: 25rpx;
  454. font-weight: 500;
  455. color: $base-color;
  456. line-height: 55rpx;
  457. text-align: center;
  458. }
  459. }
  460. .fjmd {
  461. width: 708rpx;
  462. height: 233rpx;
  463. margin: 20rpx auto;
  464. image {
  465. width: 100%;
  466. height: 100%;
  467. }
  468. }
  469. .sygl {
  470. .sy-top {
  471. position: relative;
  472. height: 100rpx;
  473. image {
  474. width: 369rpx;
  475. height: 8rpx;
  476. position: absolute;
  477. top: 0;
  478. bottom: 0;
  479. left: 0;
  480. right: 0;
  481. margin: auto;
  482. }
  483. .top-tit {
  484. font-size: 32rpx;
  485. font-weight: bold;
  486. color: #4A2723;
  487. text-align: center;
  488. line-height: 100rpx;
  489. }
  490. }
  491. .sy-content {
  492. padding: 0 10rpx 65rpx;
  493. .content-item {
  494. flex-grow: 1;
  495. flex-direction: column;
  496. justify-content: center;
  497. align-items: center;
  498. font-size: 22rpx;
  499. font-weight: 500;
  500. color: #4A2723;
  501. }
  502. .sy-icon {
  503. width: 90rpx;
  504. height: 90rpx;
  505. margin-bottom: 15rpx;
  506. }
  507. .jt {
  508. flex-shrink: 0;
  509. width: 14rpx;
  510. height: 15rpx;
  511. margin-top: 40rpx;
  512. align-self: flex-start;
  513. }
  514. }
  515. }
  516. </style>