index.vue 14 KB

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