index.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599
  1. <template>
  2. <view class="page-container">
  3. <up-navbar class="inde-nav-bar" :bgColor="navBgColor">
  4. <template #left>
  5. <view class="nav-slot" v-if="!merchantNameShow()" @click="toBrowsingHistory()">
  6. <image class="dianpu" src="@/static/images/dianpu.png" mode="widthFix"></image>
  7. <view class="storeName line1">{{ merchantInfo.merchantName }}</view>
  8. <image class="zhankai" src="@/static/images/zhankai.png" mode="widthFix"></image>
  9. </view>
  10. </template>
  11. <template #center>
  12. <view class="page-title">首页</view>
  13. </template>
  14. <template #right></template>
  15. </up-navbar>
  16. <!-- 自定义 tabBar -->
  17. <customTabBar :current="0" :showBackTop="showBackTop" @backTop="scrollToTop" />
  18. <!-- <view class="page-index" :class="{ bgf: navIndex > 0 }"> -->
  19. <view class="page-index">
  20. <view class="top-box jianbianBG">
  21. <view class="header">
  22. <view class="serch-wrapper">
  23. <!-- <view class="logo" @click="goBack">-->
  24. <!-- <image src="@/static/logo1.png" mode=""></image>-->
  25. <!-- </view>-->
  26. <navigator url="/pages/goods/goods_search/index" class="input" hover-class="none">
  27. <image class="searchImg" src="@/static/images/search.png"></image> 搜索商品
  28. </navigator>
  29. </view>
  30. <!-- 轮播图 -->
  31. <up-swiper class="swiper-box" :list="list1" :height="160" imgMode="scaleFill" indicator :radius="10"
  32. indicatorMode="line" :circular="true" keyName="url" @click="clickSwiper">
  33. <!-- <template v-slot:default="{item}">
  34. <image class="swiper-banner" :src="item.url" mode="heightFix"></image>
  35. </template> -->
  36. </up-swiper>
  37. </view>
  38. </view>
  39. <!-- 实时金价 -->
  40. <view class="top-bg-box">
  41. <view class="card">
  42. <view class="cardbgLinear">
  43. <view class="title" @click="btnClick">
  44. <view class="title-left">
  45. <image class="ssjj" :src="HTTP_REQUEST_URL_IMG+'shishijinjia.png'" mode="widthFix">
  46. </image>
  47. <text class="updateTime">{{ timeFormat(timestamp, "yyyy-mm-dd hh:MM:ss") }}更新</text>
  48. </view>
  49. <view class="more">
  50. <text class="txt">更多金价</text>
  51. <image class="right" src="@/static/images/right.png" mode="widthFix"></image>
  52. </view>
  53. </view>
  54. <view class="nav-list">
  55. <view class="item">
  56. <view class="price">{{ viprealGoldprice }}<text class="unit">/克</text></view>
  57. <view class="txt">黄金</view>
  58. </view>
  59. <view class="item">
  60. <view class="price">{{ viprealPtprice }}<text class="unit">/克</text></view>
  61. <view class="txt">铂金</view>
  62. </view>
  63. <view class="item">
  64. <view class="price">{{ viprealAgprice }}<text class="unit">/克</text></view>
  65. <view class="txt">白银</view>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </view>
  71. <!-- 分类卡片 -->
  72. <view class="classify-section">
  73. <up-scroll-list class="classify-scroll" :indicator="classifyList.length > 4" :scrollX="true"
  74. indicatorActiveColor="#F8C008">
  75. <view class="classify-container">
  76. <view class="classify-item" v-for="(item, index) in classifyList" :key="'item-' + index"
  77. @click="toGoodsCate(item)">
  78. <image class="classify-img" :src="item.extra" mode="widthFix"></image>
  79. <view class="classify-txt">{{ item.name }}</view>
  80. </view>
  81. </view>
  82. </up-scroll-list>
  83. </view>
  84. <view class="top-bg-box2">
  85. <view class="title">
  86. 精选商品
  87. </view>
  88. </view>
  89. <!-- 首发新品 -->
  90. <view class="index-product-wrapper">
  91. <view class="list-box animated" :class="goodsList.length > 0 ? '' : ''">
  92. <view class="item" v-for="(item, index) in calculatedProducts" :key="index" @click="goDetail(item)">
  93. <view class="pictrue">
  94. <image :src="item.image" mode=""></image>
  95. </view>
  96. <view class="text-info">
  97. <view class="title">
  98. <view class="text line1">{{ item.storeName }}</view>
  99. <view class="weight">{{ item.weight }}g</view>
  100. </view>
  101. <view class="bottom-row">
  102. <!-- <text class="price">工费: {{ item.price }}/克</text> -->
  103. <text class="price">¥ {{ item.totalPrice }}</text>
  104. <text class="sales" style="color:#666;">
  105. 销量:{{ Number(item.sales || 0) + Number(item.ficti || 0) }}件
  106. </text>
  107. <!-- <view class="txt">券</view> -->
  108. </view>
  109. <view class="bottom-row">
  110. <!-- <text class="price">工费: {{ item.price }}/克</text> -->
  111. <text class="sales">工费:¥{{ item.totalLaborCost }}</text>
  112. <text class="sales">
  113. 附加费:¥{{ item.additionalAmount }}
  114. </text>
  115. <!-- <view class="txt">券</view> -->
  116. </view>
  117. <template v-if="item?.merchant?.id && merchantNameShow()">
  118. <view class="merchantInfo" @click.stop="toMerchant(item.merchant.id)">
  119. <image class="merchantLogo" :src="item.merchant.merchantLogo" mode="scaleToFill">
  120. </image>
  121. <text class="merchantName">{{item.merchant.merchantName}}</text>
  122. <uni-icons style="margin-left: 10rpx;" type="right" size="16"
  123. color="#999999"></uni-icons>
  124. </view>
  125. </template>
  126. </view>
  127. </view>
  128. </view>
  129. <view class="loadingicon acea-row row-center-wrapper" v-if="goodScroll">
  130. <text class="loading iconfont icon-jiazai" :hidden="loading == false"></text>
  131. </view>
  132. <view class="no-data" v-if="isNoDataState">
  133. <image
  134. src="https://my-go-easy-im.oss-cn-shenzhen.aliyuncs.com/goeasy-im-%E6%B0%B4%E8%B4%9D%E5%95%86%E5%9F%8E/zhanwu_20250827104005_1720_6.png" />
  135. </view>
  136. <view class="mores-txt flex" v-if="!goodScroll && !isNoDataState">
  137. <text>我是有底线的</text>
  138. </view>
  139. </view>
  140. </view>
  141. <!-- 上半部分 -->
  142. </view>
  143. </template>
  144. <script setup>
  145. // 获取实时金价
  146. import useRealGoldPrice from "@/hooks/useRealGoldPrice";
  147. import {
  148. onLoad,
  149. onShow,
  150. onReachBottom,
  151. onPageScroll,
  152. onPullDownRefresh
  153. } from "@dcloudio/uni-app";
  154. import {
  155. ref,
  156. onMounted,
  157. reactive,
  158. computed,
  159. getCurrentInstance,
  160. watch,
  161. nextTick
  162. } from "vue";
  163. import {
  164. getIndexData,
  165. getCoupons,
  166. setCouponReceive,
  167. getMerchantBannerList
  168. } from "@/api/api.js";
  169. import {
  170. getSbmerchantInfo
  171. } from "@/api/merchant.js";
  172. import {
  173. getProductListAPI
  174. } from "@/api/factory.js";
  175. import {
  176. useStoreRights
  177. } from "@/stores/rights";
  178. import {
  179. useRealtimeTimestamp
  180. } from "@/utils/useRealtimeTimestamp.js";
  181. import {
  182. getUserLevelInfo
  183. } from "@/api/user";
  184. import {
  185. useAppStore
  186. } from "@/stores/app";
  187. import {
  188. useTabbarStore
  189. } from "@/stores/tabbar";
  190. import {
  191. goShopDetail
  192. } from "@/libs/order.js";
  193. import {
  194. HTTP_REQUEST_URL_IMG
  195. } from "@/config/app";
  196. import customTabBar from "@/components/customTabBar/index.vue";
  197. // 全局状态和时间
  198. const appStore = useAppStore();
  199. const tabbarStore = useTabbarStore();
  200. const rightsStore = useStoreRights();
  201. import {
  202. getGroomList as getGroomListApi,
  203. getProductByCategoryId,
  204. getCategoryList
  205. } from "@/api/store.js";
  206. import {
  207. timeFormat
  208. } from "@/uni_modules/uview-plus";
  209. import UniIcons from "../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
  210. import {
  211. getSceneInfo
  212. } from '@/utils/util.js';
  213. import {
  214. toLogin
  215. } from "@/libs/login.js";
  216. // 获取实时金价
  217. // 实时价格处理
  218. const {
  219. realGoldprice, // 黄金实时销售价(基础)
  220. realPtprice, // 铂金实时销售价(基础)
  221. realAgprice, // 白银实时销售价(基础)
  222. } = useRealGoldPrice({});
  223. const {
  224. timestamp
  225. } = useRealtimeTimestamp();
  226. const uid = appStore.uidComputed;
  227. console.log(uid)
  228. // 轮播图数据
  229. const list1 = ref([]);
  230. const site_name = ref("");
  231. const loading = ref(false);
  232. const goodScroll = ref(true);
  233. const classifyList = ref([])
  234. // 用户权益数据
  235. const userBenefits = ref({});
  236. const adjustPtPrice = ref({});
  237. const adjustAgPrice = ref({});
  238. const adjustGoldpriceNew = ref({});
  239. const adjustKgoldPrice = ref({});
  240. const merchantInfo = ref({});
  241. const merchantId = ref('');
  242. const goodsList = ref([]);
  243. const goodType = ref(1);
  244. // Pagination
  245. const params = ref({
  246. page: 1,
  247. limit: 10,
  248. });
  249. const isFirstLoad = ref(true);
  250. const navBgColor = ref('rgba(255,255,255,0)');
  251. // 是否显示回到顶部
  252. const showBackTop = ref(false);
  253. // 滚动阈值
  254. const SCROLL_THRESHOLD = 300;
  255. const calculatedProducts = computed(() => {
  256. // 计算逻辑与原代码一致,但基于响应式数据 products
  257. return goodsList.value.map((product) => {
  258. // 1. 将price字符串转为数字
  259. const price = Number(product.price);
  260. // 2. 计算乘积
  261. const total = (price + product.sales) * realGoldprice.value;
  262. // 3. 向上取整到两位小数(先放大100倍取整,再缩小100倍)
  263. const roundedTotal = Math.ceil(total * 100) / 100;
  264. // 4. 格式化保留两位小数
  265. const formattedTotal = roundedTotal.toFixed(2);
  266. const totalLaborCost = Number(product.totalLaborCost);
  267. const additionalAmount = Number(product.additionalAmount);
  268. const totalPrice = (totalLaborCost + additionalAmount).toFixed(2);
  269. return {
  270. ...product,
  271. calculatedTotal: formattedTotal, // 新增计算结果字段
  272. totalPrice
  273. };
  274. });
  275. });
  276. onLoad(async (options) => {
  277. const params = await getSceneInfo(options, 'index');
  278. // 2. 设置商户ID
  279. const isLogin = appStore.isLogin;
  280. if (appStore.merchantId && appStore.merchantId !== '') {
  281. merchantId.value = appStore.merchantId;
  282. if (!isLogin) {
  283. toLogin();
  284. return; // 登录后页面会刷新,避免继续执行
  285. }
  286. } else if (appStore?.userInfo?.lastVisitedMerchantId) {
  287. merchantId.value = appStore?.userInfo?.lastVisitedMerchantId;
  288. } else if (appStore?.userInfo?.merchant?.id) {
  289. merchantId.value = appStore.userInfo.merchant.id;
  290. } else {
  291. merchantId.value = '';
  292. }
  293. // if(isFirstLoad.value){
  294. await initPageData();
  295. // isFirstLoad.value = false;
  296. // }
  297. });
  298. onShow(async () => {
  299. // 隐藏原生 tabBar,使用自定义 tabBar
  300. uni.hideTabBar();
  301. const isLogin = appStore.isLogin;
  302. if (isLogin) {
  303. rightsStore.getUserBenefits(appStore.userInfo?.userId);
  304. getUserBenefits();
  305. }
  306. console.log("appStore.merchantId=>>", appStore.merchantId, "appStore.lastVisitedMerchantId=>>",
  307. appStore?.userInfo?.lastVisitedMerchantId,appStore.indexRefreshFlag)
  308. if (appStore.merchantId && appStore.merchantId !== '') {
  309. merchantId.value = appStore.merchantId;
  310. if (!isLogin) {
  311. toLogin();
  312. return; // 登录后页面会刷新,避免继续执行
  313. }
  314. } else if (appStore?.userInfo?.lastVisitedMerchantId) {
  315. if (merchantId.value != appStore?.userInfo?.lastVisitedMerchantId) {
  316. merchantId.value = appStore?.userInfo?.lastVisitedMerchantId;
  317. }
  318. if(appStore.indexRefreshFlag){
  319. appStore.setIndexRefersh(false)
  320. initPageData();
  321. }
  322. // if (!merchantInfo.value.merchantName) {
  323. // initPageData();
  324. // }
  325. } else if (appStore?.userInfo?.merchant?.id) {
  326. merchantId.value = appStore.userInfo.merchant.id;
  327. if(appStore.indexRefreshFlag){
  328. appStore.setIndexRefersh(false)
  329. initPageData();
  330. }
  331. // if (!merchantInfo.value.merchantName) {
  332. // initPageData();
  333. // }
  334. } else {
  335. merchantId.value = '';
  336. }
  337. // if(!isFirstLoad.value){
  338. // await initPageData();
  339. // }
  340. uni.setNavigationBarTitle({
  341. title: site_name.value
  342. });
  343. });
  344. const onRefresh = () => {
  345. refreshing.value = true;
  346. Promise.allSettled([
  347. initPageData()
  348. ]).finally(() => {
  349. // 添加一个短暂延迟,确保 DOM 更新完成
  350. setTimeout(() => {
  351. refreshing.value = false;
  352. uni.hideLoading();
  353. }, 50);
  354. });
  355. };
  356. const initPageData = async () => {
  357. console.log("initPageData!!!!!!!!11")
  358. try {
  359. loading.value = true;
  360. goodScroll.value = true;
  361. goodsList.value = [];
  362. goodType.value = 1;
  363. params.value = {
  364. page: 1,
  365. limit: 10,
  366. };
  367. // 并行执行不依赖的数据获取
  368. const promises = [];
  369. if (merchantId.value && merchantId.value !== '') {
  370. promises.push(getSbmerchantInfoFn());
  371. promises.push(getMerchantBannerListFn());
  372. } else {
  373. promises.push(getIndexConfig());
  374. }
  375. promises.push(getGroomList());
  376. promises.push(getAllCategory());
  377. // 等待所有数据获取完成
  378. await Promise.all(promises);
  379. } catch (error) {
  380. console.error('初始化页面数据失败:', error);
  381. uni.showToast({
  382. title: '数据加载失败',
  383. icon: 'none'
  384. });
  385. } finally {
  386. loading.value = false;
  387. }
  388. };
  389. const getMerchantBannerListFn = async () => {
  390. try {
  391. let obj = {
  392. merchantId: merchantId.value
  393. }
  394. const res = await getMerchantBannerList(obj);
  395. uni.setNavigationBarTitle({
  396. title: "首页"
  397. });
  398. site_name.value = "首页";
  399. list1.value = res.data.map((v) => {
  400. return {
  401. url: v.bannerUrl,
  402. title: "",
  403. type: "image",
  404. navUrl: v.bannerValue,
  405. };
  406. });
  407. } catch (err) {
  408. console.error(err);
  409. }
  410. }
  411. const getSbmerchantInfoFn = async () => {
  412. try {
  413. let obj = {
  414. merchantId: merchantId.value
  415. }
  416. const res = await getSbmerchantInfo(obj);
  417. merchantInfo.value = res.data;
  418. } catch (err) {
  419. console.error(err);
  420. }
  421. }
  422. const goBack = () => {
  423. uni.switchTab({
  424. url: "/pages/index/index"
  425. });
  426. };
  427. async function clickSwiper(index) {
  428. const imgItem = list1.value[index];
  429. try {
  430. if (imgItem.navUrl !== "#") {
  431. await uni.navigateTo({
  432. url: imgItem.navUrl
  433. });
  434. } else {
  435. uni.previewImage({
  436. current: index,
  437. urls: list1.value.map((item) => item.url) || [],
  438. });
  439. }
  440. } catch (err) {
  441. uni.previewImage({
  442. current: index,
  443. urls: list1.value.map((item) => item.url) || [],
  444. });
  445. return;
  446. }
  447. }
  448. const getIndexConfig = async () => {
  449. try {
  450. loading.value = true;
  451. const res = await getIndexData();
  452. uni.setNavigationBarTitle({
  453. title: "首页"
  454. });
  455. site_name.value = "首页";
  456. list1.value = res.data.banner.map((v) => {
  457. return {
  458. url: v.pic,
  459. title: "",
  460. type: "image",
  461. navUrl: v.url,
  462. };
  463. });
  464. } catch (err) {
  465. console.error(err);
  466. } finally {
  467. loading.value = false;
  468. }
  469. };
  470. const getUserBenefits = async () => {
  471. try {
  472. const res = await getUserLevelInfo(appStore?.userInfo?.userId || 0);
  473. userBenefits.value = res.data || {
  474. sold: 0,
  475. buy: 0
  476. }; // 默认权益为0,避免NaN
  477. if (
  478. userBenefits?.value?.nobleMeta &&
  479. userBenefits.value.nobleMeta.length > 0
  480. ) {
  481. const nobleMeta = userBenefits.value.nobleMeta;
  482. nobleMeta.forEach((item) => {
  483. switch (item.name) {
  484. case "黄金":
  485. adjustGoldpriceNew.value = item;
  486. break;
  487. case "K金":
  488. adjustKgoldPrice.value = item;
  489. break;
  490. case "铂金":
  491. adjustPtPrice.value = item;
  492. break;
  493. case "白银":
  494. adjustAgPrice.value = item;
  495. break;
  496. default:
  497. break;
  498. }
  499. });
  500. }
  501. } catch (error) {
  502. console.error("获取用户权益失败:", error);
  503. userBenefits.value = {
  504. sold: 0,
  505. buy: 0
  506. }; // 出错时默认权益为0
  507. }
  508. };
  509. // 黄金调整价
  510. const viprealGoldprice = computed(() => {
  511. const res =
  512. Number(realGoldprice.value) -
  513. Number(userBenefits.value.buy) +
  514. Number(adjustGoldpriceNew.value.sellPriceAdjust) || 0;
  515. if (appStore.uid) {
  516. return Number(res).toFixed(2);
  517. } else {
  518. return Number(realGoldprice.value).toFixed(2);
  519. }
  520. });
  521. const viprealPtprice = computed(() => {
  522. const res =
  523. Number(realPtprice.value) -
  524. Number(userBenefits.value.buy) +
  525. Number(adjustPtPrice.value.sellPriceAdjust) || 0;
  526. if (appStore.uid) {
  527. return Number(res).toFixed(2);
  528. } else {
  529. return Number(realPtprice.value).toFixed(2);
  530. }
  531. });
  532. const viprealAgprice = computed(() => {
  533. const res =
  534. Number(realAgprice.value) -
  535. Number(userBenefits.value.buy) +
  536. Number(adjustAgPrice.value.sellPriceAdjust) || 0;
  537. if (appStore.uid) {
  538. return Number(res).toFixed(2);
  539. } else {
  540. return Number(realAgprice.value).toFixed(2);
  541. }
  542. });
  543. const btnClick = () => {
  544. uni.navigateTo({
  545. url: "/pages/mall/dapan",
  546. });
  547. };
  548. const isNoDataState = computed(() => {
  549. return goodsList.value.length === 0 && !loading.value;
  550. });
  551. // Product Lists
  552. const getGroomList = async () => {
  553. if (!goodScroll.value) return;
  554. try {
  555. loading.value = true;
  556. merchantId.value != '' ? params.value.merchantId = merchantId.value : '';
  557. console.log(goodType.value, params.value)
  558. const param = {
  559. ...params.value
  560. }
  561. const {
  562. data
  563. } = await getGroomListApi(goodType.value, param);
  564. if (param.page == 1) {
  565. goodsList.value = [...data.productList.list] || [];
  566. } else {
  567. goodsList.value = [...goodsList.value, ...data.productList.list] || [];
  568. }
  569. goodScroll.value = data.productList.list.length >= params.value.limit;
  570. params.value.page++;
  571. } catch (err) {
  572. console.error(err);
  573. } finally {
  574. loading.value = false;
  575. }
  576. };
  577. onPageScroll((e) => {
  578. if (e.scrollTop > 0) {
  579. navBgColor.value = '#ffe079';
  580. } else {
  581. navBgColor.value = 'rgba(252,255,255,0)';
  582. }
  583. // 判断是否显示回到顶部
  584. if (e.scrollTop > SCROLL_THRESHOLD) {
  585. showBackTop.value = true;
  586. } else {
  587. showBackTop.value = false;
  588. }
  589. })
  590. onPullDownRefresh(async () => {
  591. await initPageData();
  592. uni.stopPullDownRefresh();
  593. })
  594. // 回到顶部
  595. const scrollToTop = () => {
  596. uni.pageScrollTo({
  597. scrollTop: 0,
  598. duration: 350
  599. });
  600. showBackTop.value = false;
  601. };
  602. onReachBottom(() => {
  603. getGroomList();
  604. });
  605. // Product Details
  606. const goDetail = async (item) => {
  607. // await goShopDetail(item, uid);
  608. uni.navigateTo({
  609. url: `/pages/goods/goods_details/index?id=${item.id}`
  610. });
  611. };
  612. function getAllCategory() {
  613. getCategoryList().then((res) => {
  614. const list = [];
  615. res.data.forEach((item) => {
  616. if (item.name !== "贝币商城") return list.push(item);
  617. });
  618. classifyList.value = list.sort((a, b) => a.sort - b.sort);
  619. });
  620. }
  621. const toBrowsingHistory = () => {
  622. uni.navigateTo({
  623. url: `/pages/users/browsing_history/index?merchantId=${merchantId.value}`
  624. });
  625. }
  626. const toMerchant = (merchantId) => {
  627. uni.navigateTo({
  628. url: "/pages/merchantCenters/merchant?merchantId=" + merchantId
  629. });
  630. }
  631. const toGoodsCate = (item) => {
  632. uni.setStorageSync('goods_cate', {
  633. id: item.id
  634. }); // 存储参数
  635. uni.switchTab({
  636. url: `/pages/goods_cate/goods_cate`
  637. })
  638. }
  639. const merchantNameShow = () => {
  640. if (!appStore.userInfo || (appStore.userInfo && !appStore.userInfo.merchant && !appStore.merchantId && !
  641. appStore.userInfo.lastVisitedMerchantId)) {
  642. return true;
  643. } else {
  644. return false;
  645. }
  646. }
  647. </script>
  648. <style>
  649. page {
  650. display: flex;
  651. flex-direction: column;
  652. height: 100%;
  653. }
  654. </style>
  655. <style lang="scss" scoped>
  656. .Hoverball {
  657. display: flex;
  658. justify-content: center;
  659. align-items: center;
  660. flex-direction: column;
  661. background: linear-gradient(180deg, #fefcf9 0%, #fff2df 100%);
  662. // box-shadow: 0rpx 3rpx 12rpx 0rpx rgba(0, 0, 0, 0.16);
  663. width: 105upx;
  664. height: 105upx;
  665. border-radius: 50%; // 圆形按钮
  666. position: fixed; // 固定定位(不随页面滚动)
  667. z-index: 999999; // 最高层级,避免被其他元素遮挡
  668. top: 0%;
  669. right: 0%;
  670. .title {
  671. font-size: 19rpx;
  672. color: #000000;
  673. margin-bottom: 4rpx; // 文本与价格间距
  674. }
  675. .price {
  676. font-size: 26rpx;
  677. color: #cc0000;
  678. font-weight: bold;
  679. }
  680. // 贴边/停止拖拽时的过渡动画
  681. &.transition {
  682. transition: left 0.3s ease, top 0.3s ease;
  683. }
  684. }
  685. .couponIndex {
  686. width: auto;
  687. height: 238rpx;
  688. //background-image: url("~@/static/images/yhjsy.png");
  689. background-size: 100% 100%;
  690. padding-left: 42rpx;
  691. margin-bottom: 30rpx;
  692. .titBox {
  693. padding: 47rpx 0;
  694. text-align: center;
  695. height: 100%;
  696. .tit1 {
  697. color: #ffebd2;
  698. font-size: 34rpx;
  699. font-weight: 600;
  700. }
  701. .tit2 {
  702. color: #ffebd2;
  703. font-size: 22rpx;
  704. margin: 10rpx 0 26rpx 0;
  705. }
  706. .tit3 {
  707. color: #ffdaaf;
  708. font-size: 24rpx;
  709. .iconfont {
  710. font-size: 20rpx;
  711. }
  712. }
  713. }
  714. }
  715. .sticky-box {
  716. // display: flex;
  717. // position: -webkit-sticky;
  718. // position: sticky;
  719. z-index: 99;
  720. flex-direction: row;
  721. // margin: 0px;
  722. // background: #fff;
  723. padding-bottom: 30rpx;
  724. background: #fff;
  725. margin-top: 30rpx;
  726. .active {
  727. color: #000;
  728. }
  729. .nav-bd {
  730. display: flex;
  731. align-items: center;
  732. justify-content: space-between;
  733. padding: 0 20rpx;
  734. .item {
  735. display: flex;
  736. flex-direction: column;
  737. align-items: center;
  738. justify-content: center;
  739. border-bottom: 3rpx solid #e6e6e6;
  740. box-sizing: border-box;
  741. .txt {
  742. font-size: 28rpx;
  743. color: #282828;
  744. }
  745. .label {
  746. display: flex;
  747. align-items: center;
  748. justify-content: center;
  749. width: 124rpx;
  750. height: 32rpx;
  751. margin-top: 5rpx;
  752. font-size: 24rpx;
  753. color: #999;
  754. }
  755. &.active {
  756. color: $theme-color;
  757. border-bottom: 2rpx solid #000;
  758. .txt {
  759. color: $theme-color;
  760. }
  761. .label {
  762. background: linear-gradient(90deg, $bg-star 0%, $bg-end 100%);
  763. border-radius: 16rpx;
  764. color: #fff;
  765. }
  766. }
  767. }
  768. }
  769. .second-nav {
  770. width: 100%;
  771. display: flex;
  772. flex-wrap: nowrap;
  773. overflow-x: auto;
  774. &::-webkit-scrollbar {
  775. display: none;
  776. }
  777. -webkit-overflow-scrolling: touch;
  778. padding: 0 50rpx;
  779. box-sizing: border-box;
  780. .second-nav-item {
  781. font-size: 26rpx;
  782. padding: 15rpx 0;
  783. margin: 0 10rpx 0 0;
  784. color: #000;
  785. white-space: nowrap;
  786. // flex: 1;
  787. width: 33%;
  788. display: flex;
  789. justify-content: center;
  790. align-items: center;
  791. &.active {
  792. color: #ef4800;
  793. }
  794. }
  795. }
  796. }
  797. .swiper-box {
  798. &::v-deep uni-image {
  799. width: 100%;
  800. }
  801. .swiper-banner {
  802. width: 100%;
  803. height: 160px;
  804. }
  805. }
  806. // 活动专区
  807. .active-contanier {
  808. width: 100%;
  809. box-sizing: border-box;
  810. padding: 0 30rpx;
  811. .active-scroll {
  812. width: 100%;
  813. white-space: nowrap;
  814. .active-scroll-content {
  815. margin: 30rpx 0;
  816. display: flex;
  817. flex-direction: row;
  818. white-space: nowrap;
  819. }
  820. }
  821. .active-item {
  822. // width: 335rpx;
  823. width: 48.99%;
  824. background: #ffffff;
  825. height: 180rpx;
  826. // box-shadow: 0rpx 3rpx 13rpx 0rpx rgba(0, 0, 0, 0.13);
  827. border-radius: 20rpx;
  828. padding: 13rpx 20rpx;
  829. box-sizing: border-box;
  830. display: flex;
  831. flex-direction: column;
  832. margin-right: 20rpx;
  833. flex-shrink: 0;
  834. .title-box {
  835. height: 33rpx;
  836. display: flex;
  837. font-size: 22rpx;
  838. align-items: center;
  839. .title {
  840. // width: 50%;
  841. font-weight: bold;
  842. text-align: center;
  843. }
  844. }
  845. .active-box {
  846. flex: 1;
  847. display: flex;
  848. .active-item-left {
  849. flex: 1;
  850. display: flex;
  851. flex-direction: column;
  852. .image-box {
  853. flex: 1;
  854. // width: 115rpx;
  855. display: flex;
  856. align-items: center;
  857. image {
  858. border-radius: 5rpx;
  859. width: 115rpx;
  860. height: 110rpx;
  861. }
  862. .da-jin-tiao {
  863. width: 51rpx;
  864. }
  865. }
  866. }
  867. .active-item-right {
  868. display: flex;
  869. flex-direction: column;
  870. justify-content: space-between;
  871. flex: 1;
  872. min-width: 0;
  873. width: 0;
  874. .ms {
  875. font-size: 16rpx;
  876. color: #000000;
  877. width: 100%;
  878. overflow: hidden;
  879. text-overflow: ellipsis;
  880. white-space: nowrap;
  881. display: block;
  882. max-width: 100%;
  883. box-sizing: border-box;
  884. }
  885. .tag {
  886. display: flex;
  887. .tag-text {
  888. color: #acacac;
  889. background-color: #ebebeb;
  890. border-radius: 5rpx;
  891. font-size: 16rpx;
  892. text-align: center;
  893. padding: 0rpx 5rpx;
  894. }
  895. }
  896. .price-box {
  897. display: flex;
  898. justify-content: space-between;
  899. .price {
  900. font-size: 18rpx;
  901. font-weight: bold;
  902. color: #000000;
  903. margin-right: 10rpx;
  904. }
  905. .btn {
  906. width: 77rpx;
  907. height: 26rpx;
  908. background-image: linear-gradient(270deg, #fc962c 0%, #f0470d 100%);
  909. border-radius: 100rpx;
  910. display: flex;
  911. justify-content: center;
  912. align-items: center;
  913. font-size: 14rpx;
  914. color: #ffffff;
  915. }
  916. }
  917. }
  918. }
  919. }
  920. }
  921. .listAll {
  922. width: 20%;
  923. text-indent: 62rpx;
  924. font-size: 30rpx;
  925. border-left: 1px #eee solid;
  926. margin: 1% 0;
  927. padding: 5rpx;
  928. position: relative;
  929. image {
  930. position: absolute;
  931. left: 20rpx;
  932. top: 8rpx;
  933. }
  934. }
  935. .tab {
  936. position: relative;
  937. display: flex;
  938. font-size: 28rpx;
  939. white-space: nowrap;
  940. &__item {
  941. flex: 1;
  942. padding: 0 20rpx;
  943. text-align: center;
  944. height: 60rpx;
  945. line-height: 60rpx;
  946. color: #666;
  947. &.active {
  948. color: #09c2c9;
  949. }
  950. }
  951. }
  952. .tab__line {
  953. display: block;
  954. height: 6rpx;
  955. position: absolute;
  956. bottom: 0;
  957. left: 0;
  958. z-index: 1;
  959. border-radius: 3rpx;
  960. position: relative;
  961. background: #2fc6cd;
  962. }
  963. .scroll-view_H {
  964. width: 100%;
  965. display: flex;
  966. overflow-x: auto;
  967. padding: 12rpx 0;
  968. background-color: #fff;
  969. box-sizing: border-box;
  970. &::-webkit-scrollbar {
  971. display: none;
  972. }
  973. -webkit-overflow-scrolling: touch;
  974. .tab.nav-bd {
  975. display: flex;
  976. align-items: center;
  977. width: 100%;
  978. }
  979. #tab_item.item {
  980. display: flex;
  981. flex-direction: column;
  982. align-items: center;
  983. // margin: 0 24rpx;
  984. padding: 8rpx 0;
  985. cursor: pointer;
  986. flex: 1;
  987. transition: all 0.3s ease;
  988. .uni-icons {
  989. font-size: 44rpx;
  990. margin-bottom: 6rpx;
  991. }
  992. .txt {
  993. font-size: 26rpx;
  994. color: #333;
  995. }
  996. }
  997. #tab_list:first-of-type .item.active {
  998. .uni-icons {
  999. color: #000;
  1000. }
  1001. .txt {
  1002. color: #000;
  1003. font-weight: bold;
  1004. }
  1005. }
  1006. .privacy-wrapper {
  1007. z-index: 999;
  1008. position: fixed;
  1009. left: 0;
  1010. top: 0;
  1011. width: 100%;
  1012. height: 100%;
  1013. background: #7f7f7f;
  1014. .privacy-box {
  1015. position: absolute;
  1016. left: 50%;
  1017. top: 50%;
  1018. transform: translate(-50%, -50%);
  1019. width: 560rpx;
  1020. padding: 50rpx 45rpx 0;
  1021. background: #fff;
  1022. border-radius: 20rpx;
  1023. .title {
  1024. text-align: center;
  1025. font-size: 32rpx;
  1026. text-align: center;
  1027. color: #333;
  1028. font-weight: 700;
  1029. }
  1030. .content {
  1031. margin-top: 20rpx;
  1032. line-height: 1.5;
  1033. font-size: 26rpx;
  1034. color: #666;
  1035. text-indent: 54rpx;
  1036. i {
  1037. font-style: normal;
  1038. color: $theme-color;
  1039. }
  1040. }
  1041. .btn-box {
  1042. margin-top: 40rpx;
  1043. text-align: center;
  1044. font-size: 30rpx;
  1045. .btn-item {
  1046. height: 82rpx;
  1047. line-height: 82rpx;
  1048. background: linear-gradient(90deg, #f67a38 0%, #f11b09 100%);
  1049. color: #fff;
  1050. border-radius: 41rpx;
  1051. }
  1052. .btn {
  1053. padding: 30rpx 0;
  1054. }
  1055. }
  1056. }
  1057. }
  1058. }
  1059. .page-index {
  1060. position: relative;
  1061. z-index: 1;
  1062. height: 100%;
  1063. padding-bottom: 200rpx;
  1064. box-sizing: border-box;
  1065. .top-box {
  1066. padding-top: 168rpx;
  1067. //background: linear-gradient(180deg, #ffe079 0%, #ffffff 100%);
  1068. //background-image: url("https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/new-mini/jianbianBG.png");
  1069. background-size: 100% 100%;
  1070. }
  1071. }
  1072. .header {
  1073. //position: sticky;
  1074. //top: 0;
  1075. //z-index: 200000;
  1076. width: 100%;
  1077. padding: 28rpx 20rpx 0;
  1078. .serch-wrapper {
  1079. //margin-top: var(--status-bar-height);
  1080. margin-bottom: 16rpx;
  1081. display: flex;
  1082. justify-content: center;
  1083. align-items: center;
  1084. /* #ifdef MP-WEIXIN */
  1085. width: 100%;
  1086. /* #endif */
  1087. .logo {
  1088. width: 154rpx;
  1089. height: 47rpx;
  1090. margin-right: 24rpx;
  1091. }
  1092. image {
  1093. width: 118rpx;
  1094. height: 42rpx;
  1095. }
  1096. .input {
  1097. display: flex;
  1098. align-items: center;
  1099. width: 100%;
  1100. height: 80rpx;
  1101. background-color: #ffffff;
  1102. border-radius: 16rpx;
  1103. font-size: 28rpx;
  1104. color: #868686;
  1105. .iconfont {
  1106. margin: 0 10rpx;
  1107. font-size: 26rpx;
  1108. color: #666666;
  1109. }
  1110. .searchImg {
  1111. width: 32rpx;
  1112. height: 32rpx;
  1113. margin: 0 20rpx;
  1114. }
  1115. }
  1116. }
  1117. .tabNav {
  1118. padding-top: 24rpx;
  1119. }
  1120. }
  1121. .page_content {
  1122. padding: 0 30rpx;
  1123. }
  1124. .index-product-wrapper {
  1125. padding: 0 16rpx;
  1126. margin-bottom: 200rpx;
  1127. /* 为自定义 tabBar 留出空间 */
  1128. min-height: 700rpx;
  1129. //background: #fff;
  1130. &.on {
  1131. min-height: 1500rpx;
  1132. }
  1133. .list-box {
  1134. display: flex;
  1135. flex-wrap: wrap;
  1136. justify-content: space-between;
  1137. .item {
  1138. width: 48.99%;
  1139. //height: 490rpx;
  1140. background-color: #ffffff;
  1141. // box-shadow: 0rpx 3rpx 13rpx 0rpx rgba(0, 0, 0, 0.13);
  1142. border-radius: 16rpx;
  1143. margin-bottom: 16rpx;
  1144. overflow: hidden;
  1145. display: flex;
  1146. flex-direction: column;
  1147. justify-content: space-between;
  1148. .pictrue {
  1149. position: relative;
  1150. image {
  1151. width: 100%;
  1152. height: 330rpx;
  1153. }
  1154. }
  1155. .text-info {
  1156. padding: 16rpx 8rpx;
  1157. .title {
  1158. color: #333;
  1159. display: flex;
  1160. align-items: center;
  1161. justify-items: space-between;
  1162. .tip {
  1163. width: 61rpx;
  1164. height: auto;
  1165. font-size: 22rpx;
  1166. display: flex;
  1167. justify-content: center;
  1168. align-items: center;
  1169. color: #ffffff;
  1170. position: relative;
  1171. margin-right: 5rpx;
  1172. background-color: #ef4800;
  1173. border-radius: 5rpx;
  1174. }
  1175. .text {
  1176. width: 80%;
  1177. font-weight: bold;
  1178. }
  1179. .weight {
  1180. background-color: rgba(197, 128, 3, 0.10);
  1181. color: #C58003;
  1182. font-size: 24rpx;
  1183. padding: 8rpx 16rpx;
  1184. border-radius: 8rpx;
  1185. float: right;
  1186. }
  1187. }
  1188. .bottom-row {
  1189. color: $theme-color;
  1190. display: flex;
  1191. justify-content: space-between;
  1192. align-items: center;
  1193. font-size: 28rpx;
  1194. margin: 10rpx 0 0;
  1195. .price {
  1196. padding-bottom: 4rpx;
  1197. font-weight: 800;
  1198. white-space: nowrap;
  1199. font-size: 28rpx;
  1200. color: #f16327;
  1201. }
  1202. .sales {
  1203. font-size: 22rpx;
  1204. white-space: nowrap;
  1205. flex-shrink: 0;
  1206. color: #999999;
  1207. }
  1208. }
  1209. .merchantInfo {
  1210. display: flex;
  1211. align-items: center;
  1212. height: 40rpx;
  1213. margin-top: 16rpx;
  1214. }
  1215. .merchantLogo {
  1216. width: 40rpx;
  1217. height: 40rpx;
  1218. border-radius: 50%;
  1219. margin-right: 8rpx;
  1220. }
  1221. .merchantName {
  1222. font-size: 24rpx;
  1223. color: #333;
  1224. }
  1225. }
  1226. }
  1227. &.on {
  1228. display: flex;
  1229. }
  1230. }
  1231. }
  1232. .top-bg-box2 {
  1233. overflow: hidden;
  1234. padding: 16rpx;
  1235. box-sizing: border-box;
  1236. .title {
  1237. font-size: 32rpx;
  1238. color: #333333;
  1239. font-weight: bold;
  1240. line-height: 48rpx;
  1241. }
  1242. }
  1243. .top-bg-box {
  1244. overflow: hidden;
  1245. padding: 16rpx;
  1246. box-sizing: border-box;
  1247. // background-image: linear-gradient(
  1248. // to bottom,
  1249. // $header-color 0%,
  1250. // $header-color 10%,
  1251. // #ffe9a1 50%,
  1252. // transparent 100%
  1253. // );
  1254. .card {
  1255. background-color: #fff;
  1256. padding: 4rpx;
  1257. box-sizing: border-box;
  1258. border-radius: 20rpx;
  1259. .cardbgLinear {
  1260. padding: 20rpx 16rpx;
  1261. box-sizing: border-box;
  1262. border-radius: 20rpx;
  1263. background: linear-gradient(to bottom,
  1264. rgba(255, 240, 200, 0.7) 0%,
  1265. rgba(255, 240, 200, 0.4) 8%,
  1266. rgba(255, 255, 255, 1) 20%,
  1267. rgba(255, 255, 255, 1) 100%);
  1268. }
  1269. }
  1270. }
  1271. .top-bg-box {
  1272. .title {
  1273. display: flex;
  1274. justify-content: space-between; // 左右两端对齐
  1275. align-items: center; // 垂直居中
  1276. .title-left {
  1277. display: flex;
  1278. align-items: center;
  1279. .ssjj {
  1280. width: 150rpx;
  1281. height: 36rpx;
  1282. vertical-align: middle;
  1283. }
  1284. .updateTime {
  1285. font-size: 20rpx;
  1286. color: #666666;
  1287. padding: 0 20rpx 0 8rpx;
  1288. box-sizing: border-box;
  1289. }
  1290. }
  1291. .more {
  1292. display: flex;
  1293. align-items: center;
  1294. .txt {
  1295. font-size: 24rpx;
  1296. color: #666666;
  1297. }
  1298. .right {
  1299. width: 24rpx;
  1300. height: 24rpx;
  1301. vertical-align: middle;
  1302. // margin-left: 10rpx; // 添加一些间距
  1303. }
  1304. }
  1305. }
  1306. }
  1307. .nav-list {
  1308. width: 100%;
  1309. display: flex;
  1310. justify-content: space-between;
  1311. align-items: center;
  1312. padding: 0 40rpx 0;
  1313. margin-top: 30rpx;
  1314. .item {
  1315. text-align: center;
  1316. .price {
  1317. font-size: 40rpx;
  1318. color: #FD5F3C;
  1319. font-weight: bold;
  1320. .unit {
  1321. font-size: 24rpx;
  1322. }
  1323. }
  1324. .txt {
  1325. font-size: 28rpx;
  1326. color: #666666;
  1327. line-height: 60rpx;
  1328. }
  1329. }
  1330. }
  1331. .no-data {
  1332. margin: 150rpx auto 0;
  1333. text-align: center;
  1334. img {
  1335. width: 65%;
  1336. height: auto;
  1337. }
  1338. }
  1339. .inde-nav-bar {
  1340. .page-title {
  1341. color: #fff;
  1342. }
  1343. }
  1344. // 分类卡片区域样式
  1345. .classify-section {
  1346. background: #fff;
  1347. margin: 0 16rpx;
  1348. border-radius: 16rpx;
  1349. padding: 30rpx 0 10rpx;
  1350. // box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  1351. }
  1352. .classify-scroll {
  1353. width: 100%;
  1354. white-space: nowrap;
  1355. }
  1356. .classify-container {
  1357. width: 100%;
  1358. display: inline-flex;
  1359. flex-wrap: nowrap;
  1360. min-width: 100%;
  1361. }
  1362. .classify-item {
  1363. display: inline-flex;
  1364. flex-direction: column;
  1365. align-items: center;
  1366. justify-content: center;
  1367. width: 175rpx;
  1368. flex-shrink: 0;
  1369. box-sizing: border-box;
  1370. .classify-img {
  1371. width: 100rpx;
  1372. height: 100rpx;
  1373. }
  1374. .classify-txt {
  1375. font-size: 24rpx;
  1376. color: #333;
  1377. margin-top: 10rpx;
  1378. text-align: center;
  1379. white-space: nowrap;
  1380. overflow: hidden;
  1381. text-overflow: ellipsis;
  1382. max-width: 120rpx;
  1383. }
  1384. }
  1385. .nav-slot {
  1386. //width: 60%;
  1387. display: flex;
  1388. justify-content: space-between;
  1389. align-items: center;
  1390. .dianpu {
  1391. width: 32rpx;
  1392. }
  1393. .zhankai {
  1394. width: 20rpx;
  1395. }
  1396. .storeName {
  1397. width: 60%;
  1398. font-size: 28rpx;
  1399. color: #333;
  1400. }
  1401. }
  1402. .no-data {
  1403. margin: 150rpx auto 0;
  1404. text-align: center;
  1405. img {
  1406. width: 65%;
  1407. height: auto;
  1408. }
  1409. }
  1410. .mores-txt {
  1411. width: 100%;
  1412. align-items: center;
  1413. justify-content: center;
  1414. height: 70rpx;
  1415. color: #999;
  1416. font-size: 24rpx;
  1417. .iconfont {
  1418. margin-top: 2rpx;
  1419. font-size: 20rpx;
  1420. }
  1421. }
  1422. :deep(.page-title) {
  1423. font-size: 36rpx;
  1424. }
  1425. </style>