瀏覽代碼

增加用户隐私协议

dev01 1 年之前
父節點
當前提交
eaef624253

+ 5 - 4
project.config.json

@@ -7,7 +7,7 @@
         "urlCheck": false,
         "es6": false,
         "enhance": true,
-        "postcss": false,
+        "postcss": true,
         "preloadBackgroundData": false,
         "minified": true,
         "newFeature": false,
@@ -23,8 +23,8 @@
         "compileHotReLoad": false,
         "lazyloadPlaceholderEnable": false,
         "useMultiFrameRuntime": false,
-        "useApiHook": false,
-        "useApiHostProcess": false,
+        "useApiHook": true,
+        "useApiHostProcess": true,
         "babelSetting": {
             "ignore": [],
             "disablePlugins": [],
@@ -40,7 +40,8 @@
         "minifyWXML": true,
         "showES6CompileOption": false,
         "useCompilerPlugins": false,
-        "useStaticServer": true
+        "useStaticServer": true,
+        "condition": false
     },
     "compileType": "miniprogram",
     "condition": {},

+ 7 - 0
project.private.config.json

@@ -0,0 +1,7 @@
+{
+    "description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
+    "libVersion": "3.0.0",
+    "setting": {
+        "lazyloadPlaceholderEnable": false
+    }
+}

+ 2 - 1
src/app.config.js

@@ -63,5 +63,6 @@ export default {
       desc: "你的位置信息将用于小程序定位"
     }
   },
-  "lazyCodeLoading": "requiredComponents"
+  "lazyCodeLoading": "requiredComponents",
+  "__usePrivacyCheck__": true,
 }

+ 3 - 4
src/app.jsx

@@ -22,7 +22,7 @@ class App extends Component {
     updateManager.onCheckForUpdate(function (res) {
       // 请求完新版本信息的回调
       //console.log('请求完新版本信息的回调')
-      console.log(res.hasUpdate);
+      // console.log(res.hasUpdate);
     })
 
     updateManager.onUpdateReady(function () {
@@ -31,7 +31,6 @@ class App extends Component {
         content: '新版本已经准备好,是否重启应用?',
         success(res) {
           if (res.confirm) {
-            console.log("go")
             // 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
             updateManager.applyUpdate()
           }
@@ -88,11 +87,11 @@ class App extends Component {
         'token': token,
       },
       // 生产
-      // url: 'wss://bm.jishutao.com/webSocketServer',
+      url: 'wss://bm.jishutao.com/webSocketServer',
       // 本地
       // url: 'wss://172.16.0.255:8080/webSocketServer'
       // 测试
-      url: 'wss://uat.jishutao.com/webSocketServer'
+      // url: 'wss://uat.jishutao.com/webSocketServer'
     })
 
     //连接成功

+ 56 - 0
src/components/common/privacy/privacy.js

@@ -0,0 +1,56 @@
+Component({
+  /**
+   * 组件的初始数据
+   */
+  data: {
+    privacyContractName: '',
+    showPrivacy: false
+  },
+  /**
+   * 组件的生命周期
+   */
+  lifetimes: {
+    attached() {
+      const _ = this
+      wx.getPrivacySetting({
+        success(res) {
+          if (res.errMsg == "getPrivacySetting:ok") {
+            _.setData({
+              privacyContractName: res.privacyContractName,
+              showPrivacy: res.needAuthorization
+            })
+          }
+        }
+      })
+    },
+  },
+  /**
+   * 组件的方法列表
+   */
+  methods: {
+    // 打开隐私协议页面
+    openPrivacyContract() {
+      const _ = this
+      wx.openPrivacyContract({
+        fail: () => {
+          wx.showToast({
+            title: '遇到错误',
+            icon: 'error'
+          })
+        }
+      })
+    },
+    // 拒绝隐私协议
+    exitMiniProgram() {
+      // 直接退出小程序
+      wx.exitMiniProgram()
+    },
+    // 同意隐私协议
+    handleAgreePrivacyAuthorization() {
+      const _ = this
+      _.setData({
+        showPrivacy: false
+      })
+    },
+  },
+})

+ 4 - 0
src/components/common/privacy/privacy.json

@@ -0,0 +1,4 @@
+{
+  "component": true,
+  "usingComponents": {}
+}

+ 13 - 0
src/components/common/privacy/privacy.wxml

@@ -0,0 +1,13 @@
+<!--component/privacy/privacy.wxml-->
+<view class="privacy" wx:if="{{showPrivacy}}">
+    <view class="content">
+        <view class="title">隐私保护指引</view>
+        <view class="des">
+            在使用当前小程序服务之前,请仔细阅读<text class="link" bind:tap="openPrivacyContract">{{privacyContractName}}</text>。如你同意{{privacyContractName}},请点击“同意”开始使用。
+        </view>
+        <view class="btns">
+            <button class="item reject" bind:tap="exitMiniProgram">拒绝</button>
+            <button id="agree-btn" class="item agree" open-type="agreePrivacyAuthorization" bindagreeprivacyauthorization="handleAgreePrivacyAuthorization">同意</button>
+        </view>
+    </view>
+</view>

+ 68 - 0
src/components/common/privacy/privacy.wxss

@@ -0,0 +1,68 @@
+/* component/privacy/privacy.wxss */
+.privacy {
+    position: fixed;
+    top: 0;
+    right: 0;
+    bottom: 0;
+    left: 0;
+    background: rgba(0, 0, 0, .5);
+    z-index: 9999999;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+}
+
+.content {
+    width: 632rpx;
+    padding: 48rpx;
+    box-sizing: border-box;
+    background: #fff;
+    border-radius: 16rpx;
+}
+
+.content .title {
+    text-align: center;
+    color: #333;
+    font-weight: bold;
+    font-size: 32rpx;
+}
+
+.content .des {
+    font-size: 26rpx;
+    color: #666;
+    margin-top: 40rpx;
+    text-align: justify;
+    line-height: 1.6;
+}
+
+.content .des .link {
+    color: #07c160;
+    text-decoration: underline;
+}
+
+.btns {
+    margin-top: 48rpx;
+    display: flex;
+}
+
+.btns .item {
+    justify-content: space-between;
+    width: 244rpx;
+    height: 80rpx;
+    display: flex;
+    align-items: center;
+    justify-content: center;
+    border-radius: 16rpx;
+    box-sizing: border-box;
+    border: none;
+}
+
+.btns .reject {
+    background: #f4f4f5;
+    color: #909399;
+}
+
+.btns .agree {
+    background: #07c160;
+    color: #fff;
+}

+ 4 - 1
src/pages/login/index.config.js

@@ -1,4 +1,7 @@
 export default {
   navigationBarTitleText: '登录',
-  navigationStyle:'custom'
+  navigationStyle:'custom',
+  usingComponents: {
+    privacy: '../../components/common/privacy/privacy'
+  }
 }

+ 115 - 114
src/pages/login/index.jsx

@@ -1,12 +1,12 @@
 import { Component } from 'react'
 import Taro from '@tarojs/taro'
 import { connect } from 'react-redux'
-import {View, Input, Image} from '@tarojs/components'
-import {login,getWorkingHours,setOpenId} from '../../utils/servers/servers';
+import { View, Input, Image } from '@tarojs/components'
+import { login, getWorkingHours, setOpenId } from '../../utils/servers/servers';
 
 import { add, minus, asyncAdd } from '../../actions/counter'
 
-import { AtButton,AtIcon,AtModal  } from 'taro-ui'
+import { AtButton, AtIcon, AtModal } from 'taro-ui'
 
 import NavBar from '../../components/common/NavBar';
 
@@ -17,33 +17,33 @@ import 'taro-ui/dist/style/components/loading.scss';
 import 'taro-ui/dist/style/components/icon.scss';
 import 'taro-ui/dist/style/components/modal.scss';
 
-import selectIcon from '../../image/select.png' ;
+import selectIcon from '../../image/select.png';
 
 import './index.less'
 
 @connect(({ counter }) => ({
   counter
 }), (dispatch) => ({
-  add () {
+  add() {
     dispatch(add())
   },
-  dec () {
+  dec() {
     dispatch(minus())
   },
-  asyncAdd () {
+  asyncAdd() {
     dispatch(asyncAdd())
   }
 }))
 class Login extends Component {
   constructor(props) {
     super(props);
-    this.state={
-      username:'',
-      password:'',
-      isOpened:false,
-      openedType:0,
-      usernameList:Taro.getStorageSync('usernameList') || [],
-      rememberPassword:true
+    this.state = {
+      username: '',
+      password: '',
+      isOpened: false,
+      openedType: 0,
+      usernameList: Taro.getStorageSync('usernameList') || [],
+      rememberPassword: true,
     }
     this.login = this.login.bind(this);
     this.authorization = this.authorization.bind(this);
@@ -52,7 +52,7 @@ class Login extends Component {
     this.getWorkingHours = this.getWorkingHours.bind(this);
   }
 
-  componentDidShow () {
+  componentDidShow() {
 
   }
 
@@ -60,21 +60,21 @@ class Login extends Component {
 
   }
 
-  authorization(){
+  authorization() {
     this.setState({
-      loading:true,
+      loading: true,
     })
-    let _this= this;
+    let _this = this;
     Taro.getSetting({
       withSubscriptions: true,
-      success:(res)=>{
+      success: (res) => {
         //console.log(res.subscriptionsSetting,'res.subscriptionsSetting')
-        if(res.subscriptionsSetting.mainSwitch){
-          if(res.subscriptionsSetting['j7WH3EwQnxGxwuV2HwmJhryxySPE8vOiV5cVOpp-42I'] === "reject" || res.subscriptionsSetting['pWia-KJPFwDM8ReDu_BOa9FJn31VFc81bp3yxfBmIRI'] === "reject" || res.subscriptionsSetting['vo28uzT2sLS-9ioroNyZbMSvu0mMvf6le2pDZVN891U'] === "reject"){
+        if (res.subscriptionsSetting.mainSwitch) {
+          if (res.subscriptionsSetting['j7WH3EwQnxGxwuV2HwmJhryxySPE8vOiV5cVOpp-42I'] === "reject" || res.subscriptionsSetting['pWia-KJPFwDM8ReDu_BOa9FJn31VFc81bp3yxfBmIRI'] === "reject" || res.subscriptionsSetting['vo28uzT2sLS-9ioroNyZbMSvu0mMvf6le2pDZVN891U'] === "reject") {
             this.setState({
-              isOpened:true,
-              loading:false,
-              openedType:1
+              isOpened: true,
+              loading: false,
+              openedType: 1
             })
             return;
           }
@@ -84,36 +84,36 @@ class Login extends Component {
               'j7WH3EwQnxGxwuV2HwmJhryxySPE8vOiV5cVOpp-42I',
               'vo28uzT2sLS-9ioroNyZbMSvu0mMvf6le2pDZVN891U'
             ], //此处写在后台获取的模板ID,可以写多个模板ID,看自己的需求
-             success: function (s) {
-                _this.setState({
-                  loading:false,
-                })
-               _this.login();
+            success: function (s) {
+              _this.setState({
+                loading: false,
+              })
+              _this.login();
             },
             fail: function (err) {
               _this.setState({
-                loading:false,
+                loading: false,
               })
               //console.log(err)
             }
           })
-        }else{
+        } else {
           this.setState({
-            isOpened:true,
-            loading:false,
+            isOpened: true,
+            loading: false,
           })
         }
       },
-      fail:()=>{
+      fail: () => {
         this.setState({
-          loading:false,
+          loading: false,
         })
       }
     })
   }
 
-  login(){
-    if(!this.state.username){
+  login() {
+    if (!this.state.username) {
       Taro.showToast({
         title: '请输入用户名',
         icon: 'none',
@@ -121,7 +121,7 @@ class Login extends Component {
       })
       return;
     }
-    if(!this.state.password){
+    if (!this.state.password) {
       Taro.showToast({
         title: '请输入密码',
         icon: 'none',
@@ -130,87 +130,87 @@ class Login extends Component {
       return;
     }
     this.setState({
-      loading:true,
+      loading: true,
     })
     login({
-      username:this.state.username,
-      password:this.state.password
-    }).then((msg)=>{
+      username: this.state.username,
+      password: this.state.password
+    }).then((msg) => {
       this.setState({
-        loading:false
+        loading: false
       });
-      if(!msg.data.openId){
+      if (!msg.data.openId) {
         Taro.login({
-          success: (res)=>{
+          success: (res) => {
             setOpenId({
-              code:res.code,
-            }).then(v=>{
-              if(v.error.length === 0){
-                this.setUsernameList(this.state.username,this.state.password);
+              code: res.code,
+            }).then(v => {
+              if (v.error.length === 0) {
+                this.setUsernameList(this.state.username, this.state.password);
                 Taro.eventCenter.trigger('getStorageSync');
                 this.getWorkingHours(msg.data.departmentId);
-              }else{
+              } else {
                 Taro.showToast({
-                  title:v.error[0].message,
-                  icon:'none',
+                  title: v.error[0].message,
+                  icon: 'none',
                 })
               }
             })
           },
-          fail:()=>{
-            Taro.showToast({title:'系统错误,请稍后重试'})
+          fail: () => {
+            Taro.showToast({ title: '系统错误,请稍后重试' })
           }
         });
-      }else{
-        this.setUsernameList(this.state.username,this.state.password);
+      } else {
+        this.setUsernameList(this.state.username, this.state.password);
         Taro.eventCenter.trigger('getStorageSync');
         this.getWorkingHours(msg.data.departmentId);
       }
-    }).catch((err)=>{
+    }).catch((err) => {
       //console.log(err)
       this.setState({
-        loading:false
+        loading: false
       })
     })
   }
 
-  getWorkingHours(depId){
+  getWorkingHours(depId) {
     getWorkingHours({
       depId
-    }).then((msg)=>{
-      if(msg.error.length === 0){
+    }).then((msg) => {
+      if (msg.error.length === 0) {
         let obj = Taro.getStorageSync('userInfor');
         obj.workTimeInfor = msg.data;
         Taro.setStorageSync('userInfor', obj);
         Taro.switchTab({
           url: '/pages/punchClock/index',
         })
-      }else{
-        Taro.showToast({title:msg.error[0].message,icon:'none'})
+      } else {
+        Taro.showToast({ title: msg.error[0].message, icon: 'none' })
       }
-    }).catch((err)=>{
+    }).catch((err) => {
       // console.log(err)
     })
   }
 
-  setUsernameList(username,password){
-    if(!this.state.rememberPassword){
+  setUsernameList(username, password) {
+    if (!this.state.rememberPassword) {
       let usernameList = Taro.getStorageSync('usernameList') || [];
-      let index = usernameList.findIndex(v=>v.username === username);
-      if(index !== -1){
-        usernameList.splice(index,1)
+      let index = usernameList.findIndex(v => v.username === username);
+      if (index !== -1) {
+        usernameList.splice(index, 1)
       }
       Taro.setStorageSync('usernameList', usernameList);
-    }else{
+    } else {
       let usernameList = Taro.getStorageSync('usernameList') || [];
-      let index = usernameList.findIndex(v=>v.username === username);
-      if(index === -1){
+      let index = usernameList.findIndex(v => v.username === username);
+      if (index === -1) {
         usernameList.push({
           username,
           password
         })
-      }else{
-        usernameList[index]={
+      } else {
+        usernameList[index] = {
           username,
           password
         }
@@ -219,25 +219,25 @@ class Login extends Component {
     }
   }
 
-  getUsernameList(value = this.state.username){
+  getUsernameList(value = this.state.username) {
     let usernameList = Taro.getStorageSync('usernameList') || [];
     let arr = [];
-    for(let i of usernameList){
-      if(i.username.indexOf(value) !== -1){
+    for (let i of usernameList) {
+      if (i.username.indexOf(value) !== -1) {
         arr.push(i)
       }
     }
     this.setState({
-      usernameList:arr,
-      isopenUsernameList:true
+      usernameList: arr,
+      isopenUsernameList: true
     })
   }
 
-  render () {
+  render() {
     return (
-      <View className='login' onClick={()=>{
+      <View className='login' onClick={() => {
         this.setState({
-          isopenUsernameList:false
+          isopenUsernameList: false
         })
       }}>
         <NavBar
@@ -245,32 +245,33 @@ class Login extends Component {
           title='科德集团'
           background='#0000'
           color='#FFF'
-          onHome={()=>{}}
+          onHome={() => { }}
         />
         <View className='welcome'>
-          <Image src={BG} className='bg' mode='heightFix'/>
+          <Image src={BG} className='bg' mode='heightFix' />
           <View className='welcomeTitle'>科德科技服务系统</View>
           <View className='welcomeTitle'>欢迎您!</View>
         </View>
+        <privacy />
         <View className='loginContent'>
           <View className='loginItem'>
-            <AtIcon value='user' size='20' color='#999999'/>
+            <AtIcon value='user' size='20' color='#999999' />
             <View className='usernameContent'>
               <Input
-                style={{marginLeft:'15px',width:'100%'}}
+                style={{ marginLeft: '15px', width: '100%' }}
                 type='text'
                 placeholder='请输入您的系统账户'
                 value={this.state.username}
-                onInput={(v)=>{
+                onInput={(v) => {
                   this.setState({
                     username: v.detail.value
                   })
                   this.getUsernameList(v.detail.value);
                 }}
-                onFocus={()=>{
+                onFocus={() => {
                   this.getUsernameList();
                 }}
-                onBlur={()=>{
+                onBlur={() => {
                   // this.setState({
                   //   isopenUsernameList:false
                   // })
@@ -279,17 +280,17 @@ class Login extends Component {
             </View>
           </View>
           <View className='usernameListContent'>
-            {this.state.isopenUsernameList && this.state.usernameList.length >0 ? <View className='usernameList'>
+            {this.state.isopenUsernameList && this.state.usernameList.length > 0 ? <View className='usernameList'>
               {
-                this.state.usernameList.map((v,k)=>(
-                  <View key={k} className='usernameItem' onClick={()=>{
+                this.state.usernameList.map((v, k) => (
+                  <View key={k} className='usernameItem' onClick={() => {
                     this.setState({
-                      username:v.username,
-                      password:v.password,
-                      isopenUsernameList:false
+                      username: v.username,
+                      password: v.password,
+                      isopenUsernameList: false
                     })
                   }}>
-                    <AtIcon value='user' size='20' color='#c6c4c4'/>
+                    <AtIcon value='user' size='20' color='#c6c4c4' />
                     <View className='value'>
                       <View className='name'>{v.username}</View>
                       <View className='password'>*******</View>
@@ -300,13 +301,13 @@ class Login extends Component {
             </View> : null}
           </View>
           <View className='loginItem'>
-            <AtIcon value='lock' size='20' color='#999999'/>
+            <AtIcon value='lock' size='20' color='#999999' />
             <Input
-              style={{marginLeft:'15px',width:'100%'}}
+              style={{ marginLeft: '15px', width: '100%' }}
               type='password'
               placeholder='请输入密码'
               value={this.state.password}
-              onInput={(v)=>{
+              onInput={(v) => {
                 this.setState({
                   password: v.detail.value
                 })
@@ -314,16 +315,16 @@ class Login extends Component {
             />
           </View>
           <View className='rememberPassword'>
-            <View className='selectContent' onClick={()=>{
+            <View className='selectContent' onClick={() => {
               this.setState({
-                rememberPassword:!this.state.rememberPassword
+                rememberPassword: !this.state.rememberPassword
               })
             }}>
-              <Image src={selectIcon} className='selectIcon' style={{visibility:this.state.rememberPassword ? "visible" : "hidden"}}/>
+              <Image src={selectIcon} className='selectIcon' style={{ visibility: this.state.rememberPassword ? "visible" : "hidden" }} />
             </View>
             记住密码
           </View>
-          <AtButton type='primary' 	circle loading={this.state.loading} onClick={this.authorization}>登录</AtButton>
+          <AtButton type='primary' circle loading={this.state.loading} onClick={this.authorization}>登录</AtButton>
           <View className='tips'>
             暂无账号?请联系管理员进行添加
           </View>
@@ -336,25 +337,25 @@ class Login extends Component {
           title='提醒'
           cancelText='取消'
           confirmText='确认'
-          onClose={()=>{
+          onClose={() => {
             this.setState({
-              isOpened:false,
-              openedType:0,
+              isOpened: false,
+              openedType: 0,
             })
           }}
-          onCancel={()=>{
+          onCancel={() => {
             this.setState({
-              isOpened:false,
-              openedType:0
+              isOpened: false,
+              openedType: 0
             })
           }}
-          onConfirm={()=>{
+          onConfirm={() => {
             this.setState({
-              isOpened:false,
-              openedType:0
-            },()=>{
+              isOpened: false,
+              openedType: 0
+            }, () => {
               Taro.openSetting({
-                success:(value)=> {
+                success: (value) => {
 
                 }
               })

+ 3 - 0
src/pages/punchClock/index.config.js

@@ -1,3 +1,6 @@
 export default {
   navigationBarTitleText: '打卡',
+  usingComponents: {
+    privacy: '../../components/common/privacy/privacy'
+  }
 }

+ 1 - 0
src/pages/punchClock/index.jsx

@@ -103,6 +103,7 @@ class PunchClock extends Component {
           onConfirm={this.handleConfirm}
           content='您确定是否切换位置?切换位置,将重新提交“公出审核”,如您的公出审核已通过,则需再次审核。'
         />
+        <privacy />
       </>
     )
   }

+ 6 - 1
src/pages/punchClock/punchClocks.jsx

@@ -151,8 +151,12 @@ class PunchClocks extends Component {
   }
 
   componentWillMount() {
+    let obj = Taro.getStorageSync('userInfor');
+    if (!obj) {
+      // 判断是否登录
+      return
+    }
     this.wxConfig = Taro.getStorageSync('wxConfig');
-
     //获得当前位置
     Taro.getLocation({
       type: 'gcj02',
@@ -287,6 +291,7 @@ class PunchClocks extends Component {
       })
     })
   }
+
   // 异常打卡
   abnormalClockIn() {
     if (!this.state.clockInRemarks) {

+ 2 - 2
src/utils/config.js

@@ -1,7 +1,7 @@
 // 本地
 // export const resourceAddress = 'http://172.16.0.255:3000/upload;'
 // 生产
-// export const resourceAddress = 'https://s.jishutao.com/upload';
+export const resourceAddress = 'https://s.jishutao.com/upload';
 // 测试
-export const resourceAddress = 'https://static.jishutao.com/upload';
+// export const resourceAddress = 'https://static.jishutao.com/upload';
 

+ 2 - 2
src/utils/servers/baseUrl.js

@@ -8,8 +8,8 @@ const getBaseUrl = (url) => {
   } else {
     // 生产环境
     // BASE_URL = 'http://172.16.0.255:8080'
-    BASE_URL = 'https://uat.jishutao.com'
-    // BASE_URL = 'https://bm.jishutao.com'
+    // BASE_URL = 'https://uat.jishutao.com'
+    BASE_URL = 'https://bm.jishutao.com'
   }
   return BASE_URL
 }