index.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  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.content }}</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 :long="1" type="3" ref="goodslist"/>
  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. onLaunch() {},
  74. onShow() {
  75. this.$nextTick(()=>{
  76. this.$refs.goodslist.loadData();
  77. })
  78. this.getBanner(); //获取轮播图
  79. this.getAnnounce(); //获取公告列表
  80. // this.getImageTwo(); //金刚区
  81. // this.getImage(); //获取活动列表
  82. },
  83. onHide() {},
  84. methods: {
  85. // 获取轮播图
  86. getBanner() {
  87. post("banner").then((res) => {
  88. if (res.code === 0) {
  89. res.data.data.forEach(e => {
  90. if(e.image) this.BannerImg.push(e.image)
  91. });
  92. // this.BannerImg = res.list;
  93. }
  94. });
  95. },
  96. // 获取公告列表
  97. getAnnounce() {
  98. post("notice").then((res) => {
  99. console.log(res);
  100. if (res.code === 0) {
  101. this.not_list = [res.data.data];
  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(e) {
  123. let id = e.id;
  124. // uni.navigateTo({
  125. // url: "/pages/prefecture-list/index?id=" + id + "&type=1",
  126. // });
  127. },
  128. // 金刚区跳转
  129. setPageUrl(item){
  130. if(item.showType == 1){
  131. this.goto('/pages/product/productRetail')
  132. }else if(item.showType == 2){
  133. this.goto('/pages/product/productWholesale')
  134. }else{
  135. appEv.errTips('此功能暂未开放!')
  136. return false
  137. }
  138. },
  139. },
  140. computed: {},
  141. watch: {},
  142. };
  143. </script>
  144. <style scoped lang='scss'>
  145. .head {
  146. padding: 12rpx 28rpx;
  147. }
  148. .head_search {
  149. width: 100%;
  150. height: 64rpx;
  151. line-height: 64rpx;
  152. background: #f3f5f7;
  153. border-radius: 32rpx;
  154. text-align: center;
  155. font-size: 28rpx;
  156. color: #bbbbbb;
  157. margin-bottom: 26rpx;
  158. .search_text {
  159. margin-left: 14rpx;
  160. }
  161. }
  162. .head_notice {
  163. margin: 30rpx 0;
  164. .notice_title {
  165. width: 130rpx;
  166. height: 40rpx;
  167. float: left;
  168. .gg_img {
  169. width: 100%;
  170. height: 40rpx;
  171. }
  172. }
  173. .notice_swiper {
  174. height: 40rpx;
  175. padding-left: 20rpx;
  176. font-size: 28rpx;
  177. float: left;
  178. box-sizing: border-box;
  179. width: calc(100% - 130rpx);
  180. .not_list {
  181. width: calc(100% - 50rpx);
  182. }
  183. .not_ico {
  184. width: 30rpx;
  185. font-size: 28rpx;
  186. color: #999;
  187. }
  188. .not_list,
  189. .not_ico {
  190. display: inline-block;
  191. vertical-align: middle;
  192. height: 40rpx;
  193. line-height: 40rpx;
  194. }
  195. }
  196. }
  197. // 金刚区
  198. .head_area {
  199. margin: 20rpx 0 20rpx;
  200. padding: 20rpx 0;
  201. border-radius: 18rpx;
  202. box-shadow: 2px 2px 13px 1px rgba(17, 18, 29, 0.08);
  203. .area_list {
  204. display: inline-block;
  205. width: 25%;
  206. text-align: center;
  207. .area_img {
  208. width: 46rpx;
  209. height: 46rpx;
  210. margin-bottom: 12rpx;
  211. }
  212. .area_name {
  213. font-size: 24rpx;
  214. color: #474747;
  215. }
  216. }
  217. }
  218. // 金刚区-end
  219. // 活动
  220. .activity {
  221. .act_one_img {
  222. display: inline-block;
  223. width: 300rpx;
  224. height: 378rpx;
  225. margin-right: 10rpx;
  226. }
  227. .act_other {
  228. display: inline-block;
  229. width: calc(100% - 300rpx - 10rpx);
  230. }
  231. .act_two_img {
  232. width: 100%;
  233. height: 185rpx;
  234. }
  235. }
  236. // 活动-end
  237. // 商品列表
  238. .list_bar{
  239. .tit{
  240. text-align: center;
  241. font-size: 36rpx;
  242. color: #121212;
  243. padding: 40rpx 0 20rpx;
  244. font-weight: bold;
  245. }
  246. }
  247. </style>