四零语境前端代码仓库
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

480 lines
14 KiB

1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
1 month ago
  1. <template>
  2. <view class="user-container">
  3. <!-- 用户信息区域 -->
  4. <view class="user-info-section">
  5. <!-- #ifndef H5 -->
  6. <view class="page-title">我的</view>
  7. <!-- #endif -->
  8. <view class="user-info">
  9. <view class="user-avatar" @click="goLogin">
  10. <image
  11. :src="isLogin ? userInfo.avatar === 'undefined' ? displayInfo.avatar : userInfo.avatar : displayInfo.avatar"
  12. mode="aspectFill"></image>
  13. </view>
  14. <view class="user-details" @click="clickInfo">
  15. <view class="user-name">{{ isLogin ? userInfo.name : displayInfo.name }}</view>
  16. <view class="user-phone">手机号{{ isLogin ? userInfo.phone || displayInfo.phone : displayInfo.phone }}
  17. </view>
  18. <!-- <view class="user-desc">{{ displayInfo.description }}</view> -->
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 功能菜单列表 -->
  23. <!-- 第一组菜单 -->
  24. <!-- 会员中心 -->
  25. <view class="menu-item special-item" @click="goToMember">
  26. <view class="menu-left">
  27. <image src="/static/member-diamond.png" class="menu-icon"></image>
  28. <text class="menu-title">会员中心</text>
  29. </view>
  30. <view class="menu-right">
  31. <uv-button shape="circle" :customStyle="{
  32. width: '170rpx',
  33. height: '70rpx',
  34. fontSize: '28rpx',
  35. fontWeight: '500',
  36. lineHeight: '70rpx',
  37. letterSpacing: '0%',
  38. verticalAlign: 'middle',
  39. backgroundColor: '#06DADC',
  40. color: '#fff',
  41. }">查看会员</uv-button>
  42. </view>
  43. </view>
  44. <view class="menu-list">
  45. <!-- 推广中心 -->
  46. <view class="menu-item" @click="goToPromotion" v-if="userInfo.isPromote === 'Y'">
  47. <view class="menu-left">
  48. <image src="/static/promotion-icon.png" class="menu-icon"></image>
  49. <text class="menu-title">推广中心</text>
  50. </view>
  51. <view class="menu-right">
  52. <uv-icon name="arrow-right" color="#999" size="16"></uv-icon>
  53. </view>
  54. </view>
  55. <!-- 我的优惠券 -->
  56. <view class="menu-item" @click="goToCoupons">
  57. <view class="menu-left">
  58. <image src="/static/coupon-icon.png" class="menu-icon"></image>
  59. <text class="menu-title">我的优惠券</text>
  60. </view>
  61. <view class="menu-right">
  62. <uv-icon name="arrow-right" color="#999" size="16"></uv-icon>
  63. </view>
  64. </view>
  65. <!-- 产品介绍 -->
  66. <view class="menu-item" @click="goToProduct">
  67. <view class="menu-left">
  68. <image src="/static/intro-icon.png" class="menu-icon"></image>
  69. <text class="menu-title">产品介绍</text>
  70. </view>
  71. <view class="menu-right">
  72. <uv-icon name="arrow-right" color="#999" size="16"></uv-icon>
  73. </view>
  74. </view>
  75. </view>
  76. <!-- 第二组菜单 -->
  77. <view class="menu-list">
  78. <!-- 联系我们 -->
  79. <view class="menu-item" @click="goToContact">
  80. <view class="menu-left">
  81. <image src="/static/contact-icon.png" class="menu-icon"></image>
  82. <text class="menu-title">联系我们</text>
  83. </view>
  84. <view class="menu-right">
  85. <uv-icon name="arrow-right" color="#999" size="16"></uv-icon>
  86. </view>
  87. </view>
  88. <!-- 服务协议与隐私政策 -->
  89. <view class="menu-item" @click="goToPolicy">
  90. <view class="menu-left">
  91. <image src="/static/privacy-icon.png" class="menu-icon"></image>
  92. <text class="menu-title">服务与隐私</text>
  93. </view>
  94. <view class="menu-right">
  95. <text class="menu-arrow">></text>
  96. </view>
  97. </view>
  98. <view class="menu-item" @click="goToProfile">
  99. <view class="menu-left">
  100. <image src="/static/edit-info-icon.png" class="menu-icon"></image>
  101. <text class="menu-title">修改信息</text>
  102. </view>
  103. <view class="menu-right">
  104. <uv-icon name="arrow-right" color="#999" size="16"></uv-icon>
  105. </view>
  106. </view>
  107. <view class="menu-item" @click="logout" v-if="isLogin">
  108. <view class="menu-left">
  109. <image src="/static/logout-icon.png" class="menu-icon"></image>
  110. <text class="menu-title">退出登录</text>
  111. </view>
  112. <view class="menu-right">
  113. <uv-icon name="arrow-right" color="#999" size="16"></uv-icon>
  114. </view>
  115. </view>
  116. </view>
  117. <view>
  118. <uv-popup ref="contactModal" closeIconPos="top-left" closeable round="30rpx" :safeAreaInsetBottom="false">
  119. <view class="contact-content">
  120. <view class="title">联系我们</view>
  121. <view class="contact-item" @click="callPhone">
  122. <text class="contact-phone">{{ configParamContent('contact_us') }}</text>
  123. <image src="/static/phone-icon.png" class="contact-icon"></image>
  124. </view>
  125. </view>
  126. </uv-popup>
  127. </view>
  128. </view>
  129. </template>
  130. <script>
  131. export default {
  132. data() {
  133. return {
  134. userInfo: {
  135. avatar: '/static/default-avatar.png',
  136. name: '请先登录',
  137. id: 'XXXXX'
  138. },
  139. isLogin: uni.getStorageSync('token'),
  140. // 用户展示信息
  141. displayInfo: {
  142. name: '点击登录',
  143. phone: 'xxxxxxxxx',
  144. avatar: '/static/default-avatar.png'
  145. }
  146. }
  147. },
  148. computed: {
  149. // 检查是否已登录
  150. },
  151. onShow() {
  152. this.isLogin = uni.getStorageSync('token')
  153. // 如果没登陆过 就别登了
  154. if (uni.getStorageSync('token')) {
  155. this.getUserInfo();
  156. }
  157. },
  158. methods: {
  159. // 拨打电话
  160. callPhone() {
  161. uni.makePhoneCall({
  162. phoneNumber: this.configParamContent('contact_us'),
  163. })
  164. },
  165. // 跳转登录页面
  166. goLogin() {
  167. if (!this.isLogin) {
  168. uni.navigateTo({
  169. url: '/subPages/login/login'
  170. })
  171. } else {
  172. uni.navigateTo({
  173. url: '/subPages/user/profile'
  174. })
  175. }
  176. },
  177. // 跳转到基本信息页面
  178. goToBasicInfo() {
  179. uni.navigateTo({
  180. url: '/subPages/user/profile'
  181. })
  182. },
  183. // 获取用户信息
  184. async getUserInfo() {
  185. const res = await this.$api.login.getUserInfo();
  186. if (res.code === 200) {
  187. this.userInfo = res.result;
  188. // 存储用户信息到store
  189. this.$store.dispatch('updateUserInfo', this.userInfo)
  190. }
  191. },
  192. // 显示隐私政策弹窗
  193. showPrivacyPolicy() {
  194. this.$refs.privacyModal.open()
  195. },
  196. // 跳转到会员页面
  197. goToMember() {
  198. uni.switchTab({
  199. url: '/pages/index/member'
  200. })
  201. },
  202. // 跳转到推广中心
  203. goToPromotion() {
  204. uni.navigateTo({
  205. url: '/subPages/user/promote'
  206. })
  207. },
  208. // 跳转到我的优惠券
  209. goToCoupons() {
  210. uni.navigateTo({
  211. url: '/subPages/user/discount'
  212. })
  213. },
  214. // 跳转到产品介绍
  215. goToProduct() {
  216. uni.navigateTo({ url: '/subPages/user/introduce' })
  217. },
  218. //// 跳转到联系我们
  219. goToContact() {
  220. this.$refs.contactModal.open('bottom')
  221. },
  222. // 跳转到隐私政策页面
  223. goToPolicy() {
  224. uni.navigateTo({
  225. url: '/subPages/user/policy'
  226. })
  227. },
  228. // 跳转到登陆页面
  229. clickInfo() {
  230. if (!this.isLogin) {
  231. uni.navigateTo({
  232. url: '/subPages/login/login'
  233. })
  234. } else {
  235. uni.navigateTo({
  236. url: '/subPages/user/profile'
  237. })
  238. }
  239. },
  240. // 退出登录
  241. logout() {
  242. uni.showModal({
  243. title: '提示',
  244. content: '确定要退出登录吗?',
  245. confirmColor: '#06DADC',
  246. success: (res) => {
  247. if (res.confirm) {
  248. // 清除本地存储的用户信息
  249. uni.removeStorageSync('token')
  250. // 清空store中的用户信息
  251. this.$store.commit('updateUserInfo', {})
  252. // 重置用户信息
  253. this.userInfo = {
  254. avatar: '/static/default-avatar.png',
  255. name: '请先登录',
  256. id: 'XXXXX'
  257. }
  258. this.isLogin = false;
  259. // 显示退出成功提示
  260. uni.showToast({
  261. title: '退出成功',
  262. icon: 'success'
  263. })
  264. }
  265. }
  266. })
  267. }
  268. }
  269. }
  270. </script>
  271. <style lang="scss" scoped>
  272. .user-container {
  273. min-height: 100vh;
  274. background: #fff;
  275. /* 用户信息区域 */
  276. .user-info-section {
  277. background: linear-gradient(180deg, #ABFFFF 0%, #FFFFFF 100%);
  278. height: 300rpx;
  279. /* #ifdef H5 */
  280. height: 200rpx;
  281. /* #endif */
  282. // display: flex;
  283. // align-items: center;
  284. padding: 60rpx 32rpx 0rpx;
  285. gap: 40rpx;
  286. .user-info {
  287. display: flex;
  288. align-items: center;
  289. }
  290. .page-title {
  291. text-align: center;
  292. margin: 0 auto;
  293. margin-top: 60rpx;
  294. margin-bottom: 40rpx;
  295. font-size: 32rpx;
  296. font-weight: 500;
  297. }
  298. }
  299. .user-avatar {
  300. width: 120rpx;
  301. height: 120rpx;
  302. border-radius: 50%;
  303. overflow: hidden;
  304. margin-right: 30rpx;
  305. border: 2px solid #FFFFFF;
  306. image {
  307. width: 100%;
  308. height: 100%;
  309. }
  310. }
  311. .user-details {
  312. flex: 1;
  313. }
  314. .user-name {
  315. font-size: 36rpx;
  316. line-height: 44rpx;
  317. font-weight: bold;
  318. color: #333;
  319. margin-bottom: 10rpx;
  320. }
  321. .user-phone {
  322. font-size: 24rpx;
  323. color: #252545;
  324. margin-bottom: 8rpx;
  325. }
  326. .user-desc {
  327. font-size: 24rpx;
  328. color: #252545;
  329. }
  330. /* 菜单列表 */
  331. .menu-list {
  332. background: #F8F8F8;
  333. border-radius: 32rpx;
  334. overflow: hidden;
  335. margin: 0 32rpx;
  336. margin-bottom: 32rpx;
  337. &:last-child {
  338. margin-bottom: 0;
  339. }
  340. }
  341. .menu-item {
  342. display: flex;
  343. align-items: center;
  344. justify-content: space-between;
  345. padding: 40rpx 30rpx;
  346. border: 2rpx solid #F2F2F2;
  347. &:last-child {
  348. border-bottom: none;
  349. }
  350. &.special-item {
  351. background: linear-gradient(180deg, #DEFFFF 0%, #FBFEFF 22.65%, #F0FBFF 100%);
  352. border: 1px solid #06DADC12;
  353. height: 98rpx;
  354. border-radius: 32rpx;
  355. border-width: 2rpx;
  356. padding-top: 12rpx;
  357. padding-right: 40rpx;
  358. padding-bottom: 12rpx;
  359. padding-left: 40rpx;
  360. gap: 24rpx;
  361. margin: 0 32rpx;
  362. margin-bottom: 32rpx;
  363. .menu-icon {
  364. width: 60rpx;
  365. height: 60rpx;
  366. }
  367. .menu-title {
  368. font-size: 36rpx;
  369. font-weight: 600;
  370. }
  371. }
  372. }
  373. .menu-left {
  374. display: flex;
  375. align-items: center;
  376. }
  377. .menu-icon {
  378. width: 40rpx;
  379. height: 40rpx;
  380. margin-right: 20rpx;
  381. }
  382. .menu-title {
  383. font-size: 32rpx;
  384. color: #333;
  385. }
  386. .menu-right {
  387. display: flex;
  388. align-items: center;
  389. }
  390. /* 联系我们弹窗样式 */
  391. .contact-content {
  392. // padding: 40rpx 0;
  393. .title {
  394. height: 90rpx;
  395. text-align: center;
  396. line-height: 90rpx;
  397. font-size: 34rpx;
  398. font-weight: 500;
  399. border-bottom: 2rpx solid #EEEEEE
  400. }
  401. // text-align: center;
  402. }
  403. .contact-item {
  404. // background: red;
  405. height: 240rpx;
  406. display: flex;
  407. align-items: center;
  408. justify-content: center;
  409. gap: 20rpx;
  410. }
  411. .contact-icon {
  412. width: 72rpx;
  413. height: 72rpx;
  414. }
  415. .contact-phone {
  416. font-size: 36rpx;
  417. color: #181818;
  418. }
  419. }
  420. </style>