index.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387
  1. <template>
  2. <Theme>
  3. <view class="wrap" :style="{ '--tabbarHeight': tabbarHeight + 'px' }">
  4. <view class="cont">
  5. <view class="cont_bg" id="tob">
  6. <Navbar bgColor="transparent" fixed>
  7. <template #left>
  8. <view class="nav_left">
  9. <image
  10. src="@/static/logo.png"
  11. class="nav_logo"
  12. mode="widthFix"
  13. ></image>
  14. </view>
  15. </template>
  16. <template #right>
  17. <view class="nav_right">
  18. <view class="icon-badge-wrap">
  19. <image
  20. src="/static/home/kefu.png"
  21. class="mobile_system"
  22. @click="toGo('/pages/setting/system')"
  23. >
  24. </image>
  25. <up-badge
  26. type="error"
  27. max="99"
  28. :value="unreadCount"
  29. class="tips"
  30. v-if="unreadCount > 0"
  31. ></up-badge>
  32. </view>
  33. <image
  34. src="/static/language.png"
  35. class="mobile_language"
  36. @click="toGo('/pages/setting/language_currency')"
  37. ></image>
  38. <navMenu />
  39. </view>
  40. </template>
  41. </Navbar>
  42. <view class="bg_top">
  43. <view class="search">
  44. <Search
  45. v-model="defaultParams.keywords"
  46. border="none"
  47. @input="onSearchInput"
  48. @click="searchClick"
  49. :placeholder="t('请粘贴商品链接或关键字')"
  50. >
  51. <template #prefix>
  52. <i class="icon-font icon-search"></i>
  53. </template>
  54. <template #suffix>
  55. <i class="icon-font icon-camera"></i>
  56. </template>
  57. </Search>
  58. </view>
  59. </view>
  60. </view>
  61. <view class="content">
  62. <!-- 轮播图区域 -->
  63. <view class="banner-section">
  64. <Swiper @click="swiperClick" height="108px" class="swiper-box" />
  65. </view>
  66. <!-- Tab导航 -->
  67. <view class="tab-section">
  68. <up-tabs
  69. :list="tabList"
  70. :current="currentTab"
  71. key="currentTab"
  72. keyName="name"
  73. @change="onTabChange"
  74. :lineHeight="2"
  75. lineColor="var(--black)"
  76. :activeStyle="{
  77. color: 'var(--black)',
  78. fontWeight: 'bold',
  79. transform: 'scale(1.05)',
  80. }"
  81. :inactiveStyle="{
  82. color: '#767676',
  83. transform: 'scale(1)',
  84. }"
  85. />
  86. </view>
  87. <!-- 商品列表 -->
  88. <view class="products_section">
  89. <List
  90. ref="listRef"
  91. url="/seller/goods/lists"
  92. :defaultParams="defaultParams"
  93. @datas="getList"
  94. >
  95. <template #item="{ item }">
  96. <productItem :item="item" />
  97. </template>
  98. </List>
  99. </view>
  100. </view>
  101. </view>
  102. </view>
  103. <IosUpdateModal />
  104. <blindModel />
  105. <Tabbar page="index" @getTabbarHeight="getTabbarHeight" />
  106. </Theme>
  107. </template>
  108. <script setup>
  109. import Tabbar from "@/components/tabbar";
  110. import Navbar from "@/components/navbar";
  111. import Swiper from "@/components/swiper";
  112. import blindModel from "@/components/blindModel";
  113. import Search from "@/components/input";
  114. import navMenu from "@/components/nav_menu";
  115. import IosUpdateModal from "@/components/IosUpdateModal";
  116. import List from "@/components/list";
  117. import productItem from "./components/product_item";
  118. import {
  119. computed,
  120. ref,
  121. watch,
  122. nextTick,
  123. onMounted,
  124. reactive,
  125. watchEffect,
  126. } from "vue";
  127. import { onLoad, onShow, onUnload, onHide } from "@dcloudio/uni-app";
  128. import { storeToRefs } from "pinia";
  129. import {
  130. useShopStore,
  131. useSystemStore,
  132. useMessageStore,
  133. useTabbarStore,
  134. useUserStore,
  135. } from "@/store";
  136. import { t } from "@/locale";
  137. import { query, systemInfo } from "@/utils";
  138. const useShop = useShopStore();
  139. const useSystem = useSystemStore();
  140. const useTabbar = useTabbarStore();
  141. const useUser = useUserStore();
  142. const langList = computed(() => useSystem.getLangeuage);
  143. const lang = computed(() => useSystem.getLang);
  144. const token = computed(() => useUser.getToken);
  145. const symbol = computed(() => useSystem.getSymbol);
  146. const userType = computed(() => useUser.getUserType);
  147. const useMessage = useMessageStore();
  148. const { globalMap } = storeToRefs(useMessage);
  149. const unreadCount = ref(0);
  150. watch(
  151. () => globalMap.value.noticeChannel,
  152. (newVal, oldVal) => {
  153. if (newVal) {
  154. unreadCount.value = newVal.unreadCount;
  155. }
  156. },
  157. {
  158. deep: true,
  159. immediate: true,
  160. }
  161. );
  162. const searchValue = ref("");
  163. const tabbarHeight = ref(0);
  164. // Tab数据
  165. const tabList = ref([]);
  166. watchEffect(() => {
  167. tabList.value = [
  168. { name: t("推荐"), sort: "views" },
  169. { name: t("新品"), sort: "id" },
  170. ];
  171. });
  172. const currentTab = ref(0);
  173. // List组件引用
  174. const listRef = ref(null);
  175. // 默认参数
  176. const defaultParams = reactive({
  177. keywords: "",
  178. sort: "views",
  179. });
  180. // Tab切换
  181. const onTabChange = (item, index) => {
  182. if (!item) return;
  183. currentTab.value = index;
  184. defaultParams.sort = item.sort;
  185. listRef.value && listRef.value.handleRefresh();
  186. };
  187. // 搜索输入
  188. const onSearchInput = (value) => {
  189. searchValue.value = value;
  190. defaultParams.keywords = value;
  191. listRef.value && listRef.value.handleRefresh();
  192. };
  193. // 获取列表数据
  194. const getList = (data) => {
  195. // console.log("商品列表数据:", data);
  196. };
  197. const searchClick = () => {
  198. // toGo("/pagesBuyer/home/search");
  199. };
  200. const toGo = (url) => {
  201. if (!url) return;
  202. uni.navigateTo({ url });
  203. };
  204. const swiperClick = (item) => {
  205. if (item.action == "goto_product") {
  206. toGo("/pagesBuyer/home/products");
  207. } else if (item.action == "goto_activity") {
  208. toGo("/pagesBuyer/home/activity");
  209. }
  210. };
  211. const getTabbarHeight = (height) => {
  212. tabbarHeight.value = height;
  213. };
  214. const loadPageData = async () => {
  215. listRef.value && listRef.value.handleRefresh();
  216. await useSystem.setBoxes({}, { isLoading: true });
  217. };
  218. onShow(() => {
  219. loadPageData();
  220. });
  221. onMounted(() => {
  222. loadPageData();
  223. });
  224. </script>
  225. <style lang="less" scoped>
  226. @import url("@/style.less");
  227. .wrap {
  228. background: var(--bor-color);
  229. min-height: calc(100vh - var(--tabbarHeight));
  230. padding-bottom: var(--tabbarHeight);
  231. .nav_left {
  232. display: flex;
  233. align-items: center;
  234. .nav_logo {
  235. width: 284rpx;
  236. }
  237. }
  238. .nav_right {
  239. display: flex;
  240. align-items: center;
  241. .mobile_language {
  242. width: 48rpx;
  243. height: 48rpx;
  244. margin: 0 20rpx 0 24rpx;
  245. }
  246. .icon-badge-wrap {
  247. position: relative;
  248. display: inline-block;
  249. width: 48rpx;
  250. height: 48rpx;
  251. .mobile_system {
  252. width: 48rpx;
  253. height: 48rpx;
  254. }
  255. .tips {
  256. position: absolute;
  257. right: -10rpx;
  258. top: -8rpx;
  259. z-index: 2;
  260. }
  261. }
  262. }
  263. .cont {
  264. width: 100%;
  265. background-color: var(--light);
  266. &_bg {
  267. // position: sticky;
  268. // top: 0;
  269. z-index: 88;
  270. background-color: var(--black);
  271. .bg_top {
  272. padding: 0 30rpx;
  273. .search {
  274. padding: 26rpx 0 60rpx 0;
  275. :deep(.u-input) {
  276. padding: 0 20px 0 16px !important;
  277. .u-input__content__field-wrapper__field {
  278. height: 47px;
  279. }
  280. }
  281. .icon-search {
  282. color: var(--text);
  283. font-size: 40rpx;
  284. }
  285. .icon-camera {
  286. color: var(--text-01);
  287. font-size: 70rpx;
  288. }
  289. }
  290. .debug-info {
  291. padding: 10rpx 0;
  292. text-align: center;
  293. text {
  294. font-size: 24rpx;
  295. color: var(--primary);
  296. background: rgba(255, 107, 107, 0.1);
  297. padding: 8rpx 16rpx;
  298. border-radius: 20rpx;
  299. }
  300. }
  301. }
  302. }
  303. .content {
  304. width: 100%;
  305. padding: 30rpx 30rpx;
  306. position: relative;
  307. box-sizing: border-box;
  308. margin-top: -30rpx;
  309. border-radius: 20rpx 20rpx 0 0;
  310. z-index: 99;
  311. background-color: var(--bor-color);
  312. .banner-section {
  313. margin-bottom: 38rpx;
  314. }
  315. .tab-section {
  316. margin-bottom: 32rpx;
  317. }
  318. .swiper-box {
  319. width: 100%;
  320. border-radius: 20rpx;
  321. overflow: hidden;
  322. }
  323. .products_section {
  324. /deep/ .uni-scroll-view-content {
  325. margin-top: 16rpx;
  326. > uni-view {
  327. .flex();
  328. flex-wrap: wrap;
  329. gap: 8rpx 16rpx;
  330. .u-list-item {
  331. width: calc((100% - 16rpx) / 2);
  332. }
  333. }
  334. }
  335. }
  336. }
  337. }
  338. }
  339. </style>