| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <!-- 首页 -->
- <template>
- <view class="home">
- <view class="user-card">
- <view class="avatar">
- <text>{{ userData.userName ? userData.userName.charAt(0) : '?' }}</text>
- </view>
- <view class="user-detail">
- <view class="user-name">{{ userData.userName || '未登录' }}</view>
- <view class="user-phone">{{ userData.phone || '---' }}</view>
- </view>
- <view class="points-section">
- <text class="points-label">当前积分</text>
- <text class="points-value">{{ userData.points ?? 0 }}</text>
- </view>
- </view>
- <view class="flex-null-1"></view>
- <view class="scan-btn-wrapper">
- <view class="scanCodeButton" @click="scanCode()">
- <text class="btn-icon"></text>
- <text class="btn-text">积分兑换</text>
- </view>
- </view>
- <view class="flex-null-2"></view>
- </view>
- </template>
- <script>
- import { getUserInfo } from '@/api/index';
- import { browserDetection } from '@/utils/auth';
- export default {
- data() {
- return {
- userData: {
- userName: '',
- phone: '',
- points: '',
- },
- }
- },
- onShow() {
- this.getUserInfo();
- browserDetection();
- },
- methods: {
- async getUserInfo() {
- let obj = {
- token: uni.getStorageSync('token'),
- phone: uni.getStorageSync('phone'),
- }
- const {
- data
- } = await getUserInfo(obj)
- if (data.code == 200) {
- this.$set(this, 'userData', data.data);
- uni.setStorageSync('points',data.data.points)
- }
- },
- scanCode() {
- // uni.navigateTo({
- // url: "/pages/scanCodePage",
- // });
- let result = 'http://192.168.166.11?mid=202504161656&sid=12&pid=1&pri=1';
- // let result = 'http://192.168.166.11?mid=20250416165612&sid=12&pid=1&pri=1';
- uni.navigateTo({
- url: '/pages/commodityInfo?q=' +
- encodeURIComponent(JSON.stringify(result))
- });
- }
- }
- }
- </script>
- <style lang="stylus" scoped>
- .home {
- flex: 1;
- display: flex;
- flex-direction: column;
- overflow: hidden;
- background: #f5f7fa;
- padding: 60rpx 40rpx;
- box-sizing: border-box;
- align-items: center;
- background: url(../static/back2.png);
- background-size: 100% 100%;
- .user-card {
- width: 500rpx;
- background: #ffffff;
- border-radius: 24rpx;
- padding: 48rpx 40rpx;
- box-shadow: 0 12rpx 30rpx rgba(0, 0, 0, 0.06);
- display: flex;
- align-items: center;
- gap: 30rpx;
- margin-bottom: 80rpx;
- .avatar {
- width: 100rpx;
- height: 100rpx;
- border-radius: 50%;
- background: linear-gradient(135deg, #0183FA, #00BFFF);
- display: flex;
- align-items: center;
- justify-content: center;
- flex-shrink: 0;
- }
- .avatar text {
- font-size: 44rpx;
- color: #fff;
- font-weight: bold;
- }
- .user-detail {
- flex: 1;
- display: flex;
- flex-direction: column;
- gap: 12rpx;
- .user-name {
- font-size: 36rpx;
- font-weight: 600;
- color: #333;
- line-height: 1.4;
- }
- .user-phone {
- font-size: 28rpx;
- color: #999;
- line-height: 1.4;
- }
- }
- .points-section {
- display: flex;
- flex-direction: column;
- align-items: flex-end;
- gap: 8rpx;
- flex-shrink: 0;
- .points-label {
- font-size: 24rpx;
- color: #999;
- }
- .points-value {
- font-size: 48rpx;
- font-weight: 700;
- color: #ff9800;
- line-height: 1.2;
- }
- }
- }
- .scan-btn-wrapper {
- width: 100%;
- display: flex;
- justify-content: center;
- .scanCodeButton {
- width: 480rpx;
- height: 100rpx;
- background: linear-gradient(135deg, #0183FA, #00a8ff);
- border-radius: 50rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- gap: 12rpx;
- box-shadow: 0 10rpx 24rpx rgba(1, 131, 250, 0.35);
- transition: all 0.2s ease;
- .btn-icon {
- font-size: 36rpx;
- }
- .btn-text {
- font-size: 34rpx;
- color: #fff;
- font-weight: 600;
- letter-spacing: 2rpx;
- }
- }
- .scanCodeButton:active {
- transform: scale(0.96);
- box-shadow: 0 4rpx 12rpx rgba(1, 131, 250, 0.25);
- }
- }
- .flex-null-1 {
- flex: 8;
- }
- .flex-null-2 {
- flex: 1;
- }
- }
- </style>
|