index.vue 14 KB

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