素手挽清风 4 years ago
parent
commit
5090890284

+ 21 - 0
.gitignore

@@ -0,0 +1,21 @@
+.DS_Store
+node_modules
+/dist
+
+# local env files
+.env.local
+.env.*.local
+
+# Log files
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+
+# Editor directories and files
+.idea
+.vscode
+*.suo
+*.ntvs*
+*.njsproj
+*.sln
+*.sw?

+ 5 - 0
babel.config.js

@@ -0,0 +1,5 @@
+module.exports = {
+  presets: [
+    '@vue/app'
+  ]
+}

+ 30 - 0
mobile/index.html

@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html lang="en">
+  <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">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title>详情</title>
+    <script>
+      !function(n){
+          var  e=n.document,
+              t=e.documentElement,
+              i=720,
+              d=i/100,
+              o="orientationchange"in n?"orientationchange":"resize",
+              a=function(){
+                  var n=t.clientWidth||375;
+                  n>750&&(n=750);
+                  t.style.fontSize=n/d+"px"
+              };
+              e.addEventListener&&(n.addEventListener(o,a,!1),e.addEventListener("DOMContentLoaded",a,!1))
+      }(window);
+    </script>
+  </head>
+  <body>
+   
+    <div ></div>
+   详情
+  </body>
+</html>

File diff suppressed because it is too large
+ 11609 - 0
package-lock.json


+ 51 - 0
package.json

@@ -0,0 +1,51 @@
+{
+  "name": "coupon_share",
+  "version": "0.1.0",
+  "private": true,
+  "scripts": {
+    "serve": "vue-cli-service serve",
+    "build": "vue-cli-service build",
+    "lint": "vue-cli-service lint"
+  },
+  "dependencies": {
+    "axios": "^0.19.0",
+    "core-js": "^2.6.5",
+    "vue": "^2.6.10",
+    "vue-axios": "^2.1.4",
+    "vue-cookie": "^1.1.4",
+    "vue-router": "^3.0.7",
+    "weixin-js-sdk": "^1.4.0-test"
+  },
+  "devDependencies": {
+    "@vue/cli-plugin-babel": "^3.9.0",
+    "@vue/cli-plugin-eslint": "^3.9.0",
+    "@vue/cli-service": "^3.9.0",
+    "babel-eslint": "^10.0.1",
+    "eslint": "^5.16.0",
+    "eslint-plugin-vue": "^5.0.0",
+    "vue-template-compiler": "^2.6.10"
+  },
+  "eslintConfig": {
+    "root": true,
+    "env": {
+      "node": true
+    },
+    "extends": [
+      "plugin:vue/essential",
+      "eslint:recommended"
+    ],
+    "rules": {},
+    "parserOptions": {
+      "parser": "babel-eslint"
+    }
+  },
+  "postcss": {
+    "plugins": {
+      "autoprefixer": {}
+    }
+  },
+  "browserslist": [
+    "> 1%",
+    "last 2 versions"
+  ]
+}

BIN
public/favicon.ico


+ 32 - 0
public/index.html

@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html lang="en">
+  <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">
+    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
+    <title>coupon_share</title>
+    <script>
+      !function(n){
+          var  e=n.document,
+              t=e.documentElement,
+              i=720,
+              d=i/100,
+              o="orientationchange"in n?"orientationchange":"resize",
+              a=function(){
+                  var n=t.clientWidth||375;
+                  n>750&&(n=750);
+                  t.style.fontSize=n/d+"px"
+              };
+              e.addEventListener&&(n.addEventListener(o,a,!1),e.addEventListener("DOMContentLoaded",a,!1))
+      }(window);
+    </script>
+  </head>
+  <body>
+    <noscript>
+      <strong>We're sorry but coupon_share doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
+    </noscript>
+    <div id="app"></div>
+    <!-- built files will be auto injected -->
+  </body>
+</html>

+ 56 - 0
src/App.vue

@@ -0,0 +1,56 @@
+<template>
+  <div id="app">
+    <router-view></router-view>
+
+  </div>
+</template>
+
+<script>
+import API from './api/index'
+import wx from 'weixin-js-sdk'
+import util from './util/index'
+
+export default {
+  name: 'app',
+  mounted(){
+   // window.location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx307150d9062ebdf4&redirect_uri=http%3A%2F%2Fwww.qingyingtech.com%2Fmobile&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect'
+
+    this.checkUserAuth();
+  },
+  methods:{
+    // 检查用户是否授权过
+    checkUserAuth(){
+      let openId = this.$cookie.get('openId');
+      if(!openId){
+        window.location.href = API.wechatRedirect;
+      }else{
+        this.getWechatConfig();
+      }
+    },
+    // 获取微信配置信息
+    getWechatConfig(){
+      this.$http.get(API.wechatConfig+'?url='+location.href.split('#')[0]).then(function(response){
+        let res = response.data;
+        if(res.code == 0){
+          let data = res.data;
+          wx.config({
+            debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。
+            appId: data.appId, // 必填,公众号的唯一标识
+            timestamp: data.timestamp, // 必填,生成签名的时间戳
+            nonceStr: data.nonceStr, // 必填,生成签名的随机串
+            signature: data.signature,// 必填,签名
+            jsApiList: data.jsApiList // 必填,需要使用的JS接口列表
+          })
+          wx.ready(()=>{
+            util.initShareInfo(wx);
+          })
+        }
+      })
+    }
+  }
+}
+</script>
+
+<style>
+
+</style>

+ 7 - 0
src/api/index.js

@@ -0,0 +1,7 @@
+//存放api请求地址
+export default {
+    wechatRedirect:'/wechat/redirect?url=http%3A%2F%2Fwww.qingyingtech.com%2Fmobile&scope=snsapi_userinfo',
+    wechatConfig:'/wechat/jssdk',
+    getUserInfo:'/wechat/getUserInfo',
+
+}

+ 89 - 0
src/assets/css/base.css

@@ -0,0 +1,89 @@
+/**
+ * Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
+ * http://cssreset.com
+ */
+html, body, iframe,
+h1, h2, h3, h4, h5, h6, p, blockquote, pre,
+a, abbr, address, big, cite, code,
+del, dfn, em, img, ins, q, s, samp,
+small, strike, strong, sub, sup,
+b, u, i, center,
+dl, dt, dd, ol, ul, li,
+fieldset, form, label, legend,
+table, caption, tbody, tfoot, thead, tr, th, td,
+article, aside,  details, embed,
+figure, figcaption, footer, header, hgroup,
+menu, nav, output, ruby, section, summary,
+time, mark, audio, video {
+    margin: 0;
+    padding: 0;
+    border: 0;
+    vertical-align: baseline;
+}
+/* HTML5 display-role reset for older browsers */
+article, aside, details, figcaption, figure,
+footer, header, hgroup, menu, nav, section {
+    display: block;
+}
+*, *::before, *::after {
+    box-sizing: border-box;
+}
+ ul {
+    list-style: none;
+}
+table {
+    border-collapse: collapse;
+    border-spacing: 0;
+}
+a{
+    text-decoration: none;
+    color:inherit;
+}
+input, textarea, button, a, select, div{
+    -webkit-tap-highlight-color: rgba(255,255,255,0);
+}
+
+html{
+    font-family: sans-serif;
+    -webkit-text-size-adjust:100%;/*-webkit-user-select:none;*/
+}
+a,img,label {
+    -webkit-tap-highlight-color:rgba(255,255,255,0);
+}
+button:focus, input:focus{
+    outline:none;
+}
+input,
+input[type="checkbox"],
+input[type="radio"],
+input[type="search"],
+textarea {
+    box-sizing: border-box;
+}
+input[type="text"],
+input[type="tel"],
+input[type="number"] {
+    -webkit-appearance: none;
+    -webkit-box-shadow: none;
+    box-shadow:none
+}
+input[type="search"]::-webkit-search-cancel-button,
+input[type="search"]::-webkit-search-decoration {
+    -webkit-appearance: none;
+}
+input::-webkit-input-placeholder {
+    line-height: .4rem;
+}
+button:focus{
+    outline:none;
+}
+.clearfix::after{
+    content: "\0020";
+    display: block;
+    height: 0;
+    clear: both;
+    visibility: hidden;
+}
+.clearfix {
+    *zoom: 1;
+}

+ 18 - 0
src/assets/css/common.css

@@ -0,0 +1,18 @@
+#app{
+    max-width: 750px;
+    margin: 0 auto;
+}
+.header{
+    width: 100%;
+    height:6.24rem;
+}
+.btn{
+    width:5.4rem;
+    height:1rem;
+    line-height: 1rem;
+    text-align: center;
+    background-color: #FFFFFF;
+    border: none;
+    color:#FF3418;
+    font-size: .34rem;
+}

BIN
src/assets/img/header.png


BIN
src/assets/img/share.png


BIN
src/assets/img/share_guide.png


BIN
src/assets/img/tip.png


BIN
src/assets/logo.png


+ 58 - 0
src/components/HelloWorld.vue

@@ -0,0 +1,58 @@
+<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-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>
+h3 {
+  margin: 40px 0 0;
+}
+ul {
+  list-style-type: none;
+  padding: 0;
+}
+li {
+  display: inline-block;
+  margin: 0 10px;
+}
+a {
+  color: #42b983;
+}
+</style>

+ 17 - 0
src/components/activity-message/index.vue

@@ -0,0 +1,17 @@
+<!-- 活动消息组件定义 -->
+<template>
+  <div>
+      activity-message  
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'activity-message',
+}
+</script>
+
+
+<style scoped>
+
+</style>

+ 24 - 0
src/env/index.js

@@ -0,0 +1,24 @@
+const envList = {
+    dev: {
+        baseUrl:''
+    },
+    test: {
+        baseUrl:''
+    },
+    prod: {
+        domain:'http://m.51purse.com',
+        baseUrl:''
+    }
+}
+//每次手工修改项目的环境变量
+let currentEnv = 'prod';
+
+//根据当前浏览器环境设置环境变量
+let params = {
+     'dev-m.51purse.com': 'dev',
+     'test-m.51purse.com': 'test',
+     'm.51purse.com': 'prod',
+}
+currentEnv = params[location.hostname ]
+
+export default envList[currentEnv]; 

+ 31 - 0
src/main.js

@@ -0,0 +1,31 @@
+//项目入口文件
+import Vue from 'vue'
+import App from './App.vue'
+import axios from 'axios'
+import VueAxios from 'vue-axios'
+import Router from './router/index'
+import VueCookie from 'vue-cookie'
+import './assets/css/common.css'
+import './assets/css/base.css'
+
+Vue.config.productionTip = false
+Vue.use(VueAxios,axios);
+Vue.use(VueCookie);
+axios.interceptors.request.use(function(){
+  //loding,请求地址替换,修改
+   
+});
+
+//请求响应的统一处理 {code:0,data'',message:''}
+axios.interceptors.response.use(function(response){
+  let res = response.data;
+  if(res.code !=0 ){
+    alert(res.message);
+  }
+},function(error){
+  return Promise.reject(error);
+})
+new Vue({
+  router: Router,
+  render: h => h(App),
+}).$mount('#app')

+ 17 - 0
src/pages/activity.vue

@@ -0,0 +1,17 @@
+<!-- 活动详情-->
+<template>
+  <div>
+      activity 
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'activity',
+}
+</script>
+
+
+<style scoped>
+
+</style>

+ 34 - 0
src/pages/index.vue

@@ -0,0 +1,34 @@
+<!-- 活动首页-->
+<template>
+  <div class="index">
+      <img src="./../assets/img/header.png" class="header" alt="">
+      <div class="btn-group">
+          <button class="btn">分享</button>
+          <button class="btn btn-primary">活动详情</button>
+      </div> 
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'index',
+}
+</script>
+
+
+<style scoped>
+   .index{
+      background-color: #FFC93A;
+      height:100vh;
+   }
+
+   .btn-group{
+       padding-top: .34rem;
+       text-align: center;
+   }
+   .btn-primary{
+       background-color: #FF3418;
+       color: #FFFFFF;
+   }
+
+</style>

+ 17 - 0
src/pages/pay.vue

@@ -0,0 +1,17 @@
+
+<template>
+  <div>
+     pay 
+  </div>
+</template>
+
+<script>
+export default {
+  name: 'pay',
+}
+</script>
+
+
+<style scoped>
+
+</style>

+ 37 - 0
src/router/index.js

@@ -0,0 +1,37 @@
+import Vue from 'vue'
+import Router from 'vue-router'
+import index from './../pages/index'
+import activity from './../pages/activity'
+import pay from './../pages/pay'
+Vue.use(Router);
+
+const routes = [
+    {
+        path:'/index',
+        name:'index',
+        component:index,
+        meta:{
+            title: '首页'
+        }
+    },{
+        path:'/activity',
+        name:'activity',
+        component:activity,
+        meta:{
+            title: '活动'
+        }
+    },{
+        path:'/pay',
+        name:'pay',
+        component:pay,
+        meta:{
+            title: '支付'
+        }
+    } 
+]
+
+const router = new Router({
+    routes
+})
+
+export default router;

+ 29 - 0
src/util/index.js

@@ -0,0 +1,29 @@
+//公共函数定义
+export default {
+    //获取浏览器地址栏参数值
+    getUrlParam(name){
+        let reg = new RegExp('(^|&)'+name+'=([^&]*)');
+        let r = window.location.search.substr(1).match(reg);
+        // location.search.substr(1).match(reg)
+        if(r!=null)return decodeURIComponent(r[2]);
+    },
+    initShareInfo(wx){
+        let shareInfo = {
+            title: '优惠券推荐', // 分享标题
+            desc: '会员优惠券推荐', // 分享描述
+            link: 'http://www.qingyingtech.com/mobile', // 分享链接,该链接域名或路径必须与当前页面对应的公众号JS安全域名一致
+            imgUrl: '', // 分享图标
+            success: function () {
+              // 设置成功
+            }
+        }
+        wx.onMenuShareTimeline(shareInfo);
+        wx.onMenuShareAppMessage(shareInfo);
+        wx.onMenuShareQQ(shareInfo);
+        wx.onMenuShareQZone(shareInfo);
+
+        //wx.updateAppMessageShareData(shareInfo);
+        //wx.updateTimelineShareData(shareInfo);
+    }
+
+}

+ 27 - 0
vue.config.js

@@ -0,0 +1,27 @@
+module.exports = {
+  devServer: {
+    // 设置主机地址
+    host: 'm.51purse.com',
+    // 设置默认端口
+    port: 80,
+    // 设置代理
+    proxy: {
+      /**
+       * changeOrigin:true
+       * /api/test
+       * http://localhost:5000/test
+       * changeOrigin:false
+       * /api/test
+       * http://localhost:5000/api/test
+       */
+      '/api':{
+        // 设置目标API地址
+        target: 'http://localhost:3000',
+        // 如果要代理 websockets
+        ws: false,
+        // 将主机标头的原点改为目标URL
+        changeOrigin: false
+      }
+    }
+  }
+}