index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  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. const exit = () => {
  336. Modal({ content: t("确定要退出登录吗") }).then(async () => {
  337. useUser.loginOut();
  338. });
  339. };
  340. const handleTo = (url) => {
  341. if (!url) return Toast(t("敬请期待"));
  342. if (url === "service") return useSystem.service();
  343. uni.navigateTo({ url });
  344. };
  345. const onEdit = () => {
  346. uni.navigateTo({ url: "/pages/user/edit_user" });
  347. };
  348. const getCount = async () => {
  349. try {
  350. const res = await USER_ORDER_COUNT();
  351. entryList.value[1].num = res.data.waitPay;
  352. entryList.value[2].num = res.data.waitStock;
  353. entryList.value[3].num = res.data.waitJian;
  354. entryList.value[4].num = res.data.waitPackage;
  355. entryList.value[5].num = res.data.retund;
  356. } catch (error) {
  357. Toast(error.msg);
  358. }
  359. };
  360. onMounted(() => {});
  361. onLoad(() => {
  362. // useUser.getUserInfo();
  363. });
  364. onShow(() => {
  365. useUser.getUserInfo({}, { isLoading: true });
  366. getCount();
  367. // useUser.setStatics();
  368. });
  369. uni.hideTabBar();
  370. const handleAgreementModalClose = () => {
  371. agreementType.value = "";
  372. };
  373. // 切换用户类型
  374. const switchUserType = () => {
  375. Modal({
  376. content: t("确定要切换到买家模式吗?切换后底部导航将显示买家功能"),
  377. }).then(() => {
  378. // 设置为买家类型
  379. useUser.setUserType(2);
  380. // 跳转到买家首页
  381. uni.reLaunch({
  382. url: "/pagesBuyer/home/index",
  383. });
  384. });
  385. };
  386. </script>
  387. <style lang="less" scoped>
  388. @import url("@/style.less");
  389. .wrap {
  390. background: var(--bg);
  391. min-height: 100vh;
  392. padding-bottom: calc(90rpx + constant(safe-area-inset-bottom));
  393. padding-bottom: calc(90rpx + env(safe-area-inset-bottom));
  394. .flex();
  395. flex-direction: column;
  396. justify-content: space-between;
  397. .cont {
  398. padding-bottom: 24rpx;
  399. flex-grow: 1;
  400. &_bg {
  401. background: var(--black);
  402. border-radius: 0 0 20rpx 20rpx;
  403. position: relative;
  404. .bg_top {
  405. .flex_position(space-between);
  406. padding: 40rpx 40rpx 140rpx;
  407. position: relative;
  408. z-index: 1;
  409. .top_left {
  410. .flex();
  411. .userInfo_avatar {
  412. width: 120rpx;
  413. height: 120rpx;
  414. border-radius: 50%;
  415. }
  416. .btns {
  417. .ver();
  418. margin-left: 24rpx;
  419. column-gap: 20rpx;
  420. .btn {
  421. .flex_center();
  422. background-color: var(--primary);
  423. border: 2px solid var(--bg-primary);
  424. border-radius: 30rpx;
  425. color: var(--light);
  426. padding: 8rpx 30rpx;
  427. .size(28rpx);
  428. font-weight: 700;
  429. }
  430. .is_plain {
  431. background-color: var(--bg-primary);
  432. color: var(--primary);
  433. }
  434. }
  435. .userInfo_ {
  436. .hor();
  437. flex-direction: column;
  438. margin-left: 24rpx;
  439. color: var(--light);
  440. .user_name {
  441. .size();
  442. font-weight: 700;
  443. line-height: 44rpx;
  444. }
  445. .user_id {
  446. .size(24rpx);
  447. line-height: 40rpx;
  448. }
  449. }
  450. }
  451. .bg_right {
  452. .img {
  453. width: 40rpx;
  454. height: 40rpx;
  455. }
  456. }
  457. }
  458. .info_wrapper {
  459. .flex();
  460. .info_item {
  461. flex: 1;
  462. .flex_center();
  463. flex-direction: column;
  464. color: var(--light);
  465. .item_num {
  466. .size();
  467. font-weight: 700;
  468. line-height: 60rpx;
  469. }
  470. .item_text {
  471. .size(24rpx);
  472. font-weight: 500;
  473. line-height: 40rpx;
  474. }
  475. }
  476. }
  477. .bg_logo {
  478. position: absolute;
  479. .size(128rpx);
  480. color: var(--inputBg);
  481. opacity: 0.06;
  482. top: 0;
  483. left: 50%;
  484. font-weight: bold;
  485. transform: translateX(-50%);
  486. line-height: 128rpx;
  487. text-transform: uppercase;
  488. font-family: "HarmonyOS_Sans";
  489. white-space: nowrap;
  490. }
  491. }
  492. .entry_container {
  493. padding: 40rpx 24rpx;
  494. margin-top: -70px;
  495. position: relative;
  496. z-index: 2;
  497. .entry_wrapper {
  498. display: flex;
  499. flex-wrap: wrap;
  500. gap: 30rpx 10rpx;
  501. box-sizing: border-box;
  502. background-color: #fafafa;
  503. border-radius: 20rpx;
  504. // box-shadow: 0 2px 30px #0000000d;
  505. padding: 32rpx 0 24rpx;
  506. color: var(--text);
  507. .entry_item {
  508. width: calc(33.333% - 10rpx);
  509. // flex: 1;
  510. .flex_center();
  511. flex-direction: column;
  512. .icons {
  513. position: relative;
  514. .icons_img {
  515. width: 48rpx;
  516. height: 48rpx;
  517. .img {
  518. width: inherit;
  519. height: inherit;
  520. }
  521. }
  522. .entry_num {
  523. position: absolute;
  524. top: -8rpx;
  525. right: -10rpx;
  526. background-color: var(--danger);
  527. border: 1px solid var(--light);
  528. color: var(--light);
  529. width: 36rpx;
  530. height: 36rpx;
  531. border-radius: 50%;
  532. .size(18rpx);
  533. .flex_center();
  534. }
  535. }
  536. .entry_text {
  537. width: max-content;
  538. .size(28rpx);
  539. line-height: 44rpx;
  540. margin-top: 12rpx;
  541. }
  542. }
  543. }
  544. }
  545. .content {
  546. .menu_title {
  547. margin: 0 24rpx;
  548. font-weight: bold;
  549. color: var(--text);
  550. .size(28rpx);
  551. }
  552. .user_menu {
  553. margin-top: 0;
  554. .icons_img {
  555. width: 40rpx !important;
  556. height: 40rpx !important;
  557. }
  558. }
  559. }
  560. }
  561. .version {
  562. text-align: center;
  563. color: var(--black);
  564. .size(24rpx);
  565. padding: 24rpx 0;
  566. }
  567. }
  568. .switch_user_type {
  569. margin: 0 24rpx;
  570. margin-top: 24rpx;
  571. background-color: var(--primary);
  572. color: var(--light);
  573. .size(28rpx);
  574. height: 84rpx;
  575. padding: 16rpx 30rpx;
  576. .flex_center();
  577. border-radius: 16rpx;
  578. margin-bottom: 16rpx;
  579. }
  580. .exit_btn {
  581. // width: 80%;
  582. margin: 0 24rpx;
  583. margin-top: 24rpx;
  584. background-color: var(--black);
  585. color: var(--light);
  586. .size(28rpx);
  587. height: 84rpx;
  588. padding: 16rpx 30rpx;
  589. .flex_center();
  590. border-radius: 16rpx;
  591. }
  592. </style>