index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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.title }}</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. <view class="product-list">
  48. <view class="product" v-for="(i, s) in productList" :key="s" @click="NavToGoodsDetail(i.id,i.type)">
  49. <view class="image-view">
  50. <image class="product-image" :src="i.original_img"></image>
  51. </view>
  52. <view :class="['product-title', 'ellipsis1']">{{ i.goods_name }}</view>
  53. <view class="product-price">
  54. <text class="product-price-original"><text class="product-unit">¥</text>{{ i.price }}</text>
  55. <!-- <text class="product-price-favour">¥{{i.originalPrice}}</text> -->
  56. <!-- <text class="product-tip">{{i.tip}}</text> -->
  57. </view>
  58. <view class="product-txt">{{ i.give_integral + "积分" }}</view>
  59. </view>
  60. <view class='fz_w_text mar_t20 mar_b20'>茶,让生活更美好!</view>
  61. </view>
  62. </view>
  63. </div>
  64. </template>
  65. <script>
  66. let app=getApp();
  67. var appEv = app.$vm.$options;
  68. // import goodslist from "@/components/goodsList"; //商品列表
  69. import swiperBanner from "@/components/swiperBanner"; //轮播
  70. import { get, post } from "@/request/api.js";
  71. export default {
  72. name: "Appindex",
  73. components: {
  74. // goodslist, //商品列表
  75. swiperBanner, //轮播
  76. },
  77. data() {
  78. return {
  79. BannerImg: [], // 轮播图列表
  80. not_list: [], // 公告列表
  81. // 金刚区
  82. area_list: [
  83. {name: "零售区", url: "https://teaclub.oss-cn-chengdu.aliyuncs.com/menu/cart.png", type:1},
  84. {name: "批发区", url: "https://teaclub.oss-cn-chengdu.aliyuncs.com/menu/wholesale.png", type:2},
  85. {name: "精品优选", url: "https://teaclub.oss-cn-chengdu.aliyuncs.com/menu/preferred.png", type:3},
  86. {name: "今日值买", url: "https://teaclub.oss-cn-chengdu.aliyuncs.com/menu/integral.png", type:4}
  87. ],
  88. spc_list: [
  89. {url: "https://teaclub.oss-cn-chengdu.aliyuncs.com/ShuZiTea/ShuZiTeaHT/202210/f70cd8e0-e468-45eb-a9f7-2c42713cd607.jpg"},
  90. {url: "https://teaclub.oss-cn-chengdu.aliyuncs.com/ShuZiTea/ShuZiTeaHT/202210/b13c0186-fdfc-4b87-b466-5c9fc336cc54.jpg"},
  91. {url: "https://teaclub.oss-cn-chengdu.aliyuncs.com/ShuZiTea/ShuZiTeaHT/202210/49886d9c-ce5a-49ca-a281-12910541344f.jpg"}
  92. ], //活动列表
  93. productList: [], //商品数据
  94. };
  95. },
  96. onLoad(option) {
  97. },
  98. onLaunch() {},
  99. onShow() {
  100. this.loadData()
  101. this.getBanner(); //获取轮播图
  102. this.getAnnounce(); //获取公告列表
  103. // this.getImageTwo(); //金刚区
  104. // this.getImage(); //获取活动列表
  105. },
  106. onHide() {},
  107. methods: {
  108. loadData() {
  109. post("goods/indexGoods").then((res) => {
  110. if (res.code === 0) {
  111. this.productList = res.data.data;
  112. }
  113. });
  114. },
  115. // 跳转到商品详情页
  116. NavToGoodsDetail(id, type) {
  117. this.goto("/pages/product/p_details", { id, type });
  118. },
  119. // 获取轮播图
  120. getBanner() {
  121. post("banner").then((res) => {
  122. if (res.code === 0) {
  123. this.BannerImg = []
  124. res.data.data.forEach(e => {
  125. if(e.image) this.BannerImg.push(e.image)
  126. });
  127. // this.BannerImg = res.list;
  128. }
  129. });
  130. },
  131. // 获取公告列表
  132. getAnnounce() {
  133. post("notice").then((res) => {
  134. console.log(res);
  135. if (res.code === 0) {
  136. this.not_list = [res.data.data];
  137. }
  138. });
  139. },
  140. // 获取金刚区列表
  141. getImageTwo() {
  142. post("ShuZiTeaSpecial/special/imageTwo").then((res) => {
  143. if (res.status == 200) {
  144. this.area_list = res.data;
  145. }
  146. });
  147. },
  148. // 获取活动区列表
  149. getImage() {
  150. post("ShuZiTeaSpecial/special/image").then((res) => {
  151. if (res.status == 200) {
  152. this.spc_list = res.data;
  153. }
  154. });
  155. },
  156. // 轮播图跳转
  157. goList(e) {
  158. let id = e.id;
  159. // uni.navigateTo({
  160. // url: "/pages/prefecture-list/index?id=" + id + "&type=1",
  161. // });
  162. },
  163. // 金刚区跳转
  164. setPageUrl(item){
  165. if(item.type == 1){
  166. this.goto('/pages/product/productRetail',{type:item.type})
  167. }else if(item.type == 2){
  168. this.goto('/pages/product/productWholesale',{type:item.type})
  169. }
  170. // else if(item.type == 3){
  171. // this.goto('/pages/product/productRetail',{type:item.type})
  172. // }
  173. // else if(item.type == 4){
  174. // this.goto('/pages/product/productRetail',{type:item.type})
  175. // }
  176. else{
  177. appEv.errTips('此功能暂未开放!')
  178. return false
  179. }
  180. },
  181. },
  182. computed: {},
  183. watch: {},
  184. };
  185. </script>
  186. <style scoped lang='scss'>
  187. .head {
  188. padding: 12rpx 28rpx;
  189. }
  190. .head_search {
  191. width: 100%;
  192. height: 64rpx;
  193. line-height: 64rpx;
  194. background: #f3f5f7;
  195. border-radius: 32rpx;
  196. text-align: center;
  197. font-size: 28rpx;
  198. color: #bbbbbb;
  199. margin-bottom: 26rpx;
  200. .search_text {
  201. margin-left: 14rpx;
  202. }
  203. }
  204. .head_notice {
  205. margin: 30rpx 0;
  206. .notice_title {
  207. width: 130rpx;
  208. height: 40rpx;
  209. float: left;
  210. .gg_img {
  211. width: 100%;
  212. height: 40rpx;
  213. }
  214. }
  215. .notice_swiper {
  216. height: 40rpx;
  217. padding-left: 20rpx;
  218. font-size: 28rpx;
  219. float: left;
  220. box-sizing: border-box;
  221. width: calc(100% - 130rpx);
  222. .not_list {
  223. width: calc(100% - 50rpx);
  224. }
  225. .not_ico {
  226. width: 30rpx;
  227. font-size: 28rpx;
  228. color: #999;
  229. }
  230. .not_list,
  231. .not_ico {
  232. display: inline-block;
  233. vertical-align: middle;
  234. height: 40rpx;
  235. line-height: 40rpx;
  236. }
  237. }
  238. }
  239. // 金刚区
  240. .head_area {
  241. margin: 20rpx 0 20rpx;
  242. padding: 20rpx 0;
  243. border-radius: 18rpx;
  244. box-shadow: 2px 2px 13px 1px rgba(17, 18, 29, 0.08);
  245. .area_list {
  246. display: inline-block;
  247. width: 25%;
  248. text-align: center;
  249. .area_img {
  250. width: 46rpx;
  251. height: 46rpx;
  252. margin-bottom: 12rpx;
  253. }
  254. .area_name {
  255. font-size: 24rpx;
  256. color: #474747;
  257. }
  258. }
  259. }
  260. // 金刚区-end
  261. // 活动
  262. .activity {
  263. .act_one_img {
  264. display: inline-block;
  265. width: 300rpx;
  266. height: 378rpx;
  267. margin-right: 10rpx;
  268. }
  269. .act_other {
  270. display: inline-block;
  271. width: calc(100% - 300rpx - 10rpx);
  272. }
  273. .act_two_img {
  274. width: 100%;
  275. height: 185rpx;
  276. }
  277. }
  278. // 活动-end
  279. // 商品列表
  280. .list_bar{
  281. .tit{
  282. text-align: center;
  283. font-size: 36rpx;
  284. color: #121212;
  285. padding: 40rpx 0 20rpx;
  286. font-weight: bold;
  287. }
  288. }
  289. .product-list {
  290. padding: 0 20rpx;
  291. display: flex;
  292. width: 100%;
  293. flex-wrap: wrap;
  294. flex-direction: row;
  295. .product {
  296. width: 50%;
  297. padding: 20rpx 10rpx;
  298. display: flex;
  299. flex-direction: column;
  300. }
  301. .product-image {
  302. border-radius: 10rpx 10rpx 0 0;
  303. width: 100%;
  304. height: 260rpx;
  305. object-fit: cover;
  306. }
  307. .product-title {
  308. width: 100%;
  309. overflow: hidden;
  310. line-height: 1.5;
  311. }
  312. .product-price {
  313. color: #121212;
  314. font-size: 28rpx;
  315. position: relative;
  316. }
  317. .product-price-original {
  318. color: #18bb88;
  319. }
  320. .product-price-favour {
  321. color: #888888;
  322. text-decoration: line-through;
  323. margin-left: 10upx;
  324. }
  325. .product-tip {
  326. position: absolute;
  327. right: 10upx;
  328. background-color: #ff3333;
  329. color: #ffffff;
  330. padding: 0 10upx;
  331. border-radius: 5upx;
  332. }
  333. .product-unit {
  334. font-size: 24rpx;
  335. }
  336. .product-txt {
  337. font-size: 22rpx;
  338. color: #787878;
  339. }
  340. }
  341. </style>