Initial commit

This commit is contained in:
易焱
2021-03-13 18:42:01 +08:00
commit d9a3c376d5
3243 changed files with 627198 additions and 0 deletions
@@ -0,0 +1,14 @@
<?php
namespace Member\Controller;
use Think\Controller;
class BaseController extends \Home\Controller\BaseController{
public function _initialize(){
$this->error("未开放会员注册");
$member_id = session("member.member_id");
if(!$member_id){
$this->error("请先登录",U('Member/Public/login'));
}
//这里要调用一下home下的_initialize方法,否则无法显示购物数量
parent::_initialize();
}
}
@@ -0,0 +1,228 @@
<?php
namespace Member\Controller;
/**
* 用户中心类 继承判断是否用户登录
* Class IndexController
* @package Member\Controller
*/
class IndexController extends BaseController
{
public function __construct()
{
parent::__construct();
$this->table = D("Member");
}
public function index()
{
$ShopOrder = D("Shop/ShopOrder");
//不同状态下的订单统计
$this->readyPayt=$ShopOrder->relation(true)->where(array(
"member_id"=>session("member.member_id"),
"status_code"=>101,
))->order("order_id desc")->select();
$this->readyPaytCount=count($this->readyPayt);
$this->readyDelivery=$ShopOrder->relation(true)->where(array(
"member_id"=>session("member.member_id"),
"status_code"=>102,
))->order("order_id desc")->select();
$this->readyDeliveryCount=count($this->readyDelivery);
$this->readyReceipt=$ShopOrder->relation(true)->where(array(
"member_id"=>session("member.member_id"),
"status_code"=>103,
))->order("order_id desc")->select();
$this->readyReceiptCount=count($this->readyReceipt);
$this->display();
}
public function company_info(){
if(IS_POST){
if(!$data = $this->table->create()){
$this->error($this->table->getError());
}
$data['member_id'] = session("member.member_id");
$this->table->save($data);
$this->success("保存成功");
}
$where['catid'] = 4;
$where['catid'] = 5;
$this->data = $this->table->find(session('member.member_id'));
$this->pagetitle="公司新闻";
$this->navLight="gsxx";//菜单高亮
$this->display();
}
public function address(){
$this->address = D("MemberAddress");
if(IS_POST){
if(!$data = $this->address->create()){
$this->error($this->address->getError());
}
$this->address->save($data);
$this->success("保存成功");
}
$where["member_id"] = session("member.member_id");
$this->data = $this->address->where($where)->order("sh_status desc,sp_status desc")->select();
$this->pagetitle="收件地址";
$this->navLight="sjdz";//菜单高亮
$this->display();
}
public function getAddressInfo(){
$address = M("member_address");
$where["member_id"] = session("member.member_id");
$where["id"] = I('id');
$data = $address->where($where)->find();
if(!$data){
$this->error("你没有此地址");
}
$this->success($data);
}
public function delete(){
$address = M("member_address");
$where["member_id"] = session("member.member_id");
$where["id"] = I('id');
$data = $address->where($where)->delete();
$this->success($data);
}
public function setDefault(){
$shid = I("setsh");
$spid = I("setsp");
$this->address = D("MemberAddress");
$this->address->setDefault($shid,$spid);
$this->success();
}
public function setDefaultInvoice(){
$id = I("id");
$this->invoice = D("MemberInvoice");
$this->invoice->setDefault($id);
$this->success();
}
public function invoice(){
$this->invoice = D("MemberInvoice");
if(IS_POST){
//发果发票类型为普通发票,删除增值税相关字段
if(I("type")==0){
unset($_POST["registration_address"]);unset($_POST["registration_mobile"]);unset($_POST["opening_bank"]);unset($_POST["bank_account"]);
}
//
if(!$data = $this->invoice->create()){
$this->error($this->invoice->getError());
}
$this->invoice->save($data);
$this->success("保存成功");
}
$where["member_id"] = session("member.member_id");
$this->data = $this->invoice->where($where)->order("status desc")->select();
$this->pagetitle="发票信息";
$this->navLight="fpxx";//菜单高亮
$this->display();
}
public function getInvoiceInfo(){
$invoice = D("MemberInvoice");
$where["member_id"] = session("member.member_id");
$where["id"] = I('id');
$data = $invoice->where($where)->find();
if(!$data){
$this->error("你没有此发票信息");
}
$this->success($data);
}
public function deleteInvoice(){
$invoice = M("member_invoice");
$where["member_id"] = session("member.member_id");
$where["id"] = I('id');
$data = $invoice->where($where)->delete();
$this->success($data);
}
public function update_pwd(){
if(IS_POST){
$data = $this->table->updatePassword();
if(!$data){
$this->error($this->table->getError());
}
$this->success($this->table->getError());
}
$this->pagetitle="修改密码";
$this->display();
}
public function safe(){
$this->navLight="aqzx";//菜单高亮
$this->display();
}
public function change_mobile(){
if(IS_POST){
$data = $this->table->checkCode();
if(!$data){
$this->error($this->table->getError());
}
$this->success($this->table->getError());
}
$this->pagetitle="更换手机号码";
$this->navLight="aqzx";//菜单高亮
$this->display();
}
public function change_mobile2(){
$update_mobile = session("update_mobile");
if($update_mobile != 1){
$this->error("错误的方式");
}
if(IS_POST){
$data = $this->table->checkCodeAndSaveMobile();
if(!$data){
$this->error($this->table->getError());
}
$this->success($this->table->getError());
}
$this->pagetitle="更换手机号码";
$this->navLight="aqzx";//菜单高亮
$this->display();
}
public function change_mobile3(){
$this->pagetitle="更换手机号码";
$this->navLight="aqzx";//菜单高亮
$this->display();
}
// 发送短信验证码
public function sendMobileCode()
{
$mobile = session("member.mobile");
if(!$this->table->sendCode($mobile)){
return $this->error($this->table->getError());
}
return $this->success("发送成功");
}
}
@@ -0,0 +1,136 @@
<?php
namespace Member\Controller;
use Think\Controller;
class PublicController extends Controller
{
public function __construct()
{
parent::__construct();
$this->table = D("Public");
}
//注册
public function register(){
if (IS_POST ) {
//表单验证
if (!$data = $this->table->create()) {
//验证失败 弹出错误信息
$this->error($this->table->getError());
} else {
if($member_id=$this->table->save($data)){
$member_r=$this->table->find($member_id);
$this->table->setLogin($member_r);
//验证成功 把数据暂时存入到session中
$this->success($this->table->getError());
}else{
$this->error($this->table->getError());
}
}
} else {
$this->pagetitle="用户注册";
$this->display();
}
}
// 发送短信验证码
public function sendMobileCode(){
$mobile = I('get.mobile');
if(!$this->table->sendCode($mobile)){
return $this->error($this->table->getError());
}
return $this->success("发送成功");
}
//用户登陆
public function login(){
$this->table->logout();
if (IS_POST) {
if (!$this->table->create2()) {
$this->error($this->table->getError());
} else {
if($this->table->checkLogin()){
$this->success("登录成功");
}else{
$this->error($this->table->getError());
}
}
} else {
$this->pagetitle="用户登录";
$this->display();
}
}
public function forget(){
if (IS_POST) {
$rules = array(
array('mobile', 'require', '请输入手机号码!'), //默认情况下用正则进行验证
array('mobile', '/^1[3|4|5|7|8][0-9]\d{4,8}$/', '手机号码错误!', '0', 'regex', 1),
array('password', 'require', '请输入新密码!'), //默认情况下用正则进行验证
array("password","6,40","密码长度需要6位以上",2,"length"),
array('repassword','password','确认密码不正确',0,'confirm'), // 验证确认密码是否和密码一致
);
$data =D("member")->validate($rules)->create();
if (!$data) {//验证
$this->error(D("member")->getError());
} else {
//手机验证码验证
$MobileVerifyCode = new \Org\MobileVerify\MobileVerifyCode();
$result = $MobileVerifyCode->check($data['mobile'], I("post.verifycode"));
if (!$result) {
$this->error($MobileVerifyCode->error);
} else {
$where["mobile"] = $data["mobile"];
$data["password"] = md6($data["password"]);
D("member")->where($where)->save($data);
$this->success();
}
}
} else {
$this->pagetitle="忘记密码";
$this->display();
}
}
//修改密码验证码发送
public function forget_mobile_code()
{
# code...
$mobile = I("get.mobile");
$rules = array(
array('mobile', 'require', '请输入手机号码!'), //默认情况下用正则进行验证
array('mobile', '/^1[3|4|5|7|8][0-9]\d{4,8}$/', '手机号码错误!', '0', 'regex', 1),
);
$member = M("member");
if (!$member->validate($rules)->create($_GET)) {
$this->error($member->getError());
} else {
$count = $member->where(array("mobile" => I("get.mobile")))->count();
if ($count != 1) {
$this->error("没有此用户");
}
$MobileVerifyCode = new \Org\MobileVerify\MobileVerifyCode();
$result = $MobileVerifyCode->send_code($mobile);
if (!$result) {
$this->error($MobileVerifyCode->error);
} else {
$this->success("发送成功");
}
}
}
//用户退出
public function logout()
{
//清除session
$this->table->logout();
$this->redirect("/");
}
public function form(){
if(IS_POST){
var_dump($_FILES);
var_dump($_POST);
}
$this->display();
}
}
@@ -0,0 +1,72 @@
<?php
namespace Member\Controller;
use Think\Controller;
class TougaoController extends BaseController{
public function __construct(){
parent::__construct();
$this->modelid=I("modelid",0,"int");
$this->table=D("Tougao");
//
$this->modelform=APP_PATH.'Data/modelTempMember/'.$this->modelid.".php";
}
//首页
public function index(){
$this->data=M("model")->where("contribute=1 and status=1")->order("sort asc,modelid desc")->select();
$this->display();
}
public function add(){
if(IS_POST){
if (!$this->table->relation(true)->create()){//验证
$this->error($this->table->relation(true)->getError());
}
$result=$this->table->data_add();
if(!$result){
$this->error($this->table->getError());
}
$this->success($result);
}else{
$this->pubid=make_pubid();
$this->display();
}
}
public function editor(){
if(IS_POST){
if (!$this->table->create()){//验证
$this->error($this->table->getError());
}
$result=$this->table->data_editor();
if(!$result){
$this->error($this->table->getError());
}
$this->success($data);
}else{
$id=I("get.id",0,"int");
$r=$this->table->relation(true)->find($id);
if(!$r){$this->error("信息不存在");};
//副表数据合并
if($r["cms_".$this->modelinfo[table_name]."_data"]){
$newdata=array_merge($r,$r["cms_".$this->modelinfo[table_name]."_data"]);
unset($newdata["cms_".$this->modelinfo[table_name]."_data"]);
$r=$newdata;
}
//选中分类
$this->catid=$r[catid];
$this->cat=$this->getCat();
//
$this->assign("r",$r);
$this->display();
}
}
//删除
public function delete(){
$ids=I("ids");
$result=$this->table->data_delete($ids);
if(!$result){
$this->error($this->table->getError());
}
$this->success("删除成功");
}
}
@@ -0,0 +1 @@