index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788
  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. appStore.setIndexRefersh(true)
  303. appStore.USERINFO();
  304. uni.switchTab({
  305. url
  306. })
  307. })
  308. } else {
  309. uni.navigateTo({
  310. url
  311. });
  312. }
  313. }
  314. const goDetail = (url) => {
  315. console.log('url', url);
  316. const webviewPageUrl = `/pages/webview/index?path=${url}`;
  317. uni.navigateTo({
  318. url: webviewPageUrl,
  319. fail: (err) => {
  320. console.error("跳转到webview页面失败:", err);
  321. uni.showToast({
  322. title: "跳转失败,请重试",
  323. icon: "none",
  324. duration: 1500,
  325. });
  326. },
  327. });
  328. };
  329. // 查看商家
  330. const viewStore = (store) => {
  331. if (!store.merchantId) {
  332. return;
  333. }
  334. uni.navigateTo({
  335. url: "/pages/merchant/index?merchantId=" + store.merchantId
  336. });
  337. }
  338. // 查看全部订单
  339. const viewAllOrders = () => {
  340. uni.navigateTo({
  341. url: "/pages/order_list/index"
  342. });
  343. }
  344. // 查看订单
  345. const viewOrders = (status) => {
  346. uni.navigateTo({
  347. url: "/pages/order_list/index?status=" + status
  348. });
  349. }
  350. const navigateTo = (url) => {
  351. if (!url) return;
  352. uni.navigateTo({
  353. url
  354. });
  355. };
  356. // 用户面板事件处理
  357. function handleEdit() {
  358. // console.log("编辑资料");
  359. uni.navigateTo({
  360. url: "/pages/users/personal_info/personal_info"
  361. });
  362. }
  363. // 手机号隐藏中间4位
  364. function hidePhoneNumber(phone) {
  365. if (!phone || phone.length !== 11) return phone;
  366. return phone.substring(0, 3) + '****' + phone.substring(7);
  367. }
  368. function formatMoney(value) {
  369. // 处理非数字情况
  370. if (isNaN(value)) {
  371. return '0.00';
  372. }
  373. // 转换为数字并保留两位小数
  374. const num = parseFloat(value);
  375. if (isNaN(num)) {
  376. return '0.00';
  377. }
  378. // 处理负数
  379. const absoluteValue = Math.abs(num);
  380. const roundedValue = Math.round(absoluteValue * 100) / 100;
  381. const fixedValue = roundedValue.toFixed(2);
  382. return num < 0 ? `-${fixedValue}` : fixedValue;
  383. }
  384. </script>
  385. <style scoped lang="scss">
  386. .container {
  387. background-color: #f5f5f5;
  388. min-height: 100vh;
  389. padding-bottom: 180rpx;
  390. }
  391. /* 顶部用户信息 */
  392. .user-header {
  393. height: 600rpx;
  394. //background-image: url("https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/new-mini/jianbianBG.png");
  395. background-size: 100% 100%;
  396. padding: 150rpx 20rpx 20rpx;
  397. color: #fff;
  398. border-radius: 0 0 20rpx 20rpx;
  399. box-sizing: border-box;
  400. }
  401. .user-info {
  402. display: flex;
  403. justify-content: space-between;
  404. align-items: center;
  405. margin-bottom: 30rpx;
  406. }
  407. .user-main {
  408. display: flex;
  409. align-items: center;
  410. }
  411. .avatar {
  412. width: 120rpx;
  413. height: 120rpx;
  414. border-radius: 50%;
  415. background-color: #fff;
  416. margin-right: 30rpx;
  417. }
  418. .name-vip {
  419. //display: flex;
  420. //align-items: center;
  421. //margin-bottom: 16rpx;
  422. }
  423. .name {
  424. font-size: 32rpx;
  425. color: #333;
  426. }
  427. .phone {
  428. font-size: 28rpx;
  429. color: #666666;
  430. margin-top: 16rpx;
  431. }
  432. .vip-tag {
  433. width: 100rpx;
  434. margin-left: 16rpx;
  435. }
  436. .vip-expire,
  437. .login-tip {
  438. font-size: 28rpx;
  439. color: #666;
  440. }
  441. .btn-content {
  442. display: flex;
  443. flex-direction: column;
  444. align-items: center;
  445. justify-content: center;
  446. .setting {
  447. width: 40rpx;
  448. height: 40rpx;
  449. }
  450. .btn-text {
  451. font-size: 24rpx;
  452. color: #333;
  453. line-height: 1.5;
  454. }
  455. }
  456. /* 会员开通提示 */
  457. .vip-promote {
  458. height: 108rpx;
  459. width: 100%;
  460. height: 108rpx;
  461. padding: 0 30rpx;
  462. box-sizing: border-box;
  463. .vipBG {
  464. width: 100%;
  465. height: 100%;
  466. border-radius: 48rpx 48rpx 0 0;
  467. }
  468. .vip-text {
  469. margin-top: -108rpx;
  470. display: flex;
  471. width: 100%;
  472. justify-content: space-between;
  473. align-items: center;
  474. padding: 20rpx;
  475. box-sizing: border-box;
  476. .title {
  477. font-size: 28rpx;
  478. color: #BDAD8E;
  479. display: flex;
  480. justify-content: flex-start;
  481. align-items: center;
  482. .vipIcon {
  483. width: 70rpx;
  484. margin-right: 10rpx;
  485. }
  486. .bigText {
  487. font-size: 32rpx;
  488. color: #FACD8D;
  489. margin: 0 10rpx;
  490. }
  491. }
  492. .open-vip {
  493. width: 144rpx;
  494. height: 60rpx;
  495. line-height: 60rpx;
  496. font-size: 24rpx;
  497. color: #5D3D03;
  498. background: linear-gradient(270deg, #FEE2A3 0%, #FDEBCC 100%);
  499. border-radius: 16rpx 16rpx 16rpx 16rpx;
  500. .bofang {
  501. width: 24rpx;
  502. margin-left: 10rpx;
  503. }
  504. }
  505. }
  506. }
  507. .desc {
  508. font-size: 22rpx;
  509. opacity: 0.9;
  510. }
  511. /* 钱包余额 */
  512. .wallet-section {
  513. background: #fff;
  514. margin: -280rpx 20rpx 20rpx;
  515. border-radius: 24rpx;
  516. padding: 30rpx;
  517. }
  518. .wallet-header {
  519. display: flex;
  520. justify-content: space-between;
  521. align-items: center;
  522. margin-bottom: 20rpx;
  523. }
  524. .wallet-title {
  525. font-size: 28rpx;
  526. color: #333;
  527. }
  528. .transaction-detail {
  529. color: #666;
  530. font-size: 24rpx;
  531. display: flex;
  532. align-items: center;
  533. }
  534. .balance {
  535. font-size: 48rpx;
  536. font-weight: bold;
  537. text-align: center;
  538. margin: 10rpx 0;
  539. color: #333;
  540. }
  541. .assets {
  542. display: flex;
  543. justify-content: space-between;
  544. margin-top: 40rpx;
  545. }
  546. .asset-item {
  547. text-align: center;
  548. flex: 1;
  549. }
  550. .asset-name {
  551. font-size: 24rpx;
  552. color: #666;
  553. margin-bottom: 16rpx;
  554. display: block;
  555. }
  556. .asset-amount {
  557. font-size: 32rpx;
  558. font-weight: bold;
  559. color: #333;
  560. display: block;
  561. }
  562. .wallet-actions {
  563. display: flex;
  564. justify-content: space-between;
  565. margin-top: 50rpx;
  566. }
  567. .wallet-btn {
  568. flex: 1;
  569. text-align: center;
  570. height: 88rpx;
  571. line-height: 88rpx;
  572. margin: 0 10rpx;
  573. border-radius: 16rpx;
  574. font-size: 32rpx;
  575. }
  576. /* 功能入口 */
  577. .function-grid {
  578. background: #fff;
  579. margin: 30rpx;
  580. border-radius: 24rpx;
  581. padding: 40rpx;
  582. }
  583. .functions {
  584. display: grid;
  585. grid-template-columns: repeat(4, 1fr);
  586. gap: 40rpx;
  587. margin-top: 40rpx;
  588. }
  589. .function-item {
  590. text-align: center;
  591. }
  592. .function-icon {
  593. .img {
  594. width: 60rpx;
  595. height: 60rpx;
  596. }
  597. }
  598. .function-name {
  599. font-size: 24rpx;
  600. color: #333;
  601. }
  602. .business {
  603. display: grid;
  604. grid-template-columns: repeat(3, 1fr);
  605. margin-top: 40rpx;
  606. }
  607. .business-item {
  608. text-align: center;
  609. margin-bottom: 30rpx;
  610. }
  611. .business-num {
  612. color: #333333;
  613. font-size: 40rpx;
  614. font-weight: bold;
  615. }
  616. .business-name {
  617. color: #333333;
  618. font-size: 24rpx;
  619. }
  620. /* 最近访问 */
  621. .recent-visit,
  622. .order-section,
  623. .common-functions {
  624. background: #fff;
  625. margin: 20rpx;
  626. border-radius: 16rpx;
  627. padding: 30rpx;
  628. }
  629. .section-header {
  630. display: flex;
  631. justify-content: space-between;
  632. align-items: center;
  633. margin-bottom: 20rpx;
  634. }
  635. .section-title {
  636. font-size: 32rpx;
  637. color: #333;
  638. }
  639. .more {
  640. font-size: 24rpx;
  641. color: #666;
  642. }
  643. .store-item {
  644. display: flex;
  645. align-items: center;
  646. justify-content: flex-start;
  647. padding: 20rpx;
  648. border-bottom: 2rpx solid #f0f0f0;
  649. background-color: #F9F7F0;
  650. border-radius: 16rpx;
  651. }
  652. .store-item:last-child {
  653. border-bottom: none;
  654. }
  655. .store-logo {
  656. .img {
  657. width: 100rpx;
  658. height: 100rpx;
  659. border-radius: 16rpx;
  660. margin-right: 30rpx;
  661. }
  662. }
  663. .store-name {
  664. font-size: 32rpx;
  665. color: #333;
  666. margin-bottom: 20rpx;
  667. display: block;
  668. }
  669. .store-desc {
  670. font-size: 24rpx;
  671. color: #666;
  672. display: block;
  673. }
  674. /* 订单状态 */
  675. .order-status {
  676. display: flex;
  677. justify-content: space-between;
  678. }
  679. .status-item {
  680. text-align: center;
  681. flex: 1;
  682. }
  683. .status-icon {
  684. .img {
  685. width: 60rpx;
  686. height: 60rpx;
  687. }
  688. }
  689. .status-name {
  690. font-size: 24rpx;
  691. color: #333;
  692. }
  693. /* 常用功能 */
  694. .common-functions .functions {
  695. grid-template-columns: repeat(4, 1fr);
  696. }
  697. .page-title {
  698. font-size: 36rpx;
  699. color: #333;
  700. }
  701. </style>