增加分销二维码邀请

This commit is contained in:
gyq
2026-01-22 14:50:28 +08:00
parent 94be2739af
commit dc3174ef13
2 changed files with 36 additions and 3 deletions

View File

@@ -38,10 +38,39 @@
</template> </template>
<script setup> <script setup>
import { shareMixin, handleMixinOnLoad, returnQuery } from '@/utils/share.js';
import ymfShare from '@/components/ymf-components/ymf-share.vue'; import ymfShare from '@/components/ymf-components/ymf-share.vue';
import wQrcode from '@/uni_modules/wmf-code/components/w-qrcode/w-qrcode.vue'; import wQrcode from '@/uni_modules/wmf-code/components/w-qrcode/w-qrcode.vue';
import { desensitizePhone } from '@/utils/util.js'; import { desensitizePhone } from '@/utils/util.js';
import { ref } from 'vue'; import { ref, onMounted, nextTick } from 'vue';
onMounted(async () => {
setTimeout(async () => {
await nextTick();
const query = await returnQuery();
codeOptions.value.code = `https://cashier.sxczgkj.com/invite?${removeQAndAfter(query)}`;
console.log('codeOptions.value', codeOptions.value);
}, 500);
});
/**
* 截取字符串,移除 &q 及后面的所有内容
* @param {string} str - 原始字符串
* @returns {string} 处理后的字符串
*/
function removeQAndAfter(str) {
// 检查是否为空字符串
if (!str || typeof str !== 'string') {
return str || '';
}
// 找到 &q 的起始位置
const qIndex = str.indexOf('&q');
// 如果找到 &q截取前面的部分否则返回原字符串
return qIndex !== -1 ? str.slice(0, qIndex) : str;
}
const props = defineProps({ const props = defineProps({
inviteCode: { inviteCode: {
type: String, type: String,
@@ -52,10 +81,13 @@ const props = defineProps({
default: () => {} default: () => {}
} }
}); });
const codeOptions = ref({ const codeOptions = ref({
padding: 10,
size: 200, size: 200,
code: props.inviteCode code: ''
}); });
function copyCode() { function copyCode() {
uni.setClipboardData({ uni.setClipboardData({
data: props.inviteCode, data: props.inviteCode,

View File

@@ -497,12 +497,13 @@ onShareAppMessage(async (res) => {
}); });
onLoad(async (opt) => { onLoad(async (opt) => {
await handleMixinOnLoad(opt);
if (opt.q) { if (opt.q) {
const q = decodeURIComponent(opt.q); const q = decodeURIComponent(opt.q);
const params = parseQueryString(q.split('?')[1]); const params = parseQueryString(q.split('?')[1]);
await handleMixinOnLoad(params);
Object.assign(options, params); Object.assign(options, params);
} else { } else {
await handleMixinOnLoad(opt);
Object.assign(options, opt); Object.assign(options, opt);
} }
console.log(options); console.log(options);