index.vue 14 KB

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