index.vue 15 KB

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