xiongzhu 5 years ago
parent
commit
9adb4d381c

+ 4 - 0
build.sh

@@ -2,9 +2,13 @@ git checkout master
 git pull
 (cd src/main/vue && yarn install)
 (cd src/main/vue && yarn build)
+(cd src/main/dangjian && yarn install)
+(cd src/main/dangjian && yarn build)
 mvn clean package
 systemctl stop dangjian
 cp -f target/dangjian-0.0.1-SNAPSHOT.jar /var/www/dangjian/dangjian-0.0.1-SNAPSHOT.jar
 rm -rf /var/www/dangjian/admin
 cp -rf src/main/vue/dist /var/www/dangjian/admin
+rm -rf /var/www/dangjian/mobile
+cp -rf src/main/mobile/dist /var/www/dangjian/mobile
 systemctl start dangjian

+ 2 - 0
src/main/java/com/izouma/dangjian/domain/User.java

@@ -78,4 +78,6 @@ public class User extends BaseEntity implements Serializable {
     private String receiverPhone;
 
     private String address;
+
+    private Long invitor;
 }

+ 1 - 0
src/main/java/com/izouma/dangjian/security/WebSecurityConfig.java

@@ -81,6 +81,7 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
                 .antMatchers("/article/get/**").permitAll()
                 .antMatchers("/banner/all").permitAll()
                 .antMatchers("/banner/get/*").permitAll()
+                .antMatchers("/sysConfig/get/*").permitAll()
                 // all other requests need to be authenticated
                 .anyRequest().authenticated().and()
                 // make sure we use stateless session; session won't be used to

+ 2 - 1
src/main/java/com/izouma/dangjian/service/UserService.java

@@ -56,7 +56,7 @@ public class UserService {
         return userRepo.save(user);
     }
 
-    public String register(String nickname, String phone, String code, String password) {
+    public String register(String nickname, String phone, String code, String password, Long invitor) {
         if (userRepo.findByPhoneAndDelFalse(phone) != null) {
             throw new BusinessException("该手机已注册");
         }
@@ -72,6 +72,7 @@ public class UserService {
                 .password(new BCryptPasswordEncoder().encode(password))
                 .avatar(Constants.DEFAULT_AVATAR)
                 .authorities(Collections.singleton(Authority.builder().name("ROLE_USER").build()))
+                .invitor(invitor)
                 .build();
         user = userRepo.save(user);
         return jwtTokenUtil.generateToken(JwtUserFactory.create(user));

+ 3 - 2
src/main/java/com/izouma/dangjian/web/UserController.java

@@ -47,8 +47,8 @@ public class UserController extends BaseController {
 
     @PostMapping("/registerPhone")
     public String register(@RequestParam String nickname, @RequestParam String phone, @RequestParam String code,
-                           @RequestParam String password) {
-        return userService.register(nickname, phone, code, password);
+                           @RequestParam String password, @RequestParam(required = false) Long invitor) {
+        return userService.register(nickname, phone, code, password, invitor);
     }
 
     @PreAuthorize("hasRole('ADMIN')")
@@ -136,6 +136,7 @@ public class UserController extends BaseController {
 
     @PostMapping("/update")
     public User update(@RequestBody User user) {
+        user.setAuthorities(null);
         User orig = userRepo.findById(user.getId()).orElseThrow(new BusinessException("无记录"));
         ObjUtils.merge(orig, user);
         return userRepo.save(orig);

+ 2 - 0
src/main/mobile/.eslintignore

@@ -0,0 +1,2 @@
+src/qrcode.min.js
+src/qrcode.js

+ 2 - 0
src/main/mobile/package.json

@@ -16,6 +16,8 @@
     "dayjs": "^1.10.4",
     "less-vars-loader": "^1.1.0",
     "photoswipe": "^4.1.3",
+    "qrcode": "^1.4.4",
+    "qrcode.vue": "^1.7.0",
     "style-resources-loader": "^1.4.1",
     "url-search-params-polyfill": "^8.1.0",
     "vant": "^2.12.10",

+ 1 - 1
src/main/mobile/public/index.html

@@ -3,7 +3,7 @@
   <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">
+    <meta name="viewport" content="width=device-width,initial-scale=1.0,viewport-fit=cover,user-scalable=no">
     <link rel="icon" href="<%= BASE_URL %>favicon.ico">
     <title><%= htmlWebpackPlugin.options.title %></title>
   </head>

+ 6 - 17
src/main/mobile/src/App.vue

@@ -21,8 +21,7 @@ export default {
     --safe-right: env(safe-area-inset-right);
 }
 html {
-    width: 100%;
-    height: 100vh;
+    width: 100vw;
     font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB',
         'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
     -webkit-font-smoothing: antialiased;
@@ -32,8 +31,7 @@ html {
 }
 
 body {
-    width: 100%;
-    height: 100%;
+    width: 100vw;
     background: white;
     font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Helvetica, 'PingFang SC', 'Hiragino Sans GB',
         'Microsoft YaHei', '微软雅黑', Arial, sans-serif;
@@ -41,6 +39,8 @@ body {
     -moz-osx-font-smoothing: grayscale;
     margin: 0;
     padding: 0;
+    overflow-y: scroll;
+    -webkit-overflow-scrolling: touch;
 }
 
 * {
@@ -99,23 +99,12 @@ input {
     position: absolute;
     top: 0;
     left: 0;
-    height: 100%;
-    width: 100%;
+    min-height: 100vh;
+    width: 100vw;
     overflow-x: hidden;
     overflow-y: scroll;
     -webkit-overflow-scrolling: touch;
 }
-.router-page {
-    animation-duration: 0.3s;
-    animation-fill-mode: both;
-    backface-visibility: hidden;
-    //   transform            : translate3d(0, 0, 0);
-    flex-grow: 1;
-    box-sizing: border-box;
-    overflow-x: hidden;
-    overflow-y: auto;
-    -webkit-overflow-scrolling: touch;
-}
 
 // loading spinner style
 .sk-fading-circle {

+ 100 - 0
src/main/mobile/src/components/promoteDialog.vue

@@ -0,0 +1,100 @@
+<template>
+    <van-popup v-model="showDialog" class="promote-dialog" @close="onClose">
+        <div class="title">您的专属推广链接</div>
+        <img class="qrcode" ref="qrcode" :src="src" />
+        <div class="desc">
+            长按保存二维码或<span v-clipboard:copy="'asdfasdfasdf'" v-clipboard:success="onCopy">一键复制链接</span>
+        </div>
+        <canvas id="qrcode"></canvas>
+    </van-popup>
+</template>
+<script>
+import { mapState } from 'vuex';
+import QRCode from 'qrcode';
+export default {
+    props: {
+        visible: {
+            default: false
+        }
+    },
+    data() {
+        return {
+            showDialog: false,
+            src: ''
+        };
+    },
+    mounted() {
+        const qrCanvas = document.createElement('canvas');
+        qrCanvas.width = 400;
+        qrCanvas.height = 400;
+        let self = this;
+        QRCode.toCanvas(
+            qrCanvas,
+            'asasdgasdgsa',
+            {
+                margin: 2,
+                width: 400
+            },
+            error => {
+                if (error) console.error(error);
+                console.log('success!', qrCanvas.toDataURL());
+                console.log(this.$refs);
+                this.src = qrCanvas.toDataURL();
+            }
+        );
+    },
+    computed: {
+        ...mapState(['userInfo'])
+    },
+    methods: {
+        onClose() {
+            this.$emit('update:visible', false);
+        },
+        onCopy() {
+            this.$notify({ message: '已复制专属推广链接', background: this.$theme.prim });
+        }
+    },
+    watch: {
+        visible(val) {
+            this.showDialog = val;
+        }
+    }
+};
+</script>
+<style lang="less" scoped>
+.promote-dialog {
+    background: transparent !important;
+    .flex-col();
+    align-items: center;
+    color: white;
+    font-size: 14px;
+    .title {
+    }
+    .url {
+        width: 200px;
+        word-break: break-word;
+        margin-top: 8px;
+        line-height: 20px;
+        text-align: center;
+    }
+    .btn-copy {
+        line-height: 24px;
+        vertical-align: middle;
+        margin-top: 8px;
+    }
+    .qrcode {
+        margin-top: 15px;
+        width: 200px;
+        height: 200px;
+    }
+    .desc {
+        font-size: 14px;
+        margin-top: 15px;
+        span {
+            color: @prim;
+            text-decoration: underline;
+            font-weight: bold;
+        }
+    }
+}
+</style>

+ 1 - 0
src/main/mobile/src/main.js

@@ -49,3 +49,4 @@ const vm = new Vue({
     render: h => h(App)
 }).$mount('#app');
 store.dispatch('updateUserInfo');
+console.log(new URLSearchParams(window.location.search).get('invitor'));

+ 4 - 46
src/main/mobile/src/views/Home.vue

@@ -31,21 +31,16 @@
         </div>
         <div class="article" v-html="content1"></div>
         <div class="article" v-html="content2" id="contact"></div>
-        <div style="height: 50px"></div>
-        <van-popup v-model="showDialog" class="promote-dialog">
-            <div class="title">您的专属推广链接</div>
-            <qrcode class="qrcode" value="Hello, World!" :options="{ width: 200, margin: 2 }"></qrcode>
-            <div class="desc">
-                长按保存二维码或<span v-clipboard:copy="'asdfasdfasdf'" v-clipboard:success="onCopy">一键复制链接</span>
-            </div>
-        </van-popup>
+        <div style="height: calc(50px + max(env(safe-area-inset-bottom), 0px))"></div>
+        <promote-dialog :visible.sync="showDialog"></promote-dialog>
     </div>
 </template>
 <script>
 import { mapState } from 'vuex';
 import qrcode from '@chenfengyuan/vue-qrcode';
+import promoteDialog from '../components/promoteDialog';
 export default {
-    components: { qrcode },
+    components: { promoteDialog },
     data() {
         return {
             banners: [],
@@ -97,7 +92,6 @@ export default {
             if (this.end) {
                 let x = this.end.startOf('day');
                 let y = this.$dayjs().startOf('day');
-                console.log(x, y);
                 return this.$dayjs.duration(x.diff(y)).asDays();
             }
             return 0;
@@ -134,9 +128,6 @@ export default {
             } else {
                 return true;
             }
-        },
-        onCopy() {
-            this.$notify({ message: '已复制专属推广链接', background: this.$theme.prim });
         }
     }
 };
@@ -223,37 +214,4 @@ export default {
     padding: 0 16px;
     margin-top: 20px;
 }
-.promote-dialog {
-    background: transparent !important;
-    .flex-col();
-    align-items: center;
-    color: white;
-    font-size: 14px;
-    .title {
-    }
-    .url {
-        width: 200px;
-        word-break: break-word;
-        margin-top: 8px;
-        line-height: 20px;
-        text-align: center;
-    }
-    .btn-copy {
-        line-height: 24px;
-        vertical-align: middle;
-        margin-top: 8px;
-    }
-    .qrcode {
-        margin-top: 15px;
-    }
-    .desc {
-        font-size: 14px;
-        margin-top: 15px;
-        span {
-            color: @prim;
-            text-decoration: underline;
-            font-weight: bold;
-        }
-    }
-}
 </style>

+ 1 - 1
src/main/mobile/vue.config.js

@@ -2,7 +2,7 @@ const path = require('path');
 const vConsolePlugin = require('vconsole-webpack-plugin');
 module.exports = {
     productionSourceMap: false,
-    publicPath: '/',
+    publicPath: process.env.NODE_ENV === 'production' ? '/mobile/' : '/',
     devServer: {
         port: 8082
     },

+ 5 - 0
src/main/mobile/yarn.lock

@@ -6894,6 +6894,11 @@ q@^1.1.2:
   resolved "https://registry.npm.taobao.org/q/download/q-1.5.1.tgz#7e32f75b41381291d04611f1bf14109ac00651d7"
   integrity sha1-fjL3W0E4EpHQRhHxvxQQmsAGUdc=
 
+qrcode.vue@^1.7.0:
+  version "1.7.0"
+  resolved "https://registry.yarnpkg.com/qrcode.vue/-/qrcode.vue-1.7.0.tgz#c54b2934f0650c10d92785d08aaad36c55e0fc56"
+  integrity sha512-R7t6Y3fDDtcU7L4rtqwGUDP9xD64gJhIwpfjhRCTKmBoYF6SS49PIJHRJ048cse6OI7iwTwgyy2C46N9Ygoc6g==
+
 qrcode@^1.4.4:
   version "1.4.4"
   resolved "https://registry.yarnpkg.com/qrcode/-/qrcode-1.4.4.tgz#f0c43568a7e7510a55efc3b88d9602f71963ea83"