index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  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>
  36. <view class="entry_container">
  37. <view class="entry_wrapper">
  38. <view
  39. class="entry_item"
  40. v-for="(item, index) in entryList"
  41. :key="index"
  42. @click="item.callback"
  43. >
  44. <view class="icons">
  45. <view class="icons_img">
  46. <image
  47. class="img"
  48. :src="`../../static/user/${item.icon}.png`"
  49. ></image>
  50. </view>
  51. <view class="entry_num" v-if="item.num > 0">{{
  52. item.num
  53. }}</view>
  54. </view>
  55. <trans class="entry_text" :_t="item.text" />
  56. </view>
  57. </view>
  58. </view>
  59. <view class="content">
  60. <view class="menu_title">
  61. <trans _t="其他功能" />
  62. </view>
  63. <!-- <plaCard mode="horizontal" /> -->
  64. <view class="entry_container user_menu">
  65. <view class="entry_wrapper">
  66. <view
  67. class="entry_item"
  68. v-for="(item, index) in card"
  69. :key="index"
  70. @click="handleTo(item.url)"
  71. >
  72. <view class="icons">
  73. <view class="icons_img">
  74. <image
  75. class="img"
  76. :src="`../../static/user/${item.icon}.png`"
  77. ></image>
  78. </view>
  79. <view class="entry_num" v-if="item.num > 0">{{
  80. item.num
  81. }}</view>
  82. </view>
  83. <trans class="entry_text" :_t="item.text" />
  84. </view>
  85. </view>
  86. </view>
  87. </view>
  88. </view>
  89. <view class="footer">
  90. <view class="switch_user_type" @click="switchUserType">
  91. <trans _t="切换到卖家模式" />
  92. </view>
  93. <view class="exit_btn" @click="exit">
  94. <trans _t="退出登录" />
  95. </view>
  96. <view class="version">v {{ manifest.versionName }}</view>
  97. </view>
  98. </view>
  99. <Tabbar page="user" />
  100. <SimpleAgreementModal
  101. ref="agreementModal"
  102. :type="agreementType"
  103. @close="handleAgreementModalClose"
  104. />
  105. </Theme>
  106. </template>
  107. <script setup>
  108. import Tabbar from "@/components/tabbar";
  109. import Navbar from "@/components/navbar";
  110. import SimpleAgreementModal from "@/components/simpleAgreementModal";
  111. import plaCard from "@/components/placard";
  112. import { computed, watch, ref, reactive, onMounted, nextTick } from "vue";
  113. import { storeToRefs } from "pinia";
  114. import {
  115. useUserStore,
  116. useTabbarStore,
  117. useShopStore,
  118. useSystemStore,
  119. useMessageStore,
  120. } from "@/store";
  121. import { t } from "@/locale";
  122. import { onShow, onLoad } from "@dcloudio/uni-app";
  123. import verConfig from "@/ver.config";
  124. import manifest from "@/manifest.json";
  125. import { Modal, Toast } from "@/utils";
  126. import { USER_ORDER_COUNT } from "@/api";
  127. const useUser = useUserStore();
  128. const useTabbar = useTabbarStore();
  129. const useSystem = useSystemStore();
  130. const useMessage = useMessageStore();
  131. const { globalMap } = storeToRefs(useMessage);
  132. const unreadCount = ref(0);
  133. const customerUnreadCount = ref(0);
  134. watch(
  135. () => globalMap.value.serviceChannel,
  136. (newVal, oldVal) => {
  137. if (newVal) {
  138. unreadCount.value = newVal.unreadCount;
  139. }
  140. },
  141. {
  142. deep: true,
  143. immediate: true,
  144. }
  145. );
  146. watch(
  147. () => globalMap.value.noticeChannel,
  148. (newVal, oldVal) => {
  149. if (newVal) {
  150. customerUnreadCount.value = newVal.unreadCount;
  151. }
  152. },
  153. {
  154. deep: true,
  155. immediate: true,
  156. }
  157. );
  158. const useShop = useShopStore();
  159. const userInfo = computed(() => useUser.getuserInfo);
  160. const token = computed(() => useUser.getToken);
  161. // const cartNum = computed(() => useShop.getCartNum)
  162. const statics = computed(() => useUser.getStatics);
  163. const agreementType = ref("");
  164. const entryList = ref([
  165. {
  166. icon: "allwet",
  167. text: "钱包",
  168. num: 0,
  169. callback: () => {
  170. uni.navigateTo({ url: "/pages/bank/wallet" });
  171. },
  172. },
  173. {
  174. icon: "storage",
  175. text: "我的订单",
  176. num: 0,
  177. callback: () => {
  178. uni.navigateTo({ url: "/pagesBuyer/order/index" });
  179. },
  180. },
  181. {
  182. icon: "payment",
  183. text: "待支付",
  184. num: 0,
  185. callback: () => {
  186. uni.navigateTo({ url: `/pagesBuyer/order/index?status=100` });
  187. },
  188. },
  189. ]);
  190. const card = [
  191. {
  192. icon: "address",
  193. text: "我的地址",
  194. url: "/pages/address/index",
  195. },
  196. {
  197. icon: "invite",
  198. text: "邀请有礼",
  199. url: "/pages/user/invite",
  200. },
  201. {
  202. icon: "setting",
  203. text: "系统设置",
  204. url: "/pages/setting/index",
  205. },
  206. {
  207. icon: "enter",
  208. text: "商家入驻",
  209. url: "/pagesBuyer/profile/enter",
  210. },
  211. ];
  212. const exit = () => {
  213. Modal({ content: t("确定要退出登录吗") }).then(async () => {
  214. useUser.loginOut();
  215. });
  216. };
  217. const handleTo = (url) => {
  218. if (!url) return Toast(t("敬请期待"));
  219. if (url === "service") return useSystem.service();
  220. uni.navigateTo({ url });
  221. };
  222. const onEdit = () => {
  223. uni.navigateTo({ url: "/pages/user/edit_user" });
  224. };
  225. onMounted(() => {});
  226. onLoad(() => {
  227. // useUser.getUserInfo();
  228. });
  229. onShow(() => {
  230. useUser.getUserInfo({}, { isLoading: true });
  231. });
  232. const handleAgreementModalClose = () => {
  233. agreementType.value = "";
  234. };
  235. // 切换用户类型
  236. const switchUserType = () => {
  237. Modal({
  238. content: t("确定要切换到买家模式吗?切换后底部导航将显示买家功能"),
  239. }).then(() => {
  240. // 设置为买家类型
  241. useUser.setUserType(2);
  242. // 跳转到买家首页
  243. uni.reLaunch({
  244. url: "/pagesBuyer/home/index",
  245. });
  246. });
  247. };
  248. </script>
  249. <style lang="less" scoped>
  250. @import url("@/style.less");
  251. .wrap {
  252. background: var(--bg);
  253. min-height: 100vh;
  254. padding-bottom: calc(90rpx + constant(safe-area-inset-bottom));
  255. padding-bottom: calc(90rpx + env(safe-area-inset-bottom));
  256. .flex();
  257. flex-direction: column;
  258. justify-content: space-between;
  259. .cont {
  260. padding-bottom: 24rpx;
  261. flex-grow: 1;
  262. &_bg {
  263. background: var(--black);
  264. border-radius: 0 0 20rpx 20rpx;
  265. position: relative;
  266. .bg_top {
  267. .flex_position(space-between);
  268. padding: 40rpx 40rpx 140rpx;
  269. position: relative;
  270. z-index: 1;
  271. .top_left {
  272. .flex();
  273. .userInfo_avatar {
  274. width: 120rpx;
  275. height: 120rpx;
  276. border-radius: 50%;
  277. }
  278. .btns {
  279. .ver();
  280. margin-left: 24rpx;
  281. column-gap: 20rpx;
  282. .btn {
  283. .flex_center();
  284. background-color: var(--primary);
  285. border: 2px solid var(--bg-primary);
  286. border-radius: 30rpx;
  287. color: var(--light);
  288. padding: 8rpx 30rpx;
  289. .size(28rpx);
  290. font-weight: 700;
  291. }
  292. .is_plain {
  293. background-color: var(--bg-primary);
  294. color: var(--primary);
  295. }
  296. }
  297. .userInfo_ {
  298. .hor();
  299. flex-direction: column;
  300. margin-left: 24rpx;
  301. color: var(--light);
  302. .user_name {
  303. .size();
  304. font-weight: 700;
  305. line-height: 44rpx;
  306. }
  307. .user_id {
  308. .size(24rpx);
  309. line-height: 40rpx;
  310. }
  311. }
  312. }
  313. .bg_right {
  314. .img {
  315. width: 40rpx;
  316. height: 40rpx;
  317. }
  318. }
  319. }
  320. .info_wrapper {
  321. .flex();
  322. .info_item {
  323. flex: 1;
  324. .flex_center();
  325. flex-direction: column;
  326. color: var(--light);
  327. .item_num {
  328. .size();
  329. font-weight: 700;
  330. line-height: 60rpx;
  331. }
  332. .item_text {
  333. .size(24rpx);
  334. font-weight: 500;
  335. line-height: 40rpx;
  336. }
  337. }
  338. }
  339. .bg_logo {
  340. position: absolute;
  341. .size(128rpx);
  342. color: var(--inputBg);
  343. opacity: 0.06;
  344. top: 0;
  345. left: 50%;
  346. font-weight: bold;
  347. transform: translateX(-50%);
  348. line-height: 128rpx;
  349. text-transform: uppercase;
  350. font-family: "HarmonyOS_Sans";
  351. white-space: nowrap;
  352. }
  353. }
  354. .entry_container {
  355. padding: 40rpx 24rpx;
  356. margin-top: -70px;
  357. position: relative;
  358. z-index: 2;
  359. .entry_wrapper {
  360. display: flex;
  361. flex-wrap: wrap;
  362. gap: 30rpx 10rpx;
  363. box-sizing: border-box;
  364. background-color: #fafafa;
  365. border-radius: 20rpx;
  366. // box-shadow: 0 2px 30px #0000000d;
  367. padding: 32rpx 0 24rpx;
  368. color: var(--text);
  369. .entry_item {
  370. width: calc(33.333% - 10rpx);
  371. // flex: 1;
  372. .flex_center();
  373. flex-direction: column;
  374. .icons {
  375. position: relative;
  376. .icons_img {
  377. width: 48rpx;
  378. height: 48rpx;
  379. .img {
  380. width: inherit;
  381. height: inherit;
  382. }
  383. }
  384. .entry_num {
  385. position: absolute;
  386. top: -8rpx;
  387. right: -10rpx;
  388. background-color: var(--danger);
  389. border: 1px solid var(--light);
  390. color: var(--light);
  391. width: 36rpx;
  392. height: 36rpx;
  393. border-radius: 50%;
  394. .size(18rpx);
  395. .flex_center();
  396. }
  397. }
  398. .entry_text {
  399. width: max-content;
  400. .size(28rpx);
  401. line-height: 44rpx;
  402. margin-top: 12rpx;
  403. }
  404. }
  405. }
  406. }
  407. .content {
  408. .menu_title {
  409. margin: 0 24rpx;
  410. font-weight: bold;
  411. color: var(--text);
  412. .size(28rpx);
  413. }
  414. .user_menu {
  415. margin-top: 0;
  416. .icons_img {
  417. width: 40rpx !important;
  418. height: 40rpx !important;
  419. }
  420. }
  421. }
  422. }
  423. .version {
  424. text-align: center;
  425. color: var(--black);
  426. .size(24rpx);
  427. padding: 24rpx 0;
  428. }
  429. }
  430. .switch_user_type {
  431. margin: 0 24rpx;
  432. margin-top: 24rpx;
  433. background-color: var(--primary);
  434. color: var(--light);
  435. .size(28rpx);
  436. height: 84rpx;
  437. padding: 16rpx 30rpx;
  438. .flex_center();
  439. border-radius: 16rpx;
  440. margin-bottom: 16rpx;
  441. }
  442. .exit_btn {
  443. // width: 80%;
  444. margin: 0 24rpx;
  445. margin-top: 24rpx;
  446. background-color: var(--black);
  447. color: var(--light);
  448. .size(28rpx);
  449. height: 84rpx;
  450. padding: 16rpx 30rpx;
  451. .flex_center();
  452. border-radius: 16rpx;
  453. }
  454. </style>