四零语境前端代码仓库
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.

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