index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. <template>
  2. <Theme>
  3. <view class="wrap">
  4. <view class="cont">
  5. <Navbar bgColor="transparent" fixed height="0px" leftShow />
  6. <view class="cont_bg">
  7. <view class="bg_top">
  8. <view class="top_left">
  9. <image
  10. :src="userInfo.userimg"
  11. mode="widthFix"
  12. class="userInfo_avatar"
  13. >
  14. </image>
  15. <!-- <view class="btns" v-if="!token">
  16. <view class="btn">
  17. <trans _t="登录" />
  18. </view>
  19. <view class="btn is_plain">
  20. <trans _t="注册" />
  21. </view>
  22. </view> -->
  23. <view class="userInfo_" v-if="token">
  24. <view class="user_name"> {{ userInfo.username }}</view>
  25. <view class="user_id">
  26. <trans _t="ID" />: {{ userInfo.newid }}
  27. </view>
  28. </view>
  29. </view>
  30. <view class="bg_right" @click="onEdit">
  31. <image src="../../static/user/edit.png" class="img"></image>
  32. </view>
  33. </view>
  34. <view class="bg_logo">{{ verConfig.appNames }}</view>
  35. <!-- <view class="info_wrapper">
  36. <view class="info_item" v-for="item, index in infoItem" :key="index" @click="item.callback">
  37. <view class="item_num">{{ item.value }}</view>
  38. <trans class="item_text" :_t="item.text" />
  39. </view>
  40. </view> -->
  41. </view>
  42. <view class="entry_container">
  43. <view class="entry_wrapper">
  44. <view
  45. class="entry_item"
  46. v-for="(item, index) in entryList"
  47. :key="index"
  48. @click="item.callback"
  49. >
  50. <view class="icons">
  51. <view class="icons_img">
  52. <image
  53. class="img"
  54. :src="`../../static/user/${item.icon}.png`"
  55. ></image>
  56. </view>
  57. <view class="entry_num" v-if="item.num > 0">{{
  58. item.num
  59. }}</view>
  60. </view>
  61. <trans class="entry_text" :_t="item.text" />
  62. </view>
  63. </view>
  64. </view>
  65. <view class="content">
  66. <view class="menu_title">
  67. <trans _t="其他功能" />
  68. </view>
  69. <!-- <plaCard mode="horizontal" /> -->
  70. <view class="entry_container user_menu">
  71. <view class="entry_wrapper">
  72. <view
  73. class="entry_item"
  74. v-for="(item, index) in card"
  75. :key="index"
  76. @click="handleTo(item.url)"
  77. >
  78. <view class="icons">
  79. <view class="icons_img">
  80. <image
  81. class="img"
  82. :src="`../../static/user/${item.icon}.png`"
  83. ></image>
  84. </view>
  85. <view class="entry_num" v-if="item.num > 0">{{
  86. item.num
  87. }}</view>
  88. </view>
  89. <trans class="entry_text" :_t="item.text" />
  90. </view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. <view class="footer">
  96. <view class="switch_user_type" @click="switchUserType">
  97. <trans _t="切换到买家模式" />
  98. </view>
  99. <view class="exit_btn" @click="exit">
  100. <trans _t="退出登录" />
  101. </view>
  102. <view class="version">v {{ manifest.versionName }}</view>
  103. </view>
  104. </view>
  105. <Tabbar page="user" />
  106. <SimpleAgreementModal
  107. ref="agreementModal"
  108. :type="agreementType"
  109. @close="handleAgreementModalClose"
  110. />
  111. </Theme>
  112. </template>
  113. <script setup>
  114. import Tabbar from "@/components/tabbar";
  115. import Navbar from "@/components/navbar";
  116. import SimpleAgreementModal from "@/components/simpleAgreementModal";
  117. import plaCard from "@/components/placard";
  118. import { computed, watch, ref, reactive, onMounted, nextTick } from "vue";
  119. import { storeToRefs } from "pinia";
  120. import {
  121. useUserStore,
  122. useTabbarStore,
  123. useShopStore,
  124. useSystemStore,
  125. useMessageStore,
  126. } from "@/store";
  127. import { t } from "@/locale";
  128. import { onShow, onLoad } from "@dcloudio/uni-app";
  129. import verConfig from "@/ver.config";
  130. import manifest from "@/manifest.json";
  131. import { Modal, Toast } from "@/utils";
  132. import { USER_ORDER_COUNT } from "@/api";
  133. const useUser = useUserStore();
  134. const useTabbar = useTabbarStore();
  135. const useSystem = useSystemStore();
  136. const useMessage = useMessageStore();
  137. const { globalMap } = storeToRefs(useMessage);
  138. const unreadCount = ref(0);
  139. const customerUnreadCount = ref(0);
  140. watch(
  141. () => globalMap.value.serviceChannel,
  142. (newVal, oldVal) => {
  143. if (newVal) {
  144. unreadCount.value = newVal.unreadCount;
  145. }
  146. },
  147. {
  148. deep: true,
  149. immediate: true,
  150. }
  151. );
  152. watch(
  153. () => globalMap.value.noticeChannel,
  154. (newVal, oldVal) => {
  155. if (newVal) {
  156. customerUnreadCount.value = newVal.unreadCount;
  157. }
  158. },
  159. {
  160. deep: true,
  161. immediate: true,
  162. }
  163. );
  164. const useShop = useShopStore();
  165. const userInfo = computed(() => useUser.getuserInfo);
  166. const token = computed(() => useUser.getToken);
  167. // const cartNum = computed(() => useShop.getCartNum)
  168. const statics = computed(() => useUser.getStatics);
  169. const agreementType = ref("");
  170. const infoItem = computed(() => {
  171. return [
  172. {
  173. value: "¥ " + (userInfo.value.money || "0.00"),
  174. text: "余额",
  175. callback: () => {
  176. uni.navigateTo({ url: "/pages/bank/wallet" });
  177. },
  178. },
  179. {
  180. value: statics.value.coupon || 0,
  181. text: "优惠券",
  182. callback: () => {},
  183. },
  184. {
  185. value: statics.value.collect || 0,
  186. text: "收藏夹",
  187. callback: () => {
  188. uni.navigateTo({ url: "/pages/dashboard/favorites" });
  189. },
  190. },
  191. ];
  192. });
  193. const entryList = ref([
  194. {
  195. icon: "allwet",
  196. text: "钱包",
  197. num: 0,
  198. callback: () => {
  199. uni.navigateTo({ url: "/pages/bank/wallet" });
  200. },
  201. },
  202. {
  203. icon: "payment",
  204. text: "待支付",
  205. num: 0,
  206. callback: () => {
  207. useShop.setTabParams({
  208. tab: 0,
  209. type: 1,
  210. status: 100,
  211. });
  212. uni.switchTab({ url: "/pages/order/index" });
  213. useTabbar.getPageCur("order");
  214. },
  215. },
  216. {
  217. icon: "storage",
  218. text: "待入库",
  219. num: 0,
  220. callback: () => {
  221. useShop.setTabParams({
  222. tab: 0,
  223. type: 3,
  224. status: 500,
  225. });
  226. uni.switchTab({ url: "/pages/order/index" });
  227. useTabbar.getPageCur("order");
  228. },
  229. },
  230. {
  231. icon: "inspection",
  232. text: "待质检",
  233. num: 0,
  234. callback: () => {
  235. useShop.setTabParams({
  236. tab: 0,
  237. type: 4,
  238. status: 520,
  239. });
  240. uni.switchTab({ url: "/pages/order/index" });
  241. useTabbar.getPageCur("order");
  242. },
  243. },
  244. {
  245. icon: "consolidation",
  246. text: "待集运",
  247. num: 0,
  248. callback: () => {
  249. useShop.setTabParams({
  250. tab: 2,
  251. type: 1,
  252. status: 100,
  253. });
  254. uni.switchTab({ url: "/pages/order/index" });
  255. useTabbar.getPageCur("order");
  256. },
  257. },
  258. {
  259. icon: "refund",
  260. text: "退款和售后",
  261. num: 0,
  262. callback: () => {
  263. useShop.setTabParams({
  264. tab: 0,
  265. type: 5,
  266. status: 40,
  267. });
  268. uni.switchTab({ url: "/pages/order/index" });
  269. useTabbar.getPageCur("order");
  270. },
  271. },
  272. ]);
  273. const card = [
  274. {
  275. icon: "weal",
  276. text: "福利中心",
  277. url: "/pages/user/weal_center",
  278. },
  279. // {
  280. // icon: "coupon",
  281. // text: "我的优惠券",
  282. // url: "/pages/user/coupon",
  283. // },
  284. {
  285. icon: "address",
  286. text: "我的地址",
  287. url: "/pages/address/index",
  288. },
  289. {
  290. icon: "invite",
  291. text: "邀请有礼",
  292. url: "/pages/user/invite",
  293. },
  294. {
  295. icon: "store",
  296. text: "门店",
  297. url: "/pages/user/mystore",
  298. },
  299. // {
  300. // icon: "attest",
  301. // text: "实名认证",
  302. // url: "/pages/user/verification",
  303. // },
  304. {
  305. icon: "setting",
  306. text: "系统设置",
  307. url: "/pages/setting/index",
  308. },
  309. {
  310. icon: "message",
  311. text: "系统消息",
  312. url: "/pages/user/message/list",
  313. },
  314. {
  315. icon: "sift",
  316. text: "VAVA精选",
  317. url: "",
  318. },
  319. {
  320. icon: "repo",
  321. text: "我要回购",
  322. url: "/pages/repo/index",
  323. },
  324. {
  325. icon: "kefu",
  326. text: "客服中心",
  327. url: "/pages/setting/system",
  328. },
  329. {
  330. icon: "purpose",
  331. text: "意向表单",
  332. url: "/pages/purpose/index",
  333. },
  334. {
  335. icon: "store",
  336. text: "店铺订单",
  337. url: "/pages/store/index",
  338. },
  339. ];
  340. const exit = () => {
  341. Modal({ content: t("确定要退出登录吗") }).then(async () => {
  342. useUser.loginOut();
  343. });
  344. };
  345. const handleTo = (url) => {
  346. if (!url) return Toast(t("敬请期待"));
  347. if (url === "service") return useSystem.service();
  348. uni.navigateTo({ url });
  349. };
  350. const onEdit = () => {
  351. uni.navigateTo({ url: "/pages/user/edit_user" });
  352. };
  353. const getCount = async () => {
  354. try {
  355. const res = await USER_ORDER_COUNT();
  356. entryList.value[1].num = res.data.waitPay;
  357. entryList.value[2].num = res.data.waitStock;
  358. entryList.value[3].num = res.data.waitJian;
  359. entryList.value[4].num = res.data.waitPackage;
  360. entryList.value[5].num = res.data.retund;
  361. } catch (error) {
  362. Toast(error.msg);
  363. }
  364. };
  365. onMounted(() => {});
  366. onLoad(() => {
  367. // useUser.getUserInfo();
  368. });
  369. onShow(() => {
  370. useUser.getUserInfo({}, { isLoading: true });
  371. getCount();
  372. // useUser.setStatics();
  373. });
  374. uni.hideTabBar();
  375. const handleAgreementModalClose = () => {
  376. agreementType.value = "";
  377. };
  378. // 切换用户类型
  379. const switchUserType = () => {
  380. Modal({
  381. content: t("确定要切换到买家模式吗?切换后底部导航将显示买家功能"),
  382. }).then(() => {
  383. // 设置为买家类型
  384. useUser.setUserType(0);
  385. // 跳转到买家首页
  386. uni.reLaunch({
  387. url: "/pagesBuyer/home/index",
  388. });
  389. });
  390. };
  391. </script>
  392. <style lang="less" scoped>
  393. @import url("@/style.less");
  394. .wrap {
  395. background: var(--bg);
  396. min-height: 100vh;
  397. padding-bottom: calc(90rpx + constant(safe-area-inset-bottom));
  398. padding-bottom: calc(90rpx + env(safe-area-inset-bottom));
  399. .flex();
  400. flex-direction: column;
  401. justify-content: space-between;
  402. .cont {
  403. padding-bottom: 24rpx;
  404. flex-grow: 1;
  405. &_bg {
  406. background: var(--black);
  407. border-radius: 0 0 20rpx 20rpx;
  408. position: relative;
  409. .bg_top {
  410. .flex_position(space-between);
  411. padding: 40rpx 40rpx 140rpx;
  412. position: relative;
  413. z-index: 1;
  414. .top_left {
  415. .flex();
  416. .userInfo_avatar {
  417. width: 120rpx;
  418. height: 120rpx;
  419. border-radius: 50%;
  420. }
  421. .btns {
  422. .ver();
  423. margin-left: 24rpx;
  424. column-gap: 20rpx;
  425. .btn {
  426. .flex_center();
  427. background-color: var(--primary);
  428. border: 2px solid var(--bg-primary);
  429. border-radius: 30rpx;
  430. color: var(--light);
  431. padding: 8rpx 30rpx;
  432. .size(28rpx);
  433. font-weight: 700;
  434. }
  435. .is_plain {
  436. background-color: var(--bg-primary);
  437. color: var(--primary);
  438. }
  439. }
  440. .userInfo_ {
  441. .hor();
  442. flex-direction: column;
  443. margin-left: 24rpx;
  444. color: var(--light);
  445. .user_name {
  446. .size();
  447. font-weight: 700;
  448. line-height: 44rpx;
  449. }
  450. .user_id {
  451. .size(24rpx);
  452. line-height: 40rpx;
  453. }
  454. }
  455. }
  456. .bg_right {
  457. .img {
  458. width: 40rpx;
  459. height: 40rpx;
  460. }
  461. }
  462. }
  463. .info_wrapper {
  464. .flex();
  465. .info_item {
  466. flex: 1;
  467. .flex_center();
  468. flex-direction: column;
  469. color: var(--light);
  470. .item_num {
  471. .size();
  472. font-weight: 700;
  473. line-height: 60rpx;
  474. }
  475. .item_text {
  476. .size(24rpx);
  477. font-weight: 500;
  478. line-height: 40rpx;
  479. }
  480. }
  481. }
  482. .bg_logo {
  483. position: absolute;
  484. .size(128rpx);
  485. color: var(--inputBg);
  486. opacity: 0.06;
  487. top: 0;
  488. left: 50%;
  489. font-weight: bold;
  490. transform: translateX(-50%);
  491. line-height: 128rpx;
  492. text-transform: uppercase;
  493. font-family: "HarmonyOS_Sans";
  494. white-space: nowrap;
  495. }
  496. }
  497. .entry_container {
  498. padding: 40rpx 24rpx;
  499. margin-top: -70px;
  500. position: relative;
  501. z-index: 2;
  502. .entry_wrapper {
  503. display: flex;
  504. flex-wrap: wrap;
  505. gap: 30rpx 10rpx;
  506. box-sizing: border-box;
  507. background-color: #fafafa;
  508. border-radius: 20rpx;
  509. // box-shadow: 0 2px 30px #0000000d;
  510. padding: 32rpx 0 24rpx;
  511. color: var(--text);
  512. .entry_item {
  513. width: calc(33.333% - 10rpx);
  514. // flex: 1;
  515. .flex_center();
  516. flex-direction: column;
  517. .icons {
  518. position: relative;
  519. .icons_img {
  520. width: 48rpx;
  521. height: 48rpx;
  522. .img {
  523. width: inherit;
  524. height: inherit;
  525. }
  526. }
  527. .entry_num {
  528. position: absolute;
  529. top: -8rpx;
  530. right: -10rpx;
  531. background-color: var(--danger);
  532. border: 1px solid var(--light);
  533. color: var(--light);
  534. width: 36rpx;
  535. height: 36rpx;
  536. border-radius: 50%;
  537. .size(18rpx);
  538. .flex_center();
  539. }
  540. }
  541. .entry_text {
  542. width: max-content;
  543. .size(28rpx);
  544. line-height: 44rpx;
  545. margin-top: 12rpx;
  546. }
  547. }
  548. }
  549. }
  550. .content {
  551. .menu_title {
  552. margin: 0 24rpx;
  553. font-weight: bold;
  554. color: var(--text);
  555. .size(28rpx);
  556. }
  557. .user_menu {
  558. margin-top: 0;
  559. .icons_img {
  560. width: 40rpx !important;
  561. height: 40rpx !important;
  562. }
  563. }
  564. }
  565. }
  566. .version {
  567. text-align: center;
  568. color: var(--black);
  569. .size(24rpx);
  570. padding: 24rpx 0;
  571. }
  572. }
  573. .switch_user_type {
  574. margin: 0 24rpx;
  575. margin-top: 24rpx;
  576. background-color: var(--primary);
  577. color: var(--light);
  578. .size(28rpx);
  579. height: 84rpx;
  580. padding: 16rpx 30rpx;
  581. .flex_center();
  582. border-radius: 16rpx;
  583. margin-bottom: 16rpx;
  584. }
  585. .exit_btn {
  586. // width: 80%;
  587. margin: 0 24rpx;
  588. margin-top: 24rpx;
  589. background-color: var(--black);
  590. color: var(--light);
  591. .size(28rpx);
  592. height: 84rpx;
  593. padding: 16rpx 30rpx;
  594. .flex_center();
  595. border-radius: 16rpx;
  596. }
  597. </style>