|
@@ -25,7 +25,7 @@
|
|
|
</a-spin>
|
|
|
</div>
|
|
|
<div class="pay-button">
|
|
|
- <a-button icon="sync" type="dashed" block @click="getCodeUrl">刷新二维码</a-button>
|
|
|
+ <a-button icon="sync" type="dashed" block @click="getCodeUrl(key)">刷新二维码</a-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</a-modal>
|
|
@@ -33,10 +33,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import QRCode from 'qrcode' // 定义生成二维码组件
|
|
|
import { couponCode } from '@/api/coupon.js'
|
|
|
-import { Base64 } from 'base64-js'
|
|
|
-import { encode, decode } from 'js-base64'
|
|
|
export default {
|
|
|
name: 'CouponCode',
|
|
|
props: {
|
|
@@ -54,7 +51,7 @@ export default {
|
|
|
data () {
|
|
|
return {
|
|
|
key: 1, // 当前会员类型 未持卡客户:1 VIP持卡会员:2
|
|
|
- codeImg: null,
|
|
|
+ codeImg: '',
|
|
|
isShow: this.openModal,
|
|
|
status: 'loading' // 是否显示加载提示框
|
|
|
}
|
|
@@ -75,38 +72,22 @@ export default {
|
|
|
methods: {
|
|
|
pageInit () {
|
|
|
this.key = 1
|
|
|
+ this.codeImg = ''
|
|
|
this.getCodeUrl()
|
|
|
},
|
|
|
// 获取二维码地址
|
|
|
getCodeUrl (type) {
|
|
|
- const _this = this
|
|
|
this.key = type || this.key
|
|
|
this.status = 'loading'
|
|
|
couponCode({
|
|
|
couponId: this.data.id,
|
|
|
- customerType: type == 1 ? 'normal' : 'cardholder'
|
|
|
+ customerType: this.key == 1 ? 'normal' : 'cardholder'
|
|
|
}).then(res => {
|
|
|
this.status = 'nomore'
|
|
|
if (res.status == 200) {
|
|
|
- var opts = {
|
|
|
- errorCorrectionLevel: 'H',
|
|
|
- type: 'image/jpeg',
|
|
|
- quality: 0.3,
|
|
|
- margin: 1.5,
|
|
|
- color: {
|
|
|
- dark: '#000000',
|
|
|
- light: '#ffffff'
|
|
|
- }
|
|
|
- }
|
|
|
- console.log(res.data, '11111111')
|
|
|
- const url = res.data
|
|
|
- // const url = Base64.decode(res.data)
|
|
|
- console.log(url)
|
|
|
- QRCode.toDataURL(url, opts, function (err, url) {
|
|
|
- console.log(err, 2222)
|
|
|
- _this.codeImg = url
|
|
|
- })
|
|
|
+ this.codeImg = 'data:image/png;base64,' + res.data
|
|
|
} else {
|
|
|
+ this.codeImg = ''
|
|
|
this.$message.error(res.message)
|
|
|
}
|
|
|
})
|