index.vue 34 KB

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