index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. <template>
  2. <view class="index">
  3. <view class="head-back">
  4. <image src="/static/newIndex/index-bg.png" mode="widthFix"></image>
  5. </view>
  6. <view class="head">
  7. <!-- 顶部状态栏占位 -->
  8. <view class="top"></view>
  9. <!-- 头部内容 -->
  10. <view class="header">
  11. <view class="shop-info" @click="shopDetails">
  12. <view class="logo">
  13. <image :src="logo ? logo : '/static/index/address.png'" mode="aspectFill"></image>
  14. </view>
  15. <view class="shop-meta">
  16. <view class="shop-name">
  17. <text class="name-text">{{ name }}</text>
  18. <image class="down-icon" src="/static/index/down.png" mode=""></image>
  19. </view>
  20. <view class="phone">手机号 {{ phone || '--' }}</view>
  21. </view>
  22. </view>
  23. <view class="logout-btn" @click.stop="loginOut">退出账号</view>
  24. </view>
  25. <view class="data_box">
  26. <view class="data">
  27. <view class="item">
  28. <span>{{ numberOrders || 0 }}</span>订单数
  29. </view>
  30. <view class="item">
  31. <span>{{ turnover || 0 }}</span>营业总额(元)
  32. </view>
  33. <view class="item" @click="goUser">
  34. <span>{{ newCustomer || 0 }}</span>新客
  35. </view>
  36. </view>
  37. </view>
  38. </view>
  39. <view class="service">
  40. <view class="main">
  41. <view class="left">
  42. <view class="scan blue" @click="scanRecord">
  43. <view class="">
  44. <span>核销记录</span><br />
  45. 查看历史核销记录<u-icon name="arrow-right"></u-icon>
  46. </view>
  47. <view class="back">
  48. <image src="/static/index/recores-back.png" mode=""></image>
  49. </view>
  50. <image src="/static/index/scan.png" mode=""></image>
  51. </view>
  52. <view class="scan green" @click="goOrder">
  53. <view class="">
  54. <span>售卖订单</span><br />
  55. 查看历史售卖记录<u-icon name="arrow-right"></u-icon>
  56. </view>
  57. <view class="back">
  58. <image src="/static/index/order-back.png" mode=""></image>
  59. </view>
  60. <image src="/static/index/order.png" mode=""></image>
  61. </view>
  62. </view>
  63. <view class="right" @click="scan">
  64. <span>核销扫码</span><br />
  65. 扫一扫快速核销<u-icon name="arrow-right" style="margin-left: 10rpx;"></u-icon>
  66. <view class="back">
  67. <image src="/static/index/scan-back.png" mode=""></image>
  68. </view>
  69. <image src="/static/index/records.png" mode=""></image>
  70. </view>
  71. </view>
  72. <view class="other">
  73. <indexNav :showTopUp="showTopUp" :showGroupMeal="showGroupMeal" />
  74. </view>
  75. </view>
  76. <!-- 消息通知 -->
  77. <view class="message">
  78. <view class="msg-head">
  79. <text class="title">消息通知</text>
  80. <view class="more" @click="goMessage">
  81. 查看更多
  82. <u-icon name="arrow-right" color="#999" size="24"></u-icon>
  83. </view>
  84. </view>
  85. <view class="msg" v-if="msg.length">
  86. <view class="item" v-for="(item, index) in msg" :key="item.id || index" @click="toNotification(item)">
  87. <view class="type">
  88. <view class="img">
  89. <image :src="msgIcon(item.category)" mode=""></image>
  90. <span>{{ item.categoryName }}</span>
  91. </view>
  92. </view>
  93. <view class="details">{{ item.content }}</view>
  94. <view class="time">{{ item.createTimeDisplay }}</view>
  95. </view>
  96. </view>
  97. <view class="msg-empty" v-else>暂无消息</view>
  98. </view>
  99. <!-- 完善信息弹窗,storeStatus == 3 (店铺已经审核通过 ) -->
  100. <checkPopup :status="storeStatus" :describe="describe" :referenceId="referenceId" @cutPopup="isPopup = false"
  101. v-if="isPopup" />
  102. </view>
  103. </template>
  104. <script>
  105. import indexNav from "@/components/index_nav.vue";
  106. import checkPopup from "@/components/check-popup.vue";
  107. import prepaidApi from "@/api/memberPrepaid.js";
  108. import api from "@/api/api";
  109. import { updateMsgTabBadge, setMsgTabBadge, isUnreadNotice } from "@/common/util/msgBadge.js";
  110. export default {
  111. components: {
  112. indexNav,
  113. checkPopup,
  114. },
  115. data() {
  116. return {
  117. numberOrders: "", //订单
  118. newCustomer: "", //新客
  119. turnover: "", //营业总额
  120. name: "",
  121. phone: "",
  122. msg: [],
  123. categoryIcons: {
  124. "1": "/static/index/deal.png",
  125. "2": "/static/index/verify.png",
  126. "3": "/static/index/system.png",
  127. },
  128. merchantId: "",
  129. storeStatus: 0, //商户店铺设置状态
  130. userId: "", //用户id
  131. describe: "", //描述
  132. isPopup: false, //弹窗是否出现
  133. referenceId: "", //邀请码
  134. logo: "",
  135. showTopUp: false, // 行业是否为美食
  136. showGroupMeal: false, // 团餐报名是否审核通过
  137. };
  138. },
  139. onLoad: function() {
  140. this.PageCur = "home";
  141. ++this.commponent1Key;
  142. ++this.commponent2Key;
  143. },
  144. methods: {
  145. NavChange: function(e) {
  146. this.PageCur = e.currentTarget.dataset.cur;
  147. },
  148. //新客
  149. goUser() {
  150. uni.navigateTo({
  151. url: "/pages/index/userControl",
  152. });
  153. },
  154. //扫码核销
  155. scan() {
  156. uni.navigateTo({
  157. url: "/pages/scan/manual",
  158. });
  159. },
  160. goOrder() {
  161. uni.switchTab({
  162. url: "/pages/order/index",
  163. });
  164. },
  165. goMessage() {
  166. uni.switchTab({
  167. url: "/pages/message/message",
  168. });
  169. },
  170. msgIcon(category) {
  171. return this.categoryIcons[category] || "/static/index/system.png";
  172. },
  173. toNotification(item) {
  174. const str = this.$u.queryParams(item);
  175. uni.navigateTo({
  176. url: `/pages/message/details?${str}`,
  177. });
  178. },
  179. //跳转至门店详情页
  180. shopDetails() {
  181. uni.navigateTo({
  182. url: "/pages/index/shop",
  183. });
  184. },
  185. scanRecord() {
  186. uni.navigateTo({
  187. url: "/pages/scan/record",
  188. });
  189. },
  190. loginOut() {
  191. uni.showModal({
  192. title: "提示",
  193. content: "是否确认退出当前账号?",
  194. success: (res) => {
  195. if (res.confirm) {
  196. api.logout().then(() => {
  197. setMsgTabBadge(0);
  198. uni.clearStorageSync();
  199. uni.navigateTo({
  200. url: `/pages/login/login`,
  201. });
  202. });
  203. }
  204. },
  205. });
  206. },
  207. gettodayData() {
  208. this.$http
  209. .get("/merchant/account/todayOverview", {})
  210. .then((res) => {
  211. if (res.data.code == 200) {
  212. this.turnover = res.data.result.turnover;
  213. this.numberOrders = res.data.result.numberOrders;
  214. this.newCustomer = res.data.result.newCustomer;
  215. }
  216. });
  217. },
  218. getMessage() {
  219. this.$http
  220. .get("/localUserNotice/localUserNotice/getListNew", {
  221. params: {
  222. userType: 1,
  223. },
  224. })
  225. .then((res) => {
  226. const list = res.data.result || [];
  227. // 首页只展示未读,已读不展示
  228. this.msg = list.filter(isUnreadNotice).slice(0, 5);
  229. })
  230. .catch(() => {
  231. this.msg = [];
  232. });
  233. updateMsgTabBadge();
  234. },
  235. // getNum 已合并到 gettodayData,新客由 /merchant/account/todayOverview 返回
  236. getNum() {},
  237. //获取商户是否完善店铺信息
  238. getStroeStatus() {
  239. this.$http
  240. .get("/merchant/app/checkMerchantInfo?userId=" + this.userId)
  241. .then((res) => {
  242. if (res.data.code == 200) {
  243. //message == 3(审核已通过)
  244. if (res.data.result != 3) {
  245. this.storeStatus = res.data.result;
  246. this.describe = res.data.message;
  247. res.data.result == 3 ?
  248. (this.isPopup = false) :
  249. (this.isPopup = true);
  250. uni.hideTabBar();
  251. }
  252. }
  253. });
  254. },
  255. /** 查询行业是否支持储值,控制首页储值管理入口 */
  256. checkTopUpEligibility() {
  257. if (!this.merchantId) {
  258. this.showTopUp = false;
  259. return;
  260. }
  261. prepaidApi
  262. .checkIndustryEligibility(this.merchantId)
  263. .then((res) => {
  264. this.showTopUp = res.data.code === 200 && !!res.data.result;
  265. })
  266. .catch(() => {
  267. this.showTopUp = false;
  268. });
  269. },
  270. /** 查询团餐报名状态,审核通过才展示团餐设置/团餐订单 */
  271. checkGroupMealApply() {
  272. this.$http
  273. .post("/groupmeal/gmMerchantApplicationRecord/isApply", {})
  274. .then((res) => {
  275. this.showGroupMeal =
  276. res.data.code === 200 &&
  277. !!res.data.result &&
  278. res.data.result.status == 1;
  279. })
  280. .catch(() => {
  281. this.showGroupMeal = false;
  282. });
  283. },
  284. },
  285. mounted() {
  286. let that = this;
  287. },
  288. onShow() {
  289. let that = this;
  290. uni.getStorage({
  291. key: "login_user_info",
  292. success: function(res) {
  293. that.name = res.data.merchantName;
  294. that.merchantId = res.data.merchantId;
  295. that.userId = res.data.id;
  296. that.logo = res.data.merchantHeadPhoto;
  297. that.phone = res.data.phone || "";
  298. that.gettodayData();
  299. that.getMessage();
  300. that.getNum();
  301. that.getStroeStatus();
  302. that.checkTopUpEligibility();
  303. that.checkGroupMealApply();
  304. },
  305. });
  306. },
  307. };
  308. </script>
  309. <style scoped lang="scss">
  310. .index {
  311. width: 100vw;
  312. min-height: 100vh;
  313. background: #f2f3f5;
  314. padding-bottom: 40rpx;
  315. position: relative;
  316. z-index: 1;
  317. .head-back {
  318. position: absolute;
  319. top: 0;
  320. left: 0;
  321. width: 100%;
  322. z-index: 1;
  323. pointer-events: none;
  324. image {
  325. width: 100%;
  326. display: block;
  327. }
  328. }
  329. .head {
  330. width: 100%;
  331. height: auto;
  332. position: relative;
  333. overflow: hidden;
  334. z-index: 2;
  335. .top {
  336. width: 100%;
  337. height: var(--status-bar-height);
  338. background-color: transparent;
  339. }
  340. .header {
  341. width: 100%;
  342. display: flex;
  343. align-items: center;
  344. justify-content: space-between;
  345. padding: 16rpx 0rpx 0rpx 32rpx;
  346. position: relative;
  347. z-index: 10;
  348. .shop-info {
  349. flex: 1;
  350. display: flex;
  351. align-items: center;
  352. min-width: 0;
  353. margin-right: 20rpx;
  354. }
  355. .logo {
  356. width: 72rpx;
  357. height: 72rpx;
  358. border-radius: 50%;
  359. overflow: hidden;
  360. margin-right: 16rpx;
  361. flex-shrink: 0;
  362. image {
  363. width: 72rpx;
  364. height: 72rpx;
  365. margin: 0;
  366. }
  367. }
  368. .shop-meta {
  369. flex: 1;
  370. min-width: 0;
  371. }
  372. .shop-name {
  373. display: flex;
  374. align-items: center;
  375. font-size: 32rpx;
  376. font-weight: 600;
  377. color: #1d2129;
  378. line-height: 44rpx;
  379. .name-text {
  380. overflow: hidden;
  381. text-overflow: ellipsis;
  382. white-space: nowrap;
  383. max-width: 360rpx;
  384. }
  385. .down-icon {
  386. width: 24rpx;
  387. height: 24rpx;
  388. margin-left: 8rpx;
  389. flex-shrink: 0;
  390. }
  391. }
  392. .phone {
  393. margin-top: 4rpx;
  394. font-size: 24rpx;
  395. color: #86909c;
  396. line-height: 34rpx;
  397. }
  398. .logout-btn {
  399. flex-shrink: 0;
  400. padding: 10rpx 24rpx;
  401. font-size: 24rpx;
  402. color: #4e5969;
  403. background: rgba(255, 255, 255, 0.72);
  404. border-radius: 28rpx 0rpx 0rpx 28rpx;
  405. line-height: 34rpx;
  406. }
  407. }
  408. .data_box {
  409. width: 686rpx;
  410. margin: 28rpx auto 16rpx;
  411. background: #ffffff;
  412. box-shadow: 0px 2rpx 8rpx 0px rgba(214, 225, 237, 0.1);
  413. border-radius: 16rpx;
  414. position: relative;
  415. z-index: 19;
  416. .data {
  417. display: flex;
  418. justify-content: space-around;
  419. align-items: center;
  420. padding: 36rpx 0;
  421. .item {
  422. display: flex;
  423. flex-direction: column;
  424. justify-content: space-around;
  425. align-items: center;
  426. font-size: 24rpx;
  427. line-height: 28rpx;
  428. color: #86909c;
  429. span {
  430. height: 62rpx;
  431. color: #333;
  432. font-size: 48rpx;
  433. font-weight: 600;
  434. line-height: 56rpx;
  435. }
  436. }
  437. }
  438. }
  439. }
  440. .service {
  441. width: 686rpx;
  442. box-shadow: 0px 2rpx 8rpx 0px rgba(214, 225, 237, 0.1);
  443. border-radius: 16rpx;
  444. margin: 0 auto;
  445. position: relative;
  446. z-index: 2;
  447. .main {
  448. height: auto;
  449. display: flex;
  450. justify-content: space-between;
  451. margin-bottom: 16rpx;
  452. align-items: stretch;
  453. background: #ffffff;
  454. padding: 20rpx;
  455. border-radius: 20rpx;
  456. .left {
  457. flex: 1;
  458. margin-right: 22rpx;
  459. height: 340rpx;
  460. display: flex;
  461. flex-direction: column;
  462. justify-content: space-between;
  463. .scan {
  464. font-size: 20rpx;
  465. font-weight: 600;
  466. width: 352rpx;
  467. height: 160rpx;
  468. padding: 10rpx 12rpx 16rpx 28rpx;
  469. display: flex;
  470. justify-content: space-between;
  471. align-items: center;
  472. position: relative;
  473. z-index: 2;
  474. border-radius: 8rpx;
  475. overflow: hidden;
  476. .back {
  477. width: 100%;
  478. height: 100%;
  479. position: absolute;
  480. bottom: 0;
  481. right: 0;
  482. z-index: -1;
  483. image {
  484. width: 100%;
  485. height: 100%;
  486. }
  487. }
  488. span {
  489. font-size: 32rpx;
  490. }
  491. image {
  492. width: 138rpx;
  493. height: 134rpx;
  494. }
  495. }
  496. .scan.blue {
  497. color: #197ffd;
  498. margin-bottom: 22rpx;
  499. }
  500. .scan.green {
  501. color: #14c584;
  502. background: #e7fff7;
  503. }
  504. }
  505. .right {
  506. width: 272rpx;
  507. height: 340rpx;
  508. color: #624fe3;
  509. font-size: 20rpx;
  510. padding: 28rpx;
  511. background: #f6f4ff;
  512. position: relative;
  513. z-index: 2;
  514. border-radius: 8rpx;
  515. overflow: hidden;
  516. .back {
  517. width: 100%;
  518. height: 100%;
  519. position: absolute;
  520. bottom: 0;
  521. right: 0;
  522. z-index: -1;
  523. image {
  524. width: 100%;
  525. height: 100%;
  526. }
  527. }
  528. span {
  529. font-weight: 600;
  530. font-size: 32rpx;
  531. margin-bottom: 10rpx;
  532. }
  533. image {
  534. width: 182rpx;
  535. height: 214rpx;
  536. margin: 8rpx auto 0;
  537. }
  538. }
  539. }
  540. .other {
  541. width: 100%;
  542. padding: 32rpx;
  543. background: #ffffff;
  544. border-radius: 16rpx;
  545. }
  546. }
  547. .message {
  548. width: 686rpx;
  549. padding: 28rpx 24rpx 8rpx;
  550. margin: 16rpx auto 0;
  551. background: #ffffff;
  552. border-radius: 16rpx;
  553. position: relative;
  554. z-index: 2;
  555. .msg-head {
  556. width: 100%;
  557. display: flex;
  558. align-items: center;
  559. justify-content: space-between;
  560. margin-bottom: 8rpx;
  561. .title {
  562. font-size: 30rpx;
  563. font-weight: 600;
  564. color: #1d2129;
  565. }
  566. .more {
  567. display: flex;
  568. align-items: center;
  569. font-size: 24rpx;
  570. color: #86909c;
  571. }
  572. }
  573. .msg {
  574. width: 100%;
  575. .item {
  576. width: 100%;
  577. padding: 24rpx 0;
  578. border-bottom: 1px solid #f2f3f5;
  579. &:last-child {
  580. border-bottom: none;
  581. }
  582. .type {
  583. width: 100%;
  584. height: 38rpx;
  585. display: flex;
  586. align-items: center;
  587. margin-bottom: 8rpx;
  588. .img {
  589. font-size: 28rpx;
  590. font-weight: 600;
  591. color: #1d2129;
  592. display: flex;
  593. align-items: center;
  594. image {
  595. width: 36rpx;
  596. height: 36rpx;
  597. margin-right: 10rpx;
  598. }
  599. }
  600. }
  601. .details {
  602. font-size: 24rpx;
  603. color: #86909c;
  604. line-height: 36rpx;
  605. margin-bottom: 8rpx;
  606. }
  607. .time {
  608. font-size: 22rpx;
  609. color: #c9cdd4;
  610. }
  611. }
  612. }
  613. .msg-empty {
  614. padding: 40rpx 0 48rpx;
  615. text-align: center;
  616. font-size: 24rpx;
  617. color: #c9cdd4;
  618. }
  619. }
  620. }
  621. </style>