├── prize
├── prize.json
├── prize.wxss
├── prize.wxml
└── prize.js
├── test
├── test.json
├── test.wxss
├── test.wxml
└── test.js
├── READMD.md
├── images
├── 1.jpg
├── 2.jpg
├── 3.jpg
├── 4.jpg
├── set.png
├── top.png
├── us.png
├── award.png
├── change.png
├── data.png
├── major.png
├── name.png
├── sport.png
├── toux.png
├── collage.png
├── nickname.png
├── playbtn.png
├── xsl_btn.png
├── award_pre.png
├── bg-lottery.png
├── ly-plate-c.gif
├── setting_btn.png
└── sport_btn.png
├── README.md
├── app.js
├── app.wxss
├── app.json
└── server
├── isFirst.php
└── getPrice.php
/prize/prize.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/test/test.json:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/READMD.md:
--------------------------------------------------------------------------------
1 | 转盘抽奖微信小程序
2 |
--------------------------------------------------------------------------------
/prize/prize.wxss:
--------------------------------------------------------------------------------
1 | /* pages/prize/prize.wxss */
--------------------------------------------------------------------------------
/images/1.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/1.jpg
--------------------------------------------------------------------------------
/images/2.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/2.jpg
--------------------------------------------------------------------------------
/images/3.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/3.jpg
--------------------------------------------------------------------------------
/images/4.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/4.jpg
--------------------------------------------------------------------------------
/images/set.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/set.png
--------------------------------------------------------------------------------
/images/top.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/top.png
--------------------------------------------------------------------------------
/images/us.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/us.png
--------------------------------------------------------------------------------
/images/award.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/award.png
--------------------------------------------------------------------------------
/images/change.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/change.png
--------------------------------------------------------------------------------
/images/data.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/data.png
--------------------------------------------------------------------------------
/images/major.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/major.png
--------------------------------------------------------------------------------
/images/name.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/name.png
--------------------------------------------------------------------------------
/images/sport.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/sport.png
--------------------------------------------------------------------------------
/images/toux.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/toux.png
--------------------------------------------------------------------------------
/images/collage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/collage.png
--------------------------------------------------------------------------------
/images/nickname.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/nickname.png
--------------------------------------------------------------------------------
/images/playbtn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/playbtn.png
--------------------------------------------------------------------------------
/images/xsl_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/xsl_btn.png
--------------------------------------------------------------------------------
/images/award_pre.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/award_pre.png
--------------------------------------------------------------------------------
/images/bg-lottery.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/bg-lottery.png
--------------------------------------------------------------------------------
/images/ly-plate-c.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/ly-plate-c.gif
--------------------------------------------------------------------------------
/images/setting_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/setting_btn.png
--------------------------------------------------------------------------------
/images/sport_btn.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BooleanlN/miniwechat_lottery/HEAD/images/sport_btn.png
--------------------------------------------------------------------------------
/test/test.wxss:
--------------------------------------------------------------------------------
1 | /* pages/test/test.wxss */
2 | .zhangh{
3 | border:1px solid #ccc;border-radius:5px;width:80%;margin:0 auto;height:60px;margin-top:10px;
4 | }
5 | .mm{
6 | border:1px solid #ccc;border-radius:5px;width:80%;margin:0 auto;margin-top:5px;height:30px;
7 | }
--------------------------------------------------------------------------------
/test/test.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # miniwechat_lottery
2 | 转盘抽奖微信小程序,主分支是微信小程序原生写的,然后其它框架版本陆续更新中..
3 | [taro框架版本](https://github.com/BooleanlN/miniwechat_lottery/tree/taro-version)
4 | 欢迎fork、star 以及指正
5 | ##### 小程序主页面
6 | 
7 | ##### 抽奖页面
8 | 
9 | ##### 抽奖后的弹窗
10 | 
11 | ##### 抽奖注册页面
12 | 
13 |
--------------------------------------------------------------------------------
/prize/prize.wxml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 抽奖界面
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | 奖品抽完为止。每个账号只有一次抽奖机会!\n抽奖后台会有记录,确保填写了有效联系方式\n一等奖2份,二等奖5份,三等奖10份\n技术支持:网络信息协会
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/app.js:
--------------------------------------------------------------------------------
1 | //app.js
2 | App({
3 | onLaunch: function () {
4 | // 展示本地存储能力
5 | var logs = wx.getStorageSync('logs') || []
6 | logs.unshift(Date.now())
7 | wx.setStorageSync('logs', logs)
8 |
9 | // 登录
10 | wx.login({
11 | success: res => {
12 | // 发送 res.code 到后台换取 openId, sessionKey, unionId
13 | }
14 | })
15 | // 获取用户信息
16 | wx.getSetting({
17 | success: res => {
18 | if (res.authSetting['scope.userInfo']) {
19 | // 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
20 | wx.getUserInfo({
21 | success: res => {
22 | // 可以将 res 发送给后台解码出 unionId
23 | this.globalData.userInfo = res.userInfo
24 | console.log(res.userInfo)
25 | // 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
26 | // 所以此处加入 callback 以防止这种情况
27 | if (this.userInfoReadyCallback) {
28 | this.userInfoReadyCallback(res)
29 | }
30 | }
31 | })
32 | }
33 | }
34 | })
35 | },
36 | globalData: {
37 | userInfo: null,
38 | name: '',
39 | major: 'null',
40 | collage: 'null',
41 | stuclass: 'null',
42 | stunum:'null',
43 | sportsData:[],
44 | touxlink:'',
45 | nickname:''
46 | }
47 | })
--------------------------------------------------------------------------------
/app.wxss:
--------------------------------------------------------------------------------
1 | /**app.wxss**/
2 | @import 'style/weui.wxss';
3 | .container {
4 | height: 100%;
5 | display: flex;
6 | flex-direction: column;
7 | box-sizing: border-box;
8 | -webkit-text-size-adjust:none;
9 | -webkit-user-select: none;
10 | font-size: 35rpx;
11 | color: #333;
12 | font-family: Helvetica,Arial,"Helvetica Neue","Droid Sans","Microsoft YaHei",sans-serif;
13 | }
14 | .top_title{
15 | box-shadow: 0px 5px 5px #888888;
16 | color:white;
17 | font-size: 20px;
18 | font-family: 'Microsoft YaHei';
19 | text-align: center;
20 | line-height: 40px;
21 | background:#eb544b;
22 | width:100%;
23 | height:40px;
24 | }
25 | .menu_bottom{
26 | position: absolute;
27 | flex-direction: row;
28 | display: inline-flex;
29 | justify-content: space-around;
30 | width: 100%;
31 | border-top: 1px solid #4c4c4c;
32 | margin-top: 20px;
33 | }
34 | .menu_bottom .bottom_nav{
35 | width:30%;
36 | border:0px solid;
37 | height:50px;
38 | text-align: center;
39 | line-height: 50px;
40 | }
41 | .menu_bottom .bottom_nav image{
42 | padding-top: 5px;
43 | display:block;
44 | width:20px;
45 | height:20px;
46 | margin:0 auto;
47 | }
48 | .menu_bottom .bottom_nav text{
49 | font-weight: bold;
50 | color: #4c4c4c;
51 | font-size: 14px;
52 | }
--------------------------------------------------------------------------------
/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "tabBar": {
3 | "selectedColor": "#000000",
4 | "color": "#696969",
5 | "backgroundColor": "#ffffff",
6 | "position": "bottom",
7 | "list": [
8 | {
9 | "pagePath": "pages/main/main",
10 | "text": "首页",
11 | "iconPath": "pages/images/sport.png",
12 | "selectedIconPath": "pages/images/sport_btn.png"
13 | },
14 | {
15 | "pagePath": "pages/xsl/xsl",
16 | "text": "数据",
17 | "iconPath": "pages/images/data.png",
18 | "selectedIconPath": "pages/images/xsl_btn.png"
19 | },
20 | {
21 | "pagePath": "pages/setting/setting",
22 | "text": "我的",
23 | "iconPath": "pages/images/set.png",
24 | "selectedIconPath": "pages/images/setting_btn.png"
25 | },
26 | {
27 | "pagePath": "pages/test/test",
28 | "text": "抽奖",
29 | "iconPath": "pages/images/award_pre.png",
30 | "selectedIconPath": "pages/images/award.png"
31 | }
32 | ]
33 | },
34 | "pages": [
35 | "pages/main/main",
36 | "pages/prize/prize",
37 | "pages/index/index",
38 | "pages/logs/logs",
39 | "pages/setting/setting",
40 | "pages/xsl/xsl",
41 | "pages/rank/rank",
42 | "pages/test/test"
43 | ],
44 | "window": {
45 | "backgroundTextStyle": "bold",
46 | "navigationBarBackgroundColor": "#eb544b",
47 | "navigationBarTitleText": "UPCSport",
48 | "navigationBarTextStyle": "white"
49 | },
50 | "debug": true
51 | }
--------------------------------------------------------------------------------
/server/isFirst.php:
--------------------------------------------------------------------------------
1 | openid;
18 | $dsn = "dbo";
19 | $pdo = new PDO($dsn,"usr","pwd");
20 | $critical = "SELECT * FROM Allstu WHERE stunum='$stu'";
21 | $res_count = $pdo->query($critical);
22 | if($res_count->rowCount()){
23 | $critical = "SELECT * FROM student WHERE stunum='$stu'";
24 | $res_count = $pdo->query($critical);
25 | if (!$res_count->rowCount()) {
26 | $sql2 = "SELECT * FROM prize_user WHERE open_id= ?";
27 | $pre2 = $pdo->prepare($sql2);
28 | $pre2->execute(array($openid));
29 | $res2 = $pre2->fetch(PDO::FETCH_ASSOC);
30 | if ($res2 == null) {
31 | echo json_encode(array("code" => 1, "open_id" => $openid));
32 | } else {
33 | echo json_encode(array("code" => -1));
34 | }
35 | } else {
36 | echo json_encode(array("code" => -2));
37 | }
38 | }
39 | else
40 | {
41 | echo json_encode(array("code" => -3));
42 | }
--------------------------------------------------------------------------------
/test/test.js:
--------------------------------------------------------------------------------
1 | // pages/test/test.js
2 | Page({
3 |
4 | /**
5 | * 页面的初始数据
6 | */
7 | data: {
8 | xm:"",
9 | xh:"",
10 | tele:""
11 | },
12 |
13 | /**
14 | * 生命周期函数--监听页面加载
15 | */
16 | onLoad: function (options) {
17 |
18 | },
19 |
20 | /**
21 | * 生命周期函数--监听页面初次渲染完成
22 | */
23 | onReady: function () {
24 |
25 | },
26 |
27 | /**
28 | * 生命周期函数--监听页面显示
29 | */
30 | onShow: function () {
31 |
32 | },
33 |
34 | /**
35 | * 生命周期函数--监听页面隐藏
36 | */
37 | onHide: function () {
38 |
39 | },
40 |
41 | /**
42 | * 生命周期函数--监听页面卸载
43 | */
44 | onUnload: function () {
45 |
46 | },
47 |
48 | /**
49 | * 页面相关事件处理函数--监听用户下拉动作
50 | */
51 | onPullDownRefresh: function () {
52 |
53 | },
54 |
55 | /**
56 | * 页面上拉触底事件的处理函数
57 | */
58 | onReachBottom: function () {
59 |
60 | },
61 |
62 | /**
63 | * 用户点击右上角分享
64 | */
65 | onShareAppMessage: function () {
66 |
67 | },
68 | inputxm:function(e){
69 | var _this = this;
70 | console.log(e.detail.value);
71 | _this.setData({
72 | xm:e.detail.value
73 | });
74 | },
75 | inputxh: function (e) {
76 | var _this = this;
77 | console.log(e.detail.value);
78 | _this.setData({
79 | xh: e.detail.value
80 | });
81 | },
82 | inputph: function (e) {
83 | var _this = this;
84 | console.log(e.detail.value);
85 | _this.setData({
86 | tele: e.detail.value
87 | });
88 | },
89 | go(){
90 | var _this = this;
91 | if (_this.data.xm != "" && _this.data.xh != "" && _this.data.tele != "")
92 | {
93 | wx.login({
94 | success:function(res){
95 | wx.request({
96 | url: 'https://www.booleanln.cn/net/isFirst.php',
97 | data:{
98 | code:res.code,
99 | name: _this.data.xm,
100 | stunum: _this.data.xh,
101 | phone: _this.data.tele
102 | },
103 | header: { "content-type":"application/www-form-urlencode"},
104 | success:function(res){
105 | console.log(res.data);
106 | if(res.data.code>0)
107 | {
108 | var str = 'xm= ' + _this.data.xm + '&xh=' + _this.data.xh + '&xtele=' + _this.data.tele+'&openid='+res.data.open_id;
109 | wx.navigateTo({
110 | url: '../../pages/prize/prize?' + str,
111 | success: function () {
112 | console.log("跳转成功");
113 |
114 | },
115 | fail: function (res) {
116 | console.log(res);
117 | }
118 | })
119 | }else{
120 | wx.showModal({
121 | title: '抽奖次数已用完!',
122 | content: '抽奖次数已用完!',
123 | })
124 | }
125 | }
126 | })
127 | }
128 | })
129 | }else{
130 | wx.showModal({
131 | title: '输入以上信息,中奖后联系!',
132 | content: '输入以上信息,中奖后联系!',
133 | })
134 | }
135 | }
136 | })
--------------------------------------------------------------------------------
/server/getPrice.php:
--------------------------------------------------------------------------------
1 | $value)
10 | {
11 | if($value>$rand)
12 | {
13 | $count = $item*60;
14 | break;
15 | }
16 | }
17 | $dsn = "---";
18 | $pdo = new PDO($dsn,"user","pwd",array(
19 | PDO::MYSQL_ATTR_INIT_COMMAND=>"set names utf8"
20 | )
21 | );
22 | //判断抽奖资格
23 | $sql = "SELECT count FROM prize WHERE prize_name= ? ";
24 | $pre = $pdo->prepare($sql);
25 | //一等奖
26 | if ($count == 60) {
27 | $str = "first";
28 | $pre->execute(array($str));
29 | $res = $pre->fetch(PDO::FETCH_ASSOC);
30 | if (intval($res['count']) > 0) {
31 | $renew = $res['count'] - 1;
32 | $up = "UPDATE prize set count = '$renew' WHERE prize_name='$str'";
33 | $pdo->exec($up);
34 | $up2 = "INSERT into prize_user(open_id,award,xh,xm,tele)VALUES ('$openid','一等奖','$stu','$name','$phe')";
35 | $pdo->exec($up2);
36 | echo $count;
37 | } else {
38 | $up2 = "INSERT into prize_user(open_id,award,xh,xm,tele)VALUES ('$openid','none','$stu','$name','$phe')";
39 | $pdo->exec($up2);
40 | echo 120;
41 | }
42 | }//二等奖
43 | else if ($count == 120) {
44 | $str = "second";
45 | $pre->execute(array($str));
46 | $res = $pre->fetch(PDO::FETCH_ASSOC);
47 | if (intval($res['count']) > 0) {
48 | $renew = $res['count'] - 1;
49 | $up = "UPDATE prize set count = '$renew' WHERE prize_name='$str'";
50 | $pdo->exec($up);
51 | $up2 = "INSERT into prize_user(open_id,award,xh,xm,tele)VALUES ('$openid','二等奖','$stu','$name','$phe')";
52 | $pdo->exec($up2);
53 | echo 240;
54 | } else {
55 | $up2 = "INSERT into prize_user(open_id,award,xh,xm,tele)VALUES ('$openid','none','$stu','$name','$phe')";
56 | $pdo->exec($up2);
57 | echo 120;
58 | }
59 | }//三等奖
60 | else if ($count == 180) {
61 | $str = "third";
62 | $pre->execute(array($str));
63 | $res = $pre->fetch(PDO::FETCH_ASSOC);
64 | if (intval($res['count']) > 0) {
65 | $renew = $res['count'] - 1;
66 | $up = "UPDATE prize set count = '$renew' WHERE prize_name='$str'";
67 | $pdo->exec($up);
68 | $up2 = "INSERT into prize_user(open_id,award,xh,xm,tele)VALUES ('$openid','三等奖','$stu','$name','$phe')";
69 | $pdo->exec($up2);
70 | echo $count;
71 | } else {
72 | $up2 = "INSERT into prize_user(open_id,award,xh,xm,tele)VALUES ('$openid','none','$stu','$name','$phe')";
73 | $pdo->exec($up2);
74 | echo 120;
75 |
76 | }
77 | }//没有中奖
78 | else {
79 | $up2 = "INSERT into prize_user(open_id,award,xh,xm,tele)VALUES ('$openid','none','$stu','$name','$phe')";
80 | $pdo->exec($up2);
81 | echo 120;
82 | }
83 |
--------------------------------------------------------------------------------
/prize/prize.js:
--------------------------------------------------------------------------------
1 | // pages/prize/prize.js
2 | var xm;
3 | var xh;
4 | var xtele;
5 | var openid;
6 | Page({
7 |
8 | /**
9 | * 页面的初始数据
10 | */
11 | data: {
12 | an_zhuanp:{},
13 | start:"start",
14 | height:"500px"
15 | },
16 |
17 | /**
18 | * 生命周期函数--监听页面加载
19 | */
20 | onLoad: function (options) {
21 | var _this = this;
22 | xm = options.xm;
23 | xh = options.xh;
24 | xtele = options.xtele;
25 | openid = options.openid;
26 | wx.getSystemInfo({
27 | success: function(res) {
28 | _this.setData({
29 | height:res.screenHeight+"px"
30 | })
31 | },
32 | })
33 | },
34 | /**
35 | * 生命周期函数--监听页面初次渲染完成
36 | */
37 | onReady: function () {
38 |
39 | },
40 |
41 | /**
42 | * 生命周期函数--监听页面显示
43 | */
44 | onShow: function () {
45 |
46 | },
47 |
48 | /**
49 | * 生命周期函数--监听页面隐藏
50 | */
51 | onHide: function () {
52 |
53 | },
54 |
55 | /**
56 | * 生命周期函数--监听页面卸载
57 | */
58 | onUnload: function () {
59 |
60 | },
61 |
62 | /**
63 | * 页面相关事件处理函数--监听用户下拉动作
64 | */
65 | onPullDownRefresh: function () {
66 |
67 | },
68 |
69 | /**
70 | * 页面上拉触底事件的处理函数
71 | */
72 | onReachBottom: function () {
73 |
74 | },
75 |
76 | /**
77 | * 用户点击右上角分享
78 | */
79 | onShareAppMessage: function () {
80 |
81 | },
82 | start:function(){
83 | var n = 1;
84 | var _this = this;
85 | var timer=setInterval(function(){
86 | var animation = wx.createAnimation({
87 | duration: 1000,
88 | timingFunction: "ease",
89 | });
90 | animation.rotate(360 * n).step();
91 | _this.setData({
92 | an_zhuanp: animation.export()
93 | });
94 | n++;
95 | },100);
96 | setTimeout(function(){
97 | clearInterval(timer);
98 | timer=null;
99 | var animation = wx.createAnimation({
100 | duration:1000,
101 | timingFunction:"ease",
102 | });
103 | var deg = 0;
104 | wx.request({
105 | url: 'https://www.booleanln.cn/net/getPrice.php',
106 | data:{
107 | phone:xtele,
108 | stunum:xh,
109 | name :xm,
110 | openid:openid
111 | },
112 | header: { "content-type": "application/www-form-urlencode" },
113 | method: 'get',
114 | success: function (res) {
115 | deg = res.data;
116 | console.log(deg);
117 | animation.rotate(deg).step();
118 | _this.setData({
119 | an_zhuanp: animation.export(),
120 | start:null
121 | });
122 | if (deg == 60) {
123 | wx.showModal({
124 | title: '恭喜获得一等奖一份',
125 | content: '恭喜获得一等奖一份',
126 | })
127 | }else if(deg==300){
128 | wx.showModal({
129 | title: '恭喜获得精美小礼品一份',
130 | content: '恭喜获得精美小礼品一份',
131 | })
132 | }else if(deg == 180){
133 | wx.showModal({
134 | title: '恭喜获得精美笔记本一份',
135 | content: '恭喜获得精美笔记本一份',
136 | })
137 | }else{
138 | wx.showModal({
139 | title: '很遗憾',
140 | content: '很遗憾',
141 | })
142 | }
143 | }
144 | })
145 |
146 | },3000);
147 | }
148 | })
--------------------------------------------------------------------------------