home.vue 3.8 KB

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