This commit is contained in:
zpc 2025-04-08 15:07:38 +08:00
parent 60b8eceb6b
commit b5792a5c68
3 changed files with 158 additions and 135 deletions

View File

@ -21,6 +21,7 @@ class RequestManager {
* @returns {Promise} 返回请求Promise
*/
static request(param, backpage, backtype) {
return new Promise((resolve, reject) => {
// 参数检查
if (!param || typeof param !== 'object') {
@ -86,19 +87,19 @@ class RequestManager {
if (data) {
// 添加时间戳参数
data.timestamp = Math.floor(Date.now() / 1000);
// 按照键名对参数进行排序
const sortedParams = {};
Object.keys(data).sort().forEach(key => {
sortedParams[key] = data[key];
});
// 组合参数为字符串
let signStr = '';
for (const key in sortedParams) {
signStr += key + '=' + sortedParams[key] + '&';
}
// 获取当前请求的域名和时间戳,组合为密钥
// 使用正则表达式从URL中提取主机名
const hostRegex = /^(?:https?:\/\/)?([^\/]+)/i;
@ -106,18 +107,18 @@ class RequestManager {
const host = matches && matches[1] ? matches[1] : 'localhost';
const timestamp = data.timestamp;
const appSecret = host + timestamp;
// 添加密钥并去除最后的&
signStr = signStr.substring(0, signStr.length - 1) + appSecret;
console.log(signStr);
// 使用MD5生成签名
const sign = md5(signStr);
// 添加签名到请求参数
data.sign = sign;
}
header = {
'content-type': 'application/json',
token: token,
@ -194,7 +195,9 @@ class RequestManager {
})
}, 100)
uni.redirectTo({
url: '/pages/user/login'
url: '/pages/user/login',
// animationType: 'pop-in',
// animationDuration: 500
})
reject(res.data)
} else {

View File

@ -1,137 +1,172 @@
<template>
<view class="content">
<view class="navLeft align-center" :style="{top:$sys().statusBarHeight+'px'}" @tap="$c.back(1)">
<uni-icons type="left" color="#000000"></uni-icons>
</view>
<view class="title1">赏品记录</view>
<view class="" style="height: 200rpx;"></view>
<page-container title="赏品记录" :showBack="true">
<view class="tab">
<view class="tab-item center relative" v-for="(item, i) in tabList" :key="i"
:class="tabCur == i?'act':'unact'" @click="tabChange(i)">
<text>{{item}}</text>
:class="tabCur == i ? 'act' : 'unact'" @click="tabChange(i)">
<text>{{ item }}</text>
</view>
</view>
<scroll-view scroll-y="true" style="width: 100%; margin-top: 24rpx;">
<view v-for="(item,index) in dataList" class=""
style="width: 680rpx; height: 88rpx; background-color: #F8F8F8; margin: 0 auto 24rpx;">
<view class="flex row align-center" style="width: 100%; height: 100%; justify-content: space-between;">
<view class="flex column" style="margin-left: 24rpx;">
<text style="font-size: 16rpx; color: #999999;">{{item.Title}}</text>
<text style="font-size: 16rpx; color: #999999; margin-top: 8rpx;">{{item.Time}}</text>
<swiper :current="tabCur" @change="swiperChange" style="width: 100%; height: calc(100vh - 180rpx);">
<!-- 参与记录 -->
<swiper-item>
<scroll-view scroll-y="true" style="width: 100%; margin-top: 24rpx; height: 100%;">
<view v-for="(item, index) in recordsList" :key="index" class="record-card">
<view class="flex row align-center"
style="width: 100%; height: 100%; justify-content: space-between;">
<view class="flex column" style="margin-left: 24rpx;">
<text style="font-size: 16rpx; color: #999999;">{{ item.Title }}</text>
<text style="font-size: 16rpx; color: #999999; margin-top: 8rpx;">{{ item.Time }}</text>
</view>
<text style="font-size: 20rpx; color: #999999; margin-right: 24rpx;">{{ item.Content
}}</text>
</view>
</view>
<text style="font-size: 20rpx; color: #999999; margin-right: 24rpx;">{{item.Content}}</text>
</view>
<view class="empty-tip" v-if="recordsList.length === 0">暂无参与记录</view>
</scroll-view>
</swiper-item>
</view>
</scroll-view>
</view>
<!-- 赏品记录 -->
<swiper-item>
<scroll-view scroll-y="true" style="width: 100%; margin-top: 24rpx; height: 100%;">
<view v-for="(item, index) in winningList" :key="index" class="record-card">
<view class="flex row align-center"
style="width: 100%; height: 100%; justify-content: space-between;">
<view class="flex column" style="margin-left: 24rpx;">
<text style="font-size: 16rpx; color: #999999;">{{ item.Title }}</text>
<text style="font-size: 16rpx; color: #999999; margin-top: 8rpx;">{{ item.Time }}</text>
</view>
<text style="font-size: 20rpx; color: #999999; margin-right: 24rpx;">{{ item.Content
}}</text>
</view>
</view>
<view class="empty-tip" v-if="winningList.length === 0">暂无赏品记录</view>
</scroll-view>
</swiper-item>
</swiper>
</page-container>
</template>
<script>
export default {
data() {
return {
tabCur: 0,
tabList: [
"赏品记录", "参与记录",
],
dataList: [{
Title: "参与时间",
Time: "2025-03-10 14:00",
Content: "晶体*1500"
}, {
Title: "参与时间",
Time: "2025-03-10 14:00",
Content: "晶体*1500"
}, {
Title: "参与时间",
Time: "2025-03-10 14:00",
Content: "晶体*1500"
}, {
Title: "参与时间",
Time: "2025-03-10 14:00",
Content: "晶体*1500"
}, ]
import PageContainer from '@/components/page-container/page-container.vue'
export default {
components: {
PageContainer
},
data() {
return {
tabCur: 0,
tabList: [
"参与记录", "赏品记录"
],
recordsList: [], //
winningList: [] //
}
},
onLoad() {
this.loadAll();
},
methods: {
tabChange(i) {
this.tabCur = i;
},
//
swiperChange(e) {
this.tabCur = e.detail.current;
},
//
loadAll() {
this.load_records();
this.load_winning_records();
},
// API
formatListData(list, isWinningRecord = false) {
return list.map(item => ({
Title: item.goods_title || "参与时间",
Time: item.create_time || "",
Content: isWinningRecord ? item.goodslist_title : (item.description)
}));
},
// API
formatListData1(list, isWinningRecord = false) {
return list.map(item => ({
Title: "参与时间",
Time: item.create_time || "",
Content: item.goods_title
}));
},
//
async load_records() {
let { status, data, msg } = await this.$request.get('fuliwu_user_records');
if (status !== 1) {
this.$c.toast(msg);
return;
}
if (data && data.list && data.list.length > 0) {
this.recordsList = this.formatListData1(data.list, false);
} else {
this.recordsList = [];
}
},
methods: {
tabChange(i) {
this.tabCur = i
},
//
async load_winning_records() {
let { status, data, msg } = await this.$request.get('fuliwu_user_winning_records');
if (status !== 1) {
this.$c.toast(msg);
return;
}
if (data && data.list && data.list.length > 0) {
this.winningList = this.formatListData(data.list, true);
} else {
this.winningList = [];
}
}
}
}
</script>
<style lang="scss">
.content {
width: 100vw;
min-height: 100vh;
box-sizing: border-box;
background: #FFFFFF;
}
.tab {
display: flex;
padding: 10rpx 32rpx;
.navLeft {
position: fixed;
left: 30rpx;
height: 44px;
z-index: 100;
.tab-item {
width: 114rpx;
height: 50rpx;
position: relative;
margin-right: 25rpx;
border-radius: 8rpx;
font-size: 20rpx;
>view {
font-weight: 400;
font-size: 50rpx;
color: #FFFFFF;
&.act {
font-weight: 500;
color: #333333;
background-color: #D8FD24;
}
&.unact {
font-weight: 500;
}
}
}
.title1 {
width: 100%;
top: 108rpx;
position: absolute;
display: flex;
align-items: center;
font-size: 34rpx;
justify-content: center;
color: black;
z-index: 50;
}
.record-card {
width: 680rpx;
height: 88rpx;
background-color: #F8F8F8;
margin: 0 auto 24rpx;
}
.tab {
display: flex;
padding: 10rpx 32rpx;
.tab-item {
width: 114rpx;
height: 50rpx;
position: relative;
margin-right: 25rpx;
border-radius: 8rpx;
font-size: 20rpx;
&.act {
font-weight: 500;
color: #333333;
background-color: #D8FD24;
}
&.unact {
font-weight: 500;
}
}
}
.empty-tip {
text-align: center;
color: #999;
font-size: 24rpx;
padding: 40rpx 0;
}
</style>

View File

@ -44,15 +44,6 @@
<text>授权登录</text>
</button>
</view>
<!-- <button
class="bottom"
withCredentials="true"
lang="zh_CN"
@tap="getUserProfile"
>
授权登录
</button> -->
</view>
</view>
</view>
@ -209,13 +200,7 @@
h5UserProfile() {
var that = this;
console.log('进入h5')
//http://api.zpc-xy.com/login.html
//http://192.168.195.30:8080/#/pages/user/login?code=021gjuFa1F8OOH0uLeJa1T5fMh4gjuFA&state=STATE
//http://192.168.195.30:8080/pages/user/login pages/user/wxlogin
// var redirect_uri = escape(this.$loginPage);
window.location.href = this.$wxloginPage;
// `https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx0e33d80d35e4a3b1&redirect_uri=${redirect_uri}&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect`;
},
getdata() {
let that = this