index.vue 34 KB

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