personalCenter.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. <template>
  2. <view class="app-container">
  3. <view class="container-mine">
  4. <uv-navbar
  5. title="个人中心"
  6. placeholder
  7. :bgColor="tabBg"
  8. leftIconSize="0"
  9. titleStyle="font-weight: 700;"
  10. />
  11. <view class="mine-top u-flex-center-sb">
  12. <view
  13. class="mine-top-user u-flex-center"
  14. @click.stop="goJump('/pages/setup/edit', true)"
  15. >
  16. <!-- src="/personalCenter/avatar.png" -->
  17. <image
  18. v-if="userInformation && userInformation.headPhoto"
  19. :src="userInformation.headPhoto"
  20. alt=""
  21. class="top-user-avatar"
  22. />
  23. <image
  24. class="top-user-avatar"
  25. v-else
  26. :src="$defaultAvatar"
  27. mode=""
  28. ></image>
  29. <view class="top-user-info" v-if="userInformation.id">
  30. <view class="top-user-name">{{ userInformation.nickname }}</view>
  31. <view class="top-user-phone u-flex-center">
  32. <image
  33. class="top-user-phone-img"
  34. :src="$handleImageUrl('/personalCenter/icon_phone.png')"
  35. alt=""
  36. />
  37. <text>{{ userInformation.mobile }}</text>
  38. </view>
  39. </view>
  40. <view class="top-user-info" v-else>
  41. <view class="top-user-name">登录/注册</view>
  42. </view>
  43. </view>
  44. <view
  45. class="mine-top-QRcode"
  46. v-if="userInformation.id"
  47. @click="showMembershipCode"
  48. >
  49. <image
  50. :src="$handleImageUrl('/personalCenter/icon_QR.png')"
  51. alt=""
  52. class="top-QRcode-img"
  53. />
  54. <view class="top-QRcode-text">会员码</view>
  55. </view>
  56. </view>
  57. <view class="mine-content">
  58. <view class="mine-content-item u-flex-center-sb">
  59. <view class="mine-content-item-view" @click="goToMyWallet">
  60. <image
  61. :src="$handleImageUrl('/personalCenter/bg_icon2.png')"
  62. alt=""
  63. class="mine-content-item-img"
  64. />
  65. <view class="mine-content-item-view">
  66. <view class="mine-content-item-title">我的余额</view>
  67. <view class="mine-content-item-value">{{
  68. $addDecimals(userInformation.balance || 0, 2)
  69. }}</view>
  70. <view class="mine-content-item-unit">元</view>
  71. </view>
  72. </view>
  73. <view class="mine-content-item-view" @click="goMypoints">
  74. <image
  75. :src="$handleImageUrl('/personalCenter/bg_icon1.png')"
  76. alt=""
  77. class="mine-content-item-img"
  78. />
  79. <view class="mine-content-item-view">
  80. <view class="mine-content-item-title">我的积分</view>
  81. <view class="mine-content-item-value">{{
  82. integralAble || 0
  83. }}</view>
  84. <view class="mine-content-item-unit">积分</view>
  85. </view>
  86. </view>
  87. </view>
  88. <view class="mine-content-order">
  89. <view class="mine-content-order-title">我的订单</view>
  90. <view class="mine-content-order-list">
  91. <view
  92. class="mine-content-order-item"
  93. @click.stop="goJump('/pages/order/mallOrder/orderList', true)"
  94. >
  95. <image
  96. class="mine-content-order-item-img1"
  97. :src="$handleImageUrl('/personalCenter/icon_mall.png')"
  98. alt=""
  99. />
  100. <view class="mine-content-order-item-title">商城订单</view>
  101. </view>
  102. <!-- <view class="order-item-line"> </view>
  103. <view
  104. class="mine-content-order-item"
  105. @click.stop="goJump('/pages/order/onlineOrder/list', true)"
  106. >
  107. <image
  108. class="mine-content-order-item-img1"
  109. :src="$handleImageUrl('/personalCenter/icon_online.png')"
  110. alt=""
  111. />
  112. <view class="mine-content-order-item-title">在线订单</view>
  113. </view>
  114. <view class="order-item-line"> </view>
  115. <view
  116. class="mine-content-order-item"
  117. @click.stop="goJump('/pages/order/queuingOrders/list', true)"
  118. >
  119. <image
  120. class="mine-content-order-item-img2"
  121. :src="$handleImageUrl('/personalCenter/icon_queue.png')"
  122. alt=""
  123. />
  124. <view class="mine-content-order-item-title">排队订单</view>
  125. </view> -->
  126. </view>
  127. </view>
  128. </view>
  129. <view class="app-center">
  130. <view class="app-center-title">
  131. <text>应用中心</text>
  132. </view>
  133. <view class="app-center-list">
  134. <view
  135. class="app-center-item"
  136. v-for="(item, index) in toolsList"
  137. :key="index"
  138. @click.stop="goSublevelPage(item)"
  139. >
  140. <template v-if="item.key == 'kf'">
  141. <!-- #ifdef MP-WEIXIN -->
  142. <button open-type="contact" class="app-center-item-button">
  143. <image
  144. :src="$handleImageUrl(item.icon)"
  145. alt=""
  146. class="app-center-item-img"
  147. />
  148. <view class="app-center-item-text">{{ item.label }}</view>
  149. </button>
  150. <!-- #endif -->
  151. <!-- #ifndef MP-WEIXIN -->
  152. <image
  153. :src="$handleImageUrl(item.icon)"
  154. alt=""
  155. class="app-center-item-img"
  156. />
  157. <view class="app-center-item-text">{{ item.label }}</view>
  158. <!-- #endif -->
  159. </template>
  160. <template v-else>
  161. <image
  162. :src="$handleImageUrl(item.icon)"
  163. alt=""
  164. class="app-center-item-img"
  165. />
  166. <view class="app-center-item-text">{{ item.label }}</view>
  167. </template>
  168. </view>
  169. </view>
  170. </view>
  171. <!-- 商家工作台 -->
  172. <image
  173. v-if="shopInfo.businessId && shopInfo.shelvedStatus"
  174. @click.stop="
  175. goSublevelPage({
  176. url: '/pages/shop/content/index',
  177. idNeedLogin: true,
  178. })
  179. "
  180. :src="$handleImageUrl('/personalCenter/img_workbench.png')"
  181. class="workbench"
  182. alt=""
  183. />
  184. </view>
  185. <!-- 会员码 -->
  186. <membershipCode ref="membershipCodeRef" />
  187. </view>
  188. </template>
  189. <script setup>
  190. import { ref } from "vue";
  191. import {
  192. onLoad,
  193. onShow,
  194. onPullDownRefresh,
  195. onPageScroll,
  196. } from "@dcloudio/uni-app";
  197. import { userInfo } from "@/api/login.js";
  198. import {
  199. messageUnreadNum_Api,
  200. totalIntegral_Api,
  201. businessUserInfo_Api,
  202. } from "@/api/userInfo.js";
  203. import utils from "@/util/index.js";
  204. const membershipCodeRef = ref(null);
  205. const userInformation = ref({});
  206. const myMsg = ref(0);
  207. const shopInfo = ref({}); // 商家信息
  208. const integralAble = ref(0); // 用户积分数据
  209. const toolsList = ref([
  210. {
  211. label: "我的拼团",
  212. icon: "/personalCenter/app_icon1.png",
  213. url: "/pages/groupBuying/myGbOrder/list",
  214. idNeedLogin: true,
  215. isPage: true,
  216. },
  217. {
  218. label: "分销中心",
  219. icon: "/personalCenter/app_icon1.png",
  220. url: "/pages/distribution/index",
  221. idNeedLogin: true,
  222. isPage: true,
  223. },
  224. {
  225. label: "收货地址",
  226. icon: "/personalCenter/app_icon1.png",
  227. url: "/pages/user/address/addressList?formType=mine",
  228. idNeedLogin: true,
  229. isPage: true,
  230. },
  231. {
  232. label: "个人信息",
  233. icon: "/personalCenter/app_icon2.png",
  234. url: "/pages/setup/edit",
  235. idNeedLogin: true,
  236. isPage: true,
  237. },
  238. {
  239. label: "我的优惠券",
  240. icon: "/personalCenter/app_icon3.png",
  241. url: "/pages/couponCenter/index?isMyCoupon=true",
  242. idNeedLogin: true,
  243. isPage: true,
  244. },
  245. {
  246. label: "优惠券中心",
  247. icon: "/personalCenter/app_icon12.png",
  248. url: "/pages/couponCenter/index",
  249. idNeedLogin: true,
  250. isPage: true,
  251. },
  252. {
  253. label: "我的收藏",
  254. icon: "/personalCenter/app_icon4.png",
  255. url: "/pages/user/collection",
  256. idNeedLogin: true,
  257. isPage: true,
  258. },
  259. {
  260. label: "商家入驻",
  261. icon: "/personalCenter/app_icon5.png",
  262. url: "/pages/user/merchant/settleIn?type=tenants_agreement",
  263. idNeedLogin: true,
  264. isPage: true,
  265. },
  266. // {
  267. // label: "代理中心",
  268. // icon: "/personalCenter/app_icon6.png",
  269. // url: "/pages/agencyCenter/index",
  270. // idNeedLogin: true,
  271. // isPage: true,
  272. // isAgent: true, // 是否为代理商才显示
  273. // },
  274. {
  275. label: "官方客服",
  276. icon: "/personalCenter/app_icon7.png",
  277. url: "",
  278. key: "kf",
  279. idNeedLogin: false,
  280. isPage: false,
  281. },
  282. {
  283. label: "常见问题",
  284. icon: "/personalCenter/app_icon8.png",
  285. url: "/pages/user/faq",
  286. idNeedLogin: false,
  287. isPage: true,
  288. },
  289. {
  290. label: "消息通知",
  291. icon: "/personalCenter/app_icon9.png",
  292. url: "/pages/user/myMsg",
  293. idNeedLogin: true,
  294. isPage: true,
  295. },
  296. {
  297. label: "投诉建议",
  298. icon: "/personalCenter/app_icon10.png",
  299. url: "/pages/set/feedback/index",
  300. idNeedLogin: true,
  301. isPage: true,
  302. },
  303. {
  304. label: "设置",
  305. icon: "/personalCenter/app_icon11.png",
  306. url: "/pages/set/index",
  307. idNeedLogin: true,
  308. isPage: true,
  309. },
  310. ]);
  311. const isSign = ref(false);
  312. const tabBg = ref("none");
  313. onPageScroll((e) => {
  314. // console.log(e.scrollTop)
  315. if (e.scrollTop > 10) {
  316. tabBg.value = "#ffffff";
  317. } else {
  318. tabBg.value = "none";
  319. }
  320. });
  321. // 获取商家信息
  322. const getbusinessUserInfo = () => {
  323. businessUserInfo_Api().then((res) => {
  324. if (res && res.code == 200) {
  325. shopInfo.value = res.data || {};
  326. }
  327. });
  328. };
  329. // 跳转我的积分
  330. function goMypoints() {
  331. if (!utils.isLoginTo(true)) {
  332. uni.navigateTo({
  333. url: "/pages/user/pointsList",
  334. });
  335. }
  336. }
  337. async function getAll() {
  338. await judgeLogin(); //判断是否登录
  339. if (utils.isLoginTo(true)) {
  340. getTotalIntegral();
  341. getbusinessUserInfo();
  342. await getUnreadNum(); //未读消息
  343. await getMyStatistics(); //登录消息
  344. uni.$forceUpdate();
  345. }
  346. }
  347. //获取未读消息
  348. function getUnreadNum() {
  349. messageUnreadNum_Api()
  350. .then((res) => {
  351. uni.stopPullDownRefresh();
  352. if (res && res.code == 200) {
  353. myMsg.value = res.data || 0;
  354. } else {
  355. myMsg.value = 0;
  356. }
  357. })
  358. .catch((err) => {
  359. myMsg.value = 0;
  360. });
  361. }
  362. //前往我的钱包
  363. function goToMyWallet() {
  364. if (utils.isLoginTo(true)) return;
  365. uni.navigateTo({
  366. url: "/pages/user/wallet/index",
  367. });
  368. }
  369. //判断是否登录
  370. async function judgeLogin() {
  371. // if (shop) {
  372. // return;
  373. userInfo().then((res) => {
  374. uni.stopPullDownRefresh();
  375. if (res && res.code == 200) {
  376. userInformation.value = res.data;
  377. isSign.value = res.data.sign_in;
  378. uni.setStorageSync("personal", res.data);
  379. }
  380. });
  381. }
  382. // 跳转子级页面
  383. const goSublevelPage = (item) => {
  384. if (item.idNeedLogin) {
  385. let url = item.url;
  386. if (item.isAgent && !userInformation.value.isAgent) {
  387. url = "/pages/agencyCenter/regionalAgent";
  388. }
  389. if (!utils.isLoginTo()) {
  390. uni.navigateTo({
  391. url,
  392. });
  393. } else {
  394. uni.$uv.toast("请先登录");
  395. }
  396. } else {
  397. if (item.key == "kf") {
  398. customerService();
  399. } else {
  400. uni.navigateTo({
  401. url: item.url,
  402. });
  403. }
  404. }
  405. };
  406. // 跳转页面
  407. const goJump = (url = "", isLogin = false) => {
  408. console.log("goJump", url, isLogin);
  409. if (!url) return;
  410. if (isLogin && utils.isLoginTo(isLogin)) return;
  411. uni.navigateTo({
  412. url,
  413. });
  414. };
  415. // 查询总积分
  416. const getTotalIntegral = () => {
  417. totalIntegral_Api().then((res) => {
  418. // console.log(res)
  419. if (res.code == 200) {
  420. integralAble.value = res.data || 0;
  421. }
  422. });
  423. };
  424. // 显示会员码
  425. const showMembershipCode = () => {
  426. membershipCodeRef.value.open();
  427. };
  428. // 客服
  429. const customerService = () => {
  430. // #ifdef APP-PLUS
  431. let sweixin;
  432. plus.share.getServices(
  433. (res) => {
  434. sweixin = res.find((i) => i.id === "weixin");
  435. if (sweixin) {
  436. sweixin.openCustomerServiceChat(
  437. {
  438. corpid: "wxf4cb2367022f4941",
  439. url: "https://work.weixin.qq.com/kfid/kfcfa748e7c99d682b8",
  440. },
  441. (suc) => {
  442. console.log("success", JSON.stringify(suc));
  443. },
  444. (err) => {
  445. console.log("error", JSON.stringify(err));
  446. }
  447. );
  448. } else {
  449. plus.nativeUI.alert("当前环境不支持微信操作!");
  450. }
  451. },
  452. function (e) {
  453. uni.showToast({
  454. title: "获取服务失败,不支持该操作。" + JSON.stringify(e),
  455. icon: "error",
  456. });
  457. }
  458. );
  459. // #endif
  460. };
  461. onLoad(() => {});
  462. //清空数据
  463. //显示弹出框
  464. onShow(async () => {
  465. let token = uni.getStorageSync("apiToken");
  466. if (token) {
  467. getTotalIntegral();
  468. getbusinessUserInfo();
  469. await judgeLogin()
  470. .then((res) => {
  471. // console.log('judgeLogin = res', res)
  472. })
  473. .catch((err) => {});
  474. await getUnreadNum();
  475. } else {
  476. integralAble.value = 0;
  477. shopInfo.value = {};
  478. myMsg.value = 0;
  479. userInformation.value = {};
  480. isSign.value = false;
  481. // uni.setStorageSync("personal", '');
  482. }
  483. });
  484. onPullDownRefresh(() => {
  485. let token = uni.getStorageSync("apiToken");
  486. if (!token) {
  487. uni.stopPullDownRefresh();
  488. } else {
  489. getAll();
  490. }
  491. });
  492. </script>
  493. <style scoped lang="scss">
  494. .app-container {
  495. background-color: #f7f8fa;
  496. }
  497. .container-mine {
  498. min-height: 100vh;
  499. box-sizing: border-box;
  500. padding: 23rpx;
  501. // background: url("/personalCenter/bg_icon.png");
  502. // 背景图片
  503. background: url("http://sly2020.oss-cn-beijing.aliyuncs.com/2025/11/25/040000f4d9254462bd559f27181bb7db.png");
  504. background-size: 100% 742rpx;
  505. background-repeat: no-repeat;
  506. .mine-top {
  507. padding-right: 60rpx;
  508. .mine-top-user {
  509. flex: 1;
  510. .top-user-avatar {
  511. width: 140rpx;
  512. height: 140rpx;
  513. border: 4rpx solid #ffffff;
  514. border-radius: 50%;
  515. flex-shrink: 0;
  516. }
  517. .top-user-info {
  518. margin-left: 20rpx;
  519. flex: 1;
  520. .top-user-name {
  521. font-size: 50rpx;
  522. color: #1a1a1a;
  523. font-weight: 700;
  524. }
  525. .top-user-phone {
  526. margin-top: 10rpx;
  527. .top-user-phone-img {
  528. width: 26rpx;
  529. height: 26rpx;
  530. }
  531. text {
  532. font-size: 28rpx;
  533. color: #1a1a1a;
  534. }
  535. }
  536. }
  537. }
  538. .mine-top-QRcode {
  539. flex-shrink: 0;
  540. margin-left: 20rpx;
  541. text-align: center;
  542. .top-QRcode-img {
  543. width: 57rpx;
  544. height: 57rpx;
  545. border-radius: 10rpx;
  546. margin: 0;
  547. }
  548. .top-QRcode-text {
  549. font-size: 24rpx;
  550. color: #1a1a1a;
  551. // margin-top: 10rpx;
  552. }
  553. }
  554. }
  555. .mine-content {
  556. margin-top: 30rpx;
  557. min-height: 447rpx;
  558. // opacity: 0.71;
  559. background: linear-gradient(180deg, #ffd0cc, #fbf3f3);
  560. border-radius: 20rpx;
  561. padding: 30rpx 24rpx;
  562. box-sizing: border-box;
  563. .mine-content-item {
  564. // background: #ffffff;
  565. border-radius: 20px;
  566. .mine-content-item-view {
  567. position: relative;
  568. width: 318rpx;
  569. height: 180rpx;
  570. .mine-content-item-img {
  571. position: absolute;
  572. left: 0;
  573. top: 0;
  574. width: 318rpx;
  575. height: 180rpx;
  576. z-index: 1;
  577. }
  578. .mine-content-item-view {
  579. position: relative;
  580. z-index: 2;
  581. display: flex;
  582. flex-direction: column;
  583. // align-items: center;
  584. justify-content: space-between;
  585. padding: 10rpx 20rpx 14rpx 20rpx;
  586. box-sizing: border-box;
  587. .mine-content-item-title {
  588. font-size: 30rpx;
  589. font-weight: 700;
  590. color: #1a1a1a;
  591. }
  592. .mine-content-item-value {
  593. font-size: 40rpx;
  594. font-weight: normal;
  595. color: #da4f4f;
  596. }
  597. .mine-content-item-unit {
  598. font-size: 28rpx;
  599. color: #666666;
  600. }
  601. }
  602. }
  603. }
  604. .mine-content-order {
  605. margin-top: 40rpx;
  606. .mine-content-order-title {
  607. font-size: 30rpx;
  608. font-weight: 600;
  609. color: #1a1a1a;
  610. margin-bottom: 15rpx;
  611. }
  612. .mine-content-order-list {
  613. display: flex;
  614. justify-content: space-around;
  615. align-items: center;
  616. .order-item-line {
  617. width: 1rpx;
  618. height: 85rpx;
  619. background: #e1d7d7;
  620. }
  621. .mine-content-order-item {
  622. text-align: center;
  623. .mine-content-order-item-img1 {
  624. width: 60rpx;
  625. height: 58rpx;
  626. }
  627. .mine-content-order-item-img2 {
  628. width: 48rpx;
  629. height: 58rpx;
  630. }
  631. .mine-content-order-item-title {
  632. margin-top: 13rpx;
  633. font-size: 24rpx;
  634. font-weight: 400;
  635. color: #1a1a1a;
  636. }
  637. }
  638. }
  639. }
  640. }
  641. .app-center {
  642. margin-top: 30rpx;
  643. padding: 38rpx 24rpx 12rpx 24rpx;
  644. box-sizing: border-box;
  645. min-height: 468rpx;
  646. background: #ffffff;
  647. border-radius: 20rpx;
  648. .app-center-title {
  649. font-size: 30rpx;
  650. font-weight: 600;
  651. color: #1a1a1a;
  652. margin-bottom: 34rpx;
  653. }
  654. .app-center-list {
  655. display: grid;
  656. grid-template-columns: repeat(4, 1fr);
  657. /* 创建4列,每列占据可用空间 */
  658. gap: 10rpx;
  659. /* 可选,设置网格之间的间隔 */
  660. text-align: center;
  661. .app-center-item-button {
  662. line-height: initial;
  663. background-color: #ffffff !important;
  664. border: 1rpx solid #ffffff !important;
  665. padding: 0;
  666. &:after {
  667. border: none !important;
  668. }
  669. }
  670. .app-center-item-img {
  671. width: 47rpx;
  672. height: 47rpx;
  673. }
  674. .app-center-item-text {
  675. font-size: 26rpx;
  676. font-weight: 400;
  677. color: #1a1a1a;
  678. margin-top: 10rpx;
  679. margin-bottom: 26rpx;
  680. }
  681. }
  682. }
  683. .workbench {
  684. width: 704rpx;
  685. height: 197rpx;
  686. border-radius: 20rpx;
  687. margin-top: 30rpx;
  688. }
  689. }
  690. </style>