zj 3 years ago
parent
commit
6506ea5721

+ 2 - 2
package.json

@@ -3,8 +3,8 @@
   "version": "0.0.0",
   "version": "0.0.0",
   "scripts": {
   "scripts": {
     "ng": "ng",
     "ng": "ng",
-    "start1": "ng serve --host 192.168.0.105",
-    "start": "ng serve",
+    "start": "ng serve --host 192.168.0.105",
+    "start1": "ng serve",
     "build": "ng build --prod",
     "build": "ng build --prod",
     "test": "ng test",
     "test": "ng test",
     "lint": "ng lint",
     "lint": "ng lint",

+ 7 - 3
src/app/app-routing.module.ts

@@ -28,10 +28,14 @@ const routes: Routes = [
   {path: 'index', component: HomeComponent},//首页
   {path: 'index', component: HomeComponent},//首页
   {path: 'rule', component: RuleComponent},//规则
   {path: 'rule', component: RuleComponent},//规则
   {path: 'login', component: LoginComponent},//登陆注册
   {path: 'login', component: LoginComponent},//登陆注册
-  {path: 's', component: ShareComponent},//分享页面1
-  {path: 'apply', component: ShareApplicationComponent},//提交
+  {
+    path: 's', children: [
+      {path: '', component: ShareComponent},
+      {path: 'apply', component: ShareApplicationComponent},//提交
+    ]
+  },//分享页面1
   {path: 'exclusive', component: ShareInviteComponent},//专属页面-我的
   {path: 'exclusive', component: ShareInviteComponent},//专属页面-我的
-  {path: '', pathMatch: 'full', redirectTo: 'index'},
+  {path: '**', pathMatch: 'full', redirectTo: 'index'},
 ];
 ];
 
 
 @NgModule({
 @NgModule({

+ 3 - 1
src/app/app.module.ts

@@ -13,7 +13,9 @@ import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
 import { FormsModule } from '@angular/forms';
 import { FormsModule } from '@angular/forms';
 import { HttpClientModule } from '@angular/common/http';
 import { HttpClientModule } from '@angular/common/http';
 import { NgZorroAntdMobileModule } from 'ng-zorro-antd-mobile';
 import { NgZorroAntdMobileModule } from 'ng-zorro-antd-mobile';
+import {HashLocationStrategy, LocationStrategy} from '@angular/common';
 
 
+// @ts-ignore
 @NgModule({
 @NgModule({
   declarations: [
   declarations: [
     AppComponent,
     AppComponent,
@@ -32,7 +34,7 @@ import { NgZorroAntdMobileModule } from 'ng-zorro-antd-mobile';
     HttpClientModule,
     HttpClientModule,
     NgZorroAntdMobileModule,
     NgZorroAntdMobileModule,
   ],
   ],
-  providers: [],
+  providers: [{ provide: LocationStrategy, useClass: HashLocationStrategy },],
   bootstrap: [AppComponent]
   bootstrap: [AppComponent]
 })
 })
 export class AppModule {
 export class AppModule {

+ 3 - 2
src/app/components/get-reward/get-reward.component.ts

@@ -65,12 +65,13 @@ export class GetRewardComponent implements OnInit {
       this.toast.show('请选择奖品', 1000);
       this.toast.show('请选择奖品', 1000);
       return;
       return;
     }
     }
-    if (this.userInfo) {
+    const campaignId = localStorage.getItem('campaignId');
+    if (this.userInfo && campaignId) {
       let address = '';
       let address = '';
       this.selectedArea.map(item => address += item.label);
       this.selectedArea.map(item => address += item.label);
       this.updateParams = {
       this.updateParams = {
         participantId: this.userInfo.participantId,
         participantId: this.userInfo.participantId,
-        campaignId: this.userInfo.campaignId,
+        campaignId: campaignId,
         reqChannel: this.config.reqChannel,
         reqChannel: this.config.reqChannel,
         receiver: this.receiver,
         receiver: this.receiver,
         receivePhone: this.receivePhone,
         receivePhone: this.receivePhone,

+ 1 - 1
src/app/components/nav/nav.component.html

@@ -1 +1 @@
-<Icon [type]="'left'" size="lg" class="nav_box" (click)="back()"></Icon>
+<Icon [type]="'left'" size="lg" class="nav_box" [color]="color" (click)="back()"></Icon>

+ 1 - 1
src/app/components/nav/nav.component.ts

@@ -6,7 +6,7 @@ import {Component, Input, OnInit} from '@angular/core';
   styleUrls: ['./nav.component.less']
   styleUrls: ['./nav.component.less']
 })
 })
 export class NavComponent implements OnInit {
 export class NavComponent implements OnInit {
-  @Input() label: string = '';
+  @Input() color: string = '#FFF';
   constructor() { }
   constructor() { }
 
 
   ngOnInit(): void {
   ngOnInit(): void {

+ 13 - 7
src/app/components/notice/notice.component.ts

@@ -22,14 +22,20 @@ export class NoticeComponent implements OnInit {
   }
   }
 
 
   getData() {
   getData() {
-    this.http.get(this.http.apis.findPageByOper, {
-      data: {
-        campaignId: this.config.campaignId
-      },
-      success: (res: any) => {
-        this.list = res.records || [];
+    setTimeout(() => {
+      const a = localStorage.getItem('campaignId');
+      if (a) {
+        this.http.get(this.http.apis.findPageByOper, {
+          data: {
+            campaignId: a
+          },
+          success: (res: any) => {
+            this.list = res.records || [];
+          }
+        });
       }
       }
-    });
+    }, 1000);
+
   }
   }
 
 
 }
 }

+ 14 - 9
src/app/pages/home/home.component.ts

@@ -47,16 +47,21 @@ export class HomeComponent implements OnInit {
 
 
   // 获取活动奖品列表
   // 获取活动奖品列表
   getProductList() {
   getProductList() {
-    this.http.get(this.http.apis.productPage, {
-      data: {
-        pageNum: 1,
-        pageSize: 20,
-        campaignId: this.config.campaignId
-      },
-      success: (res: any) => {
-        this.prizeList = res.records.sort((a: any, b: any) => a.meetCnt - b.meetCnt);
+    setTimeout(() => {
+      const a = localStorage.getItem('campaignId');
+      if (a) {
+        this.http.get(this.http.apis.productPage, {
+          data: {
+            pageNum: 1,
+            pageSize: 20,
+            campaignId: a
+          },
+          success: (res: any) => {
+            this.prizeList = res.records.sort((a: any, b: any) => a.meetCnt - b.meetCnt);
+          }
+        });
       }
       }
-    });
+    }, 1000);
   }
   }
 
 
 }
 }

+ 44 - 40
src/app/pages/login/login.component.ts

@@ -94,49 +94,53 @@ export class LoginComponent implements OnInit {
       this.toast.show('请输入短信验证码');
       this.toast.show('请输入短信验证码');
       return;
       return;
     }
     }
-    let url = this.http.apis.login;
-    let params: any = {
-      mobile: this.mobile,
-      smsCode: this.smsCode,
-      campaignId: this.config.campaignId,
-      reqChannel: this.config.reqChannel
-    };
-    if (this.type == 'register') {
-      if (!this.userName) {
-        this.toast.hide();
-        this.toast.show('请输入推荐人称呼');
-        return;
-      }
-      url = this.http.apis.register;
-      params = {
-        ...params,
-        userName: this.userName,
-        address: '',
+    const campaignId = localStorage.getItem('campaignId');
+    if (campaignId) {
+      let url = this.http.apis.login;
+      let params: any = {
+        mobile: this.mobile,
+        smsCode: this.smsCode,
+        campaignId: campaignId,
+        reqChannel: this.config.reqChannel
       };
       };
-    }
-    this.http.post(url, {
-      data: params,
-      success: (res: any) => {
-        if (this.type == 'login') {
-          // 登陆
-          this.toast.show('登陆成功');
-          localStorage.clear();
-          localStorage.setItem('params', JSON.stringify(res));
-          // location.replace(this.config.rootUrl + '/exclusive');
-          this.router.navigate(['/exclusive']).then();
+      if (this.type == 'register') {
+        if (!this.userName) {
+          this.toast.hide();
+          this.toast.show('请输入推荐人称呼');
+          return;
         }
         }
-        if (this.type == 'register') {
-          // 注册
-          this.toast.show('注册成功,请重新登陆');
-          this.type = 'login';
-          this.smsCode = '';
-          if (this.timer) {
-            clearInterval(this.timer);
-            this.timer = null;
-            this.countDown = '获取验证码';
+        url = this.http.apis.register;
+        params = {
+          ...params,
+          userName: this.userName,
+          address: '',
+        };
+      }
+      this.http.post(url, {
+        data: params,
+        success: (res: any) => {
+          if (this.type == 'login') {
+            // 登陆
+            this.toast.show('登陆成功');
+            localStorage.clear();
+            localStorage.setItem('params', JSON.stringify(res));
+            localStorage.setItem('campaignId', campaignId);
+            // location.replace(this.config.rootUrl + '/exclusive');
+            this.router.navigate(['/exclusive']).then();
+          }
+          if (this.type == 'register') {
+            // 注册
+            this.toast.show('注册成功,请重新登陆');
+            this.type = 'login';
+            this.smsCode = '';
+            if (this.timer) {
+              clearInterval(this.timer);
+              this.timer = null;
+              this.countDown = '获取验证码';
+            }
           }
           }
         }
         }
-      }
-    });
+      });
+    }
   }
   }
 }
 }

+ 1 - 0
src/app/pages/share-application/share-application.component.html

@@ -1,4 +1,5 @@
 <!-- 申请用户填写信息 -->
 <!-- 申请用户填写信息 -->
+<app-nav color="rgba(0,0,0,0.5)"></app-nav>
 <div class="bg_con">
 <div class="bg_con">
   <div class="card">
   <div class="card">
     <div class="top_locks">
     <div class="top_locks">

+ 9 - 7
src/app/pages/share-application/share-application.module.ts

@@ -5,18 +5,20 @@ import {ButtonModule} from '../../components/button/button.module';
 import {RouterModule} from '@angular/router';
 import {RouterModule} from '@angular/router';
 import {LockModule} from '../../components/lock/lock.module';
 import {LockModule} from '../../components/lock/lock.module';
 import {InputItemModule} from '../../components/input-item/input-item.module';
 import {InputItemModule} from '../../components/input-item/input-item.module';
+import {NavModule} from '../../components/nav/nav.module';
 
 
 
 
 
 
 @NgModule({
 @NgModule({
   declarations: [ShareApplicationComponent],
   declarations: [ShareApplicationComponent],
-  imports: [
-    CommonModule,
-    ButtonModule,
-    RouterModule,
-    LockModule,
-    InputItemModule
-  ],
+    imports: [
+        CommonModule,
+        ButtonModule,
+        RouterModule,
+        LockModule,
+        InputItemModule,
+        NavModule
+    ],
   exports: [ShareApplicationComponent]
   exports: [ShareApplicationComponent]
 })
 })
 export class ShareApplicationModule { }
 export class ShareApplicationModule { }

+ 2 - 3
src/app/pages/share-invite/share-invite.component.html

@@ -6,7 +6,6 @@
     </div>
     </div>
     <div class="img_inner">
     <div class="img_inner">
       <img class="img" src="assets/page1-2.png"/>
       <img class="img" src="assets/page1-2.png"/>
-
       <app-notice></app-notice>
       <app-notice></app-notice>
     </div>
     </div>
     <img class="img" src="assets/page1-3.png"/>
     <img class="img" src="assets/page1-3.png"/>
@@ -17,12 +16,12 @@
   </div>
   </div>
   <div class="share_bg" *ngIf="userInfo">
   <div class="share_bg" *ngIf="userInfo">
     <div class="share_box">
     <div class="share_box">
-      <div class="share_btn">
+      <div class="share_btn" (click)="share('0')">
         <img src="assets/icon2.png" class="icon"/>
         <img src="assets/icon2.png" class="icon"/>
         <span class="text">邀请微信好友</span>
         <span class="text">邀请微信好友</span>
       </div>
       </div>
       <div class="center_line"></div>
       <div class="center_line"></div>
-      <div class="share_btn1">
+      <div class="share_btn1" (click)="share('1')">
         <img src="assets/icon1.png" class="icon"/>
         <img src="assets/icon1.png" class="icon"/>
         <span class="text">分享到朋友圈</span>
         <span class="text">分享到朋友圈</span>
       </div>
       </div>

+ 28 - 14
src/app/pages/share-invite/share-invite.component.ts

@@ -4,7 +4,8 @@ import {RegService} from '../../service/reg.service';
 import {ModalService, ToastService} from 'ng-zorro-antd-mobile';
 import {ModalService, ToastService} from 'ng-zorro-antd-mobile';
 import {ConfigService} from '../../service/config.service';
 import {ConfigService} from '../../service/config.service';
 import {ICompany, IPrize, IUser} from '../../model';
 import {ICompany, IPrize, IUser} from '../../model';
-import {Router} from '@angular/router';
+import {ActivatedRoute, Router} from '@angular/router';
+import {PostMsgService} from '../../service/post-msg.service';
 
 
 @Component({
 @Component({
   selector: 'app-share-invite',
   selector: 'app-share-invite',
@@ -26,7 +27,9 @@ export class ShareInviteComponent implements OnInit {
     private toast: ToastService,
     private toast: ToastService,
     public config: ConfigService,
     public config: ConfigService,
     private modal: ModalService,
     private modal: ModalService,
-    private router: Router
+    private router: Router,
+    public postMsgService: PostMsgService,
+    private activatedRoute: ActivatedRoute
   ) {
   ) {
   }
   }
 
 
@@ -50,11 +53,12 @@ export class ShareInviteComponent implements OnInit {
 
 
   // 申请企业列表
   // 申请企业列表
   getList() {
   getList() {
-    if (this.userInfo) {
+    const campaignId = localStorage.getItem('campaignId');
+    if (this.userInfo && campaignId) {
       this.http.get(this.http.apis.findPageByParticipant, {
       this.http.get(this.http.apis.findPageByParticipant, {
         data: {
         data: {
-          campaignId: this.config.campaignId,
-          participantId: this.userInfo?.participantId,
+          campaignId: campaignId,
+          participantId: this.userInfo.participantId,
           status: '2'
           status: '2'
         },
         },
         success: (res: any) => {
         success: (res: any) => {
@@ -70,16 +74,22 @@ export class ShareInviteComponent implements OnInit {
 
 
   // 获取活动奖品列表
   // 获取活动奖品列表
   getProductList(total: number) {
   getProductList(total: number) {
-    this.http.get(this.http.apis.productPage, {
-      data: {
-        pageNum: 1,
-        pageSize: 20,
-        campaignId: this.config.campaignId
-      },
-      success: (res: any) => {
-        this.prizeList = res.records.filter((item: IPrize) => item.meetCnt <= total).sort((a: any, b: any) => a.meetCnt - b.meetCnt);
+    setTimeout(() => {
+      const campaignId = localStorage.getItem('campaignId');
+      if (campaignId) {
+        this.http.get(this.http.apis.productPage, {
+          data: {
+            pageNum: 1,
+            pageSize: 20,
+            campaignId: campaignId
+          },
+          success: (res: any) => {
+            this.prizeList = res.records.filter((item: IPrize) => item.meetCnt <= total).sort((a: any, b: any) => a.meetCnt - b.meetCnt);
+          }
+        });
       }
       }
-    });
+    }, 500);
+
   }
   }
 
 
   exit() {
   exit() {
@@ -94,4 +104,8 @@ export class ShareInviteComponent implements OnInit {
       }
       }
     ]);
     ]);
   }
   }
+
+  share(type: string) {
+    this.postMsgService.share(type);
+  }
 }
 }

+ 1 - 1
src/app/pages/share/share.component.html

@@ -6,6 +6,6 @@
 
 
 </div>
 </div>
 <div class="btn_box">
 <div class="btn_box">
-  <app-button [routerLink]="'/apply'" [queryParams]="params" label="提交信息并申请"></app-button>
+  <app-button [routerLink]="'/s/apply'" [queryParams]="params" label="提交信息并申请"></app-button>
 </div>
 </div>
 
 

+ 16 - 3
src/app/service/config.service.ts

@@ -8,8 +8,9 @@ export class ConfigService {
 
 
   constructor() {
   constructor() {
   }
   }
+
   public rootUrl = '/marketing/yinliu'; // 部署路径
   public rootUrl = '/marketing/yinliu'; // 部署路径
-  campaignId = 'bae3c1e4c6bf4d577f01a6312d30fe41'; // 活动id 1
+  campaignId = localStorage.getItem('campaignId') || '';//'bae3c1e4c6bf4d577f01a6312d30fe41'; // 活动id 1
   reqChannel = 3; // 渠道
   reqChannel = 3; // 渠道
   userInfo: IUser | undefined = this.getUserInfo();
   userInfo: IUser | undefined = this.getUserInfo();
 
 
@@ -24,9 +25,21 @@ export class ConfigService {
   }
   }
 
 
   // 注销用户
   // 注销用户
-  exitUser(){
+  exitUser() {
     this.userInfo = undefined;
     this.userInfo = undefined;
-    localStorage.clear();
+    localStorage.removeItem('params');
     return undefined;
     return undefined;
   }
   }
+
+  // 监听webview获取的数据
+  // getWebView() {
+  //   try {
+  //     window.addEventListener('message', (data) => {
+  //       alert(`${data.data.data}`);
+  //       window.removeEventListener('message',()=>{});
+  //     });
+  //   } catch (e) {
+  //
+  //   }
+  // }
 }
 }

+ 9 - 4
src/app/service/post-msg.service.ts

@@ -1,13 +1,18 @@
-import { Injectable } from '@angular/core';
+import {Injectable} from '@angular/core';
+
 // webview 与 rn通信
 // webview 与 rn通信
 @Injectable({
 @Injectable({
   providedIn: 'root'
   providedIn: 'root'
 })
 })
 export class PostMsgService {
 export class PostMsgService {
 
 
-  constructor() { }
+  constructor() {
+  }
 
 
-  share(){
-    // if(window.postMessage())
+  share(type: string) {
+    try {
+      // @ts-ignore
+      window.ReactNativeWebView.postMessage(type);
+    }catch (e){}
   }
   }
 }
 }