毕业设计之 ----基于微信小程序的商城购物系统


前言

今天向大加介绍一个学长代做过的微信小程序毕设,微信商城信息管理系统,它是一套完全的微信小程序+微信后台管理系统程序。

该项目可以直接用于毕业设计,需要源码的同学,留言学长获取。


项目介绍

代码工程结构

platform-wechat-mall

|–platform-admin 后台管理

|–platform-api 微信小程序商城api接口

|–platform-common 公共模块

|–platform-framework 系统WEB合并,请打包发布此项目

|–platform-gen 代码生成

|–platform-mp 微信公众号模块

|–platform-schedule 定时任务

|–platform-shop 商城后台管理

|–wx-mall 微信小程序商城

|–platform-vue 微信公众号商城

前端技术

  • Vue2.5.1
  • iview
  • layer3.0.3
  • jquery2.2.4
  • bootstrap3.3.7
  • jqgrid5.1.1
  • ztree3.5.26
  • froala_editor1.2.2

后端技术

  • springframework4.3.7.RELEASE

  • mybatis3.1.0、MyBatis-Plus 3.1.0

  • shiro1.3.2

  • servlet3.1.0

  • druid1.0.28

  • slf4j1.7.19

  • fastjson1.2.30

  • poi3.15

  • velocity1.7

  • quartz2.2.3

  • mysql5.1.39

  • swagger2.4

  • j2cache2.3.22-release

  • weixin-java-mp3.2.0

  • MybatisPlus3.1.0

  • lombok

实现功能

一:会员管理

  • a 会员管理
  • b 会员等级
  • c 收货地址管理
  • d 会员优惠劵
  • e 会员收藏
  • f 会员足迹
  • g 搜索历史
  • h 购物车

二:商城配置

  • a 区域配置
  • b 商品属性种类
  • c 品牌制造商
  • d 商品规格
  • e 订单管理
  • f 商品类型
  • g 渠道管理
  • h 商品问答
  • i 反馈
  • j 关键词

三:商品编辑

  • a 所有商品
  • b 用户评论
  • c 产品设置
  • d 商品规格
  • e 商品回收站

四:推广管理

  • a 广告列表
  • b 广告位置
  • c 优惠劵管理
  • d 专题管理
  • e 专题分类

五:订单管理

  • a 所有订单管理

六:系统管理

  • a 管理员列表
  • b 角色管理
  • c 菜单管理
  • d SQL监控
  • e 定时任务
  • f 参数管理
  • g 代码生成器
  • h 系统日志
  • i 文件上传
  • j 通用字典表

七:短信服务平台

  • a 配置短信平台账户信息
  • b 向外提供发送短信接口:

运行效果

前端效果

在这里插入图片描述

后端效果

在这里插入图片描述
在这里插入图片描述

实现部分源码

前端布局
<view class="container">  
    <view wx:for="{
    
    {menus}}" wx:key="id" class="section">
      <view class="flex-wrp" style="flex-direction:row;">
      <image style="width: 500rpx; height: 200rpx; background-color: #eeeeee;" mode="aspectFill" src="{
    
    {item.image}}" bindtap="preview" data-imgsrc="{
    
    {item.image}}" >
      </image>
        <view class="flex-item">
         <text>{
    
    {
    
    item.name}}</text>\n
          <text class="flex-desc">{
    
    {
    
    item.description}}</text>\n
          <text class="red">¥ {
    
    {
    
    item.price}}</text>
          
        </view>   
              
      </view>
      <button type='primary' bindtap="onbuy" data-id="{
    
    {item.id}}">购买</button>  
    </view><!--section-->
</view><!--container-->
后端逻辑
namespace Api\Controller;
use Think\Controller;
class ShoppingController extends Controller {
    
    

	//***************************
	//  会员获取购物车列表接口
	//***************************
	public function index(){
    
    
        $shopping=M("shopping_char");
        $product=M("menu");
		$user_id = intval($_REQUEST['user_id']);
		if (!$user_id) {
    
    
			echo json_encode(array('status'=>0));
			exit();
		}

        /*$shop = $shopping->where(''.$qz.'shopping_char.uid='.intval($user_id))->join('left join __SHANGCHANG__ on __SHANGCHANG__.id = __SHOPPING_CHAR__.shop_id')->distinct(''.$qz.'shopping_char.shop_id')->field(''.$qz.'shangchang.id,'.$qz.'shangchang.name,'.$qz.'shangchang.logo')->select();
		foreach ($shop as $n=>$v){
    
    
			$shop[$n]['logo'] = __DATAURL__.$v['logo'];
        	$shop[$n]['slist']=$shopping->where(''.$qz.'shopping_char.uid='.intval($user_id).' and '.$qz.'shopping_char.shop_id='.intval($v['id']))->join('LEFT JOIN __PRODUCT__ ON __SHOPPING_CHAR__.pid = __PRODUCT__.id')->field(''.$qz.'shopping_char.id,'.$qz.'product.id as proid,'.$qz.'product.name,'.$qz.'product.num as pnum,'.$qz.'product.price_yh,'.$qz.'product.photo_x,'.$qz.'shopping_char.num,'.$qz.'shopping_char.buff,'.$qz.'shopping_char.price')->select();
			//获取产品规格名称
			foreach ($shop[$n]['slist'] as $k=>$vl){
    
    
        		$key=explode(',', $vl['buff']);
        		foreach ($key as $m=>$val){
    
    
        			$buff_text=M('guige')->where('id='.intval($val))->getField('name');
        			$shop[$n]['slist'][$k]['g_name'] .= '&nbsp;'.$buff_text;
        		}

        		$shop[$n]['slist'][$k]['photo_x'] = __DATAURL__.$vl['photo_x'];
        	}
		}*/

		$cart = $shopping->where('uid='.intval($user_id))->field('id,uid,pid,price,num')->select();
        foreach ($cart as $k => $v) {
    
    
        	$pro_info = $product->where('id='.intval($v['pid']))->field('name,image')->find();
        	$cart[$k]['pro_name']=$pro_info['name'];
        	$cart[$k]['photo_x']=$pro_info['image'];
        }

		echo json_encode(array('status'=>1,'cart'=>$cart));
		exit();
    }

	//购物车商品删除
	public function delete(){
    
    
		$shopping=M("shopping_char");
		$cart_id=intval($_REQUEST['cart_id']);
		$check_id = $shopping->where('id='.intval($cart_id))->getField('id');
		if (!$check_id) {
    
    
			echo json_encode(array('status'=>1));
			exit();
		}

	    $res = $shopping->where('id ='.intval($cart_id))->delete(); // 删除
		if($res){
    
    
			echo json_encode(array('status'=>1));
			exit();
		}else{
    
    
			echo json_encode(array('status'=>0));
			exit();
		}
	}

	//***************************
	//  会员修改购物车数量接口
	//***************************
	public function up_cart(){
    
    
		$shopping=M("shopping_char");
		$uid = intval($_REQUEST['user_id']);
		$cart_id = intval($_REQUEST['cart_id']);
		$num=intval($_REQUEST['num']);

		if (!$uid || !$cart_id || !$num) {
    
    
			echo json_encode(array('status'=>0,'err'=>'网络异常.'.__LINE__));
			exit();
		}

		$check = $shopping->where('id='.intval($cart_id))->find();
		if (!$check) {
    
    
			echo json_encode(array('status'=>0,'err'=>'购物车信息错误!'));
			exit();
		}


		
		$data=array();
		$data['num']=$num;

		$res = $shopping->where('id ='.intval($cart_id).' AND uid='.intval($uid))->save($data);
		if ($res) {
    
    
			echo json_encode(array('status'=>1,'succ'=>'操作成功!'));
			exit();
		}else{
    
    
			echo json_encode(array('status'=>0,'err'=>'操作失败.'));
			exit();
		}
		
	}

	//多个购物车商品删除
	public function qdelete(){
    
    
		$uid = intval($_REQUEST['uid']);
		if (!$uid) {
    
    
			echo json_encode(array('status'=>0,'err'=>'网络异常,请稍后再试.'));
			exit();
		}
		$shopping=M("shopping_char");
		$cart_id=trim($_REQUEST['cart_id'],',');
		if (!$cart_id) {
    
    
			echo json_encode(array('status'=>0,'err'=>'网络错误,请稍后再试.'));
			exit();
		}

	    $res = $shopping->where('id in ('.$cart_id.') AND uid='.intval($uid))->delete(); // 删除
		if($res){
    
    
			echo json_encode(array('status'=>1));
			exit();
		}else{
    
    
			echo json_encode(array('status'=>0,'err'=>'操作失败.'));
			exit();
		}
	}


	//添加购物车
	public function add(){
    
    
		$uid = intval($_REQUEST['uid']);
		if (!$uid) {
    
    
			echo json_encode(array('status'=>0,'err'=>'登录状态异常.'));
			exit();
		}

		$pid = intval($_REQUEST['id']);
		$num = 1;
		if (!intval($pid) || !intval($num)) {
    
    
			echo json_encode(array('status'=>0,'err'=>'参数错误.'));
			exit();
		}

		//加入购物车
		$check = $this->check_cart(intval($pid));
		if ($check['status']==0) {
    
    
			echo json_encode(array('status'=>0,'err'=>$check['err']));
			exit;
		}

		$check_info = M('menu')->where('id='.intval($pid).' AND status=1')->find();

		//判断库存
		if (!$check_info) {
    
    
			echo json_encode(array('status'=>0,'err'=>'没有这个商品!'));
			exit;
		}

		$shpp=M("shopping_char");
		// $shu=trim($_POST['val'],',');
		// if($shu){
    
    
		// 	//判断用户是否已经选择完规格,未选完则提示错误
		// 	$a = explode(',', $check_info['pro_buff']);
		// 	$b = explode(',', $shu);
		// 	if (count($a)!==count($b) || in_array('0', $b)) {
    
    
		// 		echo json_encode(array('status'=>0,'err'=>'请选择规格.'));
		// 		exit;
		// 	}
		// }else{
    
    
		// 	if ($check_info['pro_buff']) {
    
    
		// 		echo json_encode(array('status'=>0,'err'=>'请选择规格.'.__LINE__));
		// 	}
		// }

		//判断购物车内是否已经存在该商品
		$data = array();
		$cart_info = $shpp->where('pid='.intval($pid).' AND uid='.intval($uid))->field('id,num')->find();
		if ($cart_info) {
    
    
			$data['num'] = intval($cart_info['num'])+intval($num);

			$shpp->where('id='.intval($cart_info['id']))->save($data);
			$res = $cart_info['id'];
		}else{
    
    
			$data['pid']=intval($pid);
			$data['num']=intval($num);
			$data['addtime']=time();
			$data['uid']=intval($uid);
			$data['shop_id']=intval($check_info['shop_id']);
			$ptype = 1;
			if (intval($check_info['pro_type'])) {
    
    
				$ptype = intval($check_info['pro_type']);
			}
			$data['type']=$ptype;
			$data['price'] = $check_info['price'];

			$res=$shpp->add($data);
		}

		if($res){
    
    
			echo json_encode(array('status'=>1,'cart_id'=>$res)); //该商品已成功加入您的购物车
			exit;
		}else{
    
    
			echo json_encode(array('status'=>0,'err'=>'加入失败.'));
			exit;
		}
	}


	//***************************
	//  会员立即购买下单接口
	//***************************
	public function check_shop(){
    
    
		$cart_id = trim($_REQUEST['cart_id'],',');
		$id=explode(',',$cart_id);
		if (!$cart_id) {
    
    
			echo json_encode(array('status'=>0));
			exit();
		}

		foreach ($id as $k=>$v){
    
    
			$shoop[$k]=M("shopping_char")->where('id ='.intval($v))->field('shop_id,pid')->find();
        }

		foreach($shoop as $key => $value){
    
    
			$result[$key] = M("product")->where('id='.intval($value['pid']))->field('id,price,price_yh')->select();
			$price[] = i_array_column($result[$key], 'price_yh');
		}
		//dump($price);exit;
		foreach($price as $keys => $va){
    
    
			$str .= implode(",", $va).",";
		}
		$str = trim($str, ",");
		$parr = explode(",", $str);
		if(array_sum($parr) && in_array("0", $parr)){
    
    
			echo json_encode(array('status'=>0));
			exit();
		}
		
		$names = i_array_column($shoop, 'shop_id');
		
		$arr=array_unique($names);
		$val= sizeof($arr);
		if($val=='1'){
    
    
			echo json_encode(array('status'=>1));
			exit();
		}else{
    
    
			echo json_encode(array('status'=>2));
			exit();
		}	 
	}

	//购物车添加。删除检测公共方法
	public function check_cart($pid){
    
    
		//检查产品是否存在或删除
		$check_info = M('menu')->where('id='.intval($pid).' AND status=1')->find();
		if (!$check_info) {
    
    
			return array('status'=>0,'err'=>'商品不存在或已下架.');
		}

		return array('status'=>1);
	}   

    /*
       去除HTNL标签
    */
    public function html_entity($array){
    
    
    	foreach ($array as $key => $value) {
    
    
        	$array[$key]['content'] = strip_tags(html_entity_decode($value['content']));
        }
        return $array;
    }

}

猜你喜欢

转载自blog.csdn.net/HUXINY/article/details/110388189