vhall-mini-sdk 0.4.1 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/gift/gift-display/gift-display.js +118 -0
- package/dist/components/gift/gift-display/gift-display.json +3 -0
- package/dist/components/gift/gift-display/gift-display.wxml +16 -0
- package/dist/components/gift/gift-display/gift-display.wxss +1 -0
- package/dist/components/gift/gift-sender/gift-sender.js +63 -0
- package/dist/components/gift/gift-sender/gift-sender.json +6 -0
- package/dist/components/gift/gift-sender/gift-sender.wxml +19 -0
- package/dist/components/gift/gift-sender/gift-sender.wxss +1 -0
- package/dist/components/lottery/lottery-accept/index.js +249 -0
- package/dist/components/lottery/lottery-accept/index.json +4 -0
- package/dist/components/lottery/lottery-accept/index.wxml +49 -0
- package/dist/components/lottery/lottery-accept/index.wxss +1 -0
- package/dist/components/lottery/lottery-history/index.js +36 -0
- package/dist/components/lottery/lottery-history/index.json +3 -0
- package/dist/components/lottery/lottery-history/index.wxml +28 -0
- package/dist/components/lottery/lottery-history/index.wxss +1 -0
- package/dist/components/lottery/lottery-shake/lottery-shake.js +328 -0
- package/dist/components/lottery/lottery-shake/lottery-shake.json +1 -0
- package/dist/components/lottery/lottery-shake/lottery-shake.wxml +52 -0
- package/dist/components/lottery/lottery-shake/lottery-shake.wxss +1 -0
- package/dist/components/lottery/lottery-slot/lottery-slot.js +230 -0
- package/dist/components/lottery/lottery-slot/lottery-slot.json +1 -0
- package/dist/components/lottery/lottery-slot/lottery-slot.wxml +62 -0
- package/dist/components/lottery/lottery-slot/lottery-slot.wxss +1 -0
- package/dist/components/lottery/lottery-wheel/lottery-wheel.js +153 -0
- package/dist/components/lottery/lottery-wheel/lottery-wheel.json +4 -0
- package/dist/components/lottery/lottery-wheel/lottery-wheel.wxml +91 -0
- package/dist/components/lottery/lottery-wheel/lottery-wheel.wxss +1 -0
- package/dist/components/lottery/lottery-winners/index.js +101 -0
- package/dist/components/lottery/lottery-winners/index.json +4 -0
- package/dist/components/lottery/lottery-winners/index.wxml +39 -0
- package/dist/components/lottery/lottery-winners/index.wxss +1 -0
- package/dist/components/lottery/lottery.js +388 -0
- package/dist/components/lottery/lottery.json +11 -0
- package/dist/components/lottery/lottery.wxml +78 -0
- package/dist/components/lottery/lottery.wxss +1 -0
- package/dist/components/lottery/wheel.json +49 -0
- package/dist/components/mall-reward/common/reward-card.wxss +0 -0
- package/dist/components/mall-reward/duration-icon/index.js +101 -0
- package/dist/components/mall-reward/duration-icon/index.json +3 -0
- package/dist/components/mall-reward/duration-icon/index.wxml +7 -0
- package/dist/components/mall-reward/duration-icon/index.wxss +1 -0
- package/dist/components/mall-reward/f-count-down/index.js +61 -0
- package/dist/components/mall-reward/f-count-down/index.json +3 -0
- package/dist/components/mall-reward/f-count-down/index.wxml +9 -0
- package/dist/components/mall-reward/f-count-down/index.wxss +1 -0
- package/dist/components/mall-reward/f-empty/index.js +11 -0
- package/dist/components/mall-reward/f-empty/index.json +3 -0
- package/dist/components/mall-reward/f-empty/index.wxml +8 -0
- package/dist/components/mall-reward/f-empty/index.wxss +1 -0
- package/dist/components/mall-reward/f-history/index.js +84 -0
- package/dist/components/mall-reward/f-history/index.json +4 -0
- package/dist/components/mall-reward/f-history/index.wxml +38 -0
- package/dist/components/mall-reward/f-history/index.wxss +1 -0
- package/dist/components/mall-reward/f-open/index.js +36 -0
- package/dist/components/mall-reward/f-open/index.json +3 -0
- package/dist/components/mall-reward/f-open/index.wxml +10 -0
- package/dist/components/mall-reward/f-open/index.wxss +1 -0
- package/dist/components/mall-reward/f-receive/index.js +36 -0
- package/dist/components/mall-reward/f-receive/index.json +3 -0
- package/dist/components/mall-reward/f-receive/index.wxml +9 -0
- package/dist/components/mall-reward/f-receive/index.wxss +1 -0
- package/dist/components/mall-reward/index.js +374 -0
- package/dist/components/mall-reward/index.json +8 -0
- package/dist/components/mall-reward/index.wxml +4 -0
- package/dist/components/mall-reward/index.wxss +0 -0
- package/dist/components/mall-reward/main-popup/index.js +46 -0
- package/dist/components/mall-reward/main-popup/index.json +12 -0
- package/dist/components/mall-reward/main-popup/index.wxml +16 -0
- package/dist/components/mall-reward/main-popup/index.wxss +1 -0
- package/dist/components/praise/praise.js +150 -0
- package/dist/components/praise/praise.json +5 -0
- package/dist/components/praise/praise.wxml +17 -0
- package/dist/components/praise/praise.wxss +1 -0
- package/dist/components/product/product-card/product-card.js +109 -0
- package/dist/components/product/product-card/product-card.json +3 -0
- package/dist/components/product/product-card/product-card.wxml +47 -0
- package/dist/components/product/product-card/product-card.wxss +1 -0
- package/dist/components/product/product-detail/product-detail.js +127 -0
- package/dist/components/product/product-detail/product-detail.json +3 -0
- package/dist/components/product/product-detail/product-detail.wxml +57 -0
- package/dist/components/product/product-detail/product-detail.wxss +1 -0
- package/dist/components/product/product-item/product-item.js +56 -0
- package/dist/components/product/product-item/product-item.json +3 -0
- package/dist/components/product/product-item/product-item.wxml +35 -0
- package/dist/components/product/product-item/product-item.wxss +1 -0
- package/dist/components/product/product-list/product-list.js +67 -0
- package/dist/components/product/product-list/product-list.json +6 -0
- package/dist/components/product/product-list/product-list.wxml +16 -0
- package/dist/components/product/product-list/product-list.wxss +1 -0
- package/dist/components/product/product-order/product-order.js +394 -0
- package/dist/components/product/product-order/product-order.json +3 -0
- package/dist/components/product/product-order/product-order.wxml +75 -0
- package/dist/components/product/product-order/product-order.wxss +1 -0
- package/dist/pubComponents/popup/popup.wxss +1 -0
- package/dist/sdk/config/index.js +1 -0
- package/dist/sdk/plugins/InteractServer.js +1 -0
- package/dist/sdk/plugins/LotteryServer.js +1 -0
- package/dist/sdk/plugins/MallRewardServer.js +1 -0
- package/dist/sdk/plugins/ProductServer.js +1 -0
- package/lib/components/live-landscape/live-landscape.js +2 -2
- package/lib/components/live-portrait/live-portrait.js +2 -2
- package/lib/components/player/components/controls/controls.wxml +6 -3
- package/lib/components/player/components/controls/controls.wxss +1 -1
- package/lib/components/player/player.wxml +26 -24
- package/lib/components/player/player.wxss +1 -1
- package/lib/components/product/product-card/product-card.wxml +1 -1
- package/lib/sdk/main/index.js +2 -2
- package/lib/shared/mpUtils.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
Component({
|
|
2
|
+
properties: {
|
|
3
|
+
sdkInstance: {
|
|
4
|
+
type: Object,
|
|
5
|
+
value: null,
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
data: {
|
|
9
|
+
giftMessages: []
|
|
10
|
+
},
|
|
11
|
+
observers: {
|
|
12
|
+
sdkInstance: function sdkInstance(_sdkInstance) {
|
|
13
|
+
if (!_sdkInstance) return;
|
|
14
|
+
this.sdkInstance = _sdkInstance;
|
|
15
|
+
this.initListener();
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
lifetimes: {
|
|
19
|
+
detached() {
|
|
20
|
+
// 组件销毁时清除监听
|
|
21
|
+
this.unlistener && this.unlistener();
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
methods: {
|
|
25
|
+
// 初始化事件监听
|
|
26
|
+
initListener() {
|
|
27
|
+
this.unlistener && this.unlistener();
|
|
28
|
+
const obj = {};
|
|
29
|
+
obj[this.sdkInstance.EVENT.GIFT_MSG] = (msg) => {
|
|
30
|
+
this.handleGiftMessage(msg);
|
|
31
|
+
};
|
|
32
|
+
this.unlistener = this.sdkInstance.on(obj);
|
|
33
|
+
},
|
|
34
|
+
|
|
35
|
+
// 处理礼物消息
|
|
36
|
+
handleGiftMessage(data) {
|
|
37
|
+
// 生成唯一ID
|
|
38
|
+
const id = Date.now() + Math.random().toString(36).substr(2, 9);
|
|
39
|
+
|
|
40
|
+
// 构建礼物消息对象
|
|
41
|
+
const giftMessage = {
|
|
42
|
+
id,
|
|
43
|
+
nickname: data.gift_user_name || '匿名用户',
|
|
44
|
+
gift: {
|
|
45
|
+
icon: data.gift_image_url || '',
|
|
46
|
+
name: data.gift_name || '礼物'
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
// 添加到礼物消息列表
|
|
51
|
+
const newGiftMessages = [...this.data.giftMessages, giftMessage];
|
|
52
|
+
this.setData({ giftMessages: newGiftMessages });
|
|
53
|
+
|
|
54
|
+
// 触发动画
|
|
55
|
+
this.triggerAnimation(id);
|
|
56
|
+
|
|
57
|
+
// 3秒后移除礼物消息
|
|
58
|
+
setTimeout(() => {
|
|
59
|
+
this.removeGiftMessage(id);
|
|
60
|
+
}, 3000);
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
// 触发动画
|
|
64
|
+
triggerAnimation(id) {
|
|
65
|
+
// 创建进入动画
|
|
66
|
+
const animation = wx.createAnimation({
|
|
67
|
+
duration: 500,
|
|
68
|
+
timingFunction: 'ease-out'
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
// 从左侧滑入并稍微向上移动
|
|
72
|
+
animation.translateX(0).translateY(-20).opacity(1).step();
|
|
73
|
+
|
|
74
|
+
// 更新动画
|
|
75
|
+
const newGiftMessages = this.data.giftMessages.map(item => {
|
|
76
|
+
if (item.id === id) {
|
|
77
|
+
return { ...item, animation: animation.export() };
|
|
78
|
+
}
|
|
79
|
+
return item;
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
this.setData({ giftMessages: newGiftMessages });
|
|
83
|
+
|
|
84
|
+
// 2秒后开始飘出动画
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
this.floatAnimation(id);
|
|
87
|
+
}, 2000);
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
// 飘出动画
|
|
91
|
+
floatAnimation(id) {
|
|
92
|
+
// 创建飘出动画
|
|
93
|
+
const animation = wx.createAnimation({
|
|
94
|
+
duration: 1000,
|
|
95
|
+
timingFunction: 'ease-in-out'
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
// 向上飘动并逐渐透明
|
|
99
|
+
animation.translateY(-60).opacity(0).step();
|
|
100
|
+
|
|
101
|
+
// 更新动画
|
|
102
|
+
const newGiftMessages = this.data.giftMessages.map(item => {
|
|
103
|
+
if (item.id === id) {
|
|
104
|
+
return { ...item, animation: animation.export() };
|
|
105
|
+
}
|
|
106
|
+
return item;
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
this.setData({ giftMessages: newGiftMessages });
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
// 移除礼物消息
|
|
113
|
+
removeGiftMessage(id) {
|
|
114
|
+
const finalGiftMessages = this.data.giftMessages.filter(item => item.id !== id);
|
|
115
|
+
this.setData({ giftMessages: finalGiftMessages });
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<view class="gift-display">
|
|
2
|
+
<view
|
|
3
|
+
wx:for="{{giftMessages}}"
|
|
4
|
+
wx:key="id"
|
|
5
|
+
class="gift-item"
|
|
6
|
+
style="top: {{index * 80}}rpx;"
|
|
7
|
+
animation="{{item.animation}}"
|
|
8
|
+
>
|
|
9
|
+
<view class="gift-content">
|
|
10
|
+
<text class="gift-user">{{item.nickname}}</text>
|
|
11
|
+
<text class="gift-action">送出了</text>
|
|
12
|
+
<text class="gift-name">{{item.gift.name}}</text>
|
|
13
|
+
<image class="gift-icon" src="{{item.gift.icon}}" mode="aspectFit"></image>
|
|
14
|
+
</view>
|
|
15
|
+
</view>
|
|
16
|
+
</view>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gift-display{left:0;pointer-events:none;position:absolute;top:100rpx;z-index:9999;z-index:100}.gift-item{background:linear-gradient(90deg,#8274ff 2.98%,rgba(249,51,249,.4) 118.57%);border-radius:25rpx;left:20rpx;margin-bottom:10rpx;min-width:300rpx;opacity:0;padding:10rpx 20rpx;position:absolute;transform:translateX(-100%)}.gift-content,.gift-item{align-items:center;display:flex}.gift-content{flex-wrap:nowrap}.gift-action,.gift-user{color:#fff;font-size:.86rem;margin-right:10rpx;white-space:nowrap}.gift-icon{height:40rpx;margin-right:10rpx;transform:scale(2);transform-origin:left center;width:40rpx}.gift-name{color:gold;font-size:.86rem;font-weight:700;white-space:nowrap}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
Component({
|
|
2
|
+
properties: {
|
|
3
|
+
sdkInstance: {
|
|
4
|
+
type: Object,
|
|
5
|
+
value: null,
|
|
6
|
+
}
|
|
7
|
+
},
|
|
8
|
+
data: {
|
|
9
|
+
giftList: [],
|
|
10
|
+
selectedGift: null
|
|
11
|
+
},
|
|
12
|
+
lifetimes: {
|
|
13
|
+
attached() {
|
|
14
|
+
// 组件挂载时调用获取礼物列表
|
|
15
|
+
if (this.properties.sdkInstance) {
|
|
16
|
+
this.sdkInstance = this.properties.sdkInstance;
|
|
17
|
+
this.getGiftList();
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
methods: {
|
|
22
|
+
// 获取礼物列表
|
|
23
|
+
async getGiftList() {
|
|
24
|
+
|
|
25
|
+
const interactServer = this.sdkInstance.get('interactServer');
|
|
26
|
+
if (!interactServer) {
|
|
27
|
+
console.error('InteractServer不存在');
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// 调用 InteractServer 的 getGiftList 方法获取礼物列表
|
|
32
|
+
const giftList = await interactServer.getGiftList();
|
|
33
|
+
this.setData({ giftList });
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
// 选择礼物
|
|
37
|
+
selectGift(e) {
|
|
38
|
+
const gift = e.currentTarget.dataset.gift;
|
|
39
|
+
this.setData({ selectedGift: gift });
|
|
40
|
+
},
|
|
41
|
+
|
|
42
|
+
// 发送礼物
|
|
43
|
+
async sendGift(e) {
|
|
44
|
+
|
|
45
|
+
if (!this.data.selectedGift) return;
|
|
46
|
+
|
|
47
|
+
const interactServer = this.sdkInstance.get('interactServer');
|
|
48
|
+
if (interactServer) {
|
|
49
|
+
const res = await interactServer.sendGift(this.data.selectedGift);
|
|
50
|
+
if(res.code==200){
|
|
51
|
+
// 触发关闭事件,通知父组件关闭弹窗
|
|
52
|
+
this.triggerEvent('onSendFinished');
|
|
53
|
+
}else{
|
|
54
|
+
wx.showToast({
|
|
55
|
+
title: res.msg,
|
|
56
|
+
icon: 'none',
|
|
57
|
+
duration: 2000
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<view class="gift-popup-content">
|
|
2
|
+
<view class="gift-popup-header">
|
|
3
|
+
</view>
|
|
4
|
+
<view class="gift-list">
|
|
5
|
+
<view
|
|
6
|
+
wx:for="{{giftList}}"
|
|
7
|
+
wx:key="id"
|
|
8
|
+
class="gift-item {{selectedGift && selectedGift.id == item.id ? 'gift-item-selected' : ''}}"
|
|
9
|
+
bindtap="selectGift"
|
|
10
|
+
data-gift="{{item}}"
|
|
11
|
+
>
|
|
12
|
+
<image class="gift-item-icon" src="{{item.icon}}" mode="aspectFit"></image>
|
|
13
|
+
<text class="gift-item-name" wx:if="{{selectedGift.id != item.id}}">{{item.name}}</text>
|
|
14
|
+
<view class="gift-item-button" wx:if="{{selectedGift && selectedGift.id == item.id}}" catchtap="sendGift">
|
|
15
|
+
<text class="gift-item-button-text">赠送</text>
|
|
16
|
+
</view>
|
|
17
|
+
</view>
|
|
18
|
+
</view>
|
|
19
|
+
</view>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.gift-popup-content{background:#fff;border-radius:20rpx 20rpx 0 0;padding:20rpx}.gift-list{display:grid;gap:20rpx;grid-template-columns:repeat(4,1fr);max-height:400rpx;overflow-y:auto;padding:20rpx 0}.gift-item{align-items:center;border-radius:10rpx;box-sizing:border-box;display:flex;flex-direction:column;height:180rpx;justify-content:space-between;position:relative;transition:all .3s}.gift-item:active{background:#f5f5f5;transform:scale(.95)}.gift-item-selected{border:1px solid #ff4d4f}.gift-item-icon{height:120rpx;margin-bottom:10rpx;width:120rpx}.gift-item-name{color:#333;margin-bottom:5rpx}.gift-item-button,.gift-item-name{font-size:.86rem;text-align:center}.gift-item-button{background:#ff4d4f;color:#fff;display:block;line-height:1.71rem;width:100%}.gift-popup-footer{border-top:1rpx solid #f0f0f0;justify-content:space-between;margin-top:20rpx;padding:20rpx 0}.gift-popup-footer,.selected-gift-info{align-items:center;display:flex}.selected-gift-icon{height:40rpx;margin-right:10rpx;width:40rpx}.selected-gift-name{color:#333;font-size:1rem;margin-right:10rpx}.selected-gift-price{color:#ff4d4f;font-size:1rem;font-weight:700}.send-button{background:#ff4d4f;border-radius:25rpx;color:#fff;font-size:1rem;font-weight:700;padding:15rpx 40rpx}.send-button:active{background:#ff7875;transform:scale(.95)}.gift-loading{align-items:center;display:flex;flex-direction:column;justify-content:center;padding:100rpx 0}.gift-loading-spinner{animation:spin 1s linear infinite;border:4rpx solid #f0f0f0;border-radius:50%;border-top-color:#ff4d4f;height:60rpx;margin-bottom:20rpx;width:60rpx}.gift-loading-text{color:#999;font-size:1rem}@keyframes spin{0%{transform:rotate(0deg)}to{transform:rotate(1turn)}}
|
|
@@ -0,0 +1,249 @@
|
|
|
1
|
+
Component({
|
|
2
|
+
properties: {
|
|
3
|
+
visible: {
|
|
4
|
+
type: Boolean,
|
|
5
|
+
value: false,
|
|
6
|
+
},
|
|
7
|
+
lotteryId: {
|
|
8
|
+
type: String,
|
|
9
|
+
value: '',
|
|
10
|
+
},
|
|
11
|
+
sdkInstance: {
|
|
12
|
+
type: Object,
|
|
13
|
+
value: null,
|
|
14
|
+
},
|
|
15
|
+
publishWinner: {
|
|
16
|
+
type: Number,
|
|
17
|
+
value: 0,
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
data: {
|
|
22
|
+
acceptType: 1, // 1表单,2客服,3无需领奖
|
|
23
|
+
winForm: [], // 中奖信息表单
|
|
24
|
+
customerServiceInfo: {}, // 客服信息
|
|
25
|
+
verified: false, // 表单是否验证通过
|
|
26
|
+
showSuccess: false, // 是否显示提交成功弹框
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
observers: {
|
|
30
|
+
visible: function (visible) {
|
|
31
|
+
if (visible && this.properties.lotteryId && this.properties.sdkInstance) {
|
|
32
|
+
this.initAcceptConfig();
|
|
33
|
+
} else {
|
|
34
|
+
this.setData({ showSuccess: false });
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
methods: {
|
|
40
|
+
// 获取领奖配置
|
|
41
|
+
async initAcceptConfig() {
|
|
42
|
+
try {
|
|
43
|
+
const lotteryServer = this.properties.sdkInstance.get('lotteryServer');
|
|
44
|
+
const webinarId = this.properties.sdkInstance.store.get('webinarId');
|
|
45
|
+
const res = await lotteryServer.getReceiveAwardSetting({
|
|
46
|
+
lottery_id: this.properties.lotteryId || '',
|
|
47
|
+
webinar_id: webinarId || '',
|
|
48
|
+
});
|
|
49
|
+
if (res.code === 200) {
|
|
50
|
+
const data = res.data;
|
|
51
|
+
if (data.receive_award_way === 1) {
|
|
52
|
+
// 表单领奖
|
|
53
|
+
this.setData({
|
|
54
|
+
acceptType: 1,
|
|
55
|
+
winForm: this.paseFormInfo(data.json_data),
|
|
56
|
+
});
|
|
57
|
+
this.fillUserInfo();
|
|
58
|
+
} else if (data.receive_award_way === 2) {
|
|
59
|
+
// 客服领奖
|
|
60
|
+
this.setData({
|
|
61
|
+
acceptType: 2,
|
|
62
|
+
customerServiceInfo: this.paseCustomerServiceInfo(data.json_data),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
} catch (err) {
|
|
67
|
+
console.error('获取领奖配置失败:', err);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
|
|
71
|
+
// 解析表单信息
|
|
72
|
+
paseFormInfo(jsonString) {
|
|
73
|
+
let info = [];
|
|
74
|
+
try {
|
|
75
|
+
const jsonObj = JSON.parse(jsonString);
|
|
76
|
+
if (Array.isArray(jsonObj)) {
|
|
77
|
+
jsonObj.map((item) => {
|
|
78
|
+
if (item.field_key == 'phone') {
|
|
79
|
+
item.maxLength = 20;
|
|
80
|
+
} else if (item.field_key == 'name') {
|
|
81
|
+
item.maxLength = 20;
|
|
82
|
+
} else if (item.field_key == 'address') {
|
|
83
|
+
item.maxLength = 50;
|
|
84
|
+
} else {
|
|
85
|
+
item.maxLength = 100;
|
|
86
|
+
}
|
|
87
|
+
item.field_value = '';
|
|
88
|
+
item.error = false;
|
|
89
|
+
info.push(item);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
} catch (e) {
|
|
93
|
+
info = [];
|
|
94
|
+
}
|
|
95
|
+
return info;
|
|
96
|
+
},
|
|
97
|
+
|
|
98
|
+
// 解析客服信息
|
|
99
|
+
paseCustomerServiceInfo(jsonString) {
|
|
100
|
+
let info = {};
|
|
101
|
+
try {
|
|
102
|
+
const jsonObj = JSON.parse(jsonString);
|
|
103
|
+
if (Array.isArray(jsonObj)) {
|
|
104
|
+
jsonObj.forEach((filedItem) => {
|
|
105
|
+
info[filedItem.field_key] = filedItem.placeholder;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
} catch (e) {
|
|
109
|
+
info = {};
|
|
110
|
+
}
|
|
111
|
+
return info;
|
|
112
|
+
},
|
|
113
|
+
|
|
114
|
+
// 验证表单是否可提交
|
|
115
|
+
validateForm() {
|
|
116
|
+
const winForm = this.data.winForm;
|
|
117
|
+
const verified = winForm.every((form) => {
|
|
118
|
+
return !form.is_required || (form.field_value && form.field_value.trim() !== '');
|
|
119
|
+
});
|
|
120
|
+
this.setData({ verified });
|
|
121
|
+
},
|
|
122
|
+
|
|
123
|
+
// 表单输入监听
|
|
124
|
+
onFormInput(e) {
|
|
125
|
+
const { index } = e.currentTarget.dataset;
|
|
126
|
+
const value = e.detail.value;
|
|
127
|
+
const winForm = this.data.winForm;
|
|
128
|
+
winForm[index].field_value = value;
|
|
129
|
+
winForm[index].error = false;
|
|
130
|
+
this.setData({ winForm });
|
|
131
|
+
this.validateForm();
|
|
132
|
+
},
|
|
133
|
+
|
|
134
|
+
// 验证表单
|
|
135
|
+
verify() {
|
|
136
|
+
const winForm = this.data.winForm;
|
|
137
|
+
const errorItem = winForm.find((item) => {
|
|
138
|
+
if (
|
|
139
|
+
item.field_key == 'phone' &&
|
|
140
|
+
((item.field_value != '' && item.field_value != null) || !!item.is_required)
|
|
141
|
+
) {
|
|
142
|
+
const phone = item.field_value.replace(/\s+/g, '');
|
|
143
|
+
// 简单的手机号校验
|
|
144
|
+
if (!/^1[3-9]\d{9}$/.test(phone)) {
|
|
145
|
+
return true;
|
|
146
|
+
}
|
|
147
|
+
} else if (!!item.is_required && item.field_value == '') {
|
|
148
|
+
return true;
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
if (errorItem) {
|
|
154
|
+
errorItem.error = true;
|
|
155
|
+
this.setData({ winForm });
|
|
156
|
+
wx.showToast({
|
|
157
|
+
title: `请输入正确的信息${errorItem.field}`,
|
|
158
|
+
icon: 'none',
|
|
159
|
+
});
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
return true;
|
|
163
|
+
},
|
|
164
|
+
|
|
165
|
+
// 提交领奖信息
|
|
166
|
+
async submit() {
|
|
167
|
+
if (!this.verify()) return;
|
|
168
|
+
|
|
169
|
+
const winForm = this.data.winForm;
|
|
170
|
+
const remark = winForm.map((item) => ({
|
|
171
|
+
field_value: item.field_value,
|
|
172
|
+
field: item.field,
|
|
173
|
+
field_key: item.field_key,
|
|
174
|
+
is_required: item.is_required,
|
|
175
|
+
is_system: item.is_system,
|
|
176
|
+
placeholder: item.placeholder,
|
|
177
|
+
rank: item.rank,
|
|
178
|
+
}));
|
|
179
|
+
|
|
180
|
+
try {
|
|
181
|
+
const lotteryServer = this.properties.sdkInstance.get('lotteryServer');
|
|
182
|
+
if (!lotteryServer) return;
|
|
183
|
+
const watchInitData = this.properties.sdkInstance.store.get('watchInitData');
|
|
184
|
+
const roomId = watchInitData?.interact?.room_id || '';
|
|
185
|
+
const res = await lotteryServer.submitLotteryAward({
|
|
186
|
+
lottery_user_name: winForm[0]?.field_value || '',
|
|
187
|
+
lottery_user_phone: winForm[1]?.field_value || '',
|
|
188
|
+
lottery_user_remark: JSON.stringify(remark),
|
|
189
|
+
lottery_id: this.properties.lotteryId || '',
|
|
190
|
+
room_id: roomId,
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
if (res.code === 200) {
|
|
194
|
+
this.setData({ showSuccess: true });
|
|
195
|
+
this.triggerEvent('success');
|
|
196
|
+
} else {
|
|
197
|
+
wx.showToast({
|
|
198
|
+
title: res.msg || '提交失败',
|
|
199
|
+
icon: 'none',
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
} catch (err) {
|
|
203
|
+
wx.showToast({
|
|
204
|
+
title: '提交失败',
|
|
205
|
+
icon: 'none',
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
},
|
|
209
|
+
|
|
210
|
+
// 预填用户信息
|
|
211
|
+
async fillUserInfo() {
|
|
212
|
+
try {
|
|
213
|
+
const lotteryServer = this.properties.sdkInstance.get('lotteryServer');
|
|
214
|
+
if (!lotteryServer) return;
|
|
215
|
+
const res = await lotteryServer.getLotteryUserInfo();
|
|
216
|
+
if (res.code === 200 && res.data) {
|
|
217
|
+
const data = res.data;
|
|
218
|
+
const winForm = this.data.winForm;
|
|
219
|
+
winForm.map((item) => {
|
|
220
|
+
if (item.field_key == 'name') {
|
|
221
|
+
item.field_value = data.lottery_user_name || '';
|
|
222
|
+
item.error = false;
|
|
223
|
+
} else if (item.field_key == 'phone') {
|
|
224
|
+
item.field_value = data.lottery_user_phone || '';
|
|
225
|
+
} else if (item.field_key == 'address') {
|
|
226
|
+
item.field_value = data.lottery_user_address || '';
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
this.setData({ winForm });
|
|
230
|
+
this.validateForm();
|
|
231
|
+
}
|
|
232
|
+
} catch (err) {
|
|
233
|
+
console.error('获取用户信息失败:', err);
|
|
234
|
+
}
|
|
235
|
+
},
|
|
236
|
+
|
|
237
|
+
// 关闭弹框
|
|
238
|
+
close() {
|
|
239
|
+
this.setData({ showSuccess: false });
|
|
240
|
+
this.triggerEvent('close');
|
|
241
|
+
},
|
|
242
|
+
|
|
243
|
+
// 查看中奖名单
|
|
244
|
+
viewWinnersList() {
|
|
245
|
+
this.setData({ showSuccess: false });
|
|
246
|
+
this.triggerEvent('viewWinners');
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
});
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
<view wx:if="{{visible}}" class="lottery-accept-modal">
|
|
2
|
+
<view class="lottery-accept-mask" bindtap="close"></view>
|
|
3
|
+
<view class="lottery-accept-content">
|
|
4
|
+
<view class="lottery-accept-title">领奖信息</view>
|
|
5
|
+
<!-- 表单领奖 -->
|
|
6
|
+
<view wx:if="{{acceptType === 1}}" class="form-wrap">
|
|
7
|
+
<view class="form">
|
|
8
|
+
<view wx:for="{{winForm}}" wx:key="index" class="form-item">
|
|
9
|
+
<view class="form-item__input {{item.is_required ? 'required' : ''}}">
|
|
10
|
+
<input class="form-input" value="{{item.field_value}}" type="text" maxlength="{{item.maxLength}}" placeholder="{{item.placeholder}}" data-index="{{index}}" bindinput="onFormInput" />
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|
|
13
|
+
</view>
|
|
14
|
+
<button class="vmp-lottery-btn {{verified ? '' : 'disabled'}}" bindtap="submit">
|
|
15
|
+
提交
|
|
16
|
+
</button>
|
|
17
|
+
</view>
|
|
18
|
+
<!-- 客服领奖 -->
|
|
19
|
+
<view wx:if="{{acceptType === 2}}" class="customer-service-container">
|
|
20
|
+
<view wx:if="{{customerServiceInfo.private_number}}" class="wechat">
|
|
21
|
+
{{customerServiceInfo.private_number}}
|
|
22
|
+
</view>
|
|
23
|
+
<image wx:if="{{customerServiceInfo.private_qrcode}}" src="{{customerServiceInfo.private_qrcode}}" class="qrcode" mode="aspectFit" />
|
|
24
|
+
<view wx:if="{{customerServiceInfo.tip_note}}" class="tip">
|
|
25
|
+
{{customerServiceInfo.tip_note}}
|
|
26
|
+
</view>
|
|
27
|
+
<button wx:if="{{publishWinner == 1}}" class="lottery-success-btn" bindtap="viewWinnersList">
|
|
28
|
+
查看中奖名单
|
|
29
|
+
</button>
|
|
30
|
+
</view>
|
|
31
|
+
</view>
|
|
32
|
+
|
|
33
|
+
<!-- 提交成功弹框 -->
|
|
34
|
+
<view wx:if="{{showSuccess}}" class="lottery-success-modal">
|
|
35
|
+
<view class="lottery-success-mask" bindtap="close"></view>
|
|
36
|
+
<view class="lottery-success-content">
|
|
37
|
+
<view class="lottery-success-close" bindtap="close">
|
|
38
|
+
<icon type="cancel" size="24" color="#999" />
|
|
39
|
+
</view>
|
|
40
|
+
<view class="lottery-success-icon">
|
|
41
|
+
<view class="success-check"></view>
|
|
42
|
+
</view>
|
|
43
|
+
<text class="lottery-success-title">信息提交成功</text>
|
|
44
|
+
<button wx:if="{{publishWinner == 1}}" class="lottery-success-btn" bindtap="viewWinnersList">
|
|
45
|
+
查看中奖名单
|
|
46
|
+
</button>
|
|
47
|
+
</view>
|
|
48
|
+
</view>
|
|
49
|
+
</view>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.lottery-accept-modal{bottom:0;display:flex;flex-direction:column;justify-content:flex-end;left:0;position:fixed;right:0;top:0;z-index:1000}.lottery-accept-mask{background:rgba(0,0,0,.5);bottom:0;left:0;position:absolute;right:0;top:0}.lottery-accept-content{background:linear-gradient(37.94deg,#fffbe8 3.86%,#fbf0e6 84.36%);border-radius:32rpx 32rpx 0 0;max-height:85vh;overflow-y:auto;padding:0 40rpx 80rpx;position:relative}.lottery-accept-title{color:#333;font-size:1.36rem;font-weight:600;line-height:4.29rem;text-align:center}.customer-service-container{align-items:center;display:flex;flex-direction:column}.customer-service-container .wechat{color:#333;font-size:1.14rem;line-height:1.71rem;text-align:center;word-break:break-all}.customer-service-container .qrcode{height:400rpx;margin-top:40rpx;width:400rpx}.customer-service-container .tip{color:#999;font-size:1rem;line-height:1.43rem;margin-top:30rpx;text-align:center}.form-item{align-items:center;background:#f8f8f8;border-radius:16rpx;display:flex;height:100rpx;margin-bottom:24rpx;overflow:hidden;position:relative}.form-item__input{flex:1;padding-left:80rpx;position:relative}.form-item__input.required:before{color:#ff4d4f;content:"*";display:inline-block;font-size:1.14rem;height:20rpx;left:30rpx;position:absolute;top:50%;transform:translateY(-50%);width:20rpx}.form-input{background:transparent;color:#333;font-size:1.14rem;height:100%;line-height:3.57rem;outline:0;vertical-align:middle}.form-input,.vmp-lottery-btn{box-sizing:border-box;width:100%}.vmp-lottery-btn{align-items:center;background:#fb2626;border:none;border-radius:60rpx;color:#fff;display:flex;font-size:1.29rem;font-weight:700;height:96rpx;justify-content:center;margin:60rpx auto 0}.vmp-lottery-btn.disabled{opacity:.4;pointer-events:none}.lottery-success-modal{align-items:center;bottom:0;display:flex;justify-content:center;left:0;position:fixed;right:0;top:0;z-index:2000}.lottery-success-mask{background:rgba(0,0,0,.5);bottom:0;left:0;position:absolute;right:0;top:0}.lottery-success-content{align-items:center;background:linear-gradient(37.94deg,#fffbe8 3.86%,#fbf0e6 84.36%);border-radius:32rpx;display:flex;flex-direction:column;padding:80rpx 40rpx;position:relative;width:600rpx}.lottery-success-close{height:48rpx;position:absolute;right:30rpx;top:30rpx;width:48rpx}.lottery-success-close,.lottery-success-icon{align-items:center;display:flex;justify-content:center}.lottery-success-icon{background:linear-gradient(135deg,gold,#ffb700);border-radius:50%;box-shadow:0 8rpx 32rpx rgba(255,183,0,.4);height:160rpx;margin-bottom:40rpx;width:160rpx}.lottery-success-icon .success-check{border-bottom:6rpx solid #fff;border-left:6rpx solid #fff;height:40rpx;margin-top:-20rpx;transform:rotate(-45deg);width:80rpx}.lottery-success-title{color:#333;font-size:1.29rem;font-weight:600;margin-bottom:60rpx}.lottery-success-btn{align-items:center;background:#fb2626;border:none;border-radius:60rpx;color:#fff;display:flex;font-size:1.14rem;font-weight:700;height:88rpx;justify-content:center;width:400rpx}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
Component({
|
|
2
|
+
properties: {
|
|
3
|
+
visible: {
|
|
4
|
+
type: Boolean,
|
|
5
|
+
value: false,
|
|
6
|
+
},
|
|
7
|
+
winLotteryHistory: {
|
|
8
|
+
type: Array,
|
|
9
|
+
value: [],
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
data: {
|
|
14
|
+
defaultLotteryImg: 'https://cnstatic01.e.vhall.com/upload/webinars/spread-imgs/default-lottery.png',
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
methods: {
|
|
18
|
+
takeAward(e) {
|
|
19
|
+
const { index } = e.currentTarget.dataset;
|
|
20
|
+
const lottery = this.properties.winLotteryHistory[index];
|
|
21
|
+
lottery.lottery_id=lottery.id;
|
|
22
|
+
this.triggerEvent('takeAward', lottery);
|
|
23
|
+
},
|
|
24
|
+
|
|
25
|
+
onItemClick(e) {
|
|
26
|
+
const { index } = e.currentTarget.dataset;
|
|
27
|
+
const lottery = this.properties.winLotteryHistory[index];
|
|
28
|
+
lottery.lottery_id = lottery.id;
|
|
29
|
+
this.triggerEvent('itemClick', lottery);
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
close() {
|
|
33
|
+
this.triggerEvent('close');
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<view wx:if="{{visible}}" class="lottery-history-modal">
|
|
2
|
+
<view class="lottery-history-mask" bindtap="close"></view>
|
|
3
|
+
<view class="lottery-history-content">
|
|
4
|
+
<view class="lottery-history-title">中奖记录</view>
|
|
5
|
+
<view class="lottery-wrap-container">
|
|
6
|
+
<scroll-view class="lottery-wrap" scroll-y>
|
|
7
|
+
<view wx:for="{{winLotteryHistory}}" wx:key="index" class="win-lottery" bindtap="onItemClick" data-index="{{index}}">
|
|
8
|
+
<view class="lottery-item">
|
|
9
|
+
<image class="lottery-item__img" src="{{(item.award_snapshoot && item.award_snapshoot.image_url) || defaultLotteryImg}}" mode="aspectFill" />
|
|
10
|
+
<view class="lottery-item__content">
|
|
11
|
+
<p class="award-name">{{item.award_snapshoot.award_name}}</p>
|
|
12
|
+
<p class="award-time">{{item.created_at}}</p>
|
|
13
|
+
</view>
|
|
14
|
+
<view class="lottery-item__status">
|
|
15
|
+
<text wx:if="{{item.take_award == 1}}" class="status-text">已领取</text>
|
|
16
|
+
<text wx:elif="{{item.need_take_award == 0}}" class="status-text">
|
|
17
|
+
已中奖
|
|
18
|
+
</text>
|
|
19
|
+
<button wx:else class="take-award-btn" bindtap="takeAward" data-index="{{index}}">
|
|
20
|
+
领取
|
|
21
|
+
</button>
|
|
22
|
+
</view>
|
|
23
|
+
</view>
|
|
24
|
+
</view>
|
|
25
|
+
</scroll-view>
|
|
26
|
+
</view>
|
|
27
|
+
</view>
|
|
28
|
+
</view>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.lottery-history-modal{bottom:0;display:flex;flex-direction:column;justify-content:flex-end;left:0;position:fixed;right:0;top:0;z-index:1000}.lottery-history-mask{background:rgba(0,0,0,.5);bottom:0;left:0;position:absolute;right:0;top:0}.lottery-history-content{background:linear-gradient(37.94deg,#fffbe8 3.86%,#fbf0e6 84.36%);border-radius:32rpx 32rpx 0 0;max-height:70vh;overflow:hidden;padding:0 40rpx 80rpx;position:relative}.lottery-history-title{border-bottom:2rpx solid #f0f0f0;color:#333;font-size:1.36rem;font-weight:600;height:100rpx;line-height:3.57rem;text-align:center}.lottery-wrap-container{padding-right:4rpx}.lottery-wrap{max-height:432rpx;min-height:128rpx}.win-lottery{margin-bottom:24rpx}.lottery-item{align-items:center;background:#fff;border-radius:24rpx;display:flex;flex-direction:row;height:144rpx;padding:28rpx 32rpx}.lottery-item__img{border:2rpx solid #d9d9d9;border-radius:24rpx;flex-shrink:0;height:160rpx;width:160rpx}.lottery-item__content{display:flex;flex:1;flex-direction:column;height:100%;justify-content:center;margin-left:30rpx}.award-name{color:#262626;font-size:1.14rem;font-weight:500;height:48rpx;line-height:1.71rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.award-time{color:#8c8c8c;font-size:.86rem;height:36rpx;line-height:1.29rem;margin-top:8rpx}.take-award-btn{align-items:center;background:linear-gradient(135deg,#ff4d4f,#ff7875);border:none;border-radius:32rpx;color:#fff;display:flex;font-size:1rem;font-weight:500;height:64rpx;justify-content:center;padding:0 40rpx;width:auto!important}.status-text{color:#bfbfbf;font-size:1rem}
|