index.vue 34 KB

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