index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503
  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" @click="goNoticeList">
  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. <div class="l_tabBar flex_r flex_jb">
  23. <div class="search-box flex_r flex_jb flex_ac">
  24. <div class="district" @click="showAddress = !showAddress">
  25. <span>{{ LocationCity }}</span>
  26. <span class="iconfont">&#xe62f;</span>
  27. </div>
  28. <div class="search flex_r flex_jb flex_ac">
  29. <span class="iconfont">&#xe661;</span>
  30. <input v-model="searchKey" @confirm="toSearch" class="inp" placeholder="搜索你要的内容">
  31. <span class="search_btn" @click="toSearch">搜索</span>
  32. </div>
  33. <!-- <div class="scan-ico iconfont">&#xe8cf;</div> -->
  34. </div>
  35. <div class="item" v-for="(i,s) in tabs" :key="s" @click="goto(i.url)">
  36. <img :src="i.ico" alt="" class="ico">
  37. <!-- <div class="tit">{{ i.tit }}</div> -->
  38. </div>
  39. </div>
  40. <!-- 专区-end -->
  41. <!-- 活动 -->
  42. <view class="activity" v-if="homeImg.length">
  43. <image class="act_img act_one_img" :src="homeImg[0].image" @click="setPageUrl({ type: 4 })" mode=""></image>
  44. <view class="act_other">
  45. <image class="act_img act_two_img" :src="homeImg[1].image" @click="goto('/pagesB/specialregion/index')" mode=""></image>
  46. <image class="act_img act_two_img" :src="homeImg[2].image" mode="" @click="goVipGift"></image>
  47. </view>
  48. </view>
  49. <!-- 活动-end -->
  50. </view>
  51. <view class="bou_head flex_r flex_ac flex_jc">
  52. <image class="bou_img" src="/static/sgin/left.png" mode=""></image>
  53. <view class="bou_title">今日推荐</view>
  54. <image class="bou_img" src="/static/sgin/right.png" mode=""></image>
  55. </view>
  56. <view class="list_bar">
  57. <view class="product-list">
  58. <view class="product" v-for="(i, s) in productList" :key="s" @click="NavToGoodsDetail(i.id, i.type)">
  59. <view class="image-view">
  60. <image class="product-image" :src="i.original_img"></image>
  61. </view>
  62. <view class="content-view">
  63. <view :class="['product-title', 'ellipsis']">{{ i.goods_name }}</view>
  64. <view class="product-price">
  65. <template v-if="i.type == 1">
  66. <text class="product-price-original">{{ i.total_amount }}</text>
  67. <text class="product-price-msg">(含服务费{{$h.Mul(i.service,2)}}元)</text>
  68. </template>
  69. <text class="product-price-original" v-else>{{ i.price }}</text>
  70. <text class="product-text" v-if="[3,4].includes(i.type)">赠<text class="corFE2C15">{{ i.give_cha_bao }}</text>茶宝</text>
  71. </view>
  72. <view class="product-txt" v-if="i.type == 4">
  73. <text class="product-price-favour">{{i.market_price}}</text>
  74. <text class="product-text">消费金抵</text>
  75. <span class="corFE2C15">¥{{ Number(i.consume) }}</span>
  76. </view>
  77. <!-- <view class="product-txt" v-if="i.type == 1">赠送{{ i.give_integral + "批发券" }}</view> -->
  78. <view class="product-txt" v-if="[3,4].includes(i.type)">限时赠送<text class="corFE2C15">{{ i.teac }}</text>TeaC</view>
  79. <view class="product-txt fenxiang" v-if="[3,4].includes(i.type)">
  80. <text class="iconfont red">&#xe62b;</text>
  81. <text class="red">分享约获得 {{ i.first_teac }} {{i.type==3?'TeaC':'现金'}}</text>
  82. </view>
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <view class="fz_w_text">让数字经济赋能美好生活!</view>
  88. <!-- 隐私指引 -->
  89. <xh-privacy title="隐私保护指引" color="#18bb88"></xh-privacy>
  90. <!-- 城市选择 -->
  91. <h-address @select="selectaddress" :visible.sync="showAddress" />
  92. </div>
  93. </template>
  94. <script>
  95. import swiperBanner from "@/components/swiperBanner/index.vue"; //轮播
  96. import xhPrivacy from "@/components/xh-privacy/xh-privacy.vue"; //隐私保护指引
  97. import hAddress from "@/components/h-address/address.vue"; //城市选择
  98. import tabs from '@/static/js/tabs' //专区入口
  99. import { post } from "@/request/api.js";
  100. export default {
  101. name: "Appindex",
  102. components: {
  103. swiperBanner, //轮播
  104. xhPrivacy,
  105. hAddress
  106. },
  107. data() {
  108. return {
  109. BannerImg: [], // 轮播图列表
  110. not_list: [], // 公告列表
  111. homeImg: "", //活动列表
  112. productList: [], //商品数据
  113. searchKey: "", //搜索关键词
  114. LocationCity: "深圳",
  115. showAddress: false,
  116. tabs
  117. };
  118. },
  119. onLoad(option) {
  120. this.getToCity()
  121. },
  122. onShow() {
  123. this.loadData();
  124. this.getBanner(); //获取轮播图
  125. this.getAnnounce(); //获取公告列表
  126. this.gethomeImg(); //活动列表
  127. },
  128. onHide() {},
  129. methods: {
  130. loadData() {
  131. post("v1/goods/indexGoods").then((res) => {
  132. if (res.code === 0) {
  133. this.productList = res.data.data;
  134. }
  135. });
  136. },
  137. // 跳转到商品详情页
  138. NavToGoodsDetail(id, type) {
  139. this.goto("/pages/product/p_details", { id, type });
  140. },
  141. // 跳转公告列表页
  142. goNoticeList() {
  143. this.goto("/pages/consultation-list/index");
  144. },
  145. // 获取轮播图
  146. getBanner() {
  147. post("v1/banner").then((res) => {
  148. if (res.code === 0) {
  149. this.BannerImg = [];
  150. res.data.data.forEach((e) => {
  151. if (e.image) this.BannerImg.push(e.image);
  152. });
  153. }
  154. });
  155. },
  156. // 活动列表
  157. gethomeImg() {
  158. post("v1/homeImg").then((res) => {
  159. if (res.code === 0) {
  160. this.homeImg = res.data.data
  161. }
  162. });
  163. },
  164. // 获取公告列表
  165. getAnnounce() {
  166. post("v1/notice", { is_index: 1 }).then((res) => {
  167. if (res.code === 0) {
  168. this.not_list = res.data.data;
  169. }
  170. });
  171. },
  172. //跳转公告详情
  173. toDetail(id) {
  174. this.goto("/pages/notice/detail", { id });
  175. },
  176. // 轮播图跳转
  177. goList(e) {},
  178. goVipGift() {
  179. this.goto("/pages/product/productRetail", { type: 4, is_vip: 1 });
  180. },
  181. // 搜索
  182. toSearch() {
  183. this.goto("/pagesC/settledMerchant/index", { key: this.searchKey });
  184. },
  185. // 获取当前城市
  186. async getToCity() {
  187. let { lat, lng } = await uni.Location();
  188. post("local/hotel/city", { longitude: lng, latitude: lat }).then(res => {
  189. if (res.code == 0) {
  190. let da = res.data
  191. this.LocationCity = da.cityName;
  192. }
  193. })
  194. },
  195. // 选择城市
  196. selectaddress(da) {
  197. this.LocationCity = da.cityName;
  198. this.showAddress = false;
  199. },
  200. },
  201. computed: {},
  202. watch: {},
  203. };
  204. </script>
  205. <style scoped lang='scss'>
  206. .head {
  207. padding: 12rpx 28rpx;
  208. }
  209. .head_search {
  210. width: 100%;
  211. height: 64rpx;
  212. line-height: 64rpx;
  213. background: #f3f5f7;
  214. border-radius: 32rpx;
  215. text-align: center;
  216. font-size: 28rpx;
  217. color: #bbbbbb;
  218. margin-bottom: 26rpx;
  219. .search_text {
  220. margin-left: 14rpx;
  221. }
  222. }
  223. .head_notice {
  224. margin: 30rpx 0;
  225. .notice_title {
  226. width: 130rpx;
  227. height: 40rpx;
  228. float: left;
  229. .gg_img {
  230. width: 100%;
  231. height: 40rpx;
  232. }
  233. }
  234. .notice_swiper {
  235. height: 40rpx;
  236. padding-left: 20rpx;
  237. font-size: 28rpx;
  238. float: left;
  239. box-sizing: border-box;
  240. width: calc(100% - 130rpx);
  241. .not_list {
  242. width: calc(100% - 50rpx);
  243. }
  244. .not_ico {
  245. width: 30rpx;
  246. font-size: 28rpx;
  247. color: #999;
  248. }
  249. .not_list,
  250. .not_ico {
  251. display: inline-block;
  252. vertical-align: middle;
  253. height: 40rpx;
  254. line-height: 40rpx;
  255. }
  256. }
  257. }
  258. .l_tabBar {
  259. margin: 32rpx 0;
  260. background-color: #fff;
  261. padding: 10rpx 20rpx;
  262. border-radius: 10rpx;
  263. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  264. flex-wrap: wrap;
  265. .search-box {
  266. width: 100%;
  267. padding: 10rpx;
  268. margin-bottom: 12rpx;
  269. .district {
  270. font-size: 32rpx;
  271. font-weight: 600;
  272. color: #333;
  273. .iconfont {
  274. font-size: 20rpx;
  275. margin-left: 12rpx;
  276. }
  277. }
  278. .search {
  279. border: 1px solid #D78C2E;
  280. height: 60rpx;
  281. line-height: 60rpx;
  282. padding-left: 20rpx;
  283. border-radius: 31rpx;
  284. .iconfont {
  285. font-size: 30rpx;
  286. }
  287. .inp {
  288. font-size: 25rpx;
  289. padding: 0 8rpx;
  290. width: 300rpx;
  291. }
  292. .search_btn {
  293. background-color: #D78C2E;
  294. height: 100%;
  295. color: #fff;
  296. border-radius: 31rpx;
  297. font-size: 28rpx;
  298. padding: 0 28rpx;
  299. }
  300. }
  301. .scan-ico {
  302. font-size: 55rpx;
  303. }
  304. }
  305. .item {
  306. width: 105rpx;
  307. margin: 10rpx 10rpx;
  308. }
  309. .ico {
  310. width: 100%;
  311. height: 138rpx;
  312. }
  313. // .tit{
  314. // font-size: 26rpx;
  315. // text-align: center;
  316. // }
  317. }
  318. .bou_head {
  319. width: 100%;
  320. height: 114rpx;
  321. // margin-top: 50rpx;
  322. .bou_img {
  323. width: 92rpx;
  324. height: 30rpx;
  325. }
  326. .bou_title {
  327. height: 30rpx;
  328. line-height: 30rpx;
  329. font-size: 36rpx;
  330. color: #121212;
  331. font-weight: bold;
  332. margin: 0 36rpx;
  333. }
  334. }
  335. // 活动
  336. .activity {
  337. .act_one_img {
  338. display: inline-block;
  339. width: 300rpx;
  340. height: 378rpx;
  341. margin-right: 10rpx;
  342. }
  343. .act_other {
  344. display: inline-block;
  345. width: calc(100% - 300rpx - 10rpx);
  346. }
  347. .act_two_img {
  348. width: 100%;
  349. height: 185rpx;
  350. }
  351. .act_img {
  352. border-radius: 10rpx;
  353. }
  354. }
  355. // 活动-end
  356. // 商品列表
  357. .list_bar {
  358. .tit {
  359. text-align: center;
  360. font-size: 36rpx;
  361. color: #121212;
  362. padding: 40rpx 0 20rpx;
  363. font-weight: bold;
  364. }
  365. }
  366. .product-list {
  367. width: 100%;
  368. display: flex;
  369. flex-wrap: wrap;
  370. flex-direction: row;
  371. padding: 0 30rpx;
  372. .product {
  373. width: 48.5%;
  374. margin-bottom: 20rpx;
  375. padding-bottom: 12rpx;
  376. border-radius: 10rpx;
  377. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  378. &:nth-child(2n) {
  379. margin-left: 3%;
  380. }
  381. }
  382. .product-image {
  383. border-radius: 10rpx 10rpx 0 0;
  384. width: 100%;
  385. height: 42.3vw;
  386. object-fit: cover;
  387. }
  388. .content-view {
  389. padding: 0 16rpx;
  390. }
  391. .product-title {
  392. width: 100%;
  393. overflow: hidden;
  394. line-height: 1.5;
  395. font-size: 28rpx;
  396. color: #121212;
  397. }
  398. .product-price {
  399. color: #121212;
  400. font-size: 28rpx;
  401. position: relative;
  402. }
  403. .product-price-original {
  404. color: #18bb88;
  405. font-size: 32rpx;
  406. font-weight: bold;
  407. &:before {
  408. content: "¥";
  409. font-size: 20rpx;
  410. }
  411. }
  412. .product-price-favour {
  413. color: #888888;
  414. text-decoration: line-through;
  415. margin-left: 20rpx;
  416. }
  417. .product-tip {
  418. position: absolute;
  419. right: 20rpx;
  420. background-color: #ff3333;
  421. color: #ffffff;
  422. padding: 0 20rpx;
  423. border-radius: 10rpx;
  424. }
  425. .product-unit {
  426. font-size: 24rpx;
  427. color: #18bb88;
  428. }
  429. .product-txt,
  430. .product-text {
  431. font-size: 22rpx;
  432. color: #787878;
  433. .iconfont {
  434. margin-right: 6rpx;
  435. }
  436. }
  437. .product-price-msg {
  438. font-size: 20rpx;
  439. color: #ff6d44;
  440. }
  441. .product-text {
  442. margin-left: 16rpx;
  443. }
  444. .red {
  445. color: #FA2E18;
  446. }
  447. .fenxiang {
  448. font-size: 20rpx;
  449. background: rgba(250, 46, 24, 0.08);
  450. display: inline-block;
  451. border-radius: 6rpx;
  452. padding: 0 16rpx;
  453. }
  454. }
  455. </style>