home.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <!-- 首页 -->
  2. <template>
  3. <view class="home">
  4. <view class="user-card">
  5. <view class="avatar">
  6. <text>{{ userData.userName ? userData.userName.charAt(0) : '?' }}</text>
  7. </view>
  8. <view class="user-detail">
  9. <view class="user-name">{{ userData.userName || '未登录' }}</view>
  10. <view class="user-phone">{{ userData.phone || '---' }}</view>
  11. </view>
  12. <view class="points-section">
  13. <text class="points-label">当前积分</text>
  14. <text class="points-value">{{ userData.points ?? 0 }}</text>
  15. </view>
  16. </view>
  17. <view class="flex-null-1"></view>
  18. <view class="scan-btn-wrapper">
  19. <view class="scanCodeButton" @click="scanCode()">
  20. <text class="btn-icon"></text>
  21. <text class="btn-text">积分兑换</text>
  22. </view>
  23. </view>
  24. <view class="flex-null-2"></view>
  25. </view>
  26. </template>
  27. <script>
  28. import { getUserInfo } from '@/api/index';
  29. import { browserDetection } from '@/utils/auth';
  30. export default {
  31. data() {
  32. return {
  33. userData: {
  34. userName: '',
  35. phone: '',
  36. points: '',
  37. },
  38. }
  39. },
  40. onShow() {
  41. this.getUserInfo();
  42. browserDetection();
  43. },
  44. methods: {
  45. async getUserInfo() {
  46. let obj = {
  47. token: uni.getStorageSync('token'),
  48. phone: uni.getStorageSync('phone'),
  49. }
  50. const {
  51. data
  52. } = await getUserInfo(obj)
  53. if (data.code == 200) {
  54. this.$set(this, 'userData', data.data);
  55. uni.setStorageSync('points',data.data.points)
  56. }
  57. },
  58. scanCode() {
  59. uni.navigateTo({
  60. url: "/pages/scanCodePage",
  61. });
  62. // let result = 'http://192.168.166.11/api/exam/points/record/exchangeMachineService?mid=2603220061&sid=6&pid=6&pri=100.00';
  63. // uni.navigateTo({
  64. // url: '/pages/commodityInfo?q=' +
  65. // encodeURIComponent(JSON.stringify(result))
  66. // });
  67. }
  68. }
  69. }
  70. </script>
  71. <style lang="stylus" scoped>
  72. .home {
  73. flex: 1;
  74. display: flex;
  75. flex-direction: column;
  76. overflow: hidden;
  77. background: #f5f7fa;
  78. padding: 60rpx 40rpx;
  79. box-sizing: border-box;
  80. align-items: center;
  81. background: url(../static/back2.png);
  82. background-size: 100% 100%;
  83. .user-card {
  84. width: 500rpx;
  85. background: #ffffff;
  86. border-radius: 24rpx;
  87. padding: 48rpx 40rpx;
  88. box-shadow: 0 12rpx 30rpx rgba(0, 0, 0, 0.06);
  89. display: flex;
  90. align-items: center;
  91. gap: 30rpx;
  92. margin-bottom: 80rpx;
  93. .avatar {
  94. width: 100rpx;
  95. height: 100rpx;
  96. border-radius: 50%;
  97. background: linear-gradient(135deg, #0183FA, #00BFFF);
  98. display: flex;
  99. align-items: center;
  100. justify-content: center;
  101. flex-shrink: 0;
  102. }
  103. .avatar text {
  104. font-size: 44rpx;
  105. color: #fff;
  106. font-weight: bold;
  107. }
  108. .user-detail {
  109. flex: 1;
  110. display: flex;
  111. flex-direction: column;
  112. gap: 12rpx;
  113. .user-name {
  114. font-size: 36rpx;
  115. font-weight: 600;
  116. color: #333;
  117. line-height: 1.4;
  118. }
  119. .user-phone {
  120. font-size: 28rpx;
  121. color: #999;
  122. line-height: 1.4;
  123. }
  124. }
  125. .points-section {
  126. display: flex;
  127. flex-direction: column;
  128. align-items: flex-end;
  129. gap: 8rpx;
  130. flex-shrink: 0;
  131. .points-label {
  132. font-size: 24rpx;
  133. color: #999;
  134. }
  135. .points-value {
  136. font-size: 48rpx;
  137. font-weight: 700;
  138. color: #ff9800;
  139. line-height: 1.2;
  140. }
  141. }
  142. }
  143. .scan-btn-wrapper {
  144. width: 100%;
  145. display: flex;
  146. justify-content: center;
  147. .scanCodeButton {
  148. width: 480rpx;
  149. height: 100rpx;
  150. background: linear-gradient(135deg, #0183FA, #00a8ff);
  151. border-radius: 50rpx;
  152. display: flex;
  153. align-items: center;
  154. justify-content: center;
  155. gap: 12rpx;
  156. box-shadow: 0 10rpx 24rpx rgba(1, 131, 250, 0.35);
  157. transition: all 0.2s ease;
  158. .btn-icon {
  159. font-size: 36rpx;
  160. }
  161. .btn-text {
  162. font-size: 34rpx;
  163. color: #fff;
  164. font-weight: 600;
  165. letter-spacing: 2rpx;
  166. }
  167. }
  168. .scanCodeButton:active {
  169. transform: scale(0.96);
  170. box-shadow: 0 4rpx 12rpx rgba(1, 131, 250, 0.25);
  171. }
  172. }
  173. .flex-null-1 {
  174. flex: 8;
  175. }
  176. .flex-null-2 {
  177. flex: 1;
  178. }
  179. }
  180. </style>