index.vue 35 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509
  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" style="color:#666;">
  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. classifyList.value = res.data.sort((a, b) => a.sort - b.sort);
  569. })
  570. }
  571. const toBrowsingHistory = () => {
  572. uni.navigateTo({ url: `/pages/users/browsing_history/index?merchantId=${merchantId.value}` });
  573. }
  574. const toMerchant = (merchantId) => {
  575. uni.navigateTo({ url:"/pages/merchantCenters/merchant?merchantId="+merchantId });
  576. }
  577. const toGoodsCate = (item) => {
  578. uni.setStorageSync('goods_cate', { id: item.id }); // 存储参数
  579. uni.switchTab({url:`/pages/goods_cate/goods_cate`})
  580. }
  581. const merchantNameShow = () => {
  582. if(!appStore.userInfo ||(appStore.userInfo && !appStore.userInfo.merchant && !appStore.merchantId && !appStore.userInfo.lastVisitedMerchantId)){
  583. return true;
  584. }else{
  585. return false;
  586. }
  587. }
  588. </script>
  589. <style>
  590. page {
  591. display: flex;
  592. flex-direction: column;
  593. height: 100%;
  594. }
  595. </style>
  596. <style lang="scss" scoped>
  597. .Hoverball {
  598. display: flex;
  599. justify-content: center;
  600. align-items: center;
  601. flex-direction: column;
  602. background: linear-gradient(180deg, #fefcf9 0%, #fff2df 100%);
  603. // box-shadow: 0rpx 3rpx 12rpx 0rpx rgba(0, 0, 0, 0.16);
  604. width: 105upx;
  605. height: 105upx;
  606. border-radius: 50%; // 圆形按钮
  607. position: fixed; // 固定定位(不随页面滚动)
  608. z-index: 999999; // 最高层级,避免被其他元素遮挡
  609. top: 0%;
  610. right: 0%;
  611. .title {
  612. font-size: 19rpx;
  613. color: #000000;
  614. margin-bottom: 4rpx; // 文本与价格间距
  615. }
  616. .price {
  617. font-size: 26rpx;
  618. color: #cc0000;
  619. font-weight: bold;
  620. }
  621. // 贴边/停止拖拽时的过渡动画
  622. &.transition {
  623. transition: left 0.3s ease, top 0.3s ease;
  624. }
  625. }
  626. .couponIndex {
  627. width: auto;
  628. height: 238rpx;
  629. //background-image: url("~@/static/images/yhjsy.png");
  630. background-size: 100% 100%;
  631. padding-left: 42rpx;
  632. margin-bottom: 30rpx;
  633. .titBox {
  634. padding: 47rpx 0;
  635. text-align: center;
  636. height: 100%;
  637. .tit1 {
  638. color: #ffebd2;
  639. font-size: 34rpx;
  640. font-weight: 600;
  641. }
  642. .tit2 {
  643. color: #ffebd2;
  644. font-size: 22rpx;
  645. margin: 10rpx 0 26rpx 0;
  646. }
  647. .tit3 {
  648. color: #ffdaaf;
  649. font-size: 24rpx;
  650. .iconfont {
  651. font-size: 20rpx;
  652. }
  653. }
  654. }
  655. }
  656. .sticky-box {
  657. // display: flex;
  658. // position: -webkit-sticky;
  659. // position: sticky;
  660. z-index: 99;
  661. flex-direction: row;
  662. // margin: 0px;
  663. // background: #fff;
  664. padding-bottom: 30rpx;
  665. background: #fff;
  666. margin-top: 30rpx;
  667. .active {
  668. color: #000;
  669. }
  670. .nav-bd {
  671. display: flex;
  672. align-items: center;
  673. justify-content: space-between;
  674. padding: 0 20rpx;
  675. .item {
  676. display: flex;
  677. flex-direction: column;
  678. align-items: center;
  679. justify-content: center;
  680. border-bottom: 3rpx solid #e6e6e6;
  681. box-sizing: border-box;
  682. .txt {
  683. font-size: 28rpx;
  684. color: #282828;
  685. }
  686. .label {
  687. display: flex;
  688. align-items: center;
  689. justify-content: center;
  690. width: 124rpx;
  691. height: 32rpx;
  692. margin-top: 5rpx;
  693. font-size: 24rpx;
  694. color: #999;
  695. }
  696. &.active {
  697. color: $theme-color;
  698. border-bottom: 2rpx solid #000;
  699. .txt {
  700. color: $theme-color;
  701. }
  702. .label {
  703. background: linear-gradient(90deg, $bg-star 0%, $bg-end 100%);
  704. border-radius: 16rpx;
  705. color: #fff;
  706. }
  707. }
  708. }
  709. }
  710. .second-nav {
  711. width: 100%;
  712. display: flex;
  713. flex-wrap: nowrap;
  714. overflow-x: auto;
  715. &::-webkit-scrollbar {
  716. display: none;
  717. }
  718. -webkit-overflow-scrolling: touch;
  719. padding: 0 50rpx;
  720. box-sizing: border-box;
  721. .second-nav-item {
  722. font-size: 26rpx;
  723. padding: 15rpx 0;
  724. margin: 0 10rpx 0 0;
  725. color: #000;
  726. white-space: nowrap;
  727. // flex: 1;
  728. width: 33%;
  729. display: flex;
  730. justify-content: center;
  731. align-items: center;
  732. &.active {
  733. color: #ef4800;
  734. }
  735. }
  736. }
  737. }
  738. .swiper-box {
  739. &::v-deep uni-image {
  740. width: 100%;
  741. }
  742. .swiper-banner{
  743. width: 100%;
  744. height: 160px;
  745. }
  746. }
  747. // 活动专区
  748. .active-contanier {
  749. width: 100%;
  750. box-sizing: border-box;
  751. padding: 0 30rpx;
  752. .active-scroll {
  753. width: 100%;
  754. white-space: nowrap;
  755. .active-scroll-content {
  756. margin: 30rpx 0;
  757. display: flex;
  758. flex-direction: row;
  759. white-space: nowrap;
  760. }
  761. }
  762. .active-item {
  763. // width: 335rpx;
  764. width: 48.99%;
  765. background: #ffffff;
  766. height: 180rpx;
  767. // box-shadow: 0rpx 3rpx 13rpx 0rpx rgba(0, 0, 0, 0.13);
  768. border-radius: 20rpx;
  769. padding: 13rpx 20rpx;
  770. box-sizing: border-box;
  771. display: flex;
  772. flex-direction: column;
  773. margin-right: 20rpx;
  774. flex-shrink: 0;
  775. .title-box {
  776. height: 33rpx;
  777. display: flex;
  778. font-size: 22rpx;
  779. align-items: center;
  780. .title {
  781. // width: 50%;
  782. font-weight: bold;
  783. text-align: center;
  784. }
  785. }
  786. .active-box {
  787. flex: 1;
  788. display: flex;
  789. .active-item-left {
  790. flex: 1;
  791. display: flex;
  792. flex-direction: column;
  793. .image-box {
  794. flex: 1;
  795. // width: 115rpx;
  796. display: flex;
  797. align-items: center;
  798. image {
  799. border-radius: 5rpx;
  800. width: 115rpx;
  801. height: 110rpx;
  802. }
  803. .da-jin-tiao {
  804. width: 51rpx;
  805. }
  806. }
  807. }
  808. .active-item-right {
  809. display: flex;
  810. flex-direction: column;
  811. justify-content: space-between;
  812. flex: 1;
  813. min-width: 0;
  814. width: 0;
  815. .ms {
  816. font-size: 16rpx;
  817. color: #000000;
  818. width: 100%;
  819. overflow: hidden;
  820. text-overflow: ellipsis;
  821. white-space: nowrap;
  822. display: block;
  823. max-width: 100%;
  824. box-sizing: border-box;
  825. }
  826. .tag {
  827. display: flex;
  828. .tag-text {
  829. color: #acacac;
  830. background-color: #ebebeb;
  831. border-radius: 5rpx;
  832. font-size: 16rpx;
  833. text-align: center;
  834. padding: 0rpx 5rpx;
  835. }
  836. }
  837. .price-box {
  838. display: flex;
  839. justify-content: space-between;
  840. .price {
  841. font-size: 18rpx;
  842. font-weight: bold;
  843. color: #000000;
  844. margin-right: 10rpx;
  845. }
  846. .btn {
  847. width: 77rpx;
  848. height: 26rpx;
  849. background-image: linear-gradient(270deg, #fc962c 0%, #f0470d 100%);
  850. border-radius: 100rpx;
  851. display: flex;
  852. justify-content: center;
  853. align-items: center;
  854. font-size: 14rpx;
  855. color: #ffffff;
  856. }
  857. }
  858. }
  859. }
  860. }
  861. }
  862. .listAll {
  863. width: 20%;
  864. text-indent: 62rpx;
  865. font-size: 30rpx;
  866. border-left: 1px #eee solid;
  867. margin: 1% 0;
  868. padding: 5rpx;
  869. position: relative;
  870. image {
  871. position: absolute;
  872. left: 20rpx;
  873. top: 8rpx;
  874. }
  875. }
  876. .tab {
  877. position: relative;
  878. display: flex;
  879. font-size: 28rpx;
  880. white-space: nowrap;
  881. &__item {
  882. flex: 1;
  883. padding: 0 20rpx;
  884. text-align: center;
  885. height: 60rpx;
  886. line-height: 60rpx;
  887. color: #666;
  888. &.active {
  889. color: #09c2c9;
  890. }
  891. }
  892. }
  893. .tab__line {
  894. display: block;
  895. height: 6rpx;
  896. position: absolute;
  897. bottom: 0;
  898. left: 0;
  899. z-index: 1;
  900. border-radius: 3rpx;
  901. position: relative;
  902. background: #2fc6cd;
  903. }
  904. .scroll-view_H {
  905. width: 100%;
  906. display: flex;
  907. overflow-x: auto;
  908. padding: 12rpx 0;
  909. background-color: #fff;
  910. box-sizing: border-box;
  911. &::-webkit-scrollbar {
  912. display: none;
  913. }
  914. -webkit-overflow-scrolling: touch;
  915. .tab.nav-bd {
  916. display: flex;
  917. align-items: center;
  918. width: 100%;
  919. }
  920. #tab_item.item {
  921. display: flex;
  922. flex-direction: column;
  923. align-items: center;
  924. // margin: 0 24rpx;
  925. padding: 8rpx 0;
  926. cursor: pointer;
  927. flex: 1;
  928. transition: all 0.3s ease;
  929. .uni-icons {
  930. font-size: 44rpx;
  931. margin-bottom: 6rpx;
  932. }
  933. .txt {
  934. font-size: 26rpx;
  935. color: #333;
  936. }
  937. }
  938. #tab_list:first-of-type .item.active {
  939. .uni-icons {
  940. color: #000;
  941. }
  942. .txt {
  943. color: #000;
  944. font-weight: bold;
  945. }
  946. }
  947. .privacy-wrapper {
  948. z-index: 999;
  949. position: fixed;
  950. left: 0;
  951. top: 0;
  952. width: 100%;
  953. height: 100%;
  954. background: #7f7f7f;
  955. .privacy-box {
  956. position: absolute;
  957. left: 50%;
  958. top: 50%;
  959. transform: translate(-50%, -50%);
  960. width: 560rpx;
  961. padding: 50rpx 45rpx 0;
  962. background: #fff;
  963. border-radius: 20rpx;
  964. .title {
  965. text-align: center;
  966. font-size: 32rpx;
  967. text-align: center;
  968. color: #333;
  969. font-weight: 700;
  970. }
  971. .content {
  972. margin-top: 20rpx;
  973. line-height: 1.5;
  974. font-size: 26rpx;
  975. color: #666;
  976. text-indent: 54rpx;
  977. i {
  978. font-style: normal;
  979. color: $theme-color;
  980. }
  981. }
  982. .btn-box {
  983. margin-top: 40rpx;
  984. text-align: center;
  985. font-size: 30rpx;
  986. .btn-item {
  987. height: 82rpx;
  988. line-height: 82rpx;
  989. background: linear-gradient(90deg, #f67a38 0%, #f11b09 100%);
  990. color: #fff;
  991. border-radius: 41rpx;
  992. }
  993. .btn {
  994. padding: 30rpx 0;
  995. }
  996. }
  997. }
  998. }
  999. }
  1000. .page-index {
  1001. position: relative;
  1002. z-index: 1;
  1003. height: 100%;
  1004. padding-bottom: 200rpx;
  1005. box-sizing: border-box;
  1006. .top-box {
  1007. padding-top: 168rpx;
  1008. //background: linear-gradient(180deg, #ffe079 0%, #ffffff 100%);
  1009. //background-image: url("https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/new-mini/jianbianBG.png");
  1010. background-size: 100% 100%;
  1011. }
  1012. }
  1013. .header {
  1014. //position: sticky;
  1015. //top: 0;
  1016. //z-index: 200000;
  1017. width: 100%;
  1018. padding: 28rpx 20rpx 0;
  1019. .serch-wrapper {
  1020. //margin-top: var(--status-bar-height);
  1021. margin-bottom: 16rpx;
  1022. display: flex;
  1023. justify-content: center;
  1024. align-items: center;
  1025. /* #ifdef MP-WEIXIN */
  1026. width: 100%;
  1027. /* #endif */
  1028. .logo {
  1029. width: 154rpx;
  1030. height: 47rpx;
  1031. margin-right: 24rpx;
  1032. }
  1033. image {
  1034. width: 118rpx;
  1035. height: 42rpx;
  1036. }
  1037. .input {
  1038. display: flex;
  1039. align-items: center;
  1040. width: 100%;
  1041. height: 80rpx;
  1042. background-color: #ffffff;
  1043. border-radius: 16rpx;
  1044. font-size: 28rpx;
  1045. color: #868686;
  1046. .iconfont {
  1047. margin: 0 10rpx;
  1048. font-size: 26rpx;
  1049. color: #666666;
  1050. }
  1051. .searchImg{
  1052. width: 32rpx;
  1053. height: 32rpx;
  1054. margin: 0 20rpx;
  1055. }
  1056. }
  1057. }
  1058. .tabNav {
  1059. padding-top: 24rpx;
  1060. }
  1061. }
  1062. .page_content {
  1063. padding: 0 30rpx;
  1064. }
  1065. .index-product-wrapper {
  1066. padding: 0 16rpx;
  1067. margin-bottom: 200rpx; /* 为自定义 tabBar 留出空间 */
  1068. min-height: 700rpx;
  1069. //background: #fff;
  1070. &.on {
  1071. min-height: 1500rpx;
  1072. }
  1073. .list-box {
  1074. display: flex;
  1075. flex-wrap: wrap;
  1076. justify-content: space-between;
  1077. .item {
  1078. width: 48.99%;
  1079. //height: 490rpx;
  1080. background-color: #ffffff;
  1081. // box-shadow: 0rpx 3rpx 13rpx 0rpx rgba(0, 0, 0, 0.13);
  1082. border-radius: 16rpx;
  1083. margin-bottom: 16rpx;
  1084. overflow: hidden;
  1085. display: flex;
  1086. flex-direction: column;
  1087. justify-content: space-between;
  1088. .pictrue {
  1089. position: relative;
  1090. image {
  1091. width: 100%;
  1092. height: 330rpx;
  1093. }
  1094. }
  1095. .text-info {
  1096. padding: 10rpx 20rpx 20rpx;
  1097. .title {
  1098. color: #333;
  1099. display: flex;
  1100. align-items: center;
  1101. justify-items: space-between;
  1102. .tip {
  1103. width: 61rpx;
  1104. height: auto;
  1105. font-size: 22rpx;
  1106. display: flex;
  1107. justify-content: center;
  1108. align-items: center;
  1109. color: #ffffff;
  1110. position: relative;
  1111. margin-right: 5rpx;
  1112. background-color: #ef4800;
  1113. border-radius: 5rpx;
  1114. }
  1115. .text{
  1116. width: 80%;
  1117. font-weight: bold;
  1118. }
  1119. .weight{
  1120. background-color: rgba(197, 128, 3, 0.10);
  1121. color: #C58003;
  1122. font-size: 24rpx;
  1123. padding: 8rpx 16rpx;
  1124. border-radius: 8rpx;
  1125. float: right;
  1126. }
  1127. }
  1128. .bottom-row {
  1129. color: $theme-color;
  1130. display: flex;
  1131. justify-content: space-between;
  1132. align-items: center;
  1133. font-size: 28rpx;
  1134. margin: 10rpx 0 0;
  1135. .price {
  1136. padding-bottom: 4rpx;
  1137. font-weight: 800;
  1138. white-space: nowrap;
  1139. font-size: 28rpx;
  1140. color: #f16327;
  1141. }
  1142. .sales {
  1143. font-size: 22rpx;
  1144. white-space: nowrap;
  1145. flex-shrink: 0;
  1146. color: #999999;
  1147. }
  1148. }
  1149. .merchantInfo{
  1150. display: flex;
  1151. align-items: center;
  1152. height: 60rpx;
  1153. }
  1154. .merchantLogo{
  1155. width: 40rpx;
  1156. height: 40rpx;
  1157. border-radius: 50%;
  1158. margin-right: 20rpx;
  1159. }
  1160. .merchantName{
  1161. font-size: 24rpx;
  1162. color: #333;
  1163. }
  1164. }
  1165. }
  1166. &.on {
  1167. display: flex;
  1168. }
  1169. }
  1170. }
  1171. .top-bg-box2 {
  1172. overflow: hidden;
  1173. padding: 16rpx;
  1174. box-sizing: border-box;
  1175. .title{
  1176. font-size: 32rpx;
  1177. color: #333333;
  1178. font-weight: bold;
  1179. line-height: 48rpx;
  1180. }
  1181. }
  1182. .top-bg-box {
  1183. overflow: hidden;
  1184. padding: 16rpx;
  1185. box-sizing: border-box;
  1186. // background-image: linear-gradient(
  1187. // to bottom,
  1188. // $header-color 0%,
  1189. // $header-color 10%,
  1190. // #ffe9a1 50%,
  1191. // transparent 100%
  1192. // );
  1193. .card{
  1194. background-color: #fff;
  1195. padding: 4rpx;
  1196. box-sizing: border-box;
  1197. border-radius: 20rpx;
  1198. .cardbgLinear{
  1199. padding: 20rpx 16rpx;
  1200. box-sizing: border-box;
  1201. border-radius: 20rpx;
  1202. background: linear-gradient(to bottom,
  1203. rgba(255, 240, 200, 0.7) 0%,
  1204. rgba(255, 240, 200, 0.4) 8%,
  1205. rgba(255, 255, 255, 1) 20%,
  1206. rgba(255, 255, 255, 1) 100%);
  1207. }
  1208. }
  1209. }
  1210. .top-bg-box {
  1211. .title {
  1212. display: flex;
  1213. justify-content: space-between; // 左右两端对齐
  1214. align-items: center; // 垂直居中
  1215. .title-left {
  1216. display: flex;
  1217. align-items: center;
  1218. .ssjj {
  1219. width: 150rpx;
  1220. height: 36rpx;
  1221. vertical-align: middle;
  1222. }
  1223. .updateTime {
  1224. font-size: 20rpx;
  1225. color: #666666;
  1226. padding: 0 20rpx 0 8rpx;
  1227. box-sizing: border-box;
  1228. }
  1229. }
  1230. .more {
  1231. display: flex;
  1232. align-items: center;
  1233. .txt {
  1234. font-size: 24rpx;
  1235. color: #666666;
  1236. }
  1237. .right {
  1238. width: 24rpx;
  1239. height: 24rpx;
  1240. vertical-align: middle;
  1241. // margin-left: 10rpx; // 添加一些间距
  1242. }
  1243. }
  1244. }
  1245. }
  1246. .nav-list {
  1247. width: 100%;
  1248. display: flex;
  1249. justify-content: space-between;
  1250. align-items: center;
  1251. padding: 0 40rpx 0;
  1252. margin-top: 30rpx;
  1253. .item {
  1254. text-align: center;
  1255. .price{
  1256. font-size: 40rpx;
  1257. color: #FD5F3C;
  1258. font-weight: bold;
  1259. .unit{
  1260. font-size: 24rpx;
  1261. }
  1262. }
  1263. .txt{
  1264. font-size: 28rpx;
  1265. color: #666666;
  1266. line-height: 60rpx;
  1267. }
  1268. }
  1269. }
  1270. .no-data {
  1271. margin: 150rpx auto 0;
  1272. text-align: center;
  1273. img {
  1274. width: 65%;
  1275. height: auto;
  1276. }
  1277. }
  1278. .inde-nav-bar{
  1279. .page-title{
  1280. color: #fff;
  1281. }
  1282. }
  1283. // 分类卡片区域样式
  1284. .classify-section {
  1285. background: #fff;
  1286. margin: 0 16rpx;
  1287. border-radius: 16rpx;
  1288. padding: 30rpx 0 10rpx;
  1289. // box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.06);
  1290. }
  1291. .classify-scroll {
  1292. width: 100%;
  1293. white-space: nowrap;
  1294. }
  1295. .classify-container {
  1296. width: 100%;
  1297. display: inline-flex;
  1298. flex-wrap: nowrap;
  1299. min-width: 100%;
  1300. }
  1301. .classify-item {
  1302. display: inline-flex;
  1303. flex-direction: column;
  1304. align-items: center;
  1305. justify-content: center;
  1306. width: 175rpx;
  1307. flex-shrink: 0;
  1308. box-sizing: border-box;
  1309. .classify-img {
  1310. width: 100rpx;
  1311. height: 100rpx;
  1312. }
  1313. .classify-txt {
  1314. font-size: 24rpx;
  1315. color: #333;
  1316. margin-top: 10rpx;
  1317. text-align: center;
  1318. white-space: nowrap;
  1319. overflow: hidden;
  1320. text-overflow: ellipsis;
  1321. max-width: 120rpx;
  1322. }
  1323. }
  1324. .nav-slot{
  1325. //width: 60%;
  1326. display: flex;
  1327. justify-content: space-between;
  1328. align-items: center;
  1329. .dianpu{
  1330. width: 32rpx;
  1331. }
  1332. .zhankai{
  1333. width: 20rpx;
  1334. }
  1335. .storeName{
  1336. width: 60%;
  1337. font-size: 28rpx;
  1338. color: #333;
  1339. }
  1340. }
  1341. .no-data {
  1342. margin: 150rpx auto 0;
  1343. text-align: center;
  1344. img {
  1345. width: 65%;
  1346. height: auto;
  1347. }
  1348. }
  1349. .mores-txt {
  1350. width: 100%;
  1351. align-items: center;
  1352. justify-content: center;
  1353. height: 70rpx;
  1354. color: #999;
  1355. font-size: 24rpx;
  1356. .iconfont {
  1357. margin-top: 2rpx;
  1358. font-size: 20rpx;
  1359. }
  1360. }
  1361. :deep(.page-title){
  1362. font-size: 36rpx;
  1363. }
  1364. </style>