index.vue 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  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" @click="setPageUrl(item)">
  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. <view class="list_bar">
  46. <div class="tit">猜你喜欢</div>
  47. <goodslist :url="goodslistUrl" :long="1" />
  48. </view>
  49. </div>
  50. </template>
  51. <script>
  52. let app=getApp();
  53. var appEv = app.$vm.$options;
  54. import goodslist from "@/components/goodsList"; //商品列表
  55. import swiperBanner from "@/components/swiperBanner"; //轮播
  56. import { get, post } from "@/request/api.js";
  57. export default {
  58. name: "Appindex",
  59. components: {
  60. goodslist, //商品列表
  61. swiperBanner, //轮播
  62. },
  63. data() {
  64. return {
  65. BannerImg: [], // 轮播图列表
  66. not_list: [], // 公告列表
  67. area_list: [], // 金刚区
  68. spc_list: [], //活动列表
  69. goodslistUrl: "ShuZiTeaYW/shop/getGoodsLikeByUserId", //首页商品列表
  70. };
  71. },
  72. onLoad(option) {
  73. this.getBanner(); //获取轮播图
  74. this.getAnnounce(); //获取公告列表
  75. this.getImageTwo(); //金刚区
  76. this.getImage(); //获取活动列表
  77. },
  78. onLaunch() {},
  79. onShow() {},
  80. onHide() {},
  81. methods: {
  82. // 获取轮播图
  83. getBanner() {
  84. post("ShuZiTeaYW/shop/play").then((res) => {
  85. if (res.status == 200) {
  86. this.BannerImg = res.list;
  87. }
  88. });
  89. },
  90. // 获取公告列表
  91. getAnnounce() {
  92. post("ShuZiTeaYW/announce/getAnnounce", {
  93. status: 2,
  94. }).then((res) => {
  95. if (res.status == 200) {
  96. this.not_list = res.announce;
  97. }
  98. });
  99. },
  100. // 获取公告列表
  101. getAnnounce() {
  102. post("ShuZiTeaYW/announce/getAnnounce", {
  103. status: 2,
  104. }).then((res) => {
  105. if (res.status == 200) {
  106. this.not_list = res.announce;
  107. }
  108. });
  109. },
  110. // 获取金刚区列表
  111. getImageTwo() {
  112. post("ShuZiTeaSpecial/special/imageTwo").then((res) => {
  113. if (res.status == 200) {
  114. this.area_list = res.data;
  115. }
  116. });
  117. },
  118. // 获取活动区列表
  119. getImage() {
  120. post("ShuZiTeaSpecial/special/image").then((res) => {
  121. if (res.status == 200) {
  122. this.spc_list = res.data;
  123. }
  124. });
  125. },
  126. // 轮播图跳转
  127. goList(e) {
  128. let id = e.id;
  129. // uni.navigateTo({
  130. // url: "/pages/prefecture-list/index?id=" + id + "&type=1",
  131. // });
  132. },
  133. // 金刚区跳转
  134. setPageUrl(item){
  135. if(item.showType == 1){
  136. this.goto('/pages/product/productRetail')
  137. }else if(item.showType == 2){
  138. this.goto('/pages/product/productWholesale')
  139. }else{
  140. appEv.errTips('此功能暂未开放!')
  141. return false
  142. }
  143. },
  144. },
  145. computed: {},
  146. watch: {},
  147. };
  148. </script>
  149. <style scoped lang='scss'>
  150. .head {
  151. padding: 12rpx 28rpx;
  152. }
  153. .head_search {
  154. width: 100%;
  155. height: 64rpx;
  156. line-height: 64rpx;
  157. background: #f3f5f7;
  158. border-radius: 32rpx;
  159. text-align: center;
  160. font-size: 28rpx;
  161. color: #bbbbbb;
  162. margin-bottom: 26rpx;
  163. .search_text {
  164. margin-left: 14rpx;
  165. }
  166. }
  167. .head_notice {
  168. margin: 30rpx 0;
  169. .notice_title {
  170. width: 130rpx;
  171. height: 40rpx;
  172. float: left;
  173. .gg_img {
  174. width: 100%;
  175. height: 40rpx;
  176. }
  177. }
  178. .notice_swiper {
  179. height: 40rpx;
  180. padding-left: 20rpx;
  181. font-size: 28rpx;
  182. float: left;
  183. box-sizing: border-box;
  184. width: calc(100% - 130rpx);
  185. .not_list {
  186. width: calc(100% - 50rpx);
  187. }
  188. .not_ico {
  189. width: 30rpx;
  190. font-size: 28rpx;
  191. color: #999;
  192. }
  193. .not_list,
  194. .not_ico {
  195. display: inline-block;
  196. vertical-align: middle;
  197. height: 40rpx;
  198. line-height: 40rpx;
  199. }
  200. }
  201. }
  202. // 金刚区
  203. .head_area {
  204. margin: 20rpx 0 20rpx;
  205. padding: 20rpx 0;
  206. border-radius: 18rpx;
  207. box-shadow: 2px 2px 13px 1px rgba(17, 18, 29, 0.08);
  208. .area_list {
  209. display: inline-block;
  210. width: 25%;
  211. text-align: center;
  212. .area_img {
  213. width: 46rpx;
  214. height: 46rpx;
  215. margin-bottom: 12rpx;
  216. }
  217. .area_name {
  218. font-size: 24rpx;
  219. color: #474747;
  220. }
  221. }
  222. }
  223. // 金刚区-end
  224. // 活动
  225. .activity {
  226. .act_one_img {
  227. display: inline-block;
  228. width: 300rpx;
  229. height: 378rpx;
  230. margin-right: 10rpx;
  231. }
  232. .act_other {
  233. display: inline-block;
  234. width: calc(100% - 300rpx - 10rpx);
  235. }
  236. .act_two_img {
  237. width: 100%;
  238. height: 185rpx;
  239. }
  240. }
  241. // 活动-end
  242. // 商品列表
  243. .list_bar{
  244. .tit{
  245. text-align: center;
  246. font-size: 36rpx;
  247. color: #121212;
  248. padding: 40rpx 0 20rpx;
  249. font-weight: bold;
  250. }
  251. }
  252. </style>