index.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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. import {
  104. saveUrl,
  105. interceptor
  106. } from '@/utils/loginUtils.js';
  107. import {
  108. loadIndexs
  109. } from '@/api/index.js'
  110. import {
  111. mapState
  112. } from "vuex"
  113. export default {
  114. data() {
  115. return {
  116. carouselList: [], //轮播图
  117. };
  118. },
  119. computed: {
  120. ...mapState('user', ['userInfo', 'hasLogin']),
  121. },
  122. // 切换或显示后变动tabbar颜色
  123. onHide() {
  124. },
  125. onLoad: function(option) {
  126. // #ifndef MP
  127. if (option.spread) {
  128. // 存储其他邀请人
  129. uni.setStorageSync('spread', option.spread);
  130. }
  131. // #endif
  132. // #ifdef MP
  133. if (option.scene) {
  134. // 存储小程序邀请人
  135. uni.setStorage({
  136. key: 'spread_code',
  137. data: option.scene
  138. });
  139. }
  140. // #endif
  141. },
  142. onShow() {
  143. this.getIndex()
  144. },
  145. onReady() {
  146. },
  147. // #ifdef MP
  148. onShareAppMessage(options) {
  149. // 设置菜单中的转发按钮触发转发事件时的转发内容
  150. let pages = getCurrentPages(); //获取加载的页面
  151. let currentPage = pages[pages.length - 1]; //获取当前页面的对象
  152. let url = currentPage.route; //当前页面url
  153. let item = currentPage.options; //如果要获取url中所带的参数可以查看options
  154. let shareObj = {
  155. title: '租电', // 默认是小程序的名称(可以写slogan等)
  156. path: url, // 默认是当前页面,必须是以‘/’开头的完整路径
  157. imageUrl: '',
  158. desc: '',
  159. success: function(res) {
  160. // 转发成功之后的回调
  161. if (res.errMsg == 'shareAppMessage:ok') {}
  162. },
  163. fail: function() {
  164. // 转发失败之后的回调
  165. if (res.errMsg == 'shareAppMessage:fail cancel') {
  166. // 用户取消转发
  167. } else if (res.errMsg == 'shareAppMessage:fail') {
  168. // 转发失败,其中 detail message 为详细失败信息
  169. }
  170. }
  171. };
  172. // 判断是否可以邀请
  173. // if (this.userInfo.uid) {
  174. // shareObj.path += '&spread=' + this.userInfo.uid;
  175. // }
  176. return shareObj;
  177. },
  178. // #endif
  179. methods: {
  180. getIndex() {
  181. loadIndexs().then(res => {
  182. this.carouselList = res.data.banner
  183. })
  184. },
  185. navTo(url, ind = 0) {
  186. if (ind == 1) {
  187. if (!this.hasLogin) {
  188. // 保存地址
  189. saveUrl();
  190. // 登录拦截
  191. interceptor();
  192. } else {
  193. if (this.userInfo.is_real == 1) {
  194. uni.navigateTo({
  195. url,
  196. fail(e) {
  197. console.log(e);
  198. }
  199. });
  200. } else {
  201. uni.showModal({
  202. title: '提示',
  203. content: '您当前未进行实名认证,是否立即实名认证?',
  204. complete(res) {
  205. if (res.confirm) {
  206. uni.navigateTo({
  207. url: '/pages/shop/attestation'
  208. })
  209. }
  210. }
  211. })
  212. }
  213. }
  214. } else {
  215. if (url.indexOf('http') != -1) {
  216. window.location.href = url
  217. } else {
  218. uni.navigateTo({
  219. url,
  220. fail() {
  221. uni.switchTab({
  222. url
  223. })
  224. }
  225. })
  226. }
  227. }
  228. },
  229. }
  230. };
  231. </script>
  232. <style lang="scss">
  233. page {
  234. background: #ffff;
  235. min-height: 100%;
  236. height: auto;
  237. }
  238. // 顶部搜索
  239. .top-search {
  240. height: 80rpx;
  241. padding: 0 20rpx;
  242. background-color: #fff;
  243. .top-logo {
  244. width: 50rpx;
  245. // height: 50rpx;
  246. margin-right: 10rpx;
  247. image {
  248. width: 48rpx;
  249. }
  250. }
  251. .search-box {
  252. justify-content: center;
  253. width: 698rpx;
  254. height: 60rpx;
  255. background: #EEEEEE;
  256. // box-shadow: 0px 10rpx 20rpx 0px rgba(4, 114, 69, 0.22);
  257. border-radius: 30rpx;
  258. .search {
  259. width: 34rpx;
  260. height: 34rpx;
  261. }
  262. .search-font {
  263. margin-left: 14rpx;
  264. font-size: 28rpx;
  265. font-family: PingFang SC;
  266. font-weight: 500;
  267. color: #CBCBCB;
  268. }
  269. }
  270. }
  271. // 顶部轮播图
  272. .top-swiper {
  273. width: 750rpx;
  274. height: 473rpx;
  275. // margin: 20rpx 0 0;
  276. image {
  277. width: 750rpx;
  278. height: 473rpx;
  279. }
  280. }
  281. .jg {
  282. height: 20rpx;
  283. background: #F8F8F8;
  284. }
  285. // 分类
  286. .cate-section {
  287. justify-content: space-around;
  288. background-color: #fff;
  289. padding: 0rpx 0 30rpx;
  290. .cate-item {
  291. flex-grow: 0;
  292. width: 20%;
  293. flex-direction: column;
  294. text-align: center;
  295. align-items: center;
  296. justify-content: center;
  297. .img-wrapper {
  298. width: 112rpx;
  299. height: 112rpx;
  300. border-radius: 20rpx;
  301. position: relative;
  302. image {
  303. width: 112rpx;
  304. height: 112rpx;
  305. position: absolute;
  306. left: 50%;
  307. top: 50%;
  308. transform: translate(-50%, -50%);
  309. }
  310. }
  311. .item-title {
  312. margin-top: 15rpx;
  313. font-size: 26rpx;
  314. font-weight: 500;
  315. color: #666666;
  316. }
  317. }
  318. }
  319. .rznow {
  320. font-weight: 500;
  321. font-size: 26rpx;
  322. color: #FFFFFF;
  323. background-color: #78797a;
  324. height: 74rpx;
  325. padding: 0 42rpx 0 52rpx;
  326. .rztit {
  327. line-height: 74rpx;
  328. }
  329. .rzbtn {
  330. width: 127rpx;
  331. height: 47rpx;
  332. text-align: center;
  333. line-height: 47rpx;
  334. background: #35d9b7;
  335. border-radius: 24rpx;
  336. font-size: 22rpx;
  337. }
  338. }
  339. .gn-wrap {
  340. margin: 45rpx auto;
  341. width: 670rpx;
  342. height: 219rpx;
  343. background: #FFFFFF;
  344. box-shadow: 0rpx 0rpx 20rpx 0rpx rgba(50, 50, 52, 0.06);
  345. border-radius: 30rpx;
  346. padding-right: 47rpx;
  347. .gn-icon {
  348. flex-shrink: 0;
  349. width: 210rpx;
  350. height: 100%;
  351. justify-content: center;
  352. image {
  353. height: 112rpx;
  354. }
  355. }
  356. .gn-tit {
  357. flex-grow: 1;
  358. font-weight: bold;
  359. color: #333333;
  360. font-size: 36rpx;
  361. flex-direction: column;
  362. justify-content: center;
  363. align-items: flex-start;
  364. .tit-jj {
  365. font-size: 25rpx;
  366. font-weight: 500;
  367. color: #666666;
  368. padding-top: 32rpx;
  369. }
  370. }
  371. .gn-btn {
  372. flex-shrink: 0;
  373. width: 127rpx;
  374. border: 1px solid $base-color;
  375. border-radius: 28rpx;
  376. font-size: 25rpx;
  377. font-weight: 500;
  378. color: $base-color;
  379. line-height: 55rpx;
  380. text-align: center;
  381. }
  382. }
  383. .fjmd {
  384. width: 708rpx;
  385. height: 233rpx;
  386. margin: 20rpx auto;
  387. image {
  388. width: 100%;
  389. height: 100%;
  390. }
  391. }
  392. .sygl {
  393. .sy-top {
  394. position: relative;
  395. height: 100rpx;
  396. image {
  397. width: 369rpx;
  398. height: 8rpx;
  399. position: absolute;
  400. top: 0;
  401. bottom: 0;
  402. left: 0;
  403. right: 0;
  404. margin: auto;
  405. }
  406. .top-tit {
  407. font-size: 32rpx;
  408. font-weight: bold;
  409. color: #4A2723;
  410. text-align: center;
  411. line-height: 100rpx;
  412. }
  413. }
  414. .sy-content {
  415. padding: 0 10rpx 65rpx;
  416. .content-item {
  417. flex-grow: 1;
  418. flex-direction: column;
  419. justify-content: center;
  420. align-items: center;
  421. font-size: 22rpx;
  422. font-weight: 500;
  423. color: #4A2723;
  424. }
  425. .sy-icon {
  426. width: 90rpx;
  427. height: 90rpx;
  428. margin-bottom: 15rpx;
  429. }
  430. .jt {
  431. flex-shrink: 0;
  432. width: 14rpx;
  433. height: 15rpx;
  434. margin-top: 40rpx;
  435. align-self: flex-start;
  436. }
  437. }
  438. }
  439. </style>