home.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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?mid=202504161656&sid=12&pid=1&pri=1';
  63. // let result = 'http://192.168.166.11?mid=20250416165612&sid=12&pid=1&pri=1';
  64. uni.navigateTo({
  65. url: '/pages/commodityInfo?q=' +
  66. encodeURIComponent(JSON.stringify(result))
  67. });
  68. }
  69. }
  70. }
  71. </script>
  72. <style lang="stylus" scoped>
  73. .home {
  74. flex: 1;
  75. display: flex;
  76. flex-direction: column;
  77. overflow: hidden;
  78. background: #f5f7fa;
  79. padding: 60rpx 40rpx;
  80. box-sizing: border-box;
  81. align-items: center;
  82. background: url(../static/back2.png);
  83. background-size: 100% 100%;
  84. .user-card {
  85. width: 500rpx;
  86. background: #ffffff;
  87. border-radius: 24rpx;
  88. padding: 48rpx 40rpx;
  89. box-shadow: 0 12rpx 30rpx rgba(0, 0, 0, 0.06);
  90. display: flex;
  91. align-items: center;
  92. gap: 30rpx;
  93. margin-bottom: 80rpx;
  94. .avatar {
  95. width: 100rpx;
  96. height: 100rpx;
  97. border-radius: 50%;
  98. background: linear-gradient(135deg, #0183FA, #00BFFF);
  99. display: flex;
  100. align-items: center;
  101. justify-content: center;
  102. flex-shrink: 0;
  103. }
  104. .avatar text {
  105. font-size: 44rpx;
  106. color: #fff;
  107. font-weight: bold;
  108. }
  109. .user-detail {
  110. flex: 1;
  111. display: flex;
  112. flex-direction: column;
  113. gap: 12rpx;
  114. .user-name {
  115. font-size: 36rpx;
  116. font-weight: 600;
  117. color: #333;
  118. line-height: 1.4;
  119. }
  120. .user-phone {
  121. font-size: 28rpx;
  122. color: #999;
  123. line-height: 1.4;
  124. }
  125. }
  126. .points-section {
  127. display: flex;
  128. flex-direction: column;
  129. align-items: flex-end;
  130. gap: 8rpx;
  131. flex-shrink: 0;
  132. .points-label {
  133. font-size: 24rpx;
  134. color: #999;
  135. }
  136. .points-value {
  137. font-size: 48rpx;
  138. font-weight: 700;
  139. color: #ff9800;
  140. line-height: 1.2;
  141. }
  142. }
  143. }
  144. .scan-btn-wrapper {
  145. width: 100%;
  146. display: flex;
  147. justify-content: center;
  148. .scanCodeButton {
  149. width: 480rpx;
  150. height: 100rpx;
  151. background: linear-gradient(135deg, #0183FA, #00a8ff);
  152. border-radius: 50rpx;
  153. display: flex;
  154. align-items: center;
  155. justify-content: center;
  156. gap: 12rpx;
  157. box-shadow: 0 10rpx 24rpx rgba(1, 131, 250, 0.35);
  158. transition: all 0.2s ease;
  159. .btn-icon {
  160. font-size: 36rpx;
  161. }
  162. .btn-text {
  163. font-size: 34rpx;
  164. color: #fff;
  165. font-weight: 600;
  166. letter-spacing: 2rpx;
  167. }
  168. }
  169. .scanCodeButton:active {
  170. transform: scale(0.96);
  171. box-shadow: 0 4rpx 12rpx rgba(1, 131, 250, 0.25);
  172. }
  173. }
  174. .flex-null-1 {
  175. flex: 8;
  176. }
  177. .flex-null-2 {
  178. flex: 1;
  179. }
  180. }
  181. </style>