Procházet zdrojové kódy

添加直播签到

puyao před 1 týdnem
rodič
revize
e1bdd2446e
3 změnil soubory, kde provedl 65 přidání a 3 odebrání
  1. 6 0
      api/living.js
  2. 1 0
      common/request.js
  3. 58 3
      pages_live/living.vue

+ 6 - 0
api/living.js

@@ -36,7 +36,13 @@ const api = {
 	subNotifyLive: '/appLive/app/live/subNotifyLive' ,//订阅消息
 	coupon: '/appLive/app/live/coupon/claim' ,//领取优惠券
 	curCoupon: '/appLive/app/live/coupon/curCoupon' ,//优惠券列表
+	sign: '/appLive/app/live/liveSign/sign' ,//直播签到
 }
+// 直播签到
+export function liveSign(data = {}) {
+	return request(api.sign, data, 'POST', 'application/json;charset=UTF-8')
+}
+
 // 点赞
 export function liveDataLike(liveId, data = {}) {
 	return request(api.liveDataLike(liveId), data, 'GET', 'application/json;charset=UTF-8')

+ 1 - 0
common/request.js

@@ -14,6 +14,7 @@ export default class Request {
 		if(router.indexOf("/appLive") !== -1) {
 			// router = router.replace('/appLive','')
 			path ='https://userapp.zkhj6.com';
+			// path = 'http://192.168.110.225:8113'; //h5接口
 		    router = router.replace('/appLive','')
 		}
 		//直播静默登录配置

+ 58 - 3
pages_live/living.vue

@@ -272,6 +272,14 @@
 				</view>
 			</u-popup>
 
+			<!-- 签到弹窗 -->
+			<u-popup :show="isShowSignPopup" round="20rpx" mode="center" bgColor="#ffffff" zIndex="10076" :closeable='true' @close='isShowSignPopup=false'>
+				<view class="sign-popup" style="padding: 40rpx; width: 500rpx; display: flex; flex-direction: column; align-items: center; border-radius: 20rpx; background: #fff;">
+					<view class="title" style="font-size: 36rpx; font-weight: bold; margin-bottom: 40rpx; color: #333;">观看直播签到</view>
+					<view class="button" style="width: 80%; height: 80rpx; line-height: 80rpx; text-align: center; background: #3C7DD7; color: #fff; border-radius: 40rpx; font-size: 30rpx;" @click="handleLiveSign">签到</view>
+				</view>
+			</u-popup>
+
 			<!-- 微信昵称授权弹窗 -->
 			<u-popup :show="userlogo" mode="bottom" round='12'>
 				<view class="userlogo column">
@@ -359,8 +367,8 @@
 		sendliveGift,
 		getUserIntegralInfo, //福币
 		loginByMp,
-	    getUserLiveInfo
-
+	    getUserLiveInfo,
+		liveSign
 	} from '@/api/living.js'
 	import {
 		getUserInfo,
@@ -586,7 +594,9 @@
 				userInfo: '',
 				urlOption: {},
 				source: '', // app,app内嵌H5页面
-				liveUserId:null
+				liveUserId:null,
+				isShowSignPopup: false,
+				signNo: ''
 			}
 		},
 		async onLoad(options) {
@@ -982,6 +992,33 @@
 			}
 		},
 		methods: { 
+			handleLiveSign() {
+				if (!this.liveId || !this.signNo) return;
+				const userName = this.userData.nickname || this.userData.nickName || '未命名';
+				liveSign({
+					liveId: this.liveId,
+					userName: userName,
+					signNo: this.signNo
+				}).then(res => {
+					if (res.code == 200) {
+						uni.showToast({
+							title: '签到成功',
+							icon: 'none'
+						});
+						this.isShowSignPopup = false;
+					} else {
+						uni.showToast({
+							title: res.msg || '签到失败',
+							icon: 'none'
+						});
+					}
+				}).catch(err => {
+					uni.showToast({
+						title: '网络错误,签到失败',
+						icon: 'none'
+					});
+				});
+			},
 			// getUserLiveInfo(){
 			// 	getUserLiveInfo().then((res) => {
 			// 				if (res.code == 200) {
@@ -3558,6 +3595,7 @@
                 
 				try {
 					const baseWsUrl = 'wss://liveapp.zkhj6.com/ws/app/webSocket'
+					// const baseWsUrl = 'ws://192.168.110.225:7114/ws/app/webSocket'//本地
 					let wsUrl =
 						`${baseWsUrl}?userId=${this.liveUserId}&liveId=${this.liveId}&userType=${this.userType}&timestamp=${this.timestamp}&signature=${signature}`
 					if (this.qrFrom) {
@@ -3878,6 +3916,23 @@
 							} else {
 								this.isShowLottery = false
 							}
+						} else if (socketMessage.cmd == 'sign') {
+							try {
+								const signData = socketMessage.data ? JSON.parse(socketMessage.data) : {}
+								if (typeof signData === 'string') {
+									const innerData = JSON.parse(signData)
+									this.signNo = innerData.signNo || ''
+								} else {
+									this.signNo = signData.signNo || ''
+								}
+								if (socketMessage.status === 1) {
+									this.isShowSignPopup = true
+								} else {
+									this.isShowSignPopup = false
+								}
+							} catch (err) {
+								console.error('解析签到数据失败:', err)
+							}
 						} else if (socketMessage.cmd == 'deleteMsg') {
 							const index = this.talklist.findIndex(item => item.msgId == socketMessage.msg)
 							if (index !== -1) {