index.vue 33 KB

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