Compare commits

...

5 Commits

@ -6,8 +6,11 @@
"scripts": {
"dev": "vite",
"build": "vite build",
"build:hot": "vite build",
"build:sta": "vite build --mode stage",
"preview": "vite preview"
"preview": "vite preview",
"postbuild:sta" : "scp -r ./dist/* root@207.148.89.145:/www/wwwroot/utel.zltest.com.tw/public/home",
"postbuild:hot" : "scp -r ./dist/* root@167.179.106.36:/www/wwwroot/pro.utel.vip/app/public/home"
},
"dependencies": {
"@line/liff": "^2.22.4",

@ -1,7 +1,5 @@
import { createRouter, createWebHistory } from "vue-router";
import store from "@/store";
import NProgress from "nprogress";
import "nprogress/nprogress.css";
@ -146,7 +144,9 @@ router.beforeEach((to, from, next) => {
if (to.path !== "/" && to.path !== "/login" && to.path !== "/actlogin" && to.path !== "/register") {
if (!sessionStorage.getItem("token")) {
console.log('to',to);
sessionStorage.setItem("redirect", to.fullPath);
sessionStorage.setItem("refer", to.query.cardid);
return next("/actlogin");
}

@ -349,7 +349,7 @@ function genCard(vcard) {
"action": {
"type": "uri",
"label": "action",
"uri": "${import.meta.env.VITE_APP_BASE_URL}/home/address?act=add&cardid=${vcard.user_id}"
"uri": "https://liff.line.me/${import.meta.env.VITE_APP_LINE_LIFF_ID}/address?act=add&cardid=${vcard.user_id}"
}
}
],

@ -315,7 +315,7 @@ function genCard(vcard) {
"action": {
"type": "uri",
"label": "收藏名片",
"uri": "${import.meta.env.VITE_APP_BASE_URL}/home/address?act=add&cardid=${vcard.user_id}"
"uri": "https://liff.line.me/${import.meta.env.VITE_APP_LINE_LIFF_ID}/address?act=add&cardid=${vcard.user_id}"
},
"color": "#c73f6d",
"height": "sm",

@ -305,7 +305,7 @@ function genCard(vcard) {
"action": {
"type": "uri",
"label": "收藏名片",
"uri": "${import.meta.env.VITE_APP_BASE_URL}/home/address?act=add&cardid=${vcard.user_id}"
"uri": "https://liff.line.me/${import.meta.env.VITE_APP_LINE_LIFF_ID}/address?act=add&cardid=${vcard.user_id}"
},
"color": "#464757",
"height": "sm",

@ -234,7 +234,7 @@ function genCard(vcard) {
"action": {
"type": "uri",
"label": "action",
"uri": "${import.meta.env.VITE_APP_BASE_URL}/home/address?act=add&cardid=${vcard.user_id}"
"uri": "https://liff.line.me/${import.meta.env.VITE_APP_LINE_LIFF_ID}/address?act=add&cardid=${vcard.user_id}"
}
}
]

@ -26,13 +26,10 @@ const selectOpt2 = ref([{ text: '重要', value: '重要' }, { text: '普通', v
const addressList = ref([]);
onBeforeMount(async () => {
onMounted(async () => {
if (route.query.act === 'add') {
let res = await addUserFavi({ uf_user_id: route.query.cardid });
}
});
onMounted(async () => {
initData();
getCateList();
});

@ -30,6 +30,29 @@ const imageUrl = ref(import.meta.env.VITE_APP_BASE_URL);
const is_due = ref(false);
async function handleBindCard(uid, verify) {
//
showConfirmDialog({
title: "卡片綁定",
message: "確認是否綁定這張卡片",
confirmButtonText: "確認",
cancelButtonText: "取消",
})
.then(async () => {
//
let bindRes = await bindCard({
uid,
verify,
});
if (bindRes.code === 200) {
showSuccessToast("綁定成功");
} else {
showFailToast("綁定失敗");
}
})
.catch(() => { });
}
onBeforeMount(async () => {
const liff = window.liff;
try {
@ -49,33 +72,16 @@ onBeforeMount(async () => {
if (loginRes.code === 200) {
if (route.query.act === "openright") {
showToast("您已經是本站會員");
if (route.query.verify) {
handleBindCard(loginRes.data.uid,route.query.verify);
}
}
sessionStorage.setItem("token", loginRes.data.token);
sessionStorage.setItem("uid", loginRes.data.uid);
} else if (loginRes.code === 202) { //
if (route.query.act === "openright") {
if (route.query.verify) {
//
showConfirmDialog({
title: "卡片綁定",
message: "確認是否綁定這張卡片",
confirmButtonText: "確認",
cancelButtonText: "取消",
})
.then(async () => {
//
let bindRes = await bindCard({
uid: loginRes.data.uid,
verify: route.query.verify,
});
if (bindRes.code === 200) {
showSuccessToast("綁定成功");
} else {
showToast.fail("綁定失敗");
}
})
.catch(() => { });
handleBindCard(loginRes.data.uid,route.query.verify);
}
}
@ -93,7 +99,7 @@ onBeforeMount(async () => {
});
return;
}else if(route.query.user_id){ //lineid
} else if (route.query.user_id) { //lineid
//
showConfirmDialog({
title: "會員綁定",
@ -198,7 +204,7 @@ const onUpdateValue = (newValue) => {
cancelButtonText: "取消",
}).then(() => {
let res = userStore.setSendWithAd(newValue)
console.log('aaa',userInfo.value.is_send_ad)
console.log('aaa', userInfo.value.is_send_ad)
}).catch(() => {
// on cancel
@ -258,17 +264,20 @@ const doCopyUid = () => {
};
const doShare = () => {
toClipboard(`https://liff.line.me/${import.meta.env.VITE_APP_LINE_LIFF_ID}/?aid=${userInfo.value.user_id}`)
toClipboard(`https://liff.line.me/${import.meta.env.VITE_APP_LINE_LIFF_ID}/?aid=${userInfo.value.agent_code}`)
showToast("已放入剪貼簿");
};
const bindTggo = () => {
let url;
if (userInfo.value.uniqid) {
let url = `https://www.tggo.com.tw/u.cgi?&mnm=mybinding&ncode=${userInfo.value.uniqid}&name=${userInfo.value.real_name}&openExternalBrowser=1`;
url = `https://www.tggo.com.tw/u.cgi?&mnm=mybinding&ncode=${userInfo.value.uniqid}&name=${userInfo.value.real_name}&openExternalBrowser=1`;
} else {
url = `https://www.tggo.com.tw/u.cgi?user=1111&from=portal&openExternalBrowser=1`;
}
window.open(url, "_blank");
return;
}
showToast('您的帳號尚未綁定感應卡');
// showToast('');
};
const handleLogout = () => {

@ -52,7 +52,7 @@ const tabItemObj = ref([
const beforeChange = (index) => {
return new Promise((resolve) => {
if (index === 1) {
if (form.value.level === 0) {
if (form.value.level === 0 && form.value.status !== 2) {
showConfirmDialog({
title: '會員資格開通提醒',
message: '本功能為標準型以上之付費功能,是否前往立即開通?',
@ -709,19 +709,23 @@ const handleChangeTplSubmit = async () => {
<!-- <Footer/> -->
<van-popup class="cropPopup" v-model:show="crop.show" closeable>
<h5 class="text-center mt-3">檔案裁切上傳</h5>
<div class="cropper-section">
<van-overlay :show="crop.show" @click="crop.show = false" />
<div class="cropper-section" v-if="crop.show">
<h5 class="text-center">檔案裁切上傳</h5>
<div class="crop-area">
<cropper class="cropper" ref="myCrop" :src="crop.img" :stencil-props="{
aspectRatio: 1 / 1,
}" :auto-zoom="true" />
</div>
<van-button round class="btn-tomatoRed rounded-pill w-50 mt-3" size="small" @click="onCrop">
<div class="crop-btn">
<van-button round class="btn-darkBlue rounded-pill w-50" size="small" @click="() => { crop.show = false }">
取消
</van-button>
<van-button round class="btn-tomatoRed rounded-pill w-50" size="small" @click="onCrop">
裁切確認
</van-button>
</div>
</van-popup>
</div>
</div>
</template>
@ -834,4 +838,29 @@ const handleChangeTplSubmit = async () => {
}
}
}
.cropper-section {
margin: 0 auto;
position: fixed;
text-align: center;
top: 50px;
height: 350px;
width: 100%;
max-width: 500px;
background: hsl(0, 0%, 87%);
z-index: 8888;
.crop-area {
margin: 5 auto;
width: 100%;
// height: 330px;
}
.crop-btn {
text-align: center;
display: flex;
justify-content: space-between;
}
}
</style>

@ -21,7 +21,7 @@ const route = useRoute();
const form = ref({
verify: route.query.verify || null,
user_id: route.query.user_id || null,
aid: route.query.aid || undefined,
aid: route.query.aid || null,
});
const title = ref("註冊成為會員");
@ -130,11 +130,10 @@ const onSubmit = async () => {
line_name: profile.displayName,
line_picture: profile.pictureUrl,
token: id_token,
refer: sessionStorage.getItem("refer") || null,
...form.value,
});
console.log("regRes.code",regRes)
if (regRes.code === 500) {
if (liff.isLoggedIn()) {
liff.logout();
@ -145,7 +144,10 @@ const onSubmit = async () => {
showToast("註冊成功");
sessionStorage.setItem("token", regRes.data.token);
sessionStorage.setItem("uid", regRes.data.uid);
return router.push("/");
let redirect = sessionStorage.getItem("redirect") || "/";
sessionStorage.removeItem("redirect");
sessionStorage.removeItem("refer");
return router.push(redirect);
} else {
showToast("註冊失敗");
return;

@ -1,344 +0,0 @@
<template>
<div class="reg-container">
<van-nav-bar :title="title" />
<van-form @submit="onSubmit">
<van-cell-group inset>
<van-field
v-model="form.real_name"
label="姓名"
name="pattern"
required
placeholder="請輸入您的姓名"
:rules="[{ required: true, message: '姓名為必填' }]"
/>
<van-field
v-model="form.company"
label="公司名稱"
name=""
required
placeholder="請輸入您的公司名稱"
:rules="[{ required: true, message: '公司名稱必填' }]"
/>
<van-field
v-model="form.title"
label="職稱"
name=""
placeholder="請輸入您的職稱"
/>
<van-field
v-model="form.phone"
label="手機"
name=""
required
placeholder="Ex. 0900000001 不要有空格"
:rules="[
{ required: true, message: '手機號必填' },
{ pattern: /\d{10}/, message: '手機號格式錯誤' },
]"
/>
<van-field
v-model="form.tel"
label="市話"
name=""
placeholder="請輸入您的市話"
/>
<van-field
v-model="form.email"
label="Email"
name=""
required
placeholder="請輸入您的Email"
:rules="[
{ required: true, message: 'Email必填' },
{
pattern: /^([\w\.\-]){1,64}\@([\w\.\-]){1,64}/,
message: 'Email格式錯誤',
},
]"
/>
<van-field
v-model="form.address"
label="住址"
name=""
placeholder="請輸入您的地址"
/>
<van-field
v-model="form.url"
label="網址"
name=""
placeholder="請輸入您的網址"
:rules="[
{ validator: validatorUrl, message: '網址格式不正確,Ex. http://' },
]"
/>
<van-field
v-model="form.line"
label="Line"
name=""
placeholder="請輸入您的Line ID"
/>
<van-field
v-model="form.facebook"
label="Facebook"
name=""
placeholder="請輸入您的臉書連結"
/>
<van-field
v-model="form.ig"
label="IG"
name=""
placeholder="請輸入您的IG ID"
/>
<van-field
v-model="form.youtube"
label="YouTube"
name=""
placeholder="請輸入您的Youtube連結"
/>
<van-uploader :after-read="afterRead" :max-count="1" name="averter">
<div class="upload-main">
<img
class="upload-img"
:src="form.avatar"
alt=""
v-if="form.avatar"
/>
<img
class="upload-img"
src="@/assets/images/upload.jpg"
alt=""
v-else
/>
<p>上傳圖片,預設為Line頭像</p>
</div>
</van-uploader>
</van-cell-group>
<div style="margin: 16px">
<van-button round block type="primary" native-type="submit">
送出註冊
</van-button>
<br />
<van-button round block type="default" @click="leaveReg">
以後在說
</van-button>
</div>
</van-form>
<van-overlay :show="crop.show" @click="crop.show = false" />
<div class="cropper-section" v-if="crop.show">
<div class="crop-area">
<cropper
class="cropper"
ref="myCrop"
:src="crop.img"
:stencil-props="{
aspectRatio: 1 / 1,
}"
:auto-zoom="true"
/>
</div>
<div class="crop-btn">
<van-button type="primary" size="small" plain @click="onClose"
>取消</van-button
>
<van-button type="success" size="small" plain @click="onCrop"
>剪裁</van-button
>
</div>
</div>
</div>
</template>
<script setup>
import axios from "axios";
import { ref, inject } from "vue";
import store from "@/store";
import router from "@/router";
import { useRoute } from "vue-router";
import { showToast } from "vant";
import { showLoadingToast,showSuccessToast } from 'vant';
import { Cropper } from "vue-advanced-cropper";
import "vue-advanced-cropper/dist/style.css";
import { register, checkLineId } from "@/api";
const URL = window.URL || window.webkitURL;
const route = useRoute();
const form = ref({
verify: route.query.verify || null,
aid: route.query.aid || undefined,
});
const title = ref("註冊成為會員");
const myCrop = ref(null);
const crop = ref({
show: false,
img: null,
});
if (route.query.verify) {
title.value = "會員開通";
}
const validatorUrl = (val) => {
if (val.length > 0) {
return /(https?:\/\/|line:\/\/|tel:|mailto:)\S+/.test(val);
} else {
return true;
}
};
const leaveReg = () => {
window.location.replace("/error.html");
};
const onCrop = () => {
const { canvas } = myCrop.value.getResult();
if (canvas) {
const imgFile = new FormData();
canvas.toBlob(async (blob) => {
let ufile = new File([blob], "image.jpg");
imgFile.append("user_id", form.value.user_id);
imgFile.append("fileType", "IMAGE");
imgFile.append("file", ufile);
crop.value.show = false;
showLoadingToast({
duration: 0,
message: "圖片上傳中...",
forbidClick: true,
});
let res = await axios.post(
`${import.meta.env.VITE_APP_API_URL}/user/uploadAvatar`,
imgFile,
{}
);
if (res.data.code == 200) {
form.value.avatar = res.data.data;
showSuccessToast("上傳成功");
} else {
showToast.fail("上傳失敗");
}
}, "image/jpeg");
}
return;
};
const onClose = () => {
crop.value.show = false;
};
const afterRead = async (file, name) => {
crop.value.show = true;
const ofile = file.file;
crop.value.img = URL.createObjectURL(ofile);
return;
};
const onSubmit = async () => {
const liff = window.liff;
try {
if (!liff.isLoggedIn()) liff.login({ redirectUri: window.location.href });
} catch (err) {
console.log(`liff.state init error ${err}`);
showToast("登入失敗。請聯絡管理員");
router.push("/login");
}
const profile = await liff.getProfile();
let checkRes = await checkLineId(profile.userId);
if (checkRes.code !== 200) {
showToast("您已是我們的會員,請直接登入");
router.push("/login");
}
const id_token = liff.getIDToken();
showLoadingToast({
duration: 0,
message: "資料傳送中...",
forbidClick: true,
});
let regRes = await register({
line_id: profile.userId,
line_name: profile.displayName,
line_picture: profile.pictureUrl,
token: id_token,
...form.value,
});
if (regRes.code === 500) {
if (liff.isLoggedIn()) {
liff.logout();
}
showToast("line 登入已過期");
return;
} else if (regRes.code === 200) {
showToast("註冊成功");
sessionStorage.setItem("token", regRes.data.token);
sessionStorage.setItem("uid", regRes.data.uid);
return router.push("/");
} else {
showToast("註冊失敗");
return;
}
};
</script>
<style lang="less" scoped>
.container {
padding-bottom: 30px;
}
.title {
font-size: 20px;
text-align: center;
}
.upload-img {
width: 80px;
}
.cropper {
height: 300px;
// width: 300px;
background: #ddd;
}
.cropper-section {
margin: 0 auto;
position: fixed;
text-align: center;
top: 50px;
// left: 0;
height: 350px;
width: 100%;
max-width: 500px;
background: #ddd;
z-index: 8888;
.crop-area {
margin: 5 auto;
width: 100%;
height: 330px;
}
.crop-btn {
background-color: #666;
text-align: center;
}
}
</style>
Loading…
Cancel
Save