index.vue 16 KB

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