123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481 |
- <<<<<<< HEAD
- <template>
- <view class="content">
-
-
-
-
-
-
-
-
-
- <image :src="ctxSrc" mode="widthFix" class="tki-qrcode-canvas"></image>
-
-
- {{ loading ? '点击生成图片' : '长按二维码下载' }}
-
- </view>
- </template>
- <script>
- import tkiQrcode from '@/components/tki-qrcode/tki-qrcode.vue';
- import { spreadBanner } from '@/api/shareQrCode.js';
- import { getUserInfo } from '@/api/login.js';
- import { weixindata, shareData, loadShareData } from '@/utils/wxAuthorized.js';
- import { mapState } from 'vuex';
- import { share } from '@/api/wx';
- export default {
- computed: {
- ...mapState(['baseURL', 'urlFile']),
- ...mapState('user', ['userInfo'])
- },
-
- data() {
- return {
- cid: 'tki-qrcode-canvas',
- size: 180,
- unit: 'upx',
-
- val: '',
- background: '#ffffff',
- foreground: '#333333',
- pdground: '#333333',
- icon: '',
- iconSize: 40,
- lv: 3,
- onval: false,
- loadMake: false,
- usingComponents: false,
- showLoading: false,
- loadingText: '二维码生成中',
- src: '',
- ratio: 1,
- ctxSrc: '',
- loading: true,
- canHeight: '',
- canWeidth: '',
- login: false
- };
- },
- onShow() {
- let obj = this;
- if (!obj.login) {
-
- getUserInfo()
- .then(e => {
- obj.login = true;
- uni.showLoading({
- title: '邀请图生成中',
- mask: true
- });
- obj.loadCodeList();
- })
- .catch(e => {
- console.log(e);
- });
- }
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- methods: {
-
- setShare() {
- let obj = this;
-
-
- obj.loadSareData().then(e => {
- weixindata({
- link: obj.ctxSrc,
- imgUrl:obj.baseURL+obj.urlFile+'/img/logo.jpg',
- desc:'欢迎加入满园春',
- title: '满园春线上商城',
- success: function() {},
- fail: function() {}
- });
- });
-
- },
- loadSareData() {
- if (!shareData) {
- return loadShareData();
- } else {
- return new Promise((resolve, reject) => {
- resolve(shareData);
- });
- }
- },
- loadCodeList() {
- let obj = this;
-
- spreadBanner({
-
-
-
- })
- .then(e => {
- console.log(e);
-
-
- obj.ctxSrc = e.data[0].wap_poster;
-
-
- uni.hideLoading();
-
-
- })
- .catch(e => {
- console.log(e)
-
-
-
-
- uni.hideLoading();
- });
- },
-
- alertCanv() {
- uni.showModal({
- title: '请先点击生成图片',
- showCancel: false
- });
- },
-
- showImg() {
- uni.showLoading({
- title: '图片生成中',
- mask: true
- });
- let obj = this;
-
- setTimeout(function() {
- uni.canvasToTempFilePath({
- x: 0,
- y: 0,
- width: obj.canWeidth,
- height: obj.canHeight,
- destWidth: obj.canWeidth,
- destHeight: obj.canHeight,
- fileType: 'jpg',
- quality: 1,
- canvasId: 'qrShareBox',
- success: res => {
- uni.hideLoading();
- uni.showModal({
- title: '创建成功,长按二维码下载图片',
- showCancel: false
- });
-
- obj.loading = false;
- obj.ctxSrc = res.tempFilePath;
- },
- fail(e) {
- console.log(e);
- }
- });
- }, 50);
- },
-
- loadImg(src) {
- let obj = this;
- const ctxBg = '/static/img/img14.jpg';
- let context = uni.createCanvasContext('qrShareBox');
- const codeSize = this.size * this.ratio;
- const codeX = ((523 - this.size) * this.ratio) / 2;
- const codeY = 700 * this.ratio;
- const codeBoxColor = '#FFFFFF';
- const codeBoxWidht = 0;
- const codeBoxSize = (codeBoxWidht / 2) * this.ratio;
- const codeBoxX = codeX - codeBoxSize;
- const codeBoxY = codeY - codeBoxSize;
- const codeBoxEnd = codeSize + codeBoxWidht * this.ratio;
-
- const fontTop = codeY + codeBoxEnd + (codeBoxWidht + 30) * this.ratio;
- const fontLeft = codeX - 50 * this.ratio;
- const fontSize = 14;
- const fontText = '邀请人:' + uni.getStorageSync('userInfo').nickname;
-
- context.drawImage(ctxBg, 0, 0, obj.canWeidth, obj.canHeight);
-
- context.setFontSize(fontSize);
- context.fillText(fontText, fontLeft, fontTop);
-
- context.beginPath();
- context.setLineJoin('round');
- context.setLineWidth(codeBoxWidht * this.ratio);
- context.setStrokeStyle(codeBoxColor);
- context.strokeRect(codeBoxX, codeBoxY, codeBoxEnd, codeBoxEnd);
- context.stroke();
-
- context.drawImage(src, codeX, codeY, codeSize, codeSize);
-
- context.draw();
- },
-
- creatQrcode() {
- this.$refs.qrcode._makeCode();
- },
-
- saveQrcode() {
- this.$refs.qrcode._saveCode();
- },
-
- qrR(res) {
- this.src = res;
- },
-
- clearQrcode(e) {
- this.$refs.qrcode._clearCode();
- this.val = '';
- }
- }
- };
- </script>
- <style lang="scss">
- .content {
- // padding-top: 30rpx;
- }
- // #qrShareBox {
- // position: absolute;
- // left: -9999rpx;
- // top: -9999rpx;
- // }
- .qrimg {
- position: absolute;
- left: -9999rpx;
- top: -9999rpx;
- }
- .tki-qrcode-canvas {
- width: 750rpx;
- margin: 0 auto;
- }
- .share-bottom {
- width: 560rpx;
- height: 80rpx;
- color: #ffffff;
- background-color: $base-color;
- margin: 0 auto;
- font-size: $font-lg - 2rpx;
- margin-top: 30rpx;
- border-radius: 99rpx;
- justify-content: center;
- &.action-share-bottom {
- background-color: $color-gray;
- }
- }
- </style>
- =======
- <template>
- <view class="container">
- <image @longtap="bc_code" class="backImg" :src="backImg"></image>
- <view class="tki-qrcode">
- <canvas @longtap="bc_code" canvas-id="qrcode" />
- </view>
- </view>
- </template>
- <script>
- import { getUserInfo,spreadBanner } from '@/api/user.js';
- export default {
- props: {
- qrval: {
-
- type: String,
- }
- },
- data() {
- return {
- url: '',
- backImg:'',
- userInfo:''
- };
- },
- onLoad() {
- this.spread();
- this.getInfo();
- },
- computed: {
- cpSize() {
- if(this.unit == "upx"){
- return uni.upx2px(this.size)
- }else{
- return this.size
- }
- }
- },
- methods: {
- spread(){
- let obj = this;
- spreadBanner({
- type:2
- }).then(({ data }) => {
- obj.backImg = data[0].wap_poster;
- });
- },
- getInfo(){
- let obj = this;
- getUserInfo({}).then(({ data }) => {
- obj.userInfo = data;
-
- });
- },
- bc_code(){
- let that = this;
- console.log('保存二维码',this.backImg)
- uni.downloadFile({
- url:this.backImg,
- success:(res)=>{
-
- if(res.statusCode == 200){
- uni.saveImageToPhotosAlbum({
- filePath:res.tempFilePath,
- success() {
- that.$api.msg('保存成功')
- },
- fail() {
- that.$api.msg('保存失败')
- }
- })
- }
- }
- })
- },
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- },
- };
- </script>
- <style lang="scss">
- page{
- width: 100%;
- min-height: 100%;
- .container{
- width: 100%;
- height: 100%;
- }
- }
- .backImg{
- position: absolute;
- width: 100%;
- height: 100%;
- }
- .portrait{
- width: 100%;
- text-align: center;
- padding-top: 80rpx;
- padding-bottom: 30rpx;
- image{
- width: 250rpx;
- height: 250rpx;
- }
- }
- .text{
- text-align: center;
- width: 100%;
- color: #FFFFFF;
- font-size:55rpx;
- letter-spacing:15rpx;
- }
- .uid-name{
- padding: 50rpx 0rpx;
- text-align: center;
- width: 100%;
- color: #FFFFFF;
- }
- .copy-btn{
- color: #FFFFFF;
- background-color: #4BA6ED;
- border-radius: 50rpx;
- width: 170rpx;
- line-height: 70rpx;
- margin: 0rpx auto;
- text-align: center;
- }
- .tki-qrcode{
- position: fixed;
- bottom: 10%;
- left: 30%;
- }
- canvas{
- width:150px;
- height: 150px;
- margin: auto;
-
- }
- </style>
- >>>>>>> 4114c25969fb9b7b2c1d4af1f04837ed1c250f54
|