index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  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/indexWX' ,show:!kcglShow.value},
  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. // 页面加载
  151. onShow(() => {
  152. console.log(appStore.userInfo)
  153. kcglShow.value = appStore?.$wxConfig?.auditModeEnabled;
  154. merchantInfo.value = appStore.userInfo.merchant;
  155. if (appStore.merchantId || appStore.userInfo?.merchant?.id) {
  156. wdsyShow.value = true;
  157. } else {
  158. wdsyShow.value = false;
  159. }
  160. getMerchantSalesSummary()
  161. })
  162. onPageScroll((e) => {
  163. if(e.scrollTop > 0){
  164. navBgColor.value ='#ffe079';
  165. }else{
  166. navBgColor.value ='rgba(252,255,255,0)';
  167. }
  168. })
  169. // 编辑资料
  170. const editProfile = () => {
  171. uni.showToast({
  172. title: '编辑资料',
  173. icon: 'none'
  174. })
  175. }
  176. // 经营状况
  177. const getMerchantSalesSummary = async () =>{
  178. let obj = {
  179. merchantId:parseInt(merchantInfo.value.id)
  180. }
  181. const { data } = await merchantSalesSummary(obj);
  182. businessOverview.value[0].num = data.onSaleProductCount;
  183. businessOverview.value[1].num = data.toBeShippedOrderCount;
  184. businessOverview.value[2].num = data.totalOrderCount;
  185. businessOverview.value[3].num = formatMoney(data.totalSalesAmount);
  186. }
  187. // 功能点击
  188. const handleFunctionClick = (url,name) => {
  189. if (!url) return;
  190. if(name == '库存管理' || name == '卡包管理'){
  191. goDetail(url);
  192. }else if(name == '我的商城'){
  193. uni.switchTab({url})
  194. }else{
  195. uni.navigateTo({ url });
  196. }
  197. }
  198. const goDetail = (url) => {
  199. console.log('url',url);
  200. const webviewPageUrl = `/pages/webview/index?path=${url}`;
  201. uni.navigateTo({
  202. url: webviewPageUrl,
  203. fail: (err) => {
  204. console.error("跳转到webview页面失败:", err);
  205. uni.showToast({
  206. title: "跳转失败,请重试",
  207. icon: "none",
  208. duration: 1500,
  209. });
  210. },
  211. });
  212. };
  213. // 查看商家
  214. const viewStore = (store) => {
  215. if(!store.merchantId ){
  216. return;
  217. }
  218. uni.navigateTo({ url:"/pages/merchant/index?merchantId="+store.merchantId });
  219. }
  220. // 查看全部订单
  221. const viewAllOrders = () => {
  222. uni.navigateTo({ url:"/pages/order_list/index" });
  223. }
  224. // 查看订单
  225. const viewOrders = (status) => {
  226. uni.navigateTo({ url:"/pages/order_list/index?status="+ status});
  227. }
  228. const navigateTo = (url) => {
  229. if (!url) return;
  230. uni.navigateTo({ url });
  231. };
  232. // 用户面板事件处理
  233. function handleEdit() {
  234. // console.log("编辑资料");
  235. uni.navigateTo({ url: "/pages/users/personal_info/personal_info" });
  236. }
  237. // 手机号隐藏中间4位
  238. function hidePhoneNumber(phone) {
  239. if (!phone || phone.length !== 11) return phone;
  240. return phone.substring(0, 3) + '****' + phone.substring(7);
  241. }
  242. function formatMoney(value) {
  243. // 处理非数字情况
  244. if (isNaN(value)) {
  245. return '0.00';
  246. }
  247. // 转换为数字并保留两位小数
  248. const num = parseFloat(value);
  249. if (isNaN(num)) {
  250. return '0.00';
  251. }
  252. // 处理负数
  253. const absoluteValue = Math.abs(num);
  254. const roundedValue = Math.round(absoluteValue * 100) / 100;
  255. const fixedValue = roundedValue.toFixed(2);
  256. return num < 0 ? `-${fixedValue}` : fixedValue;
  257. }
  258. </script>
  259. <style scoped lang="scss">
  260. .container {
  261. background-color: #f5f5f5;
  262. min-height: 100vh;
  263. padding-bottom: 180rpx;
  264. }
  265. /* 顶部用户信息 */
  266. .user-header {
  267. height: 600rpx;
  268. //background-image: url("https://sb-admin.oss-cn-shenzhen.aliyuncs.com/shuibei-mini/new-mini/jianbianBG.png");
  269. background-size: 100% 100%;
  270. padding: 150rpx 20rpx 20rpx;
  271. color: #fff;
  272. border-radius: 0 0 20rpx 20rpx;
  273. box-sizing: border-box;
  274. }
  275. .user-info {
  276. display: flex;
  277. justify-content: space-between;
  278. align-items: center;
  279. margin-bottom: 30rpx;
  280. }
  281. .user-main {
  282. display: flex;
  283. align-items: center;
  284. }
  285. .avatar {
  286. width: 120rpx;
  287. height: 120rpx;
  288. border-radius: 50%;
  289. background-color: #fff;
  290. margin-right: 30rpx;
  291. }
  292. .name-vip {
  293. //display: flex;
  294. //align-items: center;
  295. //margin-bottom: 16rpx;
  296. }
  297. .name {
  298. font-size: 32rpx;
  299. color: #333;
  300. }
  301. .phone{
  302. font-size: 28rpx;
  303. color:#666666;
  304. margin-top: 16rpx;
  305. }
  306. .vip-tag {
  307. width: 100rpx;
  308. margin-left: 16rpx;
  309. }
  310. .vip-expire, .login-tip {
  311. font-size: 28rpx;
  312. color: #666;
  313. }
  314. .btn-content {
  315. display: flex;
  316. flex-direction: column;
  317. align-items: center;
  318. justify-content: center;
  319. .setting{
  320. width: 40rpx;
  321. height: 40rpx;
  322. }
  323. .btn-text {
  324. font-size: 24rpx;
  325. color: #333;
  326. line-height: 1.5;
  327. }
  328. }
  329. /* 会员开通提示 */
  330. .vip-promote {
  331. height: 108rpx;
  332. width: 100%;
  333. height: 108rpx;
  334. padding: 0 30rpx;
  335. box-sizing: border-box;
  336. .vipBG{
  337. width: 100%;
  338. height: 100%;
  339. border-radius: 48rpx 48rpx 0 0;
  340. }
  341. .vip-text{
  342. margin-top: -108rpx;
  343. display: flex;
  344. width: 100%;
  345. justify-content: space-between;
  346. align-items: center;
  347. padding: 20rpx;
  348. box-sizing: border-box;
  349. .title{
  350. font-size: 28rpx;
  351. color: #BDAD8E;
  352. display: flex;
  353. justify-content: flex-start;
  354. align-items: center;
  355. .vipIcon{
  356. width: 70rpx;
  357. margin-right: 10rpx;
  358. }
  359. .bigText{
  360. font-size: 32rpx;
  361. color: #FACD8D;
  362. margin: 0 10rpx;
  363. }
  364. }
  365. .open-vip{
  366. width: 144rpx;
  367. height: 60rpx;
  368. line-height: 60rpx;
  369. font-size: 24rpx;
  370. color: #5D3D03;
  371. background: linear-gradient( 270deg, #FEE2A3 0%, #FDEBCC 100%);
  372. border-radius: 16rpx 16rpx 16rpx 16rpx;
  373. .bofang{
  374. width: 24rpx;
  375. margin-left: 10rpx;
  376. }
  377. }
  378. }
  379. }
  380. .desc {
  381. font-size: 22rpx;
  382. opacity: 0.9;
  383. }
  384. /* 钱包余额 */
  385. .wallet-section {
  386. background: #fff;
  387. margin: -280rpx 20rpx 20rpx;
  388. border-radius: 24rpx;
  389. padding: 30rpx;
  390. }
  391. .wallet-header {
  392. display: flex;
  393. justify-content: space-between;
  394. align-items: center;
  395. margin-bottom: 20rpx;
  396. }
  397. .wallet-title {
  398. font-size: 28rpx;
  399. color: #333;
  400. }
  401. .transaction-detail {
  402. color: #666;
  403. font-size: 24rpx;
  404. display: flex;
  405. align-items: center;
  406. }
  407. .balance {
  408. font-size: 48rpx;
  409. font-weight: bold;
  410. text-align: center;
  411. margin: 10rpx 0;
  412. color: #333;
  413. }
  414. .assets {
  415. display: flex;
  416. justify-content: space-between;
  417. margin-top: 40rpx;
  418. }
  419. .asset-item {
  420. text-align: center;
  421. flex: 1;
  422. }
  423. .asset-name {
  424. font-size: 24rpx;
  425. color: #666;
  426. margin-bottom: 16rpx;
  427. display: block;
  428. }
  429. .asset-amount {
  430. font-size: 32rpx;
  431. font-weight: bold;
  432. color: #333;
  433. display: block;
  434. }
  435. .wallet-actions {
  436. display: flex;
  437. justify-content: space-between;
  438. margin-top: 50rpx;
  439. }
  440. .wallet-btn {
  441. flex: 1;
  442. text-align: center;
  443. height: 88rpx;
  444. line-height: 88rpx;
  445. margin: 0 10rpx;
  446. border-radius: 16rpx;
  447. font-size: 32rpx;
  448. }
  449. /* 功能入口 */
  450. .function-grid {
  451. background: #fff;
  452. margin: 30rpx;
  453. border-radius: 24rpx;
  454. padding: 40rpx;
  455. }
  456. .functions {
  457. display: grid;
  458. grid-template-columns: repeat(4, 1fr);
  459. gap: 40rpx;
  460. margin-top: 40rpx;
  461. }
  462. .function-item {
  463. text-align: center;
  464. }
  465. .function-icon {
  466. .img{
  467. width: 60rpx;
  468. height: 60rpx;
  469. }
  470. }
  471. .function-name {
  472. font-size: 24rpx;
  473. color: #333;
  474. }
  475. .business {
  476. display: grid;
  477. grid-template-columns: repeat(3, 1fr);
  478. margin-top: 40rpx;
  479. }
  480. .business-item {
  481. text-align: center;
  482. margin-bottom: 30rpx;
  483. }
  484. .business-num{
  485. color: #333333;
  486. font-size: 40rpx;
  487. font-weight: bold;
  488. }
  489. .business-name{
  490. color: #333333;
  491. font-size: 24rpx;
  492. }
  493. /* 最近访问 */
  494. .recent-visit, .order-section, .common-functions {
  495. background: #fff;
  496. margin: 20rpx;
  497. border-radius: 16rpx;
  498. padding: 30rpx;
  499. }
  500. .section-header {
  501. display: flex;
  502. justify-content: space-between;
  503. align-items: center;
  504. margin-bottom: 20rpx;
  505. }
  506. .section-title {
  507. font-size: 32rpx;
  508. color: #333;
  509. }
  510. .more {
  511. font-size: 24rpx;
  512. color: #666;
  513. }
  514. .store-item {
  515. display: flex;
  516. align-items: center;
  517. justify-content: flex-start;
  518. padding: 20rpx;
  519. border-bottom: 2rpx solid #f0f0f0;
  520. background-color: #F9F7F0;
  521. border-radius: 16rpx;
  522. }
  523. .store-item:last-child {
  524. border-bottom: none;
  525. }
  526. .store-logo {
  527. .img{
  528. width: 100rpx;
  529. height: 100rpx;
  530. border-radius: 16rpx;
  531. margin-right: 30rpx;
  532. }
  533. }
  534. .store-name {
  535. font-size: 32rpx;
  536. color: #333;
  537. margin-bottom: 20rpx;
  538. display: block;
  539. }
  540. .store-desc {
  541. font-size: 24rpx;
  542. color: #666;
  543. display: block;
  544. }
  545. /* 订单状态 */
  546. .order-status {
  547. display: flex;
  548. justify-content: space-between;
  549. }
  550. .status-item {
  551. text-align: center;
  552. flex: 1;
  553. }
  554. .status-icon {
  555. .img{
  556. width: 60rpx;
  557. height: 60rpx;
  558. }
  559. }
  560. .status-name {
  561. font-size: 24rpx;
  562. color: #333;
  563. }
  564. /* 常用功能 */
  565. .common-functions .functions {
  566. grid-template-columns: repeat(4, 1fr);
  567. }
  568. .page-title{
  569. font-size: 36rpx;
  570. color: #333;
  571. }
  572. </style>