index.vue 12 KB

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