| @@ -2,6 +2,7 @@ | |||
| const Http = require("../../utils/HttpBasics"); | |||
| const imgurl = require("../../utils/imgurl"); | |||
| const config = require("../../config/config"); | |||
| const QR = require("../../utils/memberqrcode.js"); | |||
| let app = getApp(); | |||
| Page({ | |||
| data: { | |||
| @@ -22,6 +23,66 @@ Page({ | |||
| showIf: false, | |||
| page: 1 // 刷新进入页面时已经加载了第一页数据,onReachBottom时 page++,从第2页开始加载 | |||
| }, | |||
| gotodiscountCardList:function(){ | |||
| wx.navigateTo({ | |||
| url: '/pages/discountCardList/discountCardList' | |||
| }) | |||
| }, | |||
| gotoRushBuy:function(){ | |||
| wx.navigateTo({ | |||
| url: '/pages/rushToBuy/index', | |||
| }) | |||
| }, | |||
| qrcode: function (e) { | |||
| var that = this; | |||
| that.setData({ | |||
| showQrcode: true | |||
| }) | |||
| wx.showToast({ | |||
| title: '生成中...', | |||
| icon: 'loading', | |||
| duration: 2000 | |||
| }); | |||
| console.log(e) | |||
| var st = setTimeout(function () { | |||
| wx.hideToast() | |||
| var size = that.setCanvasSize(); | |||
| var url = JSON.stringify({ flagid: that.data.memberId }); | |||
| that.createQrCode(url, "mycanvas2", size.w, size.h); | |||
| that.setData({ | |||
| maskHidden: true | |||
| }); | |||
| clearTimeout(st); | |||
| }, 1000) | |||
| }, | |||
| hideQrcode: function () { | |||
| let that = this; | |||
| that.setData({ | |||
| showQrcode: false | |||
| }) | |||
| }, | |||
| //适配不同屏幕大小的canvas | |||
| setCanvasSize: function () { | |||
| var size = {}; | |||
| try { | |||
| var res = wx.getSystemInfoSync(); | |||
| var scale = 750 / 500; | |||
| //不同屏幕下canvas的适配比例;设计稿是750宽 | |||
| var width = res.windowWidth / scale; | |||
| var height = width; | |||
| //canvas画布为正方形 | |||
| size.w = width; | |||
| size.h = height; | |||
| } catch (e) { | |||
| // Do something when catch error | |||
| console.log("获取设备信息失败" + e); | |||
| } | |||
| return size; | |||
| }, | |||
| createQrCode: function (url, canvasId, cavW, cavH) { | |||
| //调用插件中的draw方法,绘制二维码图片 | |||
| QR.api.draw(url, canvasId, cavW, cavH); | |||
| }, | |||
| swiperChange: function (e) { | |||
| this.setData({ | |||
| swiperCurrent: e.detail.current | |||
| @@ -133,6 +194,34 @@ Page({ | |||
| }) | |||
| }; | |||
| }, | |||
| // 会员码获取 | |||
| getmemberId: function (token){ | |||
| let that = this; | |||
| Http.get({ | |||
| url: config.api.getScore, | |||
| data: { | |||
| token: token | |||
| } | |||
| }).then(res => { | |||
| console.log(res) | |||
| if (res.data.nickName) { | |||
| that.setData({ | |||
| ismember: true, | |||
| memberId: res.data.id | |||
| }) | |||
| var size = this.setCanvasSize(); | |||
| var initUrl = JSON.stringify({ flagid: res.data.id }); | |||
| that.createQrCode(initUrl, "mycanvas1", size.w, size.h); | |||
| } | |||
| }) | |||
| .catch(err => { | |||
| wx.showModal({ | |||
| title: '提示', | |||
| content: err.message, | |||
| showCancel: false | |||
| }) | |||
| }) | |||
| }, | |||
| /** | |||
| * | |||
| * @param {code,page} | |||
| @@ -190,6 +279,7 @@ Page({ | |||
| if (res.data.token){ | |||
| that.getGameOne(res.data.token) | |||
| that.getStaticGame(res.data.token) | |||
| that.getmemberId(res.data.token); | |||
| } | |||
| Http.setToken(res.data.token); | |||
| that.checkUserCarStatus(); | |||
| @@ -2,18 +2,16 @@ | |||
| <view class="container"> | |||
| <c-banner wx:key="unique" list="{{list}}" /> | |||
| <!-- 折扣卡 --> | |||
| <discount-card wx:key="unique" /> | |||
| <c-rushToBuy /> | |||
| <view class='section'> | |||
| <view> | |||
| <view bindtap='gotoRushBuy'> | |||
| <image src='./../../assets/images/icon001.png' mode='widthFix'></image> | |||
| <text>限时抢购</text> | |||
| </view> | |||
| <view> | |||
| <view bindtap='gotodiscountCardList'> | |||
| <image src='./../../assets/images/icon002.png' mode='widthFix'></image> | |||
| <text>优惠卡</text> | |||
| </view> | |||
| <view> | |||
| <view bindtap='qrcode'> | |||
| <image src='./../../assets/images/icon003.png' mode='widthFix'></image> | |||
| <text>会员权益</text> | |||
| </view> | |||
| @@ -26,4 +24,10 @@ | |||
| </view> | |||
| <c-coupons id="lists" bind:myevent="onGetCode" loadingtext="{{loadingtext}}" loading="{{loading}}" /> | |||
| <g-entry id="listss" wx:if="{{showGame&&!played&&!havePlayEd}}" gamedata="{{gamedata}}" bind:myevent="" /> | |||
| </view> | |||
| </view> | |||
| <view class='showQrcode' bindtap='hideQrcode' wx:if="{{showQrcode}}"> | |||
| <view class="canvas-box"> | |||
| <canvas hidden="{{canvasHidden}}" style="height:500rpx;background:0 0 0 .6;margin:10rpx auto;" canvas-id="mycanvas2" /> | |||
| <text class='memberIds'>会员号:{{memberId}}</text> | |||
| </view> | |||
| </view> | |||
| @@ -15,28 +15,86 @@ | |||
| page { | |||
| width: 100%; | |||
| height: auto!important; | |||
| height: auto !important; | |||
| overflow-x: hidden; | |||
| } | |||
| .txt { | |||
| margin-left: 20rpx; | |||
| } | |||
| .game-entry{ | |||
| .game-entry { | |||
| width: 690rpx; | |||
| height: 140rpx; | |||
| margin: 30rpx auto 0; | |||
| margin: 57rpx auto 0; | |||
| } | |||
| .gameimg{ | |||
| .gameimg { | |||
| display: block; | |||
| width: 100%; | |||
| height: 140rpx; | |||
| } | |||
| .section{ | |||
| .section { | |||
| display: flex; | |||
| justify-content: space-around; | |||
| text-align: center; | |||
| margin-top: 40rpx; | |||
| } | |||
| .section >view image{ | |||
| .section >view image { | |||
| width: 121rpx; | |||
| display: block; | |||
| } | |||
| .section text { | |||
| height: 23rpx; | |||
| font-size: 24rpx; | |||
| font-family: PingFang-SC-Medium; | |||
| font-weight: 500; | |||
| color: rgba(51, 51, 51, 1); | |||
| display: block; | |||
| margin-top: 0rpx; | |||
| } | |||
| .showQrcode { | |||
| position: fixed; | |||
| top: 0; | |||
| left: 0; | |||
| right: 0; | |||
| bottom: 0; | |||
| z-index: 1000; | |||
| background: rgba(0, 0, 0, 0.6); | |||
| } | |||
| .qrcode image { | |||
| width: 70rpx; | |||
| margin-right: 20rpx; | |||
| } | |||
| .showQrcode { | |||
| position: fixed; | |||
| top: 0; | |||
| left: 0; | |||
| right: 0; | |||
| bottom: 0; | |||
| z-index: 1000; | |||
| background: rgba(0, 0, 0, 0.6); | |||
| } | |||
| .canvas-box { | |||
| position: fixed; | |||
| width: 500rpx; | |||
| height: 587rpx; | |||
| overflow: hidden; | |||
| left: 0; | |||
| top: 0; | |||
| bottom: 0; | |||
| right: 0; | |||
| margin: auto; | |||
| background: #fff; | |||
| border-radius: 16rpx; | |||
| } | |||
| .showQrcode text{ | |||
| display: block; | |||
| text-align: center; | |||
| font-size: 28rpx; | |||
| } | |||
| @@ -127,14 +127,14 @@ Page({ | |||
| score: res.data.score, | |||
| levelName: res.data.levelName, | |||
| }) | |||
| if (res.data.nickName || res.data.phone){ | |||
| if (res.data.nickName){ | |||
| that.setData({ | |||
| ismember:true, | |||
| memberId: res.data.id | |||
| }) | |||
| var size = this.setCanvasSize(); | |||
| var initUrl = JSON.stringify({flagid:res.data.id}); | |||
| this.createQrCode(initUrl, "mycanvas1", size.w, size.h); | |||
| that.createQrCode(initUrl, "mycanvas1", size.w, size.h); | |||
| } | |||
| }) | |||
| .catch(err => { | |||