feat(uniapp_v2): 二开功能迁移与小程序主包优化
- 从 uniapp 迁移 HJF 页面、API、组件及用户/订单相关改动 - queue、assets 使用独立分包以降低主包体积 - 修复首页单根节点与支付结果页 v-if 链 - 关闭 HjfDemoPanel 全局注册;uniNoticeBar 注释 $getAppWebview 避免 __webviewId__ 报错 - 配置域名与 manifest 应用名称;cache/store 防御性处理 Made-with: Cursor
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
<template>
|
||||
<view @longtap.stop="longtap">
|
||||
<canvas
|
||||
:width="destWidth"
|
||||
:height="destHeight"
|
||||
:canvas-id="item.id"
|
||||
:id="item.id"
|
||||
:style="{width:width,height: height}"
|
||||
v-for="(item,index) in listCode"
|
||||
:key="item.id"
|
||||
@error="handleError"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import { BarCode, GetCodeImg,GetPixelRatio,GetPx } from '../../js_sdk';
|
||||
import { getUUid, deepClone ,platform} from '../../common/helper.js'
|
||||
export default {
|
||||
name: 'WBarcode',
|
||||
props:{
|
||||
options:{
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () =>{
|
||||
return {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
destHeight: 0,
|
||||
destWidth: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
listCode: [],
|
||||
id: getUUid()
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.height = GetPx(this.options.height) + 'px';
|
||||
this.width = GetPx(this.options.width) + 'px';
|
||||
this.destHeight = GetPx(this.options.height) * GetPixelRatio() + 'px';
|
||||
this.destWidth = GetPx(this.options.width) * GetPixelRatio() + 'px';
|
||||
this.SpecialTreatment(this.options)
|
||||
this.$nextTick(()=>{
|
||||
this.generateCode();
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
options:{
|
||||
deep: true,
|
||||
handler (val) {
|
||||
this.height = GetPx(val.height) + 'px';
|
||||
this.width = GetPx(val.width) + 'px';
|
||||
this.destHeight = GetPx(this.options.height) * GetPixelRatio() + 'px';
|
||||
this.destWidth = GetPx(this.options.width) * GetPixelRatio() + 'px';
|
||||
this.SpecialTreatment(val)
|
||||
setTimeout(()=>{// h5平台动态改变canvas大小
|
||||
this.generateCode();
|
||||
},50)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
longtap (e){
|
||||
this.$emit('press',e)
|
||||
},
|
||||
handleError (e) {//当发生错误时触发 error 事件,字节跳动小程序与飞书小程序不支持
|
||||
this.$emit('error',e.detail)
|
||||
},
|
||||
SpecialTreatment (val) {//微信小程序渲染多个canvas特殊处理
|
||||
let obj = deepClone(val);
|
||||
obj.id = this.id;
|
||||
this.listCode = [obj]
|
||||
},
|
||||
generateCode () {
|
||||
try{
|
||||
const parameter = {...this.options,source: platform(),id: this.id,ctx: this};
|
||||
BarCode(parameter,(res)=>{
|
||||
this.$emit('generate',res)
|
||||
})
|
||||
}catch(err){}
|
||||
},
|
||||
async GetCodeImg (){
|
||||
try{
|
||||
return await GetCodeImg({id: this.id,width: this.options.width,height: this.options.height,ctx: this});
|
||||
}catch(e){}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,192 @@
|
||||
<template>
|
||||
<view @longtap.stop="longtap">
|
||||
<canvas
|
||||
:width="info.orient == 'vertical' ? info.destHeight : info.destWidth "
|
||||
:height="info.orient == 'vertical' ? info.destWidth : info.destHeight"
|
||||
:canvas-id="item.id"
|
||||
:id="item.id"
|
||||
:style="{width:info.orient == 'vertical' ? info.height : info.width,height: info.orient == 'vertical' ? info.width : info.height}"
|
||||
v-for="item in info.listCode"
|
||||
:key="item.id"
|
||||
@error="handleError"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
<!-- #ifdef VUE3 -->
|
||||
<script setup name="WBarcode">
|
||||
import {
|
||||
reactive,
|
||||
watch,
|
||||
onMounted,
|
||||
nextTick,
|
||||
getCurrentInstance,
|
||||
} from 'vue';
|
||||
import {
|
||||
BarCode,
|
||||
GetImg,
|
||||
GetPixelRatio,
|
||||
GetPx ,
|
||||
} from '@/uni_modules/wmf-code/js_sdk/index.js';
|
||||
import {
|
||||
getUUid,
|
||||
deepClone,
|
||||
platform,
|
||||
} from '../../common/helper.js'
|
||||
//定义props
|
||||
const props = defineProps({
|
||||
options:{
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () =>{
|
||||
return {}
|
||||
}
|
||||
}
|
||||
});
|
||||
const emits = defineEmits(['generate','press','error'])
|
||||
const opt = props.options;
|
||||
const that = getCurrentInstance();
|
||||
const HSize = opt.text ? opt.text.size || 40 + opt.text.padding || 20 : 0;
|
||||
let info = reactive({
|
||||
id: getUUid(),
|
||||
destWidth: GetPixelRatio() * GetPx(opt.width) + 'px',
|
||||
destHeight: GetPixelRatio() * GetPx(opt.height + HSize) + 'px',
|
||||
width: GetPx(opt.width) + 'px',
|
||||
height: GetPx(opt.height + HSize) + 'px',
|
||||
orient: opt.orient || 'horizontal',
|
||||
listCode: []
|
||||
})
|
||||
onMounted(()=>{
|
||||
SpecialTreatment(opt);
|
||||
nextTick(()=>{
|
||||
generateCode(opt)
|
||||
})
|
||||
});
|
||||
watch(()=>props.options,(val)=>{
|
||||
SpecialTreatment(val);
|
||||
const HSize = val.text ? val.text.size || 40 + val.text.padding || 20 : 0;
|
||||
info.destWidth= GetPixelRatio() * GetPx(val.width) + 'px',
|
||||
info.destHeight= GetPixelRatio() * GetPx(val.height + HSize) + 'px',
|
||||
info.orient = val.orient || 'horizontal',
|
||||
info.width= GetPx(val.width) + 'px',
|
||||
info.height= GetPx(val.height + HSize) + 'px',
|
||||
setTimeout(()=>{
|
||||
generateCode(val)
|
||||
},100)
|
||||
},{ deep: true })
|
||||
const generateCode = (val)=> {
|
||||
try{
|
||||
const parameter = {...val,source: platform(),id: info.id,ctx: that};
|
||||
BarCode(parameter,(res)=>{
|
||||
emits('generate',res)
|
||||
})
|
||||
}catch(err){console.warn(err)}
|
||||
}
|
||||
const GetCodeImg = async ()=> {
|
||||
try{
|
||||
return await GetImg({id: info.id,width: opt.orient == 'vertical' ? opt.height : opt.width,height: opt.orient == 'vertical' ? opt.width : opt.height,ctx: that});
|
||||
}catch(e){console.warn(e)}
|
||||
};
|
||||
const SpecialTreatment = (val) => {//渲染多个canvas特殊处理
|
||||
let obj = deepClone(val);
|
||||
obj.id = info.id;
|
||||
info.listCode = [obj];
|
||||
};
|
||||
// 长按事件
|
||||
const longtap = (e)=>{
|
||||
emits('press',e)
|
||||
}
|
||||
// canvas创建错误 触发
|
||||
const handleError = (e)=>{
|
||||
emits('error',e.detail)
|
||||
}
|
||||
|
||||
</script>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifndef VUE3 -->
|
||||
<script>
|
||||
import { BarCode, GetImg,GetPixelRatio,GetPx } from '@/uni_modules/wmf-code/js_sdk/index.js';
|
||||
import { getUUid, deepClone,platform } from '../../common/helper.js'
|
||||
export default {
|
||||
name: 'WBarcode',
|
||||
props:{
|
||||
options:{
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () =>{
|
||||
return {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
info:{
|
||||
destHeight: 0,
|
||||
destWidth: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
listCode: [],
|
||||
orient: 'horizontal'
|
||||
},
|
||||
id: getUUid()
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
const HSize = this.options.text ? ((this.options.text.size || 40) + ( this.options.text.padding || 20)) : 0;
|
||||
this.info.height = GetPx(this.options.height + HSize) + 'px';
|
||||
this.info.orient = this.options.orient || 'horizontal';
|
||||
this.info.width = GetPx(this.options.width) + 'px';
|
||||
this.info.destHeight = GetPx(this.options.height + HSize) * GetPixelRatio() + 'px';
|
||||
this.info.destWidth = GetPx(this.options.width) * GetPixelRatio() + 'px';
|
||||
this.SpecialTreatment(this.options)
|
||||
this.$nextTick(()=>{
|
||||
this.generateCode();
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
options:{
|
||||
deep: true,
|
||||
handler (val) {
|
||||
const HSize = val.text ? val.text.size || 40 + val.text.padding || 20 : 0;
|
||||
this.info.height = GetPx(val.height + HSize) + 'px';
|
||||
this.info.width = GetPx(val.width) + 'px';
|
||||
this.info.destHeight = GetPx(val.height + HSize) * GetPixelRatio() + 'px';
|
||||
this.info.destWidth = GetPx(val.width) * GetPixelRatio() + 'px';
|
||||
this.info.orient = val.orient || 'horizontal'
|
||||
this.SpecialTreatment(val)
|
||||
setTimeout(()=>{// h5平台动态改变canvas大小
|
||||
this.generateCode();
|
||||
},100)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
longtap (e){
|
||||
this.$emit('press',e)
|
||||
},
|
||||
handleError (e) {//当发生错误时触发 error 事件,字节跳动小程序与飞书小程序不支持
|
||||
this.$emit('error',e.detail)
|
||||
},
|
||||
SpecialTreatment (val) {//微信小程序渲染多个canvas特殊处理
|
||||
let obj = deepClone(val);
|
||||
obj.id = this.id;
|
||||
this.info.listCode = [obj]
|
||||
},
|
||||
generateCode () {
|
||||
try{
|
||||
const parameter = {...this.options,source: platform(),id: this.id,ctx: this};
|
||||
BarCode(parameter,(res)=>{
|
||||
this.$emit('generate',res)
|
||||
})
|
||||
}catch(err){}
|
||||
},
|
||||
async GetCodeImg (){
|
||||
try{
|
||||
return await GetImg({id: this.id,width: this.options.orient == 'vertical' ? this.options.height : this.options.width,height: this.options.orient == 'vertical' ? this.options.width : this.options.height,ctx: this});
|
||||
}catch(e){}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<!-- #endif -->
|
||||
@@ -0,0 +1,88 @@
|
||||
<template>
|
||||
<view @longtap.stop="longtap">
|
||||
<canvas
|
||||
:width="destWidth"
|
||||
:height="destHeight"
|
||||
:canvas-id="item.id"
|
||||
:id="item.id"
|
||||
:style="{width:width,height: height}"
|
||||
v-for="(item,index) in listCode"
|
||||
:key="item.id"
|
||||
@error="handleError"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
<script>
|
||||
import {QRCode,GetCodeImg,GetPixelRatio,GetPx} from '../../js_sdk';
|
||||
import { getUUid, deepClone, platform } from '../../common/helper.js'
|
||||
export default {
|
||||
name: 'WQrcode',
|
||||
props:{
|
||||
options:{
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () =>{
|
||||
return {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
destHeight: 0,
|
||||
destWidth: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
listCode:[],
|
||||
id: getUUid(),
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.height = this.width = GetPx(this.options.size) + 'px';
|
||||
this.destHeight = this.destWidth = GetPx(this.options.size) * GetPixelRatio() + 'px';
|
||||
this.SpecialTreatment(this.options)
|
||||
this.$nextTick(()=>{
|
||||
this.generateCode();
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
options:{
|
||||
deep: true,
|
||||
handler (val) {
|
||||
this.height = this.width = GetPx(val.size) + 'px';
|
||||
this.destHeight = this.destWidth = GetPx(val.size) * GetPixelRatio() + 'px';
|
||||
this.SpecialTreatment(val)
|
||||
setTimeout(()=>{// h5平台动态改变canvas大小
|
||||
this.generateCode();
|
||||
},50)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
longtap (e){
|
||||
this.$emit('press',e)
|
||||
},
|
||||
handleError (e) {//当发生错误时触发 error 事件,字节跳动小程序与飞书小程序不支持
|
||||
this.$emit('error',e.detail)
|
||||
},
|
||||
SpecialTreatment (val) {//微信小程序渲染多个canvas特殊处理
|
||||
let obj = deepClone(val);
|
||||
obj.id = this.id;
|
||||
this.listCode = [obj]
|
||||
},
|
||||
generateCode () {
|
||||
try{
|
||||
const parameter = {...this.options,source: platform(),id: this.id,ctx: this};
|
||||
QRCode(parameter,(res)=>{
|
||||
this.$emit('generate',res)
|
||||
})
|
||||
}catch(err){}
|
||||
},
|
||||
async GetCodeImg (){
|
||||
try{
|
||||
return await GetCodeImg({id: this.id,width: this.options.size,height: this.options.size,ctx: this});
|
||||
}catch(e){}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,172 @@
|
||||
<template>
|
||||
<view @longtap.stop="longtap">
|
||||
<canvas
|
||||
:width="info.destWidth"
|
||||
:height="info.destHeight"
|
||||
:canvas-id="item.id"
|
||||
:id="item.id"
|
||||
:style="{width:info.width,height: info.height}"
|
||||
v-for="item in info.listCode"
|
||||
:key="item.id"
|
||||
@error="handleError"></canvas>
|
||||
</view>
|
||||
</template>
|
||||
<!-- #ifdef VUE3 -->
|
||||
<script setup name="WQrcode">
|
||||
import {reactive, watch,onMounted,nextTick,getCurrentInstance } from 'vue';
|
||||
import { QRCode, GetImg,GetPixelRatio,GetPx } from '@/uni_modules/wmf-code/js_sdk/index.js';
|
||||
import { getUUid, deepClone,platform } from '../../common/helper.js'
|
||||
//定义props
|
||||
const props = defineProps({
|
||||
options:{
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () =>{
|
||||
return {}
|
||||
}
|
||||
}
|
||||
});
|
||||
const emits = defineEmits(['generate','press','error'])
|
||||
const opt = props.options;
|
||||
const that = getCurrentInstance();
|
||||
const SIZE = GetPx(opt.size);
|
||||
let info = reactive({
|
||||
destHeight: SIZE * GetPixelRatio() + 'px',
|
||||
destWidth: SIZE * GetPixelRatio() + 'px',
|
||||
width: SIZE + 'px',
|
||||
height: SIZE + 'px',
|
||||
listCode:[],
|
||||
id: getUUid(),
|
||||
})
|
||||
onMounted(()=>{
|
||||
SpecialTreatment(opt);
|
||||
nextTick(()=>{
|
||||
generateCode(opt)
|
||||
})
|
||||
});
|
||||
watch(()=>props.options,(val)=>{
|
||||
SpecialTreatment(val);
|
||||
const SIZE_Dynamic = GetPx(val.size);
|
||||
info.destWidth= GetPixelRatio() * SIZE_Dynamic + 'px',
|
||||
info.destHeight= GetPixelRatio() * SIZE_Dynamic + 'px',
|
||||
info.width= SIZE_Dynamic + 'px',
|
||||
info.height= SIZE_Dynamic + 'px',
|
||||
setTimeout(()=>{
|
||||
generateCode(val)
|
||||
},50)
|
||||
},{ deep: true })
|
||||
const SpecialTreatment =(val)=> {//渲染多个canvas特殊处理
|
||||
let obj = deepClone(val);
|
||||
obj.id = info.id;
|
||||
info.listCode = [obj]
|
||||
};
|
||||
const generateCode = (val)=>{
|
||||
try{
|
||||
const parameter = {...val,source: platform(),id: info.id,ctx: that};
|
||||
QRCode(parameter,(res)=>{
|
||||
emits('generate',res)
|
||||
})
|
||||
}catch(err){console.warn(err)}
|
||||
};
|
||||
const GetCodeImg = async ()=> {
|
||||
try{
|
||||
return await GetImg({id: info.id,width: opt.width,height: opt.height,ctx: that});
|
||||
}catch(e){console.warn(e)}
|
||||
};
|
||||
// 长按事件
|
||||
const longtap = (e)=>{
|
||||
emits('press',e)
|
||||
}
|
||||
// canvas创建错误 触发
|
||||
const handleError = (e)=>{
|
||||
emits('error',e.detail)
|
||||
}
|
||||
</script>
|
||||
<!-- #endif -->
|
||||
|
||||
<!-- #ifndef VUE3 -->
|
||||
<script>
|
||||
import { QRCode, GetImg,GetPixelRatio,GetPx } from '@/uni_modules/wmf-code/js_sdk/index.js';
|
||||
import { getUUid, deepClone,platform } from '../../common/helper.js'
|
||||
export default {
|
||||
name: 'WQrcode',
|
||||
props:{
|
||||
options:{
|
||||
type: Object,
|
||||
required: true,
|
||||
default: () =>{
|
||||
return {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
info:{
|
||||
destHeight: 0,
|
||||
destWidth: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
listCode:[],
|
||||
},
|
||||
destHeight: 0,
|
||||
destWidth: 0,
|
||||
width: 0,
|
||||
height: 0,
|
||||
listCode:[],
|
||||
id: getUUid(),
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.info.height = this.info.width = GetPx(this.options.size) + 'px';
|
||||
this.info.destHeight = this.info.destWidth = GetPx(this.options.size) * GetPixelRatio() + 'px';
|
||||
this.SpecialTreatment(this.options)
|
||||
this.$nextTick(()=>{
|
||||
this.generateCode();
|
||||
})
|
||||
},
|
||||
watch: {
|
||||
options:{
|
||||
deep: true,
|
||||
handler (val) {
|
||||
this.info.height = this.info.width = GetPx(val.size) + 'px';
|
||||
this.info.destHeight = this.info.destWidth = GetPx(val.size) * GetPixelRatio() + 'px';
|
||||
this.SpecialTreatment(val)
|
||||
setTimeout(()=>{// h5平台动态改变canvas大小
|
||||
this.generateCode();
|
||||
},50)
|
||||
}
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
longtap (e){// 长按事件
|
||||
this.$emit('press',e);
|
||||
},
|
||||
handleError (e) {//当发生错误时触发 error 事件,字节跳动小程序与飞书小程序不支持
|
||||
this.$emit('error',e.detail)
|
||||
},
|
||||
SpecialTreatment (val) {//微信小程序渲染多个canvas特殊处理
|
||||
let obj = deepClone(val);
|
||||
obj.id = this.id;
|
||||
this.info.listCode = [obj]
|
||||
},
|
||||
// 生成二维码
|
||||
generateCode () {
|
||||
try{
|
||||
const parameter = {...this.options,source: platform(),id: this.id,ctx: this};
|
||||
QRCode(parameter,(res)=>{
|
||||
this.$emit('generate',res)
|
||||
})
|
||||
}catch(err){console.warn(err)}
|
||||
},
|
||||
// 获取二维码图片
|
||||
async GetCodeImg (){
|
||||
try{
|
||||
return await GetImg({id: this.id,width: this.options.size,height: this.options.size,ctx: this});
|
||||
}catch(e){console.warn(e)}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<!-- #endif -->
|
||||
Reference in New Issue
Block a user