zhuliu 1 年間 前
コミット
10793c445c

+ 2 - 1
app.json

@@ -32,7 +32,8 @@
     "pages/myWork/workDetail",
     "pages/about/Feedback",
     "pages/memberCenter/menberCenter2",
-    "pages/voucher/voucher"
+    "pages/voucher/voucher",
+    "pages/about/invite"
   ],
   "tabBar": {
     "list": [

+ 18 - 2
pages/about/about.js

@@ -1,5 +1,6 @@
 // pages/about/about.js
 const app = getApp()
+const api = require('../../api/index')
 Page({
 
   /**
@@ -18,7 +19,8 @@ Page({
         type:3,
         label:'意见反馈',
         icon:'',
-        page:'/pages/about/Feedback'
+        page:'/pages/about/Feedback',
+        login:true
       },
       {
         type:2,
@@ -26,6 +28,13 @@ Page({
         icon:'',
         page:'/pages/about/connection'
       },
+      {
+        type:4,
+        label:'邀请',
+        icon:'',
+        page:'/pages/about/invite',
+        login:true
+      },
     ],
   },
 
@@ -52,7 +61,14 @@ Page({
 
   //点击跳转
   clickMenu(e){
-    var {page} = e.currentTarget.dataset
+    var {item} = e.currentTarget.dataset
+    if(item.login){
+      var isLogin = api.isLogin()
+      if(!isLogin){
+        return false
+      }
+    }
+    var page = item.page
       wx.navigateTo({
         url: page,
       })

+ 1 - 1
pages/about/about.wxml

@@ -8,7 +8,7 @@
     <view class="version">版本号:{{version}}</view>
   </view>
   <view class="menu_list">
-      <van-cell custom-class='vanCell' wx:for="{{menu}}" wx:key="index" title="{{item.label}}" is-link data-page="{{item.page}}" bind:click="clickMenu">
+      <van-cell custom-class='vanCell' wx:for="{{menu}}" wx:key="index" title="{{item.label}}" is-link data-item="{{item}}" bind:click="clickMenu">
         <van-icon slot="right-icon" name="arrow" color="green" />
       </van-cell>
   </view>

+ 138 - 0
pages/about/invite.js

@@ -0,0 +1,138 @@
+// pages/about/invite.js
+const app = getApp()
+const api = require('../../api/index')
+Page({
+
+  /**
+   * 页面的初始数据
+   */
+  data: {
+    imgHttp:app.globalData.imghttp,
+    personList:[],
+    total:0,
+    inviteCode:'123'
+  },
+
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    this.inviteUser()
+  },
+
+  /**
+   * 生命周期函数--监听页面初次渲染完成
+   */
+  onReady() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面显示
+   */
+  onShow() {
+
+  },
+
+  //邀请用户
+  async inviteUser(){
+    this.getPerson()
+    this.getinvitePerson()
+    this.showShareMenu()
+  },
+  //获取已邀请的人员
+  getinvitePerson(){
+    var data = [{
+      "name": "用户",
+      "fileGuid": "72a4ea3d42624ffdb3f37724ef2d2c38",
+      "phoneNum": "18856669949",
+      "uuid": "cf934195ff9f40fd8ae16337d538dacb",
+      "vipType": 0,
+      "vipMessageVO": {},
+      "createTime": "2024-04-10 11:37:36"
+  }]
+  data.forEach(item=>{
+    item.phoneNum = this.hideMiddleFour(item.phoneNum)
+  })
+    this.setData(
+      {
+        personList:data,
+        total:1
+      }
+    )
+  },
+  //隐藏手机号
+  hideMiddleFour(phoneNumber) {  
+    // 假设phoneNumber是一个有效的手机号码字符串  
+    if(!phoneNumber){
+      return ''
+    }
+    if (phoneNumber.length < 11) {  
+      return '无效的手机号码';  
+    }  
+    // 截取前三位  
+    let firstPart = phoneNumber.slice(0, 3);  
+    // 截取后四位  
+    let lastPart = phoneNumber.slice(-4);  
+    // 拼接并添加隐藏标记  
+    return `${firstPart}****${lastPart}`;  
+  },  
+  getPerson(){
+    api.selectPerson({},false).then(res=>{
+      if(res.code == 200){
+        this.setData(
+          {
+            inviteCode:res.data.uuid
+          }
+        )
+      }
+    }).catch(error=>{
+    })
+  },
+  showShareMenu: function() {  
+    wx.showShareMenu({  
+      withShareTicket: true ,
+      menus: ['shareAppMessage', 'shareTimeline'] 
+    });  
+  }, 
+
+
+  /**
+   * 生命周期函数--监听页面隐藏
+   */
+  onHide() {
+
+  },
+
+  /**
+   * 生命周期函数--监听页面卸载
+   */
+  onUnload() {
+
+  },
+
+  /**
+   * 页面相关事件处理函数--监听用户下拉动作
+   */
+  onPullDownRefresh() {
+
+  },
+
+  /**
+   * 页面上拉触底事件的处理函数
+   */
+  onReachBottom() {
+
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage() {
+    return {  
+      title: '邀请好友加入',  
+      path:"/pages/login/login?inviteCode=" + this.data.inviteCode,
+      
+    } 
+  }
+})

+ 5 - 0
pages/about/invite.json

@@ -0,0 +1,5 @@
+{
+  "usingComponents": {
+    "wux-avatar":"/miniprogram_npm/wux-weapp/avatar/index"
+  }
+}

+ 25 - 0
pages/about/invite.wxml

@@ -0,0 +1,25 @@
+<!--pages/about/invite.wxml-->
+<view class="invite">
+  <view class="invite_list shadow">
+    <view class="head"> 已邀请用户 <span style="font-size: 20rpx;color: darkgray;">{{total}}</span></view>
+    <view class="invite_list_content">
+      <block wx:if="{{personList.length>0}}">
+        <view class="invite_list_item" wx:for="{{personList}}" wx:key="index">
+          <wux-avatar size="large" wx:if="{{item.fileGuid}}" src="{{imgHttp}}{{item.fileGuid}}"></wux-avatar>
+          <wux-avatar size="large" wx:else src="/static/image/unlogin.jpeg"></wux-avatar>
+          <view class="message">
+            <view class="name">{{item.name}}</view>
+            <view class="phone">{{item.phoneNum}}</view>
+          </view>
+        </view>
+      </block>
+      <view wx:else class="empty">
+        暂无数据
+      </view>
+    </view>
+  </view>
+  <view class="invite_btn">
+    <!-- <view class="btn" data bind:tap="inviteUser">邀请用户</view> -->
+    <button type="primary" open-type="share" bind:tap="inviteUser">邀请用户</button>
+  </view>
+</view>

+ 67 - 0
pages/about/invite.wxss

@@ -0,0 +1,67 @@
+/* pages/about/invite.wxss */
+.invite{
+  padding: 10px;
+}
+.empty{
+  text-align: center;
+  line-height: 150px;
+  color: darkgray;
+}
+.shadow{
+  box-shadow: rgba(0, 0, 0, 0.4) 0px 2px 6px 0px;
+  border-radius: 5px;
+}
+.invite_list{
+  margin-top: 20px;
+  min-height: 200px; 
+}
+.head{
+  width: fit-content;
+  padding: 5px 15px;
+  border-radius: 5px;
+  color: white;
+  font-size: 24rpx;
+  background: var(--themeColor)
+}
+.invite_list_content{
+  margin-top: 10px;
+  padding: 8px;
+  max-height: calc(100vh - 120px);
+  overflow-y: auto;
+}
+.invite_list_item{
+  background-color: var(--themeColor);
+  padding: 8px;
+  border-radius: 10px;
+  color: white;
+  margin-bottom: 10px;
+  display: flex;
+  align-items: center;
+}
+.message{
+  margin-left: 15px;
+}
+.name{
+  font-size: 34rpx;
+}
+.phone{
+  color: darkgray;
+  font-size: 26rpx;
+}
+
+.invite_btn{
+  width: calc(100vw - 40px);
+  position: fixed;
+  bottom: 50px;
+  margin: 10px;
+}
+.btn{
+  width: 70%;
+  height: 40px;
+  text-align: center;
+  line-height: 40px;
+  margin: auto;
+  color: white;
+  border-radius: 40px;
+  background-color: var(--themeColor);
+}

+ 21 - 4
pages/login/login.js

@@ -18,13 +18,20 @@ Page({
     },
     showDialog:false,
     imgURL:null,
+    inviteCode:null
   },
 
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-
+    if(options.inviteCode){
+      this.setData(
+        {
+          inviteCode:options.inviteCode
+        }
+      )
+    }
   },
 
   /**
@@ -181,7 +188,8 @@ Page({
         if (!err) {
             var data = {
               phoneNum:this.data.loginMessage.phone,
-              phoneCode:this.data.loginMessage.code
+              phoneCode:this.data.loginMessage.code,
+              inviteCode:this.data.inviteCode
             }
             wx.showLoading({
               title: '加载中',
@@ -201,7 +209,15 @@ Page({
   isLogin({token,id,isFirst,phone}){
     wx.setStorageSync('token',token)
     this.getPersonRights()
-    wx.navigateBack()
+    var pages = getCurrentPages()
+    if (pages.length >= 2) {
+      wx.navigateBack()
+    } else {
+      wx.switchTab({
+          url: '/pages/index/index'
+      });
+  }
+    
     
   },
   getPersonRights(){
@@ -229,7 +245,8 @@ Page({
         var data= {  
           encryptedData: encryptedData,  
           iv: iv,
-          code:code
+          code:code,
+          inviteCode:this.data.inviteCode
         }
         wx.login({
           success: (res) => {

+ 1 - 1
pages/memberCenter/menberCenter2.wxml

@@ -19,7 +19,7 @@
     <!-- 开通会员类型 -->
     <scroll-view  scroll-x="true">
       <view class="vipType">
-        <view  wx:for="{{vipType}}" class="vipType_item {{chooseVip.name == item.name?'checked':''}}" data-item="{{item}}" bind:tap="chooseVip">
+        <view  wx:for="{{vipType}}" wx:key="index" class="vipType_item {{chooseVip.name == item.name?'checked':''}}" data-item="{{item}}" bind:tap="chooseVip">
           <view class="vipType_item_title">{{item.name}}</view>
           <view class="vipType_item_price"><span wx:if="{{item.finalPrice || item.finalPrice == 0}}" style="font-size: 12px;">¥</span>{{item.finalPrice}}</view>
           <view class="vipType_item_currentPrice" wx:if="{{(item.price || item.price == 0) && item.finalPrice < item.price}}"><span wx:if="{{item.price || item.price == 0}}">¥</span>{{item.price}}</view>

+ 1 - 1
pages/monitor/monitoringRecord.wxml

@@ -9,7 +9,7 @@
   <view class="main">
     <my-scroll-view wx:if="{{tableData.length>0}}" triggered="{{triggered}}" load="{{load}}" hasMore="{{hasMore}}" bindonRefresh="onRefresh" bindloadMore="loadMore" customStyle="height: calc(100vh - 300rpx)">
       <view class="content">
-        <view wx:for="{{tableData}}" class="record" data-item="{{item}}" bind:tap="checkPatent">
+        <view wx:for="{{tableData}}" wx:key="index" class="record" data-item="{{item}}" bind:tap="checkPatent">
           <view>{{item.createTime}}</view>
           <view>
             您监控的