Your Name 3 vuotta sitten
vanhempi
commit
8941d5c447

+ 4 - 1
learn/active/lib/Active.php

@@ -5,11 +5,14 @@ namespace Active\Lib;
 use Dever;
 class Active
 {
-    public function action($uid, $active_id, $num, $path, $remark = false)
+    public function action($uid, $active_id, $num, $path, $remark = false, $idcard = false)
     {
     	$user = Dever::db('active/user')->find($uid);
 		// print_R(json_decode('[{"id":"1","value":"文本"},{"id":"2","value":"文本"},{"id":"3","value":"1"}]'));die;
 		$data = Dever::db('active/info')->find($active_id);
+		if ($data['col'] && $data['col'] == 'idcard' && (!$idcard || !preg_match(Dever::rule('idcard'), $idcard))){
+			Dever::alert('身份证号不能为空或身份证号不正确');
+		}
 		// if ($data['act_status'] == 1 || (isset($data['act_start']) && $data['act_start'] && time() < $data['sign_start'])) {
 		// 	Dever::alert('活动还未开始报名');
 		// }

+ 1 - 4
learn/active/lib/Manage.php

@@ -237,17 +237,14 @@ Class Manage
         $field_svalue = '';
         $path = array();
         if ($info['path']) {
-            $path = json_decode($info['path']);
-            // print_R($path);die;
+            $path = Dever::json_decode($info['path']);
             foreach ($path as $k => $v) {
-                $v = (array)$v;
                 $field = Dever::db('active/info_field')->find($v['id']);
                 if ($field['type'] == 1) {
                     $field_name = $field['name'];
                     $field_value = $v['value'];
                 } elseif ($field['type'] == 2) {
                     $value = Dever::db('active/info_field_value')->find($v['value']);
-                    // print_R($value['name']);die;
                     if ($value) {
                         $field_sname = $field['name'];
                         $field_svalue = $value['name'];

+ 27 - 4
learn/active/src/Home.php

@@ -104,12 +104,12 @@ Class Home extends Core
 			}
 		}
 		if ($uid) {
+			$user = Dever::db('active/user')->find($uid);
 			$where['where_id'] = $uid;
 			$where['name'] = $data['name'];
-			if ($data['idcard']) {
+			if (!$user['idcard'] && $data['idcard']) {
 				$where['idcard'] = $data['idcard'];
 			}
-			
 			Dever::db('active/user')->update($where); 
 		}
 		$result = array();
@@ -125,8 +125,31 @@ Class Home extends Core
 		}
 		$remark = Dever::input('remark');
 		$path = Dever::input('path');
-
-		$result += Dever::load('active/lib/active')->action($uid, $id, $num, $path, $remark);
+		if (!$data['idcard']) {
+			$data['idcard'] = '';
+		}
+		if ($path) {
+			$p = Dever::json_decode($path);
+			$pa = array();
+			if (isset($p) && $p){
+				foreach ($p as $k => $v){
+					$pa[$v['id']] = $v; 
+				}
+			}
+		}
+		$field = Dever::db('active/info_field')->getList(array('active_id'=>$id,'state'=>1));
+		if ($field) {
+			foreach ($field as $k => $v) {
+				if ($v['is_must'] == 1) {
+					if (!isset($pa[$v['id']])) {
+						Dever::alert($v['name'].'不能为空');
+					} elseif (isset($pa[$v['id']]) && !$pa[$v['id']]) {
+						Dever::alert($v['name'].'不能为空');
+					}
+				}
+			}
+		}
+		$result += Dever::load('active/lib/active')->action($uid, $id, $num, $path, $remark,$data['idcard']);
 		return $result;
 	}
 

+ 1 - 1
learn/active/src/User.php

@@ -290,7 +290,7 @@ Class User extends Core
     	} else {
     		$data['user']['name'] = '匿名用户';
     	}
-    	$config = Dever::db('setting/base-one');
+    	$config = Dever::db('deploy/base-one');
     	$data['config']['phone'] = $config['phone'];
     	return $data;
     }

+ 75 - 0
learn/deploy/database/base.php

@@ -0,0 +1,75 @@
+<?php
+return array
+(
+	# 表名
+	'name' => 'base',
+	# 显示给用户看的名称
+	'lang' => '商学院系统配置',
+	'order' => 1,
+	# 数据结构
+	'struct' => array
+	(
+		'id' 		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '平台ID',
+			'default' 	=> '',
+			'desc' 		=> '',
+			'match' 	=> 'is_numeric',
+		),
+		
+		'name'		=> array
+		(
+			'type' 		=> 'varchar-32',
+			'name' 		=> '系统名称',
+			'default' 	=> '',
+			'desc' 		=> '请输入系统名称',
+			'match' 	=> 'is_string',
+			'update'	=> 'text',
+		),
+
+		'phone'      => array
+        (
+            'type'      => 'varchar-100',
+            'name'      => '客服电话',
+            'default'   => '',
+            'desc'      => '请输入客服电话',
+            'match'     => 'option',
+            'update'    => 'text',
+        ),
+		
+        'state'     => array
+        (
+            'type'      => 'tinyint-1',
+            'name'      => '状态',
+            'default'   => '1',
+            'desc'      => '请选择状态',
+            'match'     => 'is_numeric',
+        ),
+
+		'cdate'		=> array
+		(
+			'type' 		=> 'int-11',
+			'name' 		=> '录入时间',
+			'match' 	=> array('is_numeric', time()),
+			'desc' 		=> '',
+			# 只有insert时才生效
+			'insert'	=> true,
+		),
+	),
+
+	'default' => array
+	(
+		'col' => 'name,cdate',
+		'value' => array
+		(
+			'"商学院",' . time(),
+		),
+	),
+
+	'manage' => array
+	(
+		# 后台管理不要列表页
+		'list' => 'update',
+	),
+);

+ 10 - 0
learn/deploy/index.php

@@ -0,0 +1,10 @@
+<?php
+
+define('DEVER_APP_NAME', 'deploy');
+define('DEVER_APP_LANG', '基本配置');
+define('DEVER_APP_PATH', dirname(__FILE__) . DIRECTORY_SEPARATOR);
+define('DEVER_MANAGE_ORDER', 20);
+define('DEVER_MANAGE_ICON', 'glyphicon glyphicon-tower layui-icon-website');
+define('DEVER_GROUP_ORDER', 1);
+define('DEVER_GROUP_NAME', '商学院');
+include(DEVER_APP_PATH . '../boot.php');