index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786
  1. <template>
  2. <view class="container">
  3. <up-navbar class="inde-nav-bar" :bgColor="navBgColor">
  4. <template #left>
  5. <view></view>
  6. </template>
  7. <template #center>
  8. <view class="page-title">门店主页</view>
  9. </template>
  10. </up-navbar>
  11. <!-- 顶部用户信息 -->
  12. <view class="user-header jianbianBG">
  13. <view class="user-info">
  14. <view class="user-main">
  15. <view>
  16. <image class="avatar" :src="isHttpsImage(merchantInfo?.merchantLogo)"></image>
  17. </view>
  18. <view class="user-detail">
  19. <view class="name-vip" v-if="appStore.isLogin">
  20. <text class="name">{{ merchantInfo?.merchantName }}</text>
  21. <view class="phone">{{hidePhoneNumber(merchantInfo?.merchantPhone)}}</view>
  22. <!-- <image class="vip-tag" v-if="appStore.$userInfo?.svip" mode="widthFix" src="@/static/images/setting/vip.png">VIP</image>-->
  23. </view>
  24. <view class="name-vip" v-else @click="navigateTo('/pages/users/login/index')">
  25. <text class="name">未登录</text>
  26. </view>
  27. <!-- <text class="vip-expire" v-if="appStore.$userInfo?.svip">到期时间:{{ appStore.$userInfo?.svipExpireTime }}</text>-->
  28. </view>
  29. </view>
  30. <view class="btn-content" @click="handleEdit()">
  31. <image class="setting" :src="HTTP_REQUEST_URL_IMG+'setting.png'" mode="widthFix"></image>
  32. <text class="btn-text">编辑资料</text>
  33. </view>
  34. </view>
  35. </view>
  36. <!-- 经营概况 -->
  37. <view class="wallet-section">
  38. <view class="section-header">
  39. <text class="section-title">经营概况</text>
  40. </view>
  41. <view class="business">
  42. <view class="business-item" v-for="business in businessOverview" :key="business.name">
  43. <view class="business-num">
  44. <text>{{business.num}}</text>
  45. </view>
  46. <text class="business-name">{{ business.name }}</text>
  47. </view>
  48. </view>
  49. </view>
  50. <!-- 订单状态 -->
  51. <view class="order-section">
  52. <view class="section-header">
  53. <text class="section-title">我的订单</text>
  54. <view class="more" @click="viewAllOrders">全部订单<uni-icons style="margin-left: 10rpx;" type="right"
  55. size="16" color="#666666"></uni-icons></view>
  56. </view>
  57. <view class="order-status">
  58. <view class="status-item" v-for="order in orderStatus" :key="order.name" @click="viewOrders(order.id)">
  59. <view class="status-icon">
  60. <image class="img" :src="order.src" mode="widthFix"></image>
  61. </view>
  62. <text class="status-name">{{ order.name }}</text>
  63. </view>
  64. </view>
  65. </view>
  66. <!-- 日常经营 -->
  67. <view class="common-functions">
  68. <view class="section-header">
  69. <text class="section-title">日常经营</text>
  70. </view>
  71. <view class="functions">
  72. <template v-for="func in commonFunctions" :key="func.name">
  73. <view class="function-item" @click="handleFunctionClick(func.pageUrl,func.name)" v-if="func.show">
  74. <view class="function-icon">
  75. <image class="img" :src="func.src" mode="widthFix"></image>
  76. </view>
  77. <text class="function-name">{{ func.name }}</text>
  78. </view>
  79. </template>
  80. </view>
  81. </view>
  82. </view>
  83. </template>
  84. <script setup>
  85. import {
  86. ref,
  87. reactive,
  88. watch,
  89. computed
  90. } from 'vue'
  91. import {
  92. onLoad,
  93. onShow,
  94. onPageScroll
  95. } from "@dcloudio/uni-app";
  96. import UniIcons from "../../uni_modules/uni-icons/components/uni-icons/uni-icons.vue";
  97. import {
  98. isHttpsImage
  99. } from "@/utils/util";
  100. import {
  101. useAppStore
  102. } from "@/stores/app";
  103. import {
  104. useToast
  105. } from "@/hooks/useToast";
  106. import {
  107. merchantSalesSummary
  108. } from "@/api/merchant.js";
  109. import {
  110. toLogin
  111. } from "@/libs/login.js";
  112. import {
  113. HTTP_REQUEST_URL_IMG
  114. } from "@/config/app";
  115. import {
  116. footprintScan
  117. } from "@/api/merchant.js";
  118. const appStore = useAppStore();
  119. const {
  120. Toast
  121. } = useToast();
  122. const isLogin = appStore.isLogin;
  123. const showIcons = ref(false);
  124. const wxConfig = ref({});
  125. const tradeList = ref([]);
  126. const useList = ref([]);
  127. const wdsyShow = ref(false);
  128. const kcglShow = ref(false);
  129. const navBgColor = ref('rgba(255,255,255,0)');
  130. // 经营概况
  131. const businessOverview = ref([{
  132. name: '在售商品数',
  133. num: 123
  134. },
  135. {
  136. name: '待发货订单',
  137. num: 123
  138. },
  139. {
  140. name: '累计订单量',
  141. num: 123
  142. },
  143. {
  144. name: '累计销售额(元)',
  145. num: 123.00
  146. }
  147. ])
  148. // 主要功能列表
  149. const mainFunctions = ref([{
  150. src: `${HTTP_REQUEST_URL_IMG}setting/mailiao.png`,
  151. name: '买料',
  152. pageUrl: '/pages/users/vault/buy?type=buygold'
  153. },
  154. {
  155. src: `${HTTP_REQUEST_URL_IMG}setting/mailiao2.png`,
  156. name: '卖料',
  157. pageUrl: '/pages/users/vault/storeMetal/index?type=soldgold'
  158. },
  159. {
  160. src: `${HTTP_REQUEST_URL_IMG}setting/cunliao.png`,
  161. name: '存料',
  162. pageUrl: '/pages/users/vault/storeMetal/goldBullionStock?type=savegold'
  163. },
  164. {
  165. src: `${HTTP_REQUEST_URL_IMG}setting/tiliao.png`,
  166. name: '提料',
  167. pageUrl: '/pages/users/vault/storeMetal/metalExchange?type=materialdeduction'
  168. }
  169. ])
  170. // 订单状态
  171. const orderStatus = ref([{
  172. src: `${HTTP_REQUEST_URL_IMG}setting/daifukuan.png`,
  173. name: '待付款',
  174. id: 0
  175. },
  176. {
  177. src: `${HTTP_REQUEST_URL_IMG}setting/daifahuo.png`,
  178. name: '待发货',
  179. id: 1
  180. },
  181. {
  182. src: `${HTTP_REQUEST_URL_IMG}setting/daishouhuo.png`,
  183. name: '待收货',
  184. id: 2
  185. },
  186. {
  187. src: `${HTTP_REQUEST_URL_IMG}setting/tuikuan.png`,
  188. name: '退款/换货',
  189. id: 5
  190. },
  191. {
  192. src: `${HTTP_REQUEST_URL_IMG}setting/yiwancheng.png`,
  193. name: '已完成',
  194. id: 4
  195. },
  196. ])
  197. // 常用功能
  198. const commonFunctions = computed(() => {
  199. const baseFunctions = [{
  200. src: `${HTTP_REQUEST_URL_IMG}setting/fabu.png`,
  201. name: '发布商品',
  202. pageUrl: '/pages/merchantCenters/postInformation',
  203. show: true
  204. },
  205. {
  206. src: `${HTTP_REQUEST_URL_IMG}setting/shangpin.png`,
  207. name: '商品管理',
  208. pageUrl: '/pages/merchantCenters/productManagement',
  209. show: true
  210. },
  211. {
  212. src: `${HTTP_REQUEST_URL_IMG}setting/kucun.png`,
  213. name: '库存管理',
  214. pageUrl: '/pages/users/user_asset/asset_info/asset_info',
  215. show: !kcglShow.value
  216. },
  217. {
  218. src: `${HTTP_REQUEST_URL_IMG}setting/jinqian.png`,
  219. name: '我的收益',
  220. pageUrl: '',
  221. show: wdsyShow.value
  222. },
  223. {
  224. src: `${HTTP_REQUEST_URL_IMG}setting/kabao.png`,
  225. name: '卡包管理',
  226. pageUrl: '/pages/users/card_page/index',
  227. show: !kcglShow.value
  228. },
  229. {
  230. src: `${HTTP_REQUEST_URL_IMG}setting/mendian.png`,
  231. name: '门店推广',
  232. pageUrl: '/pages/users/my_merchant/index',
  233. show: true
  234. },
  235. {
  236. src: `${HTTP_REQUEST_URL_IMG}setting/dianpu.png`,
  237. name: '我的商城',
  238. pageUrl: `/pages/index/index`,
  239. show: true
  240. },
  241. ];
  242. // 根据 show 值过滤
  243. return baseFunctions.filter((func) => func.show);
  244. });
  245. const params = ref({
  246. page: 1,
  247. limit: 10,
  248. });
  249. const merchantInfo = ref({})
  250. // 页面加载
  251. onShow(() => {
  252. console.log(appStore.userInfo)
  253. kcglShow.value = appStore?.$wxConfig?.auditModeEnabled;
  254. merchantInfo.value = appStore.userInfo.merchant;
  255. if (appStore.merchantId || appStore.userInfo?.merchant?.id) {
  256. wdsyShow.value = true;
  257. } else {
  258. wdsyShow.value = false;
  259. }
  260. getMerchantSalesSummary()
  261. })
  262. onPageScroll((e) => {
  263. if (e.scrollTop > 0) {
  264. navBgColor.value = '#ffe079';
  265. } else {
  266. navBgColor.value = 'rgba(252,255,255,0)';
  267. }
  268. })
  269. // 编辑资料
  270. const editProfile = () => {
  271. uni.showToast({
  272. title: '编辑资料',
  273. icon: 'none'
  274. })
  275. }
  276. // 经营状况
  277. const getMerchantSalesSummary = async () => {
  278. let obj = {
  279. merchantId: parseInt(merchantInfo.value.id)
  280. }
  281. const {
  282. data
  283. } = await merchantSalesSummary(obj);
  284. businessOverview.value[0].num = data.onSaleProductCount;
  285. businessOverview.value[1].num = data.toBeShippedOrderCount;
  286. businessOverview.value[2].num = data.totalOrderCount;
  287. businessOverview.value[3].num = formatMoney(data.totalSalesAmount);
  288. }
  289. // 功能点击
  290. const handleFunctionClick = (url, name) => {
  291. if (!url) return;
  292. if (name == '库存管理' || name == '卡包管理') {
  293. goDetail(url);
  294. } else if (name == '我的商城') {
  295. console.log(appStore.userInfo.merchant.id)
  296. let obj = {
  297. merchantId: appStore.userInfo.merchant.id,
  298. userId: appStore.userInfo.userId
  299. }
  300. footprintScan(obj).then(()=>{
  301. appStore.userInfo.lastVisitedMerchantId = appStore.userInfo.merchant.id
  302. uni.switchTab({
  303. url
  304. })
  305. })
  306. } else {
  307. uni.navigateTo({
  308. url
  309. });
  310. }
  311. }
  312. const goDetail = (url) => {
  313. console.log('url', url);
  314. const webviewPageUrl = `/pages/webview/index?path=${url}`;
  315. uni.navigateTo({
  316. url: webviewPageUrl,
  317. fail: (err) => {
  318. console.error("跳转到webview页面失败:", err);
  319. uni.showToast({
  320. title: "跳转失败,请重试",
  321. icon: "none",
  322. duration: 1500,
  323. });
  324. },
  325. });
  326. };
  327. // 查看商家
  328. const viewStore = (store) => {
  329. if (!store.merchantId) {
  330. return;
  331. }
  332. uni.navigateTo({
  333. url: "/pages/merchant/index?merchantId=" + store.merchantId
  334. });
  335. }
  336. // 查看全部订单
  337. const viewAllOrders = () => {
  338. uni.navigateTo({
  339. url: "/pages/order_list/index"
  340. });
  341. }
  342. // 查看订单
  343. const viewOrders = (status) => {
  344. uni.navigateTo({
  345. url: "/pages/order_list/index?status=" + status
  346. });
  347. }
  348. const navigateTo = (url) => {
  349. if (!url) return;
  350. uni.navigateTo({
  351. url
  352. });
  353. };
  354. // 用户面板事件处理
  355. function handleEdit() {
  356. // console.log("编辑资料");
  357. uni.navigateTo({
  358. url: "/pages/users/personal_info/personal_info"
  359. });
  360. }
  361. // 手机号隐藏中间4位
  362. function hidePhoneNumber(phone) {
  363. if (!phone || phone.length !== 11) return phone;
  364. return phone.substring(0, 3) + '****' + phone.substring(7);
  365. }
  366. function formatMoney(value) {
  367. // 处理非数字情况
  368. if (isNaN(value)) {
  369. return '0.00';
  370. }
  371. // 转换为数字并保留两位小数
  372. const num = parseFloat(value);
  373. if (isNaN(num)) {
  374. return '0.00';
  375. }
  376. // 处理负数
  377. const absoluteValue = Math.abs(num);
  378. const roundedValue = Math.round(absoluteValue * 100) / 100;
  379. const fixedValue = roundedValue.toFixed(2);
  380. return num < 0 ? `-${fixedValue}` : fixedValue;
  381. }
  382. </script>
  383. <style scoped lang="scss">
  384. .container {
  385. background-color: #f5f5f5;
  386. min-height: 100vh;
  387. padding-bottom: 180rpx;
  388. }
  389. /* 顶部用户信息 */
  390. .user-header {
  391. height: 600rpx;
  392. //background-image: url("https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/new-mini/jianbianBG.png");
  393. background-size: 100% 100%;
  394. padding: 150rpx 20rpx 20rpx;
  395. color: #fff;
  396. border-radius: 0 0 20rpx 20rpx;
  397. box-sizing: border-box;
  398. }
  399. .user-info {
  400. display: flex;
  401. justify-content: space-between;
  402. align-items: center;
  403. margin-bottom: 30rpx;
  404. }
  405. .user-main {
  406. display: flex;
  407. align-items: center;
  408. }
  409. .avatar {
  410. width: 120rpx;
  411. height: 120rpx;
  412. border-radius: 50%;
  413. background-color: #fff;
  414. margin-right: 30rpx;
  415. }
  416. .name-vip {
  417. //display: flex;
  418. //align-items: center;
  419. //margin-bottom: 16rpx;
  420. }
  421. .name {
  422. font-size: 32rpx;
  423. color: #333;
  424. }
  425. .phone {
  426. font-size: 28rpx;
  427. color: #666666;
  428. margin-top: 16rpx;
  429. }
  430. .vip-tag {
  431. width: 100rpx;
  432. margin-left: 16rpx;
  433. }
  434. .vip-expire,
  435. .login-tip {
  436. font-size: 28rpx;
  437. color: #666;
  438. }
  439. .btn-content {
  440. display: flex;
  441. flex-direction: column;
  442. align-items: center;
  443. justify-content: center;
  444. .setting {
  445. width: 40rpx;
  446. height: 40rpx;
  447. }
  448. .btn-text {
  449. font-size: 24rpx;
  450. color: #333;
  451. line-height: 1.5;
  452. }
  453. }
  454. /* 会员开通提示 */
  455. .vip-promote {
  456. height: 108rpx;
  457. width: 100%;
  458. height: 108rpx;
  459. padding: 0 30rpx;
  460. box-sizing: border-box;
  461. .vipBG {
  462. width: 100%;
  463. height: 100%;
  464. border-radius: 48rpx 48rpx 0 0;
  465. }
  466. .vip-text {
  467. margin-top: -108rpx;
  468. display: flex;
  469. width: 100%;
  470. justify-content: space-between;
  471. align-items: center;
  472. padding: 20rpx;
  473. box-sizing: border-box;
  474. .title {
  475. font-size: 28rpx;
  476. color: #BDAD8E;
  477. display: flex;
  478. justify-content: flex-start;
  479. align-items: center;
  480. .vipIcon {
  481. width: 70rpx;
  482. margin-right: 10rpx;
  483. }
  484. .bigText {
  485. font-size: 32rpx;
  486. color: #FACD8D;
  487. margin: 0 10rpx;
  488. }
  489. }
  490. .open-vip {
  491. width: 144rpx;
  492. height: 60rpx;
  493. line-height: 60rpx;
  494. font-size: 24rpx;
  495. color: #5D3D03;
  496. background: linear-gradient(270deg, #FEE2A3 0%, #FDEBCC 100%);
  497. border-radius: 16rpx 16rpx 16rpx 16rpx;
  498. .bofang {
  499. width: 24rpx;
  500. margin-left: 10rpx;
  501. }
  502. }
  503. }
  504. }
  505. .desc {
  506. font-size: 22rpx;
  507. opacity: 0.9;
  508. }
  509. /* 钱包余额 */
  510. .wallet-section {
  511. background: #fff;
  512. margin: -280rpx 20rpx 20rpx;
  513. border-radius: 24rpx;
  514. padding: 30rpx;
  515. }
  516. .wallet-header {
  517. display: flex;
  518. justify-content: space-between;
  519. align-items: center;
  520. margin-bottom: 20rpx;
  521. }
  522. .wallet-title {
  523. font-size: 28rpx;
  524. color: #333;
  525. }
  526. .transaction-detail {
  527. color: #666;
  528. font-size: 24rpx;
  529. display: flex;
  530. align-items: center;
  531. }
  532. .balance {
  533. font-size: 48rpx;
  534. font-weight: bold;
  535. text-align: center;
  536. margin: 10rpx 0;
  537. color: #333;
  538. }
  539. .assets {
  540. display: flex;
  541. justify-content: space-between;
  542. margin-top: 40rpx;
  543. }
  544. .asset-item {
  545. text-align: center;
  546. flex: 1;
  547. }
  548. .asset-name {
  549. font-size: 24rpx;
  550. color: #666;
  551. margin-bottom: 16rpx;
  552. display: block;
  553. }
  554. .asset-amount {
  555. font-size: 32rpx;
  556. font-weight: bold;
  557. color: #333;
  558. display: block;
  559. }
  560. .wallet-actions {
  561. display: flex;
  562. justify-content: space-between;
  563. margin-top: 50rpx;
  564. }
  565. .wallet-btn {
  566. flex: 1;
  567. text-align: center;
  568. height: 88rpx;
  569. line-height: 88rpx;
  570. margin: 0 10rpx;
  571. border-radius: 16rpx;
  572. font-size: 32rpx;
  573. }
  574. /* 功能入口 */
  575. .function-grid {
  576. background: #fff;
  577. margin: 30rpx;
  578. border-radius: 24rpx;
  579. padding: 40rpx;
  580. }
  581. .functions {
  582. display: grid;
  583. grid-template-columns: repeat(4, 1fr);
  584. gap: 40rpx;
  585. margin-top: 40rpx;
  586. }
  587. .function-item {
  588. text-align: center;
  589. }
  590. .function-icon {
  591. .img {
  592. width: 60rpx;
  593. height: 60rpx;
  594. }
  595. }
  596. .function-name {
  597. font-size: 24rpx;
  598. color: #333;
  599. }
  600. .business {
  601. display: grid;
  602. grid-template-columns: repeat(3, 1fr);
  603. margin-top: 40rpx;
  604. }
  605. .business-item {
  606. text-align: center;
  607. margin-bottom: 30rpx;
  608. }
  609. .business-num {
  610. color: #333333;
  611. font-size: 40rpx;
  612. font-weight: bold;
  613. }
  614. .business-name {
  615. color: #333333;
  616. font-size: 24rpx;
  617. }
  618. /* 最近访问 */
  619. .recent-visit,
  620. .order-section,
  621. .common-functions {
  622. background: #fff;
  623. margin: 20rpx;
  624. border-radius: 16rpx;
  625. padding: 30rpx;
  626. }
  627. .section-header {
  628. display: flex;
  629. justify-content: space-between;
  630. align-items: center;
  631. margin-bottom: 20rpx;
  632. }
  633. .section-title {
  634. font-size: 32rpx;
  635. color: #333;
  636. }
  637. .more {
  638. font-size: 24rpx;
  639. color: #666;
  640. }
  641. .store-item {
  642. display: flex;
  643. align-items: center;
  644. justify-content: flex-start;
  645. padding: 20rpx;
  646. border-bottom: 2rpx solid #f0f0f0;
  647. background-color: #F9F7F0;
  648. border-radius: 16rpx;
  649. }
  650. .store-item:last-child {
  651. border-bottom: none;
  652. }
  653. .store-logo {
  654. .img {
  655. width: 100rpx;
  656. height: 100rpx;
  657. border-radius: 16rpx;
  658. margin-right: 30rpx;
  659. }
  660. }
  661. .store-name {
  662. font-size: 32rpx;
  663. color: #333;
  664. margin-bottom: 20rpx;
  665. display: block;
  666. }
  667. .store-desc {
  668. font-size: 24rpx;
  669. color: #666;
  670. display: block;
  671. }
  672. /* 订单状态 */
  673. .order-status {
  674. display: flex;
  675. justify-content: space-between;
  676. }
  677. .status-item {
  678. text-align: center;
  679. flex: 1;
  680. }
  681. .status-icon {
  682. .img {
  683. width: 60rpx;
  684. height: 60rpx;
  685. }
  686. }
  687. .status-name {
  688. font-size: 24rpx;
  689. color: #333;
  690. }
  691. /* 常用功能 */
  692. .common-functions .functions {
  693. grid-template-columns: repeat(4, 1fr);
  694. }
  695. .page-title {
  696. font-size: 36rpx;
  697. color: #333;
  698. }
  699. </style>