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

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