123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286 |
- <template>
- <view class="container">
- <view class="coupon-list">
- <view class="coupon-item" v-for="(item, index) in couponList" :key="index">
- <view class="hidden-box" v-show="item.spread">
- <view style="width: 100%;padding-bottom: 30rpx;" class="qrcode-box">
- <view style="width: 80rpx;height: 80rpx;float: left;border-radius:40rpx;background-color: #E6B728;text-align: center;color: #FFFFFF;">
- <view style="font-size: 32rpx;margin-top: 15rpx;">余</view>
- </view>
- <view style="margin-left: 100rpx;">
- <view class="code-tit">{{ item.familtname }}</view>
- <view class="code-num">家族ID:{{ item.id }}</view>
- </view>
- </view>
-
- <view class="qrcode-box">
- <view class="qrcode">
- <canvas :class="{ 'my-canvas': !item.spread }" :style="{ width: qrcode_w + 'px', height: qrcode_w + 'px' }"
- :canvas-id="'couponQrcode' + index" :id="'couponQrcode' + index"></canvas>
- </view>
- </view>
- <view class="list-item">
- 扫一扫上面二维码,加入家族
- </view>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- const util = require('@/utils/util.js');
- const qrCode = require('@/libs/weapp-qrcode.js');
- export default {
- data() {
- return {
- show: true,
- couponList: [{
- familtname: '陕西凤翔-余姓',
- id: '0900100200',
- spread: true,
- }],
- qrcode_w: uni.upx2px(240)
- };
- },
- onLoad: function(options) {
- const W = uni.getSystemInfoSync().windowWidth;
- const qrcode_w = uni.upx2px(260);
- this.qrcode_w = qrcode_w;
- // #ifdef APP-PLUS || MP
- setTimeout(() => {
- this.couponQrCode(this.couponList[0].id, 'couponQrcode0');
- }, 60);
- // #endif
- },
- methods: {
- spread: function(index) {
- let couponList = this.couponList;
- if (!couponList[index].spread) {
- setTimeout(() => {
- this.couponQrCode(couponList[index].id, 'couponQrcode' + index);
- }, 60);
- }
- couponList[index].spread = !couponList[index].spread;
- this.couponList = couponList;
- },
- // 二维码生成工具
- couponQrCode(text, canvasId) {
- new qrCode(canvasId, {
- text: text,
- width: this.qrcode_w,
- height: this.qrcode_w,
- colorDark: '#333333',
- colorLight: '#FFFFFF',
- correctLevel: qrCode.CorrectLevel.H
- });
- if (canvasId == 'couponQrcode0') {
- setTimeout(() => {
- if (!this.show) {
- this.show = true;
- }
- }, 0);
- }
- }
- }
- };
- </script>
- <style>
- /* #ifdef MP-ALIPAY */
- .my-canvas {
- position: fixed;
- left: -200px;
- top: 0;
- }
- /* #endif */
- .container {
- width: 100%;
- padding-bottom: env(safe-area-inset-bottom);
- }
- .header {
- width: 100%;
- padding: 0 30rpx;
- box-sizing: border-box;
- font-size: 24rpx;
- color: #999;
- height: 54rpx;
- line-height: 54rpx;
- background: #fff;
- display: flex;
- align-items: center;
- position: fixed;
- top: 0;
- /* #ifdef H5 */
- top: 44px;
- /* #endif */
- z-index: 999999;
- }
- .coupon-num {
- color: #5677fc;
- }
- .coupon-list {
- width: 100%;
- padding: 54rpx 50rpx;
- box-sizing: border-box;
- }
- .coupon-item {
- margin-top: 20rpx;
- width: 100%;
- box-shadow: 0 8rpx 10rpx -8rpx #eaeef1;
- border-radius: 2rpx;
- }
- .coupon {
- height: 160rpx;
- position: relative;
- display: flex;
- align-items: center;
- }
- .coupon-img {
- width: 100%;
- height: 160rpx;
- position: absolute;
- left: 0;
- top: 0;
- z-index: 0;
- }
- .left-tit-box {
- width: 414rpx;
- padding-left: 75rpx;
- box-sizing: border-box;
- z-index: 10;
- }
- .tit {
- width: 290rpx;
- font-size: 30rpx;
- color: #333;
- line-height: 42rpx;
- overflow: hidden;
- text-overflow: ellipsis;
- display: -webkit-box;
- -webkit-line-clamp: 2;
- -webkit-box-orient: vertical;
- }
- .term {
- width: 228rpx;
- font-size: 24rpx;
- color: #999;
- line-height: 24rpx;
- padding-top: 7rpx;
- white-space: nowrap;
- }
- .right-detail {
- width: 236rpx;
- text-align: center;
- height: 160rpx;
- display: flex;
- align-items: center;
- justify-content: center;
- z-index: 10;
- }
- .detail-txt {
- font-size: 24rpx;
- color: #fff;
- padding-right: 12rpx;
- }
- .arrow {
- width: 16rpx;
- height: 24rpx;
- transition: all 0.15s ease;
- }
- .spread {
- width: 24rpx;
- height: 16rpx;
- }
- .qrcode {
- width: 260rpx;
- height: 260rpx;
- margin: 45rpx auto 43rpx auto;
- }
- .hidden-box {
- padding: 35rpx 40rpx 27rpx 40rpx;
- box-sizing: border-box;
- color: #333;
- border-top: 1rpx solid #eaeef1;
- background: #fff;
- }
- .code-tit {
- font-size: 28rpx;
- line-height: 28rpx;
- }
- .code-num {
- font-size: 30rpx;
- line-height: 30rpx;
- padding-top: 23rpx;
- }
- .qrcode-box {
- width: 100%;
- border-bottom: 1rpx dashed #eaeef1;
- margin-bottom: 6rpx;
- }
- .list-item {
- text-align: center;
- align-items: center;
- justify-content: space-between;
- font-size: 28rpx;
- }
- .list-item::after {
- left: 0;
- }
- .item-tit {
- color: #666;
- }
- .item-con {
- color: #333;
- }
- .explain {
- font-size: 28rpx;
- line-height: 28rpx;
- color: #666;
- padding: 33rpx 0 25rpx 0;
- }
- .explain-text {
- font-size: 28rpx;
- line-height: 41rpx;
- color: #333;
- }
- .none {
- width: 100%;
- position: fixed;
- text-align: center;
- font-size: 30rpx;
- color: #ccc;
- top: 49%;
- }
- .tui-rotate_90 {
- transform: rotate(90deg);
- }
- </style>
|