@cloudbase/weda-ui 1.0.21 → 1.0.24
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/package.json +5 -3
- package/src/configs/components/dataView.json +1 -1
- package/src/configs/components/listView.json +1 -1
- package/src/configs/components/lottery.json +151 -0
- package/src/configs/index.js +2 -0
- package/src/index.js +2 -0
- package/src/mp/components/button/index.wxml +1 -2
- package/src/mp/components/form/form/index.wxml +1 -2
- package/src/mp/components/form/select/index.js +8 -20
- package/src/mp/components/form/select/region/index.js +6 -3
- package/src/mp/components/listView/index.js +5 -16
- package/src/mp/components/lottery/index.js +270 -0
- package/src/mp/components/lottery/index.json +4 -0
- package/src/mp/components/lottery/index.wxml +43 -0
- package/src/mp/components/lottery/index.wxss +317 -0
- package/src/mp/components/wxOpenApi/phone/index.js +1 -1
- package/src/mp/index.json +4 -3
- package/src/mp/utils/constant.js +15 -0
- package/src/mp/utils/lodash.js +2 -0
- package/src/web/components/chart/common/config/line.js +1 -1
- package/src/web/components/form/checkbox/index.tsx +6 -0
- package/src/web/components/form/formcell/index.tsx +10 -5
- package/src/web/components/form/radio/index.tsx +6 -0
- package/src/web/components/form/select/h5.tsx +5 -24
- package/src/web/components/form/select/index.tsx +4 -17
- package/src/web/components/form/tips/index.css +4 -0
- package/src/web/components/form/tips/index.tsx +4 -3
- package/src/web/components/index.js +1 -0
- package/src/web/components/listView/index.tsx +4 -17
- package/src/web/components/lottery/index.css +327 -0
- package/src/web/components/lottery/index.tsx +567 -0
- package/src/web/components/lottery/lotteryUtil.ts +130 -0
- package/src/web/utils/{constant.js → constant.ts} +17 -2
- package/src/web/utils/lodash.ts +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/weda-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"module": "./src/index",
|
|
6
6
|
"miniprogram": "mpdist",
|
|
@@ -56,7 +56,6 @@
|
|
|
56
56
|
"license": "MIT",
|
|
57
57
|
"description": "腾讯云微搭低代码组件库模板",
|
|
58
58
|
"dependencies": {
|
|
59
|
-
"@cloudbase/cli": "^1.12.4",
|
|
60
59
|
"@cloudbase/ui-react": "^1.0.4",
|
|
61
60
|
"@loadable/component": "^5.15.2",
|
|
62
61
|
"@react-hookz/web": "^12.3.0",
|
|
@@ -85,6 +84,7 @@
|
|
|
85
84
|
"@babel/preset-env": "^7.16.5",
|
|
86
85
|
"@babel/preset-react": "^7.16.5",
|
|
87
86
|
"@babel/preset-typescript": "^7.16.5",
|
|
87
|
+
"@cloudbase/cli": "^1.12.4",
|
|
88
88
|
"@cloudbase/lowcode-build-dependence": "^0.9.0",
|
|
89
89
|
"@commitlint/cli": "^16.0.2",
|
|
90
90
|
"@commitlint/config-conventional": "^13.2.0",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@types/jest": "^27.0.3",
|
|
105
105
|
"@types/resize-observer-browser": "^0.1.6",
|
|
106
106
|
"@typescript-eslint/eslint-plugin": "^5.9.0",
|
|
107
|
-
"@typescript-eslint/parser": "^5.
|
|
107
|
+
"@typescript-eslint/parser": "^5.21.0",
|
|
108
108
|
"babel-jest": "^27.4.5",
|
|
109
109
|
"babel-loader": "^8.2.3",
|
|
110
110
|
"babel-plugin-istanbul": "^6.1.1",
|
|
@@ -113,7 +113,9 @@
|
|
|
113
113
|
"cypress": "~9.5.1",
|
|
114
114
|
"eslint": "^8.9.0",
|
|
115
115
|
"eslint-config-tencent": "^1.0.3",
|
|
116
|
+
"eslint-import-resolver-typescript": "^2.7.1",
|
|
116
117
|
"eslint-plugin-cypress": "^2.12.1",
|
|
118
|
+
"eslint-plugin-import": "^2.26.0",
|
|
117
119
|
"eslint-plugin-jest": "^26.1.2",
|
|
118
120
|
"eslint-plugin-react": "^7.28.0",
|
|
119
121
|
"eslint-plugin-rulesdir": "^0.2.1",
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
"meta": {
|
|
145
145
|
"title": "数据详情",
|
|
146
146
|
"category": "数据容器",
|
|
147
|
-
"description": "
|
|
147
|
+
"description": "适用于以展示多条数据详细内容的场景,不借助变量绑定,即可获取数据模型中的数据。",
|
|
148
148
|
"componentOrder": 1000,
|
|
149
149
|
"icon": "//imgcache.qq.com/qcloud/lowcode/static/ide/left-material-icon/DataView.svg"
|
|
150
150
|
},
|
|
@@ -267,7 +267,7 @@
|
|
|
267
267
|
"meta": {
|
|
268
268
|
"title": "数据列表",
|
|
269
269
|
"category": "数据容器",
|
|
270
|
-
"description": "
|
|
270
|
+
"description": "适用于以列表形式展示多条数据的场景,不借助变量绑定,即可获取数据模型中的数据。",
|
|
271
271
|
"componentOrder": 1000,
|
|
272
272
|
"icon": "//imgcache.qq.com/qcloud/lowcode/static/ide/left-material-icon/ListView.svg"
|
|
273
273
|
},
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://comp-public-1303824488.cos.ap-shanghai.myqcloud.com/schema/lcds_component.json",
|
|
3
|
+
"data": {
|
|
4
|
+
"properties": {
|
|
5
|
+
"prizeList": {
|
|
6
|
+
"type": "array",
|
|
7
|
+
"title": "奖品设置",
|
|
8
|
+
"description": "仅前8项奖品会展示在组件中",
|
|
9
|
+
"items": {
|
|
10
|
+
"type": "object",
|
|
11
|
+
"title": "prizeList",
|
|
12
|
+
"default": {
|
|
13
|
+
"title": "奖品名称",
|
|
14
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/0aa4dc06-e375-45c2-8ec2-0461a83d5d4a.png"
|
|
15
|
+
},
|
|
16
|
+
"properties": {
|
|
17
|
+
"title": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"title": "奖品名称",
|
|
20
|
+
"default": "一等奖"
|
|
21
|
+
},
|
|
22
|
+
"image": {
|
|
23
|
+
"type": "image",
|
|
24
|
+
"title": "奖品图片",
|
|
25
|
+
"default": ""
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"default": [
|
|
30
|
+
{
|
|
31
|
+
"title": "8元优惠券",
|
|
32
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/70122750-ba8b-4ac7-be71-c2300f1f8c6f.png"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"title": "劳动节水杯",
|
|
36
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/c2842881-5e15-409d-8dd3-352205abe38c.png"
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
"title": "10元优惠券",
|
|
40
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/b99c4350-c619-4fff-90e0-1980075e0417.png"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/7cefce40-73e4-4cdd-aa30-d178a4cb6624.png",
|
|
44
|
+
"title": "旅行背包"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"title": "谢谢参与",
|
|
48
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/0aa4dc06-e375-45c2-8ec2-0461a83d5d4a.png"
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
"title": "20积分",
|
|
52
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/de35f413-6971-4ab3-a816-9c488e169d46.png"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"title": "流量券",
|
|
56
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/3c0ff8a2-8362-4219-875d-0778d65bba80.png"
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"title": "10元优惠券",
|
|
60
|
+
"image": "https://imgcache.qq.com/qcloud/tcloud_dtc/static/static_source_business/d11056cc-b8a1-4d50-b993-65d8a434802f.png"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"x-index": 10,
|
|
64
|
+
"x-component": "list-bind-switch",
|
|
65
|
+
"x-component-props": {
|
|
66
|
+
"origin-component": "list"
|
|
67
|
+
},
|
|
68
|
+
"x-props": {
|
|
69
|
+
"data-withBindMeta": true
|
|
70
|
+
},
|
|
71
|
+
"x-linkages": [
|
|
72
|
+
{
|
|
73
|
+
"type": "value:schema",
|
|
74
|
+
"schema": {
|
|
75
|
+
"x-component-props": {
|
|
76
|
+
"options": "{{ $value.map((title, index) => ({label: '奖品名称' + (index + 1), value: index}) ) }}"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"target": "selectedIndex"
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"enablePrize": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"title": "启动抽奖",
|
|
86
|
+
"x-index": 20,
|
|
87
|
+
"default": true
|
|
88
|
+
},
|
|
89
|
+
"prizeResult": {
|
|
90
|
+
"type": "string",
|
|
91
|
+
"title": "抽奖结果",
|
|
92
|
+
"x-index": 30,
|
|
93
|
+
"default": "1",
|
|
94
|
+
"description": "以左上角为起始位置,顺时针确定8个奖品位置分别1-8",
|
|
95
|
+
"enum": [
|
|
96
|
+
{
|
|
97
|
+
"label": "1",
|
|
98
|
+
"value": "1"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"label": "2",
|
|
102
|
+
"value": "2"
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
"label": "3",
|
|
106
|
+
"value": "3"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"label": "4",
|
|
110
|
+
"value": "4"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"label": "5",
|
|
114
|
+
"value": "5"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"label": "6",
|
|
118
|
+
"value": "6"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"label": "7",
|
|
122
|
+
"value": "7"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"label": "8",
|
|
126
|
+
"value": "8"
|
|
127
|
+
}
|
|
128
|
+
]
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
"events": [
|
|
133
|
+
{
|
|
134
|
+
"name": "clickLotteryButton",
|
|
135
|
+
"title": "开始抽奖"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"name": "finishLottery",
|
|
139
|
+
"title": "开奖",
|
|
140
|
+
"value": "event.detail.prize"
|
|
141
|
+
}
|
|
142
|
+
],
|
|
143
|
+
"meta": {
|
|
144
|
+
"title": "九宫格抽奖",
|
|
145
|
+
"description": "九宫格抽奖",
|
|
146
|
+
"category": "高级",
|
|
147
|
+
"componentOrder": 101,
|
|
148
|
+
"icon": "//imgcache.qq.com/qcloud/lowcode/static/ide/left-material-icon/NavLayout.svg",
|
|
149
|
+
"visible": ["APP"]
|
|
150
|
+
}
|
|
151
|
+
}
|
package/src/configs/index.js
CHANGED
|
@@ -48,6 +48,7 @@ import PhoneCode from './components/wxOpenApi/phoneCode.json';
|
|
|
48
48
|
import Share from './components/wxOpenApi/share.json';
|
|
49
49
|
import UserInfo from './components/wxOpenApi/userInfo.json';
|
|
50
50
|
|
|
51
|
+
import Lottery from './components/lottery.json';
|
|
51
52
|
export const components = {
|
|
52
53
|
Button,
|
|
53
54
|
Text,
|
|
@@ -94,6 +95,7 @@ export const components = {
|
|
|
94
95
|
PhoneCode,
|
|
95
96
|
Share,
|
|
96
97
|
UserInfo,
|
|
98
|
+
Lottery,
|
|
97
99
|
};
|
|
98
100
|
|
|
99
101
|
export const actions = {
|
package/src/index.js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
1
|
import classNames from '../../../utils/classnames';
|
|
2
2
|
import dayjs from '../../../utils/dayjs.min.js';
|
|
3
|
-
import { getRegionTree, buildDisplayValue } from './region/index';
|
|
4
|
-
import { provinces, cities, regions } from './region/index';
|
|
3
|
+
import { getRegionTree, buildDisplayValue , provinces, cities, regions } from './region/index';
|
|
5
4
|
import destr from '../../../utils/destr';
|
|
6
5
|
import { callDataSourceApi, callWedaApi } from '../../../utils/tcb';
|
|
6
|
+
import { REL_DICT } from '../../../utils/constant';
|
|
7
|
+
import { isNil } from '../../../utils/lodash';
|
|
7
8
|
|
|
8
|
-
// 处理where筛选条件
|
|
9
|
-
const isNull = (val) => [undefined, null].includes(val);
|
|
10
|
-
const REL_DICT = {
|
|
11
|
-
equal: 'eq', // 等于
|
|
12
|
-
unequal: 'neq', // 不等于
|
|
13
|
-
include: 'search', // 包含
|
|
14
|
-
exclude: '_exclude', // 不包含
|
|
15
|
-
begin_with: '_begin_with', // 开头是
|
|
16
|
-
greater: 'gt', // 大于
|
|
17
|
-
greater_or_equal: 'gte', // 大于等于
|
|
18
|
-
bigger_or_equal: 'gte', //大于等于
|
|
19
|
-
less: 'lt', // 小于
|
|
20
|
-
less_or_equal: 'lte', // 小于等于
|
|
21
|
-
in: 'in', // 多选值
|
|
22
|
-
not_in: 'nin', // 不在多选值
|
|
23
|
-
};
|
|
24
9
|
const getWhereList = (where) => {
|
|
25
10
|
let result = [];
|
|
26
11
|
Array.isArray(where) &&
|
|
@@ -36,7 +21,7 @@ const getWhereList = (where) => {
|
|
|
36
21
|
rel = 'regex';
|
|
37
22
|
val = `^((?!${val}).)*$`;
|
|
38
23
|
}
|
|
39
|
-
if (item2?.logic !== 'or' && item2?.key && rel && !
|
|
24
|
+
if (item2?.logic !== 'or' && item2?.key && rel && !isNil(val)) {
|
|
40
25
|
result.push({ key: item2.key, rel, val });
|
|
41
26
|
}
|
|
42
27
|
});
|
|
@@ -397,7 +382,10 @@ Component({
|
|
|
397
382
|
async getProvince() {
|
|
398
383
|
const { regionType, defaultMutiRegion } = this.properties;
|
|
399
384
|
const changeData = await getRegionTree(defaultMutiRegion || '');
|
|
400
|
-
|
|
385
|
+
//限制渲染时change事件触发,否则会有初始数据被覆盖问题
|
|
386
|
+
if (changeData?.result.length > 0) {
|
|
387
|
+
this.triggerEvent('change', changeData);
|
|
388
|
+
}
|
|
401
389
|
var provinceList = [...provinces];
|
|
402
390
|
var provinceArr = provinces.map((item) => { return { value: item.Value, code: item.Code }; }); //保存省级名称
|
|
403
391
|
this.setData({
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { callWedaApi } from '../../../../utils/tcb';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
export
|
|
3
|
+
export let provinces = [];
|
|
4
|
+
export let cities = [];
|
|
5
|
+
export let regions = [];
|
|
6
6
|
export let regionData = [];
|
|
7
7
|
/**
|
|
8
8
|
* 获取运行态地区数据
|
|
@@ -26,6 +26,9 @@ export const getRegionTree = async function (defaultValue) {
|
|
|
26
26
|
return changeResult(defaultValue, regionData);
|
|
27
27
|
};
|
|
28
28
|
export const splitAreaData = (areaData) => {
|
|
29
|
+
provinces = [];
|
|
30
|
+
cities = [];
|
|
31
|
+
regions = [];
|
|
29
32
|
areaData.forEach(item => {
|
|
30
33
|
if (!item.Deprecated) {
|
|
31
34
|
if (item?.Type == 1) {
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
unequal: 'neq', // 不等于
|
|
5
|
-
include: 'search', // 包含
|
|
6
|
-
exclude: '_exclude', // 不包含
|
|
7
|
-
begin_with: '_begin_with', // 开头是
|
|
8
|
-
greater: 'gt', // 大于
|
|
9
|
-
greater_or_equal: 'gte', // 大于等于
|
|
10
|
-
less: 'lt', // 小于
|
|
11
|
-
less_or_equal: 'lte', // 小于等于
|
|
12
|
-
in: 'in', // 多选值
|
|
13
|
-
not_in: 'nin', // 不在多选值
|
|
14
|
-
};
|
|
1
|
+
import { REL_DICT } from '../../utils/constant';
|
|
2
|
+
import { isNil } from '../../utils/lodash';
|
|
3
|
+
|
|
15
4
|
const ORDERTYPE = ['asc', 'desc'];
|
|
16
5
|
const getWhereList = (where) => {
|
|
17
6
|
let result = [];
|
|
@@ -28,7 +17,7 @@ const getWhereList = (where) => {
|
|
|
28
17
|
rel = 'regex';
|
|
29
18
|
val = `^((?!${val}).)*$`;
|
|
30
19
|
}
|
|
31
|
-
if (item2?.logic !== 'or' && item2?.key && rel && !
|
|
20
|
+
if (item2?.logic !== 'or' && item2?.key && rel && !isNil(val)) {
|
|
32
21
|
result.push({ key: item2.key, rel, val });
|
|
33
22
|
}
|
|
34
23
|
});
|
|
@@ -114,7 +103,7 @@ Component({
|
|
|
114
103
|
const tcbParams = {};
|
|
115
104
|
|
|
116
105
|
// tcb分页参数
|
|
117
|
-
if (!
|
|
106
|
+
if (!isNil(pageNo) && !isNil(pageSize)) {
|
|
118
107
|
tcbParams['pageNo'] = pageNo;
|
|
119
108
|
tcbParams['pageSize'] = pageSize;
|
|
120
109
|
}
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
Component({
|
|
2
|
+
/** 页面的初始数据 */
|
|
3
|
+
data: {
|
|
4
|
+
lotteryList: [
|
|
5
|
+
{
|
|
6
|
+
src: '',
|
|
7
|
+
desc: '',
|
|
8
|
+
actived: true,
|
|
9
|
+
selected: false,
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
src: '',
|
|
13
|
+
desc: '',
|
|
14
|
+
actived: false,
|
|
15
|
+
selected: false,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
src: '',
|
|
19
|
+
desc: '',
|
|
20
|
+
actived: false,
|
|
21
|
+
selected: true,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
src: '',
|
|
25
|
+
desc: '',
|
|
26
|
+
actived: false,
|
|
27
|
+
selected: false,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
src: '',
|
|
31
|
+
desc: '',
|
|
32
|
+
actived: false,
|
|
33
|
+
selected: false,
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
src: '',
|
|
37
|
+
desc: '',
|
|
38
|
+
actived: false,
|
|
39
|
+
selected: false,
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
src: '',
|
|
43
|
+
desc: '',
|
|
44
|
+
actived: false,
|
|
45
|
+
selected: false,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
src: '',
|
|
49
|
+
desc: '',
|
|
50
|
+
actived: false,
|
|
51
|
+
selected: false,
|
|
52
|
+
},
|
|
53
|
+
],
|
|
54
|
+
dotList: [
|
|
55
|
+
{
|
|
56
|
+
single: true,
|
|
57
|
+
position: 'left-top',
|
|
58
|
+
direction: '',
|
|
59
|
+
list: [],
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
single: true,
|
|
63
|
+
position: 'left-bottom',
|
|
64
|
+
direction: '',
|
|
65
|
+
list: [],
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
single: true,
|
|
69
|
+
position: 'right-top',
|
|
70
|
+
direction: '',
|
|
71
|
+
list: [],
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
single: true,
|
|
75
|
+
position: 'right-bottom',
|
|
76
|
+
direction: '',
|
|
77
|
+
list: [],
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
single: false,
|
|
81
|
+
position: 'top',
|
|
82
|
+
direction: 'horizontal',
|
|
83
|
+
list: ['1', '2', '3', '4', '5'],
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
single: false,
|
|
87
|
+
position: 'bottom',
|
|
88
|
+
direction: 'horizontal',
|
|
89
|
+
list: ['1', '2', '3', '4', '5'],
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
single: false,
|
|
93
|
+
position: 'left',
|
|
94
|
+
direction: 'vertical',
|
|
95
|
+
list: ['1', '2', '3', '4', '5'],
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
single: false,
|
|
99
|
+
position: 'right',
|
|
100
|
+
direction: 'vertical',
|
|
101
|
+
list: ['1', '2', '3', '4', '5'],
|
|
102
|
+
},
|
|
103
|
+
],
|
|
104
|
+
btnActived: false,
|
|
105
|
+
clickLotteryEnable: true,
|
|
106
|
+
checkedIndex: -1,
|
|
107
|
+
},
|
|
108
|
+
options: {
|
|
109
|
+
virtualHost: true,
|
|
110
|
+
},
|
|
111
|
+
properties: {
|
|
112
|
+
id: {
|
|
113
|
+
type: String,
|
|
114
|
+
value: '',
|
|
115
|
+
},
|
|
116
|
+
className: {
|
|
117
|
+
type: String,
|
|
118
|
+
value: '',
|
|
119
|
+
},
|
|
120
|
+
style: {
|
|
121
|
+
type: String,
|
|
122
|
+
value: '',
|
|
123
|
+
},
|
|
124
|
+
prizeResult: {
|
|
125
|
+
type: String,
|
|
126
|
+
value: '',
|
|
127
|
+
},
|
|
128
|
+
enablePrize: {
|
|
129
|
+
value: true,
|
|
130
|
+
type: Boolean,
|
|
131
|
+
},
|
|
132
|
+
prizeList: {
|
|
133
|
+
type: Array,
|
|
134
|
+
value: [],
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
methods: {
|
|
138
|
+
clickLotteryButton: function () {
|
|
139
|
+
const { lotteryList } = this.data;
|
|
140
|
+
const { prizeResult, enablePrize, clickLotteryEnable } = this.properties;
|
|
141
|
+
//是否正在抽奖
|
|
142
|
+
if (clickLotteryEnable) {
|
|
143
|
+
this.setData({
|
|
144
|
+
clickLotteryEnable: false,
|
|
145
|
+
});
|
|
146
|
+
} else {
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
//支持抽奖
|
|
150
|
+
if (!enablePrize) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
//触发外部事件
|
|
154
|
+
this.triggerEvent('clickLotteryButton');
|
|
155
|
+
//动画旋转次数
|
|
156
|
+
let count = 0;
|
|
157
|
+
//是否超时
|
|
158
|
+
let isTimeout = false;
|
|
159
|
+
//开启循环抽奖
|
|
160
|
+
let intervalId = setInterval(() => {
|
|
161
|
+
//再次获取抽奖结果
|
|
162
|
+
let prizeResultNew = this.properties.prizeResult;
|
|
163
|
+
if (prizeResultNew == null || !this.properties.enablePrize) {
|
|
164
|
+
//如果是禁止,立马停止
|
|
165
|
+
clearInterval();
|
|
166
|
+
this.setData({
|
|
167
|
+
clickLotteryEnable: true,
|
|
168
|
+
});
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
//触发抽奖动画
|
|
172
|
+
let index = count % lotteryList.length;
|
|
173
|
+
let tempList = [];
|
|
174
|
+
lotteryList.forEach((item, i) => {
|
|
175
|
+
if (index === i) {
|
|
176
|
+
item.actived = true;
|
|
177
|
+
} else {
|
|
178
|
+
item.actived = false;
|
|
179
|
+
}
|
|
180
|
+
item.selected = false;
|
|
181
|
+
tempList.push(item);
|
|
182
|
+
//如果超时,则终止
|
|
183
|
+
if (isTimeout) {
|
|
184
|
+
let reg = /^\+?[1-9]\d*$/;
|
|
185
|
+
if (!reg.test(prizeResult)) {
|
|
186
|
+
isTimeout = false;
|
|
187
|
+
clearInterval(intervalId);
|
|
188
|
+
wx.showToast({
|
|
189
|
+
title: '网络异常',
|
|
190
|
+
icon: 'none',
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
if (index === parseInt(prizeResultNew) - 1) {
|
|
194
|
+
isTimeout = false;
|
|
195
|
+
this.setData({
|
|
196
|
+
checkedIndex: index,
|
|
197
|
+
});
|
|
198
|
+
clearInterval(intervalId);
|
|
199
|
+
setTimeout(() => {
|
|
200
|
+
this.triggerEvent('finishLottery', {
|
|
201
|
+
prize: prizeResultNew,
|
|
202
|
+
result: lotteryList[i],
|
|
203
|
+
});
|
|
204
|
+
}, 600);
|
|
205
|
+
}
|
|
206
|
+
setTimeout(() => {
|
|
207
|
+
//防止暴力点击误触,影响抽奖可用次数结果,延迟1.5s,才可点击
|
|
208
|
+
this.setData({
|
|
209
|
+
clickLotteryEnable: true,
|
|
210
|
+
});
|
|
211
|
+
}, 1500);
|
|
212
|
+
}
|
|
213
|
+
});
|
|
214
|
+
let checkedIndex = this.data.checkedIndex;
|
|
215
|
+
this.setData({
|
|
216
|
+
btnActived: checkedIndex < 0,
|
|
217
|
+
lotteryList:
|
|
218
|
+
checkedIndex < 0
|
|
219
|
+
? tempList
|
|
220
|
+
: tempList.map((item, index) => {
|
|
221
|
+
if (index === checkedIndex) {
|
|
222
|
+
item.selected = true;
|
|
223
|
+
} else {
|
|
224
|
+
item.selected = false;
|
|
225
|
+
}
|
|
226
|
+
item.actived = false;
|
|
227
|
+
return item;
|
|
228
|
+
}),
|
|
229
|
+
});
|
|
230
|
+
//设置默认数据
|
|
231
|
+
this.setData({
|
|
232
|
+
checkedIndex: -1,
|
|
233
|
+
});
|
|
234
|
+
count++;
|
|
235
|
+
}, 150);
|
|
236
|
+
setTimeout(() => {
|
|
237
|
+
isTimeout = true;
|
|
238
|
+
}, 3000);
|
|
239
|
+
},
|
|
240
|
+
},
|
|
241
|
+
observers: {
|
|
242
|
+
prizeList: function (prizeList) {
|
|
243
|
+
//获取初始化默认数据,数据不足8条设置默认,超过8条获取前8条
|
|
244
|
+
let list = [];
|
|
245
|
+
for (let i = 0; i < 8; i++) {
|
|
246
|
+
if (i < prizeList.length) {
|
|
247
|
+
let prize = prizeList[i];
|
|
248
|
+
list.push({
|
|
249
|
+
idx: i + 1,
|
|
250
|
+
selected: false,
|
|
251
|
+
actived: false,
|
|
252
|
+
desc: prize.title,
|
|
253
|
+
src: prize.image,
|
|
254
|
+
});
|
|
255
|
+
} else {
|
|
256
|
+
list.push({
|
|
257
|
+
idx: i + 1,
|
|
258
|
+
selected: false,
|
|
259
|
+
actived: false,
|
|
260
|
+
desc: '',
|
|
261
|
+
src: '',
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
this.setData({
|
|
266
|
+
lotteryList: list,
|
|
267
|
+
});
|
|
268
|
+
},
|
|
269
|
+
},
|
|
270
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<view class="weda-lottery">
|
|
2
|
+
<view class="weda-lottery__wrap">
|
|
3
|
+
<block wx:for="{{dotList}}" wx:key="dotIndex" wx:for-item="dot">
|
|
4
|
+
<view wx-if="{{dot.single}}" class="weda-lottery__dot-single weda-lottery__dot-{{dot.position}}"></view>
|
|
5
|
+
<block wx-if="{{!dot.single}}">
|
|
6
|
+
<view class="weda-lottery__dot-{{dot.position}}">
|
|
7
|
+
<view class="weda-lottery__dot weda-lottery__dot-{{dot.direction}}">
|
|
8
|
+
<block wx:for="{{dot.list}}" wx:key="index" wx:for-item="item">
|
|
9
|
+
<view class="weda-lottery__dot-item"></view>
|
|
10
|
+
</block>
|
|
11
|
+
</view>
|
|
12
|
+
</view>
|
|
13
|
+
</block>
|
|
14
|
+
</block>
|
|
15
|
+
<view class="weda-lottery__inner">
|
|
16
|
+
<view class="weda-lottery__inner-wrap">
|
|
17
|
+
<view class="weda-lottery__list">
|
|
18
|
+
<block wx:for="{{lotteryList}}" wx:key="index" wx:for-item="item">
|
|
19
|
+
<view key="{{index}}" class="weda-lottery__turntable-item {{item.actived ? 'is-actived' : ''}}, {{item.selected ? 'is-selected' : ''}}">
|
|
20
|
+
<view class="weda-lottery__turntable-cell">
|
|
21
|
+
<view class="weda-lottery__turntable-cell-image" wx-if="{{item.src}}">
|
|
22
|
+
<image mode="aspectFit" src="{{item.src}}" alt="{{item.desc}}" class="weda-lottery__turntable-cell-icon"></image>
|
|
23
|
+
</view>
|
|
24
|
+
<view class="weda-lottery__turntable-cell-desc" wx-if="{{item.desc}}">
|
|
25
|
+
{{item.desc}}
|
|
26
|
+
</view>
|
|
27
|
+
</view>
|
|
28
|
+
</view>
|
|
29
|
+
</block>
|
|
30
|
+
</view>
|
|
31
|
+
<view class="weda-lottery__turntable-btn {{btnActived ? 'is-actived' : ''}}">
|
|
32
|
+
<view class="weda-lottery__btn-inner" bindtap="{{clickLotteryEnable ? 'clickLotteryButton' : ''}}">
|
|
33
|
+
<view class="weda-lottery__btn">
|
|
34
|
+
<view class="weda-lottery__btn-image">
|
|
35
|
+
<text class="weda-lottery__btn-text">开始抽奖</text>
|
|
36
|
+
</view>
|
|
37
|
+
</view>
|
|
38
|
+
</view>
|
|
39
|
+
</view>
|
|
40
|
+
</view>
|
|
41
|
+
</view>
|
|
42
|
+
</view>
|
|
43
|
+
</view>
|