index.vue 12 KB

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