index.vue 12 KB

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