index.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. <template>
  2. <div class="Appindex">
  3. <!-- 顶部 -->
  4. <view class="head">
  5. <!-- 搜索框 -->
  6. <view class="head_search">
  7. <text class="iconfont">&#xe661;</text>
  8. <text class="search_text">请输入搜索关键字</text>
  9. </view>
  10. <!-- 搜索框-end -->
  11. <!-- 轮播图 -->
  12. <swiper-banner :radius="1" imgScale="5:2" :imgArr="BannerImg" :duration="1000" :interval="5000" :circular="true" :autoplay="true" @goList="goList" :indicator-dots="true" indicator-active-color="#12B280" indicator-color="rgba(255, 255, 255, .82)"></swiper-banner>
  13. <!-- 轮播图-end -->
  14. <!-- 公告 -->
  15. <view class="head_notice clearfix">
  16. <view class="notice_title">
  17. <image class="gg_img" src="@/static/img/gg.png"></image>
  18. </view>
  19. <swiper class="notice_swiper" vertical autoplay circular :interval="5000" :duration="1000">
  20. <swiper-item v-for="(item, index) in not_list" :key="index">
  21. <text class="not_list ellipsis1">{{ item.contentTitle }}</text>
  22. <text class="not_ico iconfont">&#xe62e;</text>
  23. </swiper-item>
  24. </swiper>
  25. </view>
  26. <!-- 公告-end -->
  27. <!-- 金刚区 -->
  28. <view class="head_area">
  29. <view class="area_list" v-for="(item, index) in area_list" :key="index">
  30. <image class="area_img" :src="item.url"></image>
  31. <view class="area_name">{{ item.name }}</view>
  32. </view>
  33. </view>
  34. <!-- 金刚区-end -->
  35. <!-- 活动 -->
  36. <view class="activity" v-if="spc_list.length > 0">
  37. <image class="act_one_img" :src="spc_list[0].url" mode=""></image>
  38. <view class="act_other">
  39. <image class="act_two_img" :src="spc_list[1].url" mode=""></image>
  40. <image class="act_two_img" :src="spc_list[2].url" mode=""></image>
  41. </view>
  42. </view>
  43. <!-- 活动-end -->
  44. </view>
  45. <goodslist :url="goodslistUrl" :long="1" />
  46. </div>
  47. </template>
  48. <script>
  49. import goodslist from "@/components/goodsList"; //商品列表
  50. import swiperBanner from "@/components/swiperBanner"; //轮播
  51. import { get, post } from "@/request/api.js";
  52. export default {
  53. name: "Appindex",
  54. components: {
  55. goodslist, //商品列表
  56. swiperBanner, //轮播
  57. },
  58. data() {
  59. return {
  60. BannerImg: [], // 轮播图列表
  61. not_list: [], // 公告列表
  62. area_list: [], // 金刚区
  63. spc_list: [], //活动列表
  64. goodslistUrl: "ShuZiTeaYW/shop/getGoodsLikeByUserId", //首页商品列表
  65. };
  66. },
  67. onLoad(option) {
  68. this.getBanner(); //获取轮播图
  69. this.getAnnounce(); //获取公告列表
  70. this.getImageTwo(); //金刚区
  71. this.getImage(); //获取活动列表
  72. },
  73. onLaunch() {},
  74. onShow() {},
  75. onHide() {},
  76. methods: {
  77. // 获取轮播图
  78. getBanner() {
  79. post("ShuZiTeaYW/shop/play").then((res) => {
  80. if (res.status == 200) {
  81. this.BannerImg = res.list;
  82. }
  83. });
  84. },
  85. // 获取公告列表
  86. getAnnounce() {
  87. post("ShuZiTeaYW/announce/getAnnounce", {
  88. status: 2,
  89. }).then((res) => {
  90. if (res.status == 200) {
  91. this.not_list = res.announce;
  92. }
  93. });
  94. },
  95. // 获取公告列表
  96. getAnnounce() {
  97. post("ShuZiTeaYW/announce/getAnnounce", {
  98. status: 2,
  99. }).then((res) => {
  100. if (res.status == 200) {
  101. this.not_list = res.announce;
  102. }
  103. });
  104. },
  105. // 获取金刚区列表
  106. getImageTwo() {
  107. post("ShuZiTeaSpecial/special/imageTwo").then((res) => {
  108. if (res.status == 200) {
  109. this.area_list = res.data;
  110. }
  111. });
  112. },
  113. // 获取活动区列表
  114. getImage() {
  115. post("ShuZiTeaSpecial/special/image").then((res) => {
  116. if (res.status == 200) {
  117. this.spc_list = res.data;
  118. }
  119. });
  120. },
  121. // 轮播图跳转
  122. goList: function(e) {
  123. let id = e.id;
  124. uni.navigateTo({
  125. url: "/pages/prefecture-list/index?id=" + id + "&type=1",
  126. });
  127. },
  128. },
  129. computed: {},
  130. watch: {},
  131. };
  132. </script>
  133. <style scoped lang='scss'>
  134. .head {
  135. padding: 12rpx 28rpx;
  136. }
  137. .head_search {
  138. width: 100%;
  139. height: 64rpx;
  140. line-height: 64rpx;
  141. background: #f3f5f7;
  142. border-radius: 32rpx;
  143. text-align: center;
  144. font-size: 28rpx;
  145. color: #bbbbbb;
  146. margin-bottom: 26rpx;
  147. .search_text {
  148. margin-left: 14rpx;
  149. }
  150. }
  151. .head_notice {
  152. margin: 30rpx 0;
  153. .notice_title {
  154. width: 130rpx;
  155. height: 40rpx;
  156. float: left;
  157. .gg_img {
  158. width: 100%;
  159. height: 40rpx;
  160. }
  161. }
  162. .notice_swiper {
  163. height: 40rpx;
  164. padding-left: 20rpx;
  165. font-size: 28rpx;
  166. float: left;
  167. box-sizing: border-box;
  168. width: calc(100% - 130rpx);
  169. .not_list {
  170. width: calc(100% - 50rpx);
  171. }
  172. .not_ico {
  173. width: 30rpx;
  174. font-size: 28rpx;
  175. color: #999;
  176. }
  177. .not_list,
  178. .not_ico {
  179. display: inline-block;
  180. vertical-align: middle;
  181. height: 40rpx;
  182. line-height: 40rpx;
  183. }
  184. }
  185. }
  186. // 金刚区
  187. .head_area {
  188. margin: 20rpx 0 20rpx;
  189. padding: 20rpx 0;
  190. border-radius: 18rpx;
  191. box-shadow: 2px 2px 13px 1px rgba(17, 18, 29, 0.08);
  192. .area_list {
  193. display: inline-block;
  194. width: 25%;
  195. text-align: center;
  196. .area_img {
  197. width: 46rpx;
  198. height: 46rpx;
  199. margin-bottom: 12rpx;
  200. }
  201. .area_name {
  202. font-size: 24rpx;
  203. color: #474747;
  204. }
  205. }
  206. }
  207. // 金刚区-end
  208. // 活动
  209. .activity {
  210. .act_one_img {
  211. display: inline-block;
  212. width: 300rpx;
  213. height: 378rpx;
  214. margin-right: 10rpx;
  215. }
  216. .act_other {
  217. display: inline-block;
  218. width: calc(100% - 300rpx - 10rpx);
  219. }
  220. .act_two_img {
  221. width: 100%;
  222. height: 185rpx;
  223. }
  224. }
  225. // 活动-end
  226. </style>