12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- import { Toast, Notify } from 'vant'
- import Clipboard from "clipboard";
- import { getWxToken, setWxToken, openError } from "@/utils/auth";
- import { getIsIdentity, supremeAuthority, getIsWx, getTypes, getTypesName, getUserData, getEmployeeMap, getCache, setCache, removeCache, returnDeptName, getEmployeeMapItem, returnFh } from '@/utils/auth'
- //判断环境/登录状态
- export function isWxEnv(type,data) {
- return new Promise((resolve, reject) => {
- if (getIsWx()) {
- if (getWxToken()&&localStorage.getItem('wx_user_info')) {
- // Toast("微信环境已授权");
- resolve()
- } else {
- // Toast.fail("微信环境未授权");
- reject(1)
- //测试用,正式隐藏
- doWeixinLogin(type,data);
- }
- } else {
- // Toast.fail("当前不在微信环境中,请在微信中打开浏览");
- // reject(2)
- if (getWxToken()&&localStorage.getItem('wx_user_info')) {
- resolve()
- } else {
- Toast.fail("当前不在微信环境中,请在微信中打开浏览");
- reject(2)
- }
- }
- })
- }
- //请求微信授权
- export function doWeixinLogin(type,data) {
- // let defaultUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=1'
- // let dealerUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=2&pid='
- // let timinalUrl = 'https://3g954g5149.picp.vip/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=3&expendCode='
- let defaultUrl = `${process.env.BASE_API}/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=1`
- let dealerUrl = `${process.env.BASE_API}/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=2&pid=`
- let timinalUrl = `${process.env.BASE_API}/wx/mp/auth/wx65f4dde5ec7c31e7?marketing=3&expendCode=`
- if (getCache("isAndroid")) {
- if (type == 'pid'&&data) {
- window.open(`${dealerUrl}${data}`)
- } else if(type == 'code'&&data){
- window.open(`${timinalUrl}${data}`)
- }else{
- window.open(`${defaultUrl}`)
- }
- } else {
- if (type == 'pid'&&data) {
- window.location.href = `${dealerUrl}${data}`;
- } else if(type == 'code'&&data){
- window.location.href = `${timinalUrl}${data}`;
- }else{
- window.location.href = `${defaultUrl}`;
- }
- }
- }
- //复制(event必须为点击元素)
- export function copyLink(event) {
- let that = this;
- //这里是复制目标的类名
- let clipboard = new Clipboard(event, {
- text: function (trigger) {
- return trigger.getAttribute("aria-label");
- }
- });
- clipboard.on("success", function (e) {
- e.clearSelection(); //清除选中的文字的选择状态
- that.$toast.success("复制成功~");
- });
- clipboard.on("error", function (e) {
- console.error(e);
- });
- }
|