提交 b6f73c9d authored 作者: liudezheng's avatar liudezheng

双11代码提交

上级
.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# activity-h5
## Project setup
```
npm install
```
### Compiles and hot-reloads for development
```
npm run serve
```
### Compiles and minifies for production
```
npm run build
```
### Lints and fixes files
```
npm run lint
```
### Customize configuration
See [Configuration Reference](https://cli.vuejs.org/config/).
module.exports = {
presets: ["@vue/cli-plugin-babel/preset"],
};
差异被折叠。
{
"name": "activity-h5",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "vue-cli-service serve",
"build": "vue-cli-service build",
"lint": "vue-cli-service lint"
},
"dependencies": {
"amfe-flexible": "^2.2.1",
"axios": "^1.5.1",
"core-js": "^3.6.5",
"vant": "^2.13.2",
"vue": "^2.6.11",
"vue-router": "^3.2.0",
"vuex": "^3.4.0",
"weixin-js-sdk": "^1.6.2"
},
"devDependencies": {
"@vue/cli-plugin-babel": "~4.5.19",
"@vue/cli-plugin-eslint": "~4.5.19",
"@vue/cli-plugin-router": "~4.5.19",
"@vue/cli-plugin-vuex": "~4.5.19",
"@vue/cli-service": "~4.5.19",
"@vue/eslint-config-prettier": "^6.0.0",
"babel-eslint": "^10.1.0",
"eslint": "^6.7.2",
"eslint-plugin-prettier": "^3.3.1",
"eslint-plugin-vue": "^6.2.2",
"postcss-pxtorem": "^5.1.1",
"prettier": "^2.2.1",
"sass": "^1.26.5",
"sass-loader": "^8.0.2",
"vue-template-compiler": "^2.6.11"
},
"eslintConfig": {
"root": true,
"env": {
"node": true
},
"extends": [
"plugin:vue/essential",
"eslint:recommended",
"@vue/prettier"
],
"parserOptions": {
"parser": "babel-eslint"
},
"rules": {}
},
"browserslist": [
"> 1%",
"last 2 versions",
"not dead"
]
}
module.exports = {
plugins: {
// postcss-pxtorem 插件的版本需要 >= 5.0.0
// 适用版本 5.1.1
// yarn add -D postcss-pxtorem@5.1.1
// npm install postcss-pxtorem@5.1.1 -D
'postcss-pxtorem': {
rootValue({ file }) { // 如果设计稿宽度是 750px + Vant
// 判断是否是vant的文件 如果是就使用 37.5为根节点字体大小
// 否则使用75 因为vant使用的设计标准为375 但是市场现在的主流设置尺寸是750
return file.indexOf('vant') !== -1 ? 37.5 : 75;
},
// rootValue: 75, // 2.如果设计稿宽度是 750px + 不适用Vant
// rootValue: 37.5, // 3.如果设计稿宽度是 375px + 无论是否使用Vant
// 配置哪些文件中的尺寸需要转化为rem *表示所有的都要转化
propList: ['*'],
},
},
};
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta
name="viewport"
content="width=device-width,initial-scale=1.0 maximum-scale=1.0, user-scalable=no"
/>
<!-- <link rel="icon" href="<%= BASE_URL %>favicon.ico" /> -->
<title>活动即将上线,敬请期待</title>
<script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script>
<script>
// VConsole 默认会挂载到 `window.VConsole` 上
var vConsole = new window.VConsole();
// 接下来即可照常使用 `console` 等方法
// 结束调试后,可移除掉
vConsole.destroy();
</script>
</head>
<body>
<noscript>
<strong
>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work
properly without JavaScript enabled. Please enable it to
continue.</strong
>
</noscript>
<div id="app"></div>
<script>
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?28ecec9565974a32f1154f40291af6e8";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
</script>
<!-- built files will be auto injected -->
</body>
</html>
<template>
<div id="app">
<router-view></router-view>
</div>
</template>
<style lang="scss">
html,
body {
margin: 0;
padding: 0;
}
</style>
<template>
<div class="hello">
<h1>{{ msg }}</h1>
<p>
For a guide and recipes on how to configure / customize this project,<br />
check out the
<a href="https://cli.vuejs.org" target="_blank" rel="noopener"
>vue-cli documentation</a
>.
</p>
<h3>Installed CLI Plugins</h3>
<ul>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
target="_blank"
rel="noopener"
>babel</a
>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router"
target="_blank"
rel="noopener"
>router</a
>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex"
target="_blank"
rel="noopener"
>vuex</a
>
</li>
<li>
<a
href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint"
target="_blank"
rel="noopener"
>eslint</a
>
</li>
</ul>
<h3>Essential Links</h3>
<ul>
<li>
<a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a>
</li>
<li>
<a href="https://forum.vuejs.org" target="_blank" rel="noopener"
>Forum</a
>
</li>
<li>
<a href="https://chat.vuejs.org" target="_blank" rel="noopener"
>Community Chat</a
>
</li>
<li>
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener"
>Twitter</a
>
</li>
<li>
<a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a>
</li>
</ul>
<h3>Ecosystem</h3>
<ul>
<li>
<a href="https://router.vuejs.org" target="_blank" rel="noopener"
>vue-router</a
>
</li>
<li>
<a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a>
</li>
<li>
<a
href="https://github.com/vuejs/vue-devtools#vue-devtools"
target="_blank"
rel="noopener"
>vue-devtools</a
>
</li>
<li>
<a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener"
>vue-loader</a
>
</li>
<li>
<a
href="https://github.com/vuejs/awesome-vue"
target="_blank"
rel="noopener"
>awesome-vue</a
>
</li>
</ul>
</div>
</template>
<script>
export default {
name: "HelloWorld",
props: {
msg: String,
},
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped lang="scss">
h3 {
margin: 40px 0 0;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
</style>
import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "amfe-flexible";
Vue.config.productionTip = false;
Vue.config.ignoredElements = ["wx-open-launch-app", "wx-open-launch-weapp"];
import Vant from "vant";
import "vant/lib/index.css";
Vue.use(Vant);
router.beforeEach((to, from, next) => {
/* 路由发生变化修改页面title */
if (to.meta.title) {
document.title = to.meta.title;
}
next();
});
new Vue({
router,
store,
render: (h) => h(App),
}).$mount("#app");
import Vue from "vue";
import VueRouter from "vue-router";
import Home from "../views/Home.vue";
Vue.use(VueRouter);
const routes = [
{
path: "/",
name: "Home",
component: Home,
meta: {
title: "活动即将上线,敬请期待",
},
},
{
path: "/about",
name: "About",
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () =>
import(/* webpackChunkName: "about" */ "../views/About.vue"),
meta: {
title: "活动即将上线,敬请期待",
},
},
];
const router = new VueRouter({
mode: "hash",
base: process.env.NODE_ENV === "production" ? "/ft/website11/" : "/",
routes,
});
export default router;
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
state: {},
mutations: {},
actions: {},
modules: {},
});
<template>
<div class="about">
<wx-open-launch-weapp
id="launch-btn"
appid="wx6b79cb62d5aa1bdd"
username="gh_b537541d2a7"
path="/pages/productdetail/productdetail?id=792"
@launch="sucFun"
@error="errFun"
style="position: absolute; top: 0; left: 0; width: 100%; height: 100%"
>
<script type="text/wxtag-template">
<button>跳转</button>
</script>
</wx-open-launch-weapp>
</div>
</template>
<script>
// @ is an alias to /src
import axios from "axios";
import wx from "weixin-js-sdk";
export default {
name: "Home",
components: {},
async mounted() {
console.log(wx);
const urlLink = window.location.href;
let res = await axios({
method: "get",
url: "https://faces.diaosaas.com/ft/api/client/wx/getShareParameter",
params: {
url: urlLink,
},
});
console.log(res);
const { appId, signature, timestamp, nonceStr, url } = res.data.data;
// 分享数据写死
let msg = {
title: "方太双节惠购,你的厨房我来换",
desc: "晒厨房享免费换新!方太换新体验官全城火热招募",
link: "https://faces.diaosaas.com/ft/website11/",
imgUrl: "https://faces.diaosaas.com/ft/website/suolv.png?t=2023",
};
wx.config({
debug: false,
appId,
signature,
nonceStr,
timestamp,
jsApiList: [
"wx-open-subscribe",
"wx-open-launch-app",
"chooseImage",
"previewImage",
"updateAppMessageShareData",
"updateTimelineShareData",
"onMenuShareAppMessage",
"onMenuShareTimeline",
],
openTagList: ["wx-open-launch-weapp"], //打开的标签名
});
wx.ready(function (res) {
console.log(res, "ready");
wx.checkJsApi({
jsApiList: [
"updateAppMessageShareData",
"updateTimelineShareData",
"onMenuShareAppMessage",
"onMenuShareTimeline",
], // 需要检测的JS接口列表,所有JS接口列表见附录2,
success: (res) => {
console.log(res, "成功");
},
fail: (error) => {
console.log(error, "scanQRCode失败");
},
});
wx.updateAppMessageShareData({
title: msg.title, // 分享标题
desc: msg.desc, // 分享描述
link: msg.link, // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
imgUrl: msg.imgUrl, // 分享图标
});
wx.updateTimelineShareData({
title: msg.title, // 分享标题
link: msg.desc,
imgUrl: msg.link, // 分享图标
});
});
wx.error(function (err) {
console.log(err, "error");
});
},
methods: {
sucFun(msg) {
console.log(msg);
},
errFun(msg) {
console.log(msg);
},
},
};
</script>
<style lang="scss" scoped>
.about {
width: 100vh;
height: 100vw;
}
</style>
差异被折叠。
module.exports = {
lintOnSave: false,
publicPath: process.env.NODE_ENV === "production" ? "/ft/website11/" : "/",
};
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论