脚手架搭建

This commit is contained in:
Andy Leong
2022-07-26 18:26:27 +08:00
commit 30727f4f65
38 changed files with 1099 additions and 0 deletions

40
src/api/httpServe.js Normal file
View File

@@ -0,0 +1,40 @@
import axios from 'axios'
import QS from 'qs';
// 创建axios
const service = axios.create({
// baseURL: 'https://hd.xglpa.com/pars-training', //生产环境
// baseURL: 'http://test.szxgl.cn/pars-training', //测试环境
// withCredentials: true,
baseURL: process.env.VUE_APP_API,
// responseType: 'json',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
});
// 添加请求拦截器
service.interceptors.request.use(function (config) {
// 在发送请求之前做些什么
console.log("开始请求");
config
return config;
}, function (error) {
// 对请求错误做些什么
return Promise.reject(error);
});
// 添加响应拦截器
service.interceptors.response.use(function (response) {
// 对响应数据做点什么
// console.log(response.data);
return response;
}, function (error) {
// 对响应错误做点什么
return Promise.reject(error);
});
export default service;

BIN
src/assets/img/pdf.pdf Normal file

Binary file not shown.

BIN
src/assets/img/share.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

BIN
src/assets/logo.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

BIN
src/assets/media/bgm.mp3 Normal file

Binary file not shown.

BIN
src/assets/media/video.mp4 Normal file

Binary file not shown.

View File

@@ -0,0 +1,42 @@
@charset "utf-8";
$red:red;
$green:green;
// DIV宽高
@mixin box ($width,$height){
width: $width;
height: $height;
}
// DIV宽高定位
@mixin pos ($width,$height,$left,$top){
width: $width;
height: $height;
position: absolute;
left: $left;
top:$top;
}
// DIV背景
@mixin bg_pos ($src){
background: url($src) no-repeat;
background-size: 100% 100%;
}
// flex居中定位
@mixin flex (){
display: flex;
justify-content: center;
align-items: center;
}
// 全屏样式
@mixin fixed (){
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
}

63
src/components/Index.vue Normal file
View File

@@ -0,0 +1,63 @@
<template>
<div class="welcomePage">
<div @click="btn">招商证券88司庆活动</div>
</div>
</template>
<script setup>
import { onBeforeMount, onMounted, defineEmits, defineProps, reactive, ref, toRefs } from 'vue'
import gsap from "gsap";
import axios from 'axios'
import { Toast } from 'vant';
// 初始化
const emit = defineEmits(["welcomePage"]); // 声明触发事件,对应父组件上面的方法
const props = defineProps({ sendMessage: Object }); // 获取props
// 页面挂载前
onBeforeMount(() => { })
// 页面挂载后
onMounted(() => { })
const btn = () => {
Toast('项目开发中');
}
</script>
<style lang="scss" scoped>
.welcomePage {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
color: #000;
.video_container {
width: 80%;
.video {
width: 100%;
}
}
}
</style>

4
src/data/imgList.js Normal file
View File

@@ -0,0 +1,4 @@
export default [
];

50
src/page/Home/Home.vue Normal file
View File

@@ -0,0 +1,50 @@
<template>
<div class="homePage">
<Index />
</div>
</template>
<script setup>
import { onMounted, onBeforeMount, watch, ref, reactive } from "vue";
import { wxShare } from "@/utils/wxshare.js";
import h5plugin from "@/utils/plugin.js";
import gsap from "gsap";
import Index from "@/components/Index"
// 变量定义
// 页面未挂载
onBeforeMount(() => { });
// 页面挂载
onMounted(() => {
// 微信分享
const optionShare = {
title: '2022中国中产女性财富管理及幸福指数报告', // 分享标题
desc: ' ', // 分享描述
link: process.env.VUE_APP_BASE_URL + 'index.html', // 分享链接
imgUrl: process.env.VUE_APP_CDN + 'share.jpg', // 分享图标
}
wxShare(optionShare)
});
</script>
<style lang="scss" scoped>
div {
color: #fff;
}
.homePage {
font-size: 24px;
width: 750px;
max-width: 750px;
height: 100%;
overflow: hidden;
position: absolute;
top: 0;
left: 0;
background: rgb(255, 255, 255);
}
</style>

24
src/page/Home/main.js Normal file
View File

@@ -0,0 +1,24 @@
import "babel-polyfill"
import { createApp } from 'vue'
import App from './Home.vue'
import Vue from 'vue'
import store from '@/store'
import "amfe-flexible"
import VConsole from 'vconsole'
const vConsole = new VConsole();
// 注册全局方法
const app = createApp(App);
// app.use(router)
app.use(store)
app.mount('#app')

34
src/page/Share/Share.vue Normal file
View File

@@ -0,0 +1,34 @@
<template>
<div class="sharePage">
<div class="share_container">分享页</div>
</div>
</template>
<script setup>
import { onMounted, ref, reactive } from "vue";
import gsap from "gsap";
import { Toast } from "vant";
import h5plugin from "@/utils/plugin.js";
// 挂载后
onMounted(() => { });
</script>
<style lang="scss" scoped>
.sharePage {
width: 100%;
height: 100%;
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
display: flex;
align-items: center;
justify-content: center;
.share_container {
// text-align: center;
}
}
</style>

30
src/page/Share/main.js Normal file
View File

@@ -0,0 +1,30 @@
import { createApp } from 'vue'
import App from './Share.vue'
import Vue from 'vue'
import store from '@/store'
import "amfe-flexible"
import h5plugin from "../../utils/plugin"
import VConsole from 'vconsole'
const vConsole = new VConsole();
// if (process.env.NODE_ENV != 'production') {
// // 非正式环境都打开debug模式
// const vConsole = new VConsole();
// }
// 注册全局方法
const app = createApp(App);
// app.config.globalProperties.$h5plugin = h5plugin;
// app.use(router)
app.use(store)
app.mount('#share')

View File

@@ -0,0 +1,14 @@
// // 完整引入
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
// 按需引入
// import { ElButton } from "element3";
// import 'element3/lib/theme-chalk/button.css'
export default function (app) {
// 完整插件
app.use(ElementPlus)
// app.use(ElButton)
}

0
src/plugins/vantUI.js Normal file
View File

10
src/router/index.js Normal file
View File

@@ -0,0 +1,10 @@
import { createRouter, createWebHashHistory } from 'vue-router';
const router = createRouter({
history: createWebHashHistory(),
routes: [
{ path: '/', component: () => import('@/views/Home.vue') }
]
});
export default router

38
src/store/index.js Normal file
View File

@@ -0,0 +1,38 @@
import { createStore } from 'vuex';
import h5plugin from "@/utils/plugin.js"
export default createStore({
state: {
userProgress: {
pass1IsComplete: 0, //第一题完成情况
pass2IsComplete: 0, //第二题完成情况
pass3IsComplete: 0, //第三题完成情况
pass1IsDraw: 0, //第一题抽奖情况
pass2IsDraw: 0, //第二题抽奖情况
pass3IsDraw: 0, //第三题抽奖情况
pass1Prize: '', //第一题抽奖结果
pass2Prize: '', //第二题抽奖结果
pass3Prize: '', //第三题抽奖结果
}, //用户进度
openId: '', //用户openid
openToken: '', //用户openToken
pass1IsComplete: '', //第一题完成情况
pass1IsDraw: '', //第一题抽奖情况
pass1Prize: '', //第一题抽奖结果
pass2IsComplete: '', //第二题完成情况
pass2IsDraw: '', //第二题抽奖情况
pass2Prize: '', //第二题抽奖结果
pass3IsComplete: '', //第三题完成情况
pass3IsDraw: '', //第三题抽奖情况
pass3Prize: '', //第三题抽奖结果
},
// 改变方法
mutations: {
updateOpenid(state) {
// state.openid = changVal
// console.log(state.openid);
}
},
actions: {},
modules: {},
})

22
src/utils/imgPreloader.js Normal file
View File

@@ -0,0 +1,22 @@
const imgPreloader = url => {
return new Promise((resolve, reject) => {
let image = new Image();
image.src = url;
image.onload = () => {
resolve();
// console.log(image.src);
};
image.onerror = () => {
reject();
};
});
};
export const imgsPreloader = imgs => {
let promiseArr = [];
imgs.forEach(element => {
promiseArr.push(imgPreloader(element));
// console.log(element);
});
console.log("图片资源数量:", promiseArr.length);
return Promise.all(promiseArr);
};

39
src/utils/io.js Normal file
View File

@@ -0,0 +1,39 @@
const getSocket = (url, params, callback) => {
let socket;
if (typeof (WebSocket) === 'undefined') {
console.log('您的浏览器不支持WebSocket');
} else {
console.log('您的浏览器支持WebSocket');
// 初始化 WebSocket 对象,指定要连接的服务器地址与端口建立连接
socket = new WebSocket(url);
// 打开事件
socket.onopen = function () {
console.log('Socket 已打开');
socket.send(params);
};
// 获得消息事件
socket.onmessage = function (msg) {
// 发现消息进入, 开始处理前端触发逻辑
callback(msg, socket);
};
// 关闭事件
socket.onclose = function () {
console.log('Socket 已关闭');
};
// 发生了错误事件
socket.onerror = function () {
console.log('Socket 发生了错误,请刷新页面');
// 此时可以尝试刷新页面
};
}
}
export {
getSocket
}

265
src/utils/plugin.js Normal file
View File

@@ -0,0 +1,265 @@
import store from '../store'
const h5plugin = {
//是否在微信环境
isWX() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/MicroMessenger/i) == 'micromessenger') {
console.log("微信环境");
return true;
} else {
console.log("非微信环境");
return false;
}
},
// 判断微博环境
isWeibo() {
var ua = window.navigator.userAgent.toLowerCase();
if (ua.match(/WeiBo/i) == "weibo") {
console.log("微博环境");
return true;
} else {
console.log("非微博环境");
return false;
}
},
// 判断Safari环境
isSafari() {
var ua = window.navigator.userAgent.toLowerCase();
if ((/Safari/.test(navigator.userAgent) && !/Chrome/.test(navigator.userAgent))) {
console.log("Safari环境");
return true;
} else {
console.log("非Safari环境");
return false;
}
},
//是否为安卓
isAndriod() {
var naviga = navigator.userAgent;
if (naviga.indexOf('Android') > -1 || naviga.indexOf('Adr') > -1) {
console.log("Andriod环境");
return true;
} else {
console.log("非Andriod环境");
return false;
}
},
//路径获取关键字
getQueryString(name) {
//截取页面传递字符串
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]);
return null;
},
// 判断全面屏和非全面屏
judgeBigScreen() { //,这里根据返回值 true 或false ,返回true的话 则为全面屏
let result = false;
const rate = window.screen.height / window.screen.width;
let limit = window.screen.height == window.screen.availHeight ? 1.8 : 1.65; // 临界判断值
// window.screen.height为屏幕高度
// window.screen.availHeight 为浏览器 可用高度
if (rate > limit) {
// console.log("全面屏");
result = true;
return result;
}
// console.log("非面屏");
return result;
},
// 获取url html名称
getUrlHtml() {
//获取url地址
var ts_href = window.location.href;
var ts_mainText = "";
//获取地址最后一个“/”的下标
var ts_indexof = ts_href.lastIndexOf("/");
//获取地址“/”之后的的内容
var ts_indexText = ts_href.substring(ts_indexof + 1);
//获取地址“.html”的下标
var ts_htmlBeforeText = ts_indexText.indexOf(".html");
//获取 “/”到".html"之间的内容
ts_mainText = ts_indexText.substring(0, ts_htmlBeforeText);
console.log("当前入口:", ts_mainText);
return ts_mainText;
},
// 获取cookie中的值
getSetCookie(name, value, options) {
if (typeof value != 'undefined') {
options = options || {};
if (value === null) {
value = '';
options = this._extend({}, options, true);
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + options.expires * 24 * 60 * 60 * 1000);
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString();
}
var path = options.path ? '; path=' + options.path : '';
var domain = options.domain ? '; domain=' + options.domain : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
// var cookie = $.trim(cookies[i]);
var cookie = cookies[i].trim();
if (cookie.substring(0, name.length + 1) == name + '=') {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
},
// 安卓机型自动播放音乐
BGMAutoPlayMgr(url) {
this.audioContext = new (window.AudioContext || window.webkitAudioContext || window.mozAudioContext)();
this.sourceNode = null;
this.buffer = null;
this.isPlayingBGM = false;
this.toggleBGM = function () {
if (typeof this.sourceNode == 'object') {
if (this.isPlayingBGM) {
this.sourceNode.stop();
this.isPlayingBGM = false;
} else this._playSourceNode();
}
}
this._playSourceNode = function () {
const audioContext = this.audioContext;
audioContext.resume();
const _sourceNode = audioContext.createBufferSource();
_sourceNode.buffer = this.buffer;
_sourceNode.loop = true;
_sourceNode.connect(audioContext.destination);
_sourceNode.start(0);
this.sourceNode = _sourceNode;
this.isPlayingBGM = true;
}
let loadAndAutoPlay = (audioUrl) => {
const audioContext = this.audioContext;
const xhr = new XMLHttpRequest();
xhr.open('GET', audioUrl, true);
xhr.responseType = 'arraybuffer';
xhr.onreadystatechange = () => {
if (xhr.status < 400 && xhr.status >= 200 && xhr.readyState === 4) {
audioContext.decodeAudioData(xhr.response, buffer => {
this.buffer = buffer;
WeixinJSBridge.invoke("getNetworkType", {}, () => this._playSourceNode());
});
}
}
xhr.send();
}
loadAndAutoPlay(url);
loadAndAutoPlay = null;
},
// 金管家获取openid及openToken
getJGJId() {
return new Promise(resolve => {
// 获取openid
PALifeOpen.getOpenId(
{
appId: '1aeedce2a31340e591a5d64080d6105b' // 商户编号,区分⽣产和测试环境商户编号
},
rsp => {
// 调⽤接⼝成功后的回调函数
console.log('success', rsp.data);
store.state.openId = rsp.data.openId
store.state.openToken = rsp.data.openToken
if (rsp.ret == 0) {
store.state.openId = rsp.data.openId
store.state.openToken = rsp.data.openToken
const data = {
id: store.state.openId,
token: store.state.openToken
};
resolve(data);
// console.log(`获取到金管家openid时间${Math.abs(s_t - new Date().getTime())}`);
}
if (rsp.ret == -1) {
console.log(JSON.stringify(rsp));
}
},
e => {
// 调⽤接⼝异常的回调函数
console.log('failed', e);
}
)
})
},
// 金管家内部埋点
addPoint(page, spage, des = {}) {
const activityId = process.env.VUE_APP_ACTIVITYID;
PALifeOpen.invoke(
"device",
"addRecord",
{
eventId: `499${page}-${activityId}`, //必填,根据需求
labelId: `499${page}${spage}-${activityId}`, //必填,根据需求
// 扩展参数
parameters: {
ext: JSON.stringify(des)
}
},
// 调用接口成功后的回调函数 // alert(JSON.stringify(rsp))
rsp => console.debug("success ", rsp),
// 调用接口异常的回调函数
e => console.debug("failed ", e),
{
timeout: 86400000
}
);
return this;
},
// 百度统计埋点
addPointByBd(des) {
_hmt && _hmt.push(["_trackEvent", `${des}`, `${des} success`]);
return this;
},
}
export default h5plugin;

4
src/utils/websocket.min.js vendored Normal file
View File

@@ -0,0 +1,4 @@
/*reconnecting-websocket.min.js*/
!function(a,b){"function"==typeof define&&define.amd?define([],b):"undefined"!=typeof module&&module.exports?module.exports=b():a.ReconnectingWebSocket=b()}(this,function(){function a(b,c,d){function l(a,b){var c=document.createEvent("CustomEvent");return c.initCustomEvent(a,!1,!1,b),c}var e={debug:!1,automaticOpen:!0,reconnectInterval:1e3,maxReconnectInterval:3e4,reconnectDecay:1.5,timeoutInterval:2e3};d||(d={});for(var f in e)this[f]="undefined"!=typeof d[f]?d[f]:e[f];this.url=b,this.reconnectAttempts=0,this.readyState=WebSocket.CONNECTING,this.protocol=null;var h,g=this,i=!1,j=!1,k=document.createElement("div");k.addEventListener("open",function(a){g.onopen(a)}),k.addEventListener("close",function(a){g.onclose(a)}),k.addEventListener("connecting",function(a){g.onconnecting(a)}),k.addEventListener("message",function(a){g.onmessage(a)}),k.addEventListener("error",function(a){g.onerror(a)}),this.addEventListener=k.addEventListener.bind(k),this.removeEventListener=k.removeEventListener.bind(k),this.dispatchEvent=k.dispatchEvent.bind(k),this.open=function(b){h=new WebSocket(g.url,c||[]),b||k.dispatchEvent(l("connecting")),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","attempt-connect",g.url);var d=h,e=setTimeout(function(){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","connection-timeout",g.url),j=!0,d.close(),j=!1},g.timeoutInterval);h.onopen=function(){clearTimeout(e),(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onopen",g.url),g.protocol=h.protocol,g.readyState=WebSocket.OPEN,g.reconnectAttempts=0;var d=l("open");d.isReconnect=b,b=!1,k.dispatchEvent(d)},h.onclose=function(c){if(clearTimeout(e),h=null,i)g.readyState=WebSocket.CLOSED,k.dispatchEvent(l("close"));else{g.readyState=WebSocket.CONNECTING;var d=l("connecting");d.code=c.code,d.reason=c.reason,d.wasClean=c.wasClean,k.dispatchEvent(d),b||j||((g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onclose",g.url),k.dispatchEvent(l("close")));var e=g.reconnectInterval*Math.pow(g.reconnectDecay,g.reconnectAttempts);setTimeout(function(){g.reconnectAttempts++,g.open(!0)},e>g.maxReconnectInterval?g.maxReconnectInterval:e)}},h.onmessage=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onmessage",g.url,b.data);var c=l("message");c.data=b.data,k.dispatchEvent(c)},h.onerror=function(b){(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","onerror",g.url,b),k.dispatchEvent(l("error"))}},1==this.automaticOpen&&this.open(!1),this.send=function(b){if(h)return(g.debug||a.debugAll)&&console.debug("ReconnectingWebSocket","send",g.url,b),h.send(b);throw"INVALID_STATE_ERR : Pausing to reconnect websocket"},this.close=function(a,b){"undefined"==typeof a&&(a=1e3),i=!0,h&&h.close(a,b)},this.refresh=function(){h&&h.close()}}return a.prototype.onopen=function(){},a.prototype.onclose=function(){},a.prototype.onconnecting=function(){},a.prototype.onmessage=function(){},a.prototype.onerror=function(){},a.debugAll=!1,a.CONNECTING=WebSocket.CONNECTING,a.OPEN=WebSocket.OPEN,a.CLOSING=WebSocket.CLOSING,a.CLOSED=WebSocket.CLOSED,a});

61
src/utils/wxshare.js Normal file
View File

@@ -0,0 +1,61 @@
import wx from 'weixin-js-sdk';
import axios from "axios";
export function wxShare(option) {
let url = location.href.split('#')[0];
// qiween: https://www.qiween.com/wxapi/api/jsconfig
// 信蜂: https://wx.xfhd.net/wxapi/api/jsconfig?appid=wx41d80a1bb01f658d
axios.get('https://wx.xfhd.net/wxapi/api/jsconfig?appid=wx41d80a1bb01f658d', {
params: { url }
})
.then((res) => {
let data = res.data;
wx.config({
debug: false, // 开启调试模式
appId: data.appId, // 必填,公众号的唯一标识
timestamp: data.timestamp, // 必填,生成签名的时间戳
nonceStr: data.nonceStr, // 必填,生成签名的随机串
signature: data.signature, // 必填签名见附录1
jsApiList: [
'checkJsApi',
'updateTimelineShareData',
'updateAppMessageShareData',
] // 必填需要使用的JS接口列表所有JS接口列表见附录2
})
wx.ready(function () {
wx.updateTimelineShareData({
title: option.title, // 分享标题
link: option.link, // 分享链接
imgUrl: option.imgUrl, // 分享图标
desc: option.desc, // 分享描述
success() {// 用户成功分享后执行的回调函数
console.log("成功!");
_hmt.push(['_trackEvent', '微信分享', '分享好友成功',])
},
cancel() {// 用户取消分享后执行的回调函数
console.log("取消!");
}
});
wx.updateAppMessageShareData({
title: option.title, // 分享标题
desc: option.desc, // 分享描述
link: option.link, // 分享链接
imgUrl: option.imgUrl, // 分享图标
success() {// 用户成功分享后执行的回调函数
console.log("成功!");
_hmt.push(['_trackEvent', '微信分享', '分享朋友圈成功',])
},
cancel() {// 用户取消分享后执行的回调函数
console.log("取消!");
}
})
})
})
.catch(() => {
});
}