index.vue 34 KB

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