当前位置:   article > 正文

小程序首页示例代码_小程序首页模版源码

小程序首页模版源码

html

  1. <!--index.wxml-->
  2. <view class="container">
  3. <view class="curved">
  4. <swiper class="swiperImageContainer square-dot margin-top-s" indicator-dots="true" circular="true" autoplay="true" interval="5000" duration="500" easing-function="easeInOutCubic">
  5. <swiper-item wx:for="{{swiperList}}" wx:for-item="item" wx:key="id">
  6. <image class="swiperItemImg" src="{{item.url}}" ></image>
  7. </swiper-item>
  8. </swiper>
  9. <!-- 公司介绍、代理记账、公司转让 -->
  10. <view class="middle">
  11. <view class="jiesao">
  12. <image style=" background-color: #f9ce65;" class="middle-img" src="/pages/image/gongshi.png"></image>
  13. <view class="middle-text">
  14. 公司介绍
  15. </view>
  16. </view>
  17. <view class="jiesao">
  18. <image style=" background-color: #f7a056;" class="middle-img" src="/pages/image/jizang.png"></image>
  19. <view class="middle-text">
  20. 代理记账
  21. </view>
  22. </view>
  23. <view class="jiesao" bindtap="tolink">
  24. <image style=" background-color:#8ac293; width: 45rpx;height: 45rpx;padding: 15rpx;" class="middle-img" src="/pages/image/zuanrang.png"></image>
  25. <view class="middle-text">
  26. 公司转让
  27. </view>
  28. </view>
  29. <view class="jiesao">
  30. <image style="background-color:#749def;width: 45rpx;height: 45rpx;padding: 15rpx;" class="middle-img" src="/pages/image/gongsang.png"></image>
  31. <view class="middle-text">
  32. 工商代办
  33. </view>
  34. </view>
  35. </view>
  36. <van-cell-group inset>
  37. <van-cell title="南宁市西乡塘区新阳路223号A单元2303" icon="location-o" is-link bindtap="tomap"/>
  38. <van-cell icon="phone-o" title="电话:" value="17776019009" is-link bindtap="freeTell"></van-cell>
  39. </van-cell-group>
  40. <view class="zuanrang" wx:for="{{10}}">
  41. <view class="zuanrang-demo" >
  42. <view class="zuanrang-top">
  43. <view class="toptext1">
  44. </view>
  45. <view class="toptext2">
  46. 广西*****进出口有限公司
  47. </view>
  48. <image src="/pages/image/hot.png" mode=""/>
  49. </view>
  50. <view class="zuanrang-bottom">
  51. <!-- 企业行业 -->
  52. <view class="bottom-item">
  53. <view class="item-o" >
  54. <view class="bottom-item-top">
  55. <view class="sanjiao">
  56. </view>
  57. <view>
  58. 企业行业
  59. </view>
  60. </view>
  61. <view class="item-o-text">贸易类</view>
  62. </view>
  63. </view>
  64. <!-- 企业类型 -->
  65. <view class="bottom-item">
  66. <view class="item-o" >
  67. <view class="bottom-item-top">
  68. <view class="sanjiao">
  69. </view>
  70. <view>
  71. 企业类型
  72. </view>
  73. </view>
  74. <view class="item-o-text">有限责任公司</view>
  75. </view>
  76. </view>
  77. <!-- 纳税类型 -->
  78. <view class="bottom-item">
  79. <view class="item-o" >
  80. <view class="bottom-item-top">
  81. <view class="sanjiao">
  82. </view>
  83. <view>
  84. 纳税类型
  85. </view>
  86. </view>
  87. <view class="item-o-text">小规模纳税人</view>
  88. </view>
  89. </view>
  90. <!-- 注册资本 -->
  91. <view class="bottom-item">
  92. <view class="item-o" >
  93. <view class="bottom-item-top">
  94. <view class="sanjiao">
  95. </view>
  96. <view>
  97. 注册资本
  98. </view>
  99. </view>
  100. <view class="item-o-text"> 100-500万</view>
  101. </view>
  102. </view>
  103. <!-- 所在地区 -->
  104. <view class="bottom-item">
  105. <view class="item-o" >
  106. <view class="bottom-item-top">
  107. <view class="sanjiao">
  108. </view>
  109. <view>
  110. 所在地区
  111. </view>
  112. </view>
  113. <view class="item-o-text">青秀区</view>
  114. </view>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. <view>
  121. </view>
  122. </view>

js

  1. // index.js
  2. // 获取应用实例
  3. const app = getApp()
  4. Page({
  5. data: {
  6. swiperList: [
  7. {
  8. id: 0,
  9. url: 'https://imgs.yxhhr.com/Public/Uploads/2022-01-14/61e0f0930f9a0.jpg'
  10. }, {
  11. id: 1,
  12. url: 'https://imgs.yxhhr.com/Public/Uploads/2022-01-14/61e0f0930f9a0.jpg',
  13. },
  14. {
  15. id: 2,
  16. url: 'https://imgs.yxhhr.com/Public/Uploads/2022-01-14/61e0f0930f9a0.jpg'
  17. }],
  18. },
  19. onLoad() {
  20. if (wx.getUserProfile) {
  21. this.setData({
  22. canIUseGetUserProfile: true
  23. })
  24. }
  25. },
  26. tolink(){
  27. wx.navigateTo({
  28. "url": "/pages/index/link/link"
  29. })
  30. },
  31. tomap(){
  32. wx.openLocation({
  33. latitude: 23.099994,
  34. longitude: 113.324520,
  35. scale: 18
  36. })
  37. },
  38. freeTell() {
  39. wx.makePhoneCall({
  40. phoneNumber: '17776019009', //仅为示例,并非真实的电话号码
  41. success: function() {
  42. console.log("拨打电话成功!")
  43. },
  44. fail: function() {
  45. console.log("拨打电话失败!")
  46. }
  47. })
  48. },
  49. getUserProfile(e) {
  50. // 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认,开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
  51. wx.getUserProfile({
  52. desc: '展示用户信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
  53. success: (res) => {
  54. console.log(res)
  55. this.setData({
  56. userInfo: res.userInfo,
  57. hasUserInfo: true
  58. })
  59. }
  60. })
  61. },
  62. getUserInfo(e) {
  63. // 不推荐使用getUserInfo获取用户信息,预计自2021年4月13日起,getUserInfo将不再弹出弹窗,并直接返回匿名的用户个人信息
  64. console.log(e)
  65. this.setData({
  66. userInfo: e.detail.userInfo,
  67. hasUserInfo: true
  68. })
  69. }
  70. })

css

  1. page {
  2. background-color: #f8f8f8;
  3. }
  4. .curved {
  5. position: relative;
  6. background: #f46634;
  7. height: 18vh;
  8. border-bottom-left-radius: 50% 20%;
  9. border-bottom-right-radius: 50% 20%;
  10. }
  11. .swiperImageContainer {
  12. width: 100%;
  13. height: 300rpx;
  14. }
  15. .swiperItemImg {
  16. position: absolute;
  17. width: 92%;
  18. height: 300rpx;
  19. border-radius: 20rpx;
  20. margin: 0 4%;
  21. }
  22. swiper.square-dot .wx-swiper-dot {
  23. background-color: var(--white);
  24. opacity: 0.4;
  25. width: 10rpx;
  26. height: 10rpx;
  27. border-radius: 20rpx;
  28. margin: 0 8rpx !important;
  29. }
  30. swiper.square-dot .wx-swiper-dot.wx-swiper-dot-active {
  31. opacity: 1;
  32. width: 30rpx;
  33. }
  34. .middle{
  35. display: flex;
  36. justify-content: space-around;
  37. margin-top: 30rpx;
  38. margin-bottom: 30rpx;
  39. }
  40. .middle-img{
  41. padding: 6rpx;
  42. border-radius: 50%;
  43. width: 60rpx;
  44. height: 60rpx;
  45. display: flex;
  46. justify-content: center;
  47. align-items: center;
  48. }
  49. .middle-text{
  50. margin-top: 15rpx;
  51. font-size: 24rpx;
  52. }
  53. .jiesao{
  54. display: flex;
  55. flex-direction: column;
  56. align-items: center;
  57. justify-content: center;
  58. }
  59. .zuanrang{
  60. margin-top: 20rpx;
  61. background-color: white;
  62. margin-bottom: 25rpx;
  63. box-shadow: rgba(50, 50, 93, 0.25) 0px 2px 5px -1px, rgba(0, 0, 0, 0.3) 0px 1px 3px -1px;
  64. border-radius: 20rpx;
  65. margin-right: 20rpx;
  66. margin-left: 20rpx;
  67. }
  68. .zuanrang-demo{
  69. margin: 0 15rpx;
  70. }
  71. .zuanrang-top{
  72. display: flex;
  73. align-items: center;
  74. padding: 10rpx 0;
  75. margin-bottom: 5rpx;
  76. border-bottom: 1rpx solid #969696;
  77. }
  78. .zuanrang-top .toptext1{
  79. font-weight: bold;
  80. color: #f26533;
  81. margin:0 10rpx;
  82. }
  83. .zuanrang-top image{
  84. margin-left: 30rpx;
  85. width: 34rpx;
  86. height: 34rpx;
  87. }
  88. .zuanrang-bottom{
  89. display: flex;
  90. justify-content: space-between;
  91. }
  92. .item-o{
  93. display: flex;
  94. flex-direction: column;
  95. }
  96. .item-o-text{
  97. font-size: 23rpx;
  98. margin-bottom: 10rpx;
  99. }
  100. .bottom-item-top{
  101. display: flex;
  102. justify-content: space-between;
  103. font-size: 25rpx;
  104. align-items: center;
  105. color: #969696;
  106. margin-bottom: 5rpx;
  107. }
  108. .sanjiao{
  109. width: 0;
  110. height: 0;
  111. border-left: 10rpx solid #969696;
  112. border-top: 10rpx solid transparent;
  113. border-bottom: 10rpx solid transparent;
  114. margin-right:6rpx;
  115. }

json

  1. {
  2. "navigationBarTitleText": "狄牛网",
  3. "navigationBarBackgroundColor": "#f46634",
  4. "navigationBarTextStyle": "white"
  5. }
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小蓝xlanll/article/detail/232479
推荐阅读