blob: ef5f0b2cf274c76f95906c16781a5a587c804417 [file] [log] [blame]
guangchao.xu070005a2020-12-07 09:56:40 +08001<template>
2 <view class="qrcode">
3 <!-- #ifndef MP-WEIXIN -->
4 <u-navbar title="我的码" :background="background" title-color="#ffffff" :border-bottom="false" back-icon-color="#Ffffff"></u-navbar>
5 <!-- #endif -->
6 <view class="qrcode-con">
7 <view class="qrcode-con-con">
8 <view class="qrcode-con-con-title">
9 <u-icon name="money" color="#2FA8E1" size="36" custom-prefix="custom-icon"></u-icon>
10 <text>消费支付或身份认证</text>
11 </view>
12 <view class="qrcode-con-con-qrcode">
13 <text class="qrcode-con-con-qrcode-desc">扫描二维码支付或认证身份</text>
14 <canvas canvas-id="qrcode" style="width: 250px;height: 250px;" v-if="show" />
15 <u-empty text="暂无二维码" mode="list" :show="!show"></u-empty>
16 <text>二维码每15s刷新一次</text>
17 <view class="qrcode-con-con-qrcode-box" @click="isSigned">
18 <u-icon name="reflash" color="#666666" size="40" custom-prefix="custom-icon" label="刷新" label-size="36"></u-icon>
19 </view>
20 </view>
21 <view class="qrcode-con-con-footer">
22 <u-icon name="id" color="#666666" size="36" custom-prefix="custom-icon"></u-icon>
23 <view class="qrcode-con-con-footer-desc">
24 <text class="qrcode-con-con-footer-desc-card">市民卡</text>
25 <text class="qrcode-con-con-footer-desc-no">{{cardid}}</text>
26 </view>
27 </view>
28 </view>
29 </view>
30 </view>
31</template>
32
33<script>
34 const app = getApp()
35 import uQRCode from '@/static/js/uqrcode.js'
36 export default {
37
38 data() {
39 return {
40 val: "",
41 cardid: "",
42 background: {
43 'background': 'no'
44 },
45 show: "",
46 setInter: ""
47
48 }
49 },
50 onLoad() {
51 let that = this
52 that.cardid = uni.getStorageSync('cardno') ? uni.getStorageSync('cardno') : '暂无市民卡号信息'
53 // #ifndef H5
54 that.isSigned()
55 uni.getScreenBrightness({
56 success: function(res) {
57 that.val = res.value
58 }
59 });
60 uni.setScreenBrightness({
61 value: 1,
62 success: function() {
63 // console.log('success');
64 }
65 });
66 // #endif
67 },
68 methods: {
69 isSigned() {
70 let that = this
71 let signed = uni.getStorageSync("signed")
72 if (!signed) {
73 uni.showModal({
74 title: "提示",
75 content: "您还未绑定签约,无法使用二维码消费",
76 cancelText: "再等等",
77 confirmText: "去绑定",
78 success(res) {
79 if (res.confirm) {
80 uni.navigateTo({
guangchao.xu6cdd45e2021-04-16 17:44:30 +080081 url: "/pages/sub_mine/bindBankCard"
guangchao.xu070005a2020-12-07 09:56:40 +080082 })
83 }
84 }
85 })
86 return false
87 }
88 that.getQrcode()
89 clearInterval(that.setInter)
90 that.setInter = setInterval(() => {
91 that.getQrcode()
92 }, 15 * 1000)
93 },
94 getQrcode() {
95 let that = this
96 let param = {
97 version:app.globalData.version
98 }
99 that.$u.post("/v1/qrcode", param).then((res) => {
100 that.show = true
101 uQRCode.make({
102 canvasId: 'qrcode',
103 componentInstance: this,
104 text: res.qrcode,
105 size: 250,
106 margin: 10,
107 backgroundColor: '#ffffff',
108 foregroundColor: '#000000',
109 fileType: 'jpg',
110 correctLevel: uQRCode.errorCorrectLevel.H,
111 success: res => {
112 // console.log(res)
113 }
114 })
115 }).catch(res => {
116 that.show = false
117 })
118 },
119 },
120 onUnload() {
121 // #ifndef H5
122 let that = this
123 clearInterval(that.setInter)
124 uni.setScreenBrightness({
125 value: that.val,
126 success: function() {
127 // console.log('success');
128 }
129 });
130 // #endif
131 }
132 }
133</script>
134
135<style scoped lang="scss">
136 .qrcode {
137 width: 100vw;
138 height: 100vh;
139 background-color: #2FA8E1;
140
141 &-con {
142 padding: 30rpx;
143
144 // border-radius: 20rpx;
145 &-title {
146 display: flex;
147 justify-content: space-between;
148 align-items: center;
149 color: #FFFFFF;
150
151 text {
152 font-family: "PingFang-SC-Medium";
153 font-size: 32rpx;
154 }
155 }
156
157 &-con {
158 margin-top: 100rpx;
159 font-family: "PingFang-SC-Medium";
160
161 &-title {
162 background-color: #F7F7F7;
163 font-size: 30rpx;
164 display: flex;
165 align-items: center;
166 padding: 30rpx;
167 color: #2FA8E1;
168 border-top-left-radius: 20rpx;
169 border-top-right-radius: 20rpx;
170
171 text {
172 margin-left: 10rpx;
173 }
174 }
175
176 &-qrcode {
177 background-color: #FFFFFF;
178 display: flex;
179 flex-direction: column;
180 align-items: center;
181 color: #999999;
182 font-size: 26rpx;
183 padding: 30rpx 50rpx;
184 border-width: 1rpx;
185 border-style: solid;
186 border-color: #CCCCCC;
187
188 &-desc {
189 margin-bottom: 30rpx;
190 }
191
192 &-box {
193 margin-top: 30rpx;
194 display: flex;
195 align-items: center;
196
197 text {
198 margin-left: 10rpx;
199 color: #666666;
200 }
201 }
202 }
203
204 &-footer {
205 background-color: #FFFFFF;
206 display: flex;
207 align-items: flex-start;
208 padding: 30rpx;
209 border-bottom-left-radius: 20rpx;
210 border-bottom-right-radius: 20rpx;
211
212 &-desc {
213 display: flex;
214 flex-direction: column;
215 margin-left: 10rpx;
216
217 &-no {
218 color: #999999;
219 font-size: 26rpx;
220 }
221 }
222 }
223 }
224 }
225 }
226</style>