index.vue 35 KB

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