index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  1. <template>
  2. <div class="Appindex">
  3. <div class="container_box">
  4. <!-- 顶部 -->
  5. <view class="head">
  6. <!-- 专区入口 -->
  7. <div class="search_box flex_r flex_jb">
  8. <div class="search-box flex_r flex_jb flex_ac">
  9. <div class="district">
  10. <image
  11. src="/static/img/consumer_logo.png"
  12. alt="logo"
  13. class="logo"
  14. />
  15. </div>
  16. <div class="search flex_r flex_jb flex_ac">
  17. <span class="iconfont">&#xe661;</span>
  18. <input
  19. v-model="searchKey"
  20. @confirm="toSearch"
  21. class="inp"
  22. placeholder="搜索你要的内容"
  23. />
  24. <span class="search_btn" @click="toSearch">搜索</span>
  25. </div>
  26. </div>
  27. </div>
  28. <div class="l_tabBar flex_r flex_jb">
  29. <div
  30. class="item flex_c flex_ac"
  31. v-for="(i, s) in tabs"
  32. :key="s"
  33. @click="categoryClick(i)"
  34. >
  35. <img :src="i.image" alt="" class="ico" />
  36. <span class="tit">{{ i.name }}</span>
  37. </div>
  38. </div>
  39. <!-- 专区-end -->
  40. <!-- 活动 -->
  41. <view v-if="activeShow">
  42. <view class="single_product" v-if="homeImg.length">
  43. <image
  44. class="single_product_img"
  45. mode="widthFix"
  46. :src="homeImg[0].image"
  47. @click="setPageUrl(homeImg[0])"
  48. ></image>
  49. </view>
  50. <view class="activity" v-if="homeImg.length">
  51. <image
  52. class="act_img act_one_img"
  53. :src="homeImg[1].image"
  54. mode=""
  55. @click="setPageUrl(homeImg[1])"
  56. ></image>
  57. <view class="act_other">
  58. <image
  59. class="act_img act_two_img"
  60. :src="homeImg[2].image"
  61. mode=""
  62. @click="setPageUrl(homeImg[2])"
  63. ></image>
  64. <image
  65. class="act_img act_two_img"
  66. :src="homeImg[3].image"
  67. mode=""
  68. @click="setPageUrl(homeImg[3])"
  69. ></image>
  70. </view>
  71. </view>
  72. </view>
  73. <!-- 活动-end -->
  74. </view>
  75. <view class="bou_head flex_r flex_ac flex_jc">
  76. <image class="bou_img" src="/static/img/splite.png" mode=""></image>
  77. <view class="bou_title">{{ categoryTitle }}</view>
  78. <image class="bou_img" src="/static/img/splite.png" mode=""></image>
  79. </view>
  80. <view class="list_bar">
  81. <view class="product-list">
  82. <view
  83. class="product"
  84. v-for="(i, s) in productList"
  85. :key="s"
  86. @click="NavToGoodsDetail(i.id, 4)"
  87. >
  88. <view class="image-view">
  89. <image class="product-image" :src="i.goods.original_img"></image>
  90. </view>
  91. <view class="content-view">
  92. <view :class="['product-title', 'ellipsis']">{{
  93. i.goods.goods_name
  94. }}</view>
  95. <view class="product-price">
  96. <text class="product-price-original">{{ i.cost_price }}</text>
  97. <text class="product-text"
  98. >赠<text class="corFE2C15">{{ i.give_cha_bao }}</text
  99. >茶宝</text
  100. >
  101. </view>
  102. <view class="product-txt">
  103. <text class="product-price-favour">¥{{ i.market_price }}</text>
  104. <text class="product-text">消费金抵</text>
  105. <span class="corFE2C15">¥{{ Number(i.consume) }}</span>
  106. </view>
  107. <!-- <view class="product-txt" v-if="i.type == 1">赠送{{ i.give_integral + "批发券" }}</view> -->
  108. <view class="product-txt"
  109. >限时赠送<text class="corFE2C15">{{ i.teac }}</text
  110. >TeaC</view
  111. >
  112. <view class="product-txt fenxiang">
  113. <text class="iconfont red">&#xe62b;</text>
  114. <text class="red">分享约获得 {{ i.first_teac }} 现金</text>
  115. </view>
  116. </view>
  117. </view>
  118. </view>
  119. </view>
  120. <view class="con_nothing" v-if="haveGoods">
  121. <image
  122. mode="widthFix"
  123. class="image"
  124. src="/static/img/con_nothing.png"
  125. ></image>
  126. <text>{{ "暂无商品信息" }}</text>
  127. </view>
  128. <view class="fz_w_text">让数字经济赋能美好生活!</view>
  129. </div>
  130. </div>
  131. </template>
  132. <script>
  133. // import tabs from "@/static/js/tabs"; //专区入口
  134. import { post } from "@/request/api.js";
  135. export default {
  136. name: "consumerGoldIndex",
  137. data() {
  138. return {
  139. not_list: [], // 公告列表
  140. homeImg: [], //活动列表
  141. productList: [], //商品数据
  142. searchKey: "", //搜索关键词
  143. // tabs,
  144. tabs: [],
  145. haveGoods: false, // 是否有商品
  146. activeShow: true,
  147. categoryId: 1, // 分类id
  148. categoryTitle: "今日推荐",
  149. page: 1,
  150. };
  151. },
  152. onLoad(option) {
  153. // uni.Luserfun()
  154. },
  155. onShow() {
  156. this.page = 1;
  157. this.activeShow = true;
  158. this.categoryId = 1;
  159. this.categoryTitle = "今日推荐"
  160. this.productList = [];
  161. this.loadData();
  162. this.getCategory();
  163. this.gethomeImg(); //活动列表
  164. },
  165. onHide() {},
  166. methods: {
  167. loadData() {
  168. let that = this;
  169. uni.showLoading({ mask: true });
  170. let params = {
  171. page: this.page,
  172. category_id: this.categoryId,
  173. };
  174. post("v1/goods/categoryInfo", params).then((res) => {
  175. uni.hideLoading();
  176. if (res.code === 0) {
  177. let obj = res.data.data.data;
  178. if (this.page == 1) {
  179. that.productList = [];
  180. }
  181. if (this.page == 1 && obj.length <= 0) {
  182. that.haveGoods = true;
  183. } else {
  184. that.haveGoods = false;
  185. }
  186. if (obj.length > 0) {
  187. obj.forEach((e) => {
  188. that.productList.push(e);
  189. });
  190. } else {
  191. // console.log("这里");
  192. that.page = -1;
  193. // this.$toast("暂无更多");
  194. }
  195. } else {
  196. this.page = -1;
  197. this.haveGoods = true;
  198. this.$toast("暂无更多");
  199. }
  200. });
  201. },
  202. categoryClick(item) {
  203. this.page = 1;
  204. this.categoryId = item.id;
  205. this.categoryTitle = item.name;
  206. this.activeShow = false;
  207. this.productList = [];
  208. this.loadData();
  209. },
  210. // 跳转到商品详情页
  211. NavToGoodsDetail(id, type) {
  212. this.goto("/pages/product/p_details", { id, type });
  213. },
  214. // 分类列表
  215. getCategory() {
  216. post("v1/goods/category").then((res) => {
  217. if (res.code === 0) {
  218. this.tabs = res.data.data;
  219. }
  220. });
  221. },
  222. // 活动列表
  223. gethomeImg() {
  224. post("v1/goods/worthImg").then((res) => {
  225. if (res.code === 0) {
  226. this.homeImg = res.data.data;
  227. }
  228. });
  229. },
  230. // 金刚区跳转
  231. setPageUrl(item) {
  232. this.goto(
  233. "/pages/consumerGold/specialCategory?name=" +
  234. item.name +
  235. "&id=" +
  236. item.id +
  237. "&type=4"
  238. );
  239. },
  240. goVipGift() {
  241. this.goto("/pages/product/productRetail", { type: 4, is_vip: 1 });
  242. },
  243. // 搜索
  244. toSearch() {
  245. this.goto("/pagesC/settledMerchant/index", { key: this.searchKey });
  246. },
  247. },
  248. //页面上拉触底事件的处理函数
  249. onReachBottom: function () {
  250. // console.log(this.page, "page");
  251. if (this.page != -1) {
  252. var that = this;
  253. setTimeout(function () {
  254. that.page = that.page + 1;
  255. that.loadData();
  256. }, 800);
  257. }
  258. },
  259. computed: {},
  260. watch: {},
  261. };
  262. </script>
  263. <style scoped lang='scss'>
  264. .Appindex {
  265. width: 100%;
  266. height: auto;
  267. overflow: auto;
  268. background-color: #de9f4b;
  269. }
  270. .container_box {
  271. border-radius: 60rpx 60rpx 0 0;
  272. margin-top: 60rpx;
  273. background-color: #f5f6f8;
  274. }
  275. .head {
  276. padding: 12rpx 28rpx;
  277. }
  278. .head_search {
  279. width: 100%;
  280. height: 64rpx;
  281. line-height: 64rpx;
  282. background: #f3f5f7;
  283. border-radius: 32rpx;
  284. text-align: center;
  285. font-size: 28rpx;
  286. color: #bbbbbb;
  287. margin-bottom: 26rpx;
  288. .search_text {
  289. margin-left: 14rpx;
  290. }
  291. }
  292. .head_notice {
  293. margin: 30rpx 0;
  294. .notice_title {
  295. width: 130rpx;
  296. height: 40rpx;
  297. float: left;
  298. .gg_img {
  299. width: 100%;
  300. height: 40rpx;
  301. }
  302. }
  303. .notice_swiper {
  304. height: 40rpx;
  305. padding-left: 20rpx;
  306. font-size: 28rpx;
  307. float: left;
  308. box-sizing: border-box;
  309. width: calc(100% - 130rpx);
  310. .not_list {
  311. width: calc(100% - 50rpx);
  312. }
  313. .not_ico {
  314. width: 30rpx;
  315. font-size: 28rpx;
  316. color: #999;
  317. }
  318. .not_list,
  319. .not_ico {
  320. display: inline-block;
  321. vertical-align: middle;
  322. height: 40rpx;
  323. line-height: 40rpx;
  324. }
  325. }
  326. }
  327. .search-box {
  328. width: 100%;
  329. padding: 10rpx;
  330. // margin-bottom: 12rpx;
  331. .district {
  332. .logo {
  333. width: 92rpx;
  334. height: 67rpx;
  335. }
  336. }
  337. .search {
  338. border: 1px solid #d78c2e;
  339. height: 60rpx;
  340. line-height: 60rpx;
  341. padding-left: 20rpx;
  342. border-radius: 31rpx;
  343. .iconfont {
  344. font-size: 30rpx;
  345. }
  346. .inp {
  347. font-size: 25rpx;
  348. padding: 0 8rpx;
  349. width: 360rpx;
  350. }
  351. .search_btn {
  352. background-color: #d78c2e;
  353. height: 100%;
  354. color: #fff;
  355. border-radius: 31rpx;
  356. font-size: 28rpx;
  357. padding: 0 28rpx;
  358. }
  359. }
  360. .scan-ico {
  361. font-size: 55rpx;
  362. }
  363. }
  364. .l_tabBar {
  365. margin: 32rpx 0;
  366. background-color: #fff;
  367. padding: 10rpx 20rpx;
  368. border-radius: 10rpx;
  369. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  370. flex-wrap: wrap;
  371. .item {
  372. width: 105rpx;
  373. margin: 10rpx 10rpx;
  374. }
  375. .ico {
  376. width: 80rpx;
  377. height: 80rpx;
  378. padding: 20rpx 0;
  379. }
  380. .tit {
  381. font-size: 24rpx;
  382. text-align: center;
  383. }
  384. }
  385. .bou_head {
  386. width: 100%;
  387. height: 114rpx;
  388. // margin-top: 50rpx;
  389. .bou_img {
  390. width: 92rpx;
  391. height: 30rpx;
  392. }
  393. .bou_title {
  394. height: 30rpx;
  395. line-height: 30rpx;
  396. font-size: 36rpx;
  397. color: #121212;
  398. font-weight: bold;
  399. margin: 0 36rpx;
  400. }
  401. }
  402. .single_product {
  403. margin-bottom: 16rpx;
  404. &_img {
  405. width: 100%;
  406. }
  407. }
  408. // 活动
  409. .activity {
  410. .act_one_img {
  411. display: inline-block;
  412. width: 340rpx;
  413. height: 424rpx;
  414. margin-right: 10rpx;
  415. }
  416. .act_other {
  417. display: inline-block;
  418. width: calc(100% - 340rpx - 10rpx);
  419. }
  420. .act_two_img {
  421. width: 100%;
  422. height: 208rpx;
  423. }
  424. .act_img {
  425. border-radius: 10rpx;
  426. }
  427. }
  428. // 活动-end
  429. // 商品列表
  430. .list_bar {
  431. .tit {
  432. text-align: center;
  433. font-size: 36rpx;
  434. color: #121212;
  435. padding: 40rpx 0 20rpx;
  436. font-weight: bold;
  437. }
  438. }
  439. .product-list {
  440. width: 100%;
  441. display: flex;
  442. flex-wrap: wrap;
  443. flex-direction: row;
  444. padding: 0 30rpx;
  445. .product {
  446. width: 48.5%;
  447. margin-bottom: 20rpx;
  448. padding-bottom: 12rpx;
  449. border-radius: 10rpx;
  450. box-shadow: 4rpx 4rpx 8rpx 4rpx rgba(0, 0, 0, 0.12);
  451. &:nth-child(2n) {
  452. margin-left: 3%;
  453. }
  454. }
  455. .product-image {
  456. border-radius: 10rpx 10rpx 0 0;
  457. width: 100%;
  458. height: 42.3vw;
  459. object-fit: cover;
  460. }
  461. .content-view {
  462. padding: 0 16rpx;
  463. }
  464. .product-title {
  465. width: 100%;
  466. overflow: hidden;
  467. line-height: 1.5;
  468. font-size: 28rpx;
  469. color: #121212;
  470. }
  471. .product-price {
  472. color: #121212;
  473. font-size: 28rpx;
  474. position: relative;
  475. }
  476. .product-price-original {
  477. color: #18bb88;
  478. font-size: 32rpx;
  479. font-weight: bold;
  480. &:before {
  481. content: "¥";
  482. font-size: 20rpx;
  483. }
  484. }
  485. .product-price-favour {
  486. color: #888888;
  487. text-decoration: line-through;
  488. margin-left: 20rpx;
  489. }
  490. .product-tip {
  491. position: absolute;
  492. right: 20rpx;
  493. background-color: #ff3333;
  494. color: #ffffff;
  495. padding: 0 20rpx;
  496. border-radius: 10rpx;
  497. }
  498. .product-unit {
  499. font-size: 24rpx;
  500. color: #18bb88;
  501. }
  502. .product-txt,
  503. .product-text {
  504. font-size: 22rpx;
  505. color: #787878;
  506. .iconfont {
  507. margin-right: 6rpx;
  508. }
  509. }
  510. .product-price-msg {
  511. font-size: 20rpx;
  512. color: #ff6d44;
  513. }
  514. .product-text {
  515. margin-left: 16rpx;
  516. }
  517. .red {
  518. color: #fa2e18;
  519. }
  520. .fenxiang {
  521. font-size: 20rpx;
  522. background: rgba(250, 46, 24, 0.08);
  523. display: inline-block;
  524. border-radius: 6rpx;
  525. padding: 0 16rpx;
  526. }
  527. }
  528. .con_nothing {
  529. padding: 80rpx 30rpx;
  530. overflow: hidden;
  531. text-align: center;
  532. }
  533. .con_nothing .image {
  534. width: 200rpx;
  535. height: 200rpx;
  536. display: block;
  537. margin: 0 auto 20rpx;
  538. }
  539. .con_nothing text {
  540. font-size: 32rpx;
  541. color: #aaa;
  542. line-height: 1.5;
  543. padding: 20rpx 0;
  544. width: 100%;
  545. overflow: hidden;
  546. }
  547. </style>