index.vue 16 KB

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