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

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