songxingwei 2 年之前
父節點
當前提交
4c25f46b96

+ 9 - 6
application/store/controller/Goods.php

@@ -6,7 +6,7 @@ use think\cache\driver\Redis;
 use think\Db;
 
 /**
- * 商品
+ * 售卖商品
  * Class Goods
  * @package app\store\controller
  */
@@ -20,7 +20,7 @@ class Goods extends Controller
     protected $table = 'store_collection';
 
     /**
-     * 商品列表
+     * 售卖商品列表
      * @auth true
      * @menu true
      * @throws \think\Exception
@@ -32,9 +32,9 @@ class Goods extends Controller
     public function index()
     {
         checkCollectionState();
-        $this->title = '藏品管理';
+        $this->title = '售卖藏品管理';
         $query = $this->_query($this->table)->where('is_deleted',0)->like('name');
-        $query->dateBetween('create_at')->order('id desc')->page();
+        $query->dateBetween('create_at')->where('type',1)->order('id desc')->page();
     }
 
     /**
@@ -119,7 +119,6 @@ class Goods extends Controller
                 if (!$checksell)   $this->error('藏品已经开始抢购或已过期,无法修改');
             }
             if ($data['cover'] == '') $this->error('请上传藏品图片');
-            if ($data['type'] == '') $this->error('请选择藏品类型');
             if ($data['price']<=0) $this->error('藏品价格错误');
             if ($data['auth_img'] == '') $this->error('请上传作者头像');
             if ($data['describe'] == '') $this->error('请上传商品描述');
@@ -134,7 +133,7 @@ class Goods extends Controller
             }else{
                 $buy_count = 0;
             }
-
+            $data['type'] = 1;
             $data['now_inventory'] = $data['inventory']-$buy_count;
         }else{
             if (!empty($data)){
@@ -471,6 +470,10 @@ class Goods extends Controller
 
 
 
+
+
+
+
     public function detail(){
         $id=$this->request->get('id');
         $this->title = Db::name($this->table)->where('id',$id)->value('name').'--铸造明细';

+ 516 - 0
application/store/controller/Goods1.php

@@ -0,0 +1,516 @@
+<?php
+namespace app\store\controller;
+use library\Controller;
+use think\cache\driver\Redis;
+use think\Db;
+
+/**
+ * 商品
+ * Class Goods
+ * @package app\store\controller
+ */
+class Goods1 extends Controller
+{
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'store_collection';
+
+    /**
+     * 商品列表
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        checkCollectionState();
+        $this->title = '盲盒藏品管理';
+        $query = $this->_query($this->table)->where('is_deleted',0)->like('name');
+        $query->dateBetween('create_at')->where('type',3)->order('id desc')->page();
+    }
+
+    /**
+     * 数据列表处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    protected function _index_page_filter(&$data)
+    {
+        foreach ($data as &$v){
+            $checksell = $this->checkSellTime($v['id']);
+            if (!$checksell){
+                $v['is_save'] = 0;
+            }else{
+                $v['is_save'] = 1;
+            }
+
+            $v['zz']=Db::table('hash')->where('goods_id',$v['id'])->count();
+            $now_inventory = getCollectionInventory($v['id']);
+            $v['now_inventory'] = $now_inventory<=0 ? 0 : $now_inventory;
+            $v['shengyu'] = Db::name('hash')->where('goods_id',$v['id'])->where('status',0)->count();
+        }
+    }
+
+
+
+    /**
+     * 添加商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add()
+    {
+        $this->title = '添加藏品';
+        $this->_form($this->table, 'form');
+    }
+
+
+    /**
+     * 编辑商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    function edit()
+    {
+        $this->title = '编辑商品';
+        $id = $this->request->get('id');
+        $checksell = $this->checkSellTime($id);
+//        if (!$checksell)   $this->error('藏品已经开始抢购或已过期,无法修改');
+        $this->_form($this->table, 'form');
+    }
+
+
+
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if($this->request->post()){
+//            if (isset($data['id']) || !empty($data['id'])){
+//                $checksell = $this->checkSellTime($data['id']);
+//                if (!$checksell)   $this->error('藏品已经开始抢购或已过期,无法修改');
+//            }
+            if ($data['cover'] == '') $this->error('请上传藏品图片');
+            if ($data['price']<=0) $this->error('藏品价格错误');
+            if ($data['auth_img'] == '') $this->error('请上传作者头像');
+            if ($data['describe'] == '') $this->error('请上传商品描述');
+//            if ($data['buy_count']<1) $this->error('限购数量不能小于1');
+            //if ($data['share_img'] == '') $this->error('请上传分享二维码');
+//            $data['date'] = date('Y-m-d',strtotime($data['sell_time']));
+            if (isset($data['id'])){
+                $buy_count = Db::name('store_order_info')
+                    ->whereIn('status','1,3')
+                    ->where('c_id',$data['id'])
+                    ->count();
+            }else{
+                $buy_count = 0;
+            }
+            $data['type'] = 3;
+            $data['now_inventory'] = $data['inventory']-$buy_count;
+        }else{
+            if (!empty($data)){
+                $data['covers'] = $data['cover'];
+                $data['auth_imgs'] = $data['auth_img'];
+                $data['describes'] = $data['describe'];
+                $data['share_imgs'] = $data['share_img'];
+            }
+        }
+    }
+
+    /**
+     * 处理成功回调
+     */
+    public function _form_result($result,$data){
+        if ($result) {
+            setCollectionInfoHash($result);
+            $redis = new Redis();
+            $count = Db::name($this->table)->where('id',$result)->value('now_inventory');
+            $redis->set('collection_count_'.$result,$count);
+            $this->success('操作成功',url('/#/store/goods1/index'));
+        }
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品上架
+     */
+    public function up()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['status'=>1])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品下架
+     */
+    public function down()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['status'=>0])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+        //$this->_save($this->table, ['status' => '0']);
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品删除
+     */
+    public function del()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['is_deleted'=>1])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+        //$this->_save($this->table, ['is_deleted' => '1']);
+    }
+
+//    public function _save_result($result){
+//        if ($result){
+//            setCollectionInfoHash($result);
+//        }
+//    }
+
+    //判断是否已经抢购开始
+    function checkSellTime($id){
+        $sell_time = Db::name($this->table)->where('id',$id)->value('sell_time');
+        $advance_minutes = getAdvanceMinutes();
+        if ($advance_minutes>0){
+            $sell_time = strtotime($sell_time)-($advance_minutes*60);
+        }else{
+            $sell_time = strtotime($sell_time);
+        }
+        if ($sell_time<=time()) return false;
+        return true;
+    }
+
+
+    public function send(){
+        if($this->request->post()){
+            $data = $this->request->post();
+            if (!isset($data['mid']) || $data['mid']==''){
+                $this->error('请选择用户');
+            }
+            $inventory = Db::name($this->table)->where('id',$data['id'])->value('inventory');
+            $info = Db::name($this->table)->where('id',$data['id'])->find();
+
+            $redis = new Redis();
+            $zhuzao_count = $redis->Llen('collectionHash_'.$data['id']);
+            if ($zhuzao_count<$data['number']){
+                $this->error('铸造的的数量不足,无法赠送');
+            }
+
+            $com = true;
+            Db::startTrans();
+            try {
+                $array = [];
+                for ($i=0;$i<$data['number'];$i++){
+                    //获取排名
+                    $rank = getRanking($data['id'])+1;
+                    $tag = getTag($data['id'],$rank,$inventory);
+                    saveRanking($data['id']);
+                    $company = '纪元部落有限公司';
+                    $hash = getCompanyHash($data['id']);
+                    $company_hash = $hash['hash'];
+                    $company_hash_time = $hash['create_at'];
+                    Db::name('hash')->where('hash',$hash['hash'])->update(['status'=>1]);
+                    $collectors_hash = '';
+                    $date = [
+                        'order_no'=>get_order_sn(),
+                        'tag'=>$tag,
+                        'mid'=>$data['mid'],
+                        'c_id'=>$data['id'],
+                        'name'=>$info['name'],
+                        'cover'=>$info['cover'],
+                        'pro_info'=>json_encode($info,true),
+                        'company'=>$company,
+                        'company_hash'=>$company_hash,
+                        'company_hash_time'=>$company_hash_time,
+                        'collectors_hash'=>$collectors_hash,
+                        'collectors_hash_time'=>''
+                    ];
+                    $array[] = $date;
+                }
+                Db::name('store_order_info')->insertAll($array);
+
+                Db::commit();
+            } catch (\Exception $e){
+                Db::rollback();
+                $com = false;
+            }
+            if ($com){
+                //减掉库存
+                loseCollectionInventory($data['id'],$data['number']);
+                $this->success('赠送成功');
+            }else{
+                $this->error('赠送失败');
+            }
+        }else{
+            $id=$this->request->get('id');
+            $this->assign('id',$id);
+            $user = Db::name('store_member')->where('is_deleted',0)->field('id,name,phone')->select();
+            $this->assign('user',$user);
+            $this->fetch();
+
+        }
+    }
+
+
+    public function hash(){
+
+        if($this->request->post()){
+            $id = $this->request->post('id');
+            $number = $this->request->post('number');
+
+            if ($number<=0){
+                $this->error('数量错误');
+            }
+            if (Db::name('store_collection')->where('id',$id)->setInc('casting_num',$number)){
+                $redis = new Redis();
+                $redis->Incrby('castingHash_'.$id,$number);
+                $this->success('增加成功,正在铸造中');
+            }
+            $this->error('增加失败,请稍后重试');
+
+        }else{
+
+            $id=$this->request->get('id');
+            $this->assign('id',$id);
+            $this->fetch();
+
+        }
+
+    }
+
+
+
+    /**
+     * 批量赠送
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function import()
+    {
+        list($msec, $sec) = explode(' ', microtime());
+        $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);  //毫秒值
+        $get = $this->request->get();
+        $import_path = $_SERVER['DOCUMENT_ROOT'].'/'.$get['path'];
+        $url = $get['url'];
+        $c_id = $get['c_id'];
+        if (getConfigValue('storage_type')=='oss'){
+            $save_dir = "./upload/excle/"; // 服务资源目录
+            $filename = date('Ymd').time().".xlsx"; // 自定义名称
+            $res = $this->getFile($url,$save_dir,$filename,1);
+            $import_path = $_SERVER['DOCUMENT_ROOT'].'/upload/excle/'.$res;
+        }
+        $info = getCollectionInfoHash($c_id);
+        $num = 1;
+        try {
+            $objReader =\PHPExcel_IOFactory::createReader('Excel2007');
+            $objExcel = $objReader->load($import_path);
+            $list = $objExcel->getActiveSheet()->toArray();
+            $result = 0;
+            $success = 0;
+            $number = 0;
+            $array = array();
+            foreach ($list as $k=>$v){
+                if($k>$num-1){
+                    if(array_filter($v)){
+                        $data=[];
+                        foreach ($v as $kk=>$vv){
+                            $data[IntToChr($kk)]=trim($vv);
+                        }
+                        $a['phone'] = $data['A'];
+                        $a['number'] = $data['B'];
+                        array_push($array,$a);
+                        $number = $number+$data['B'];
+                    }
+                }
+            }
+            $redis = new Redis();
+            $zhuzao_count = $redis->Llen('collectionHash_'.$c_id);
+            if ($zhuzao_count<$number){
+                $this->error('铸造的的数量不足,无法赠送',[],3);
+            }
+            $error = 0;
+            foreach ($array as &$v){
+                $member = Db::name('store_member')->where('phone',$v['phone'])->find();
+                if (!$member){
+                    $error = $error+1;
+                }else{
+                    $array1 = [];
+                    for ($i=0;$i<$v['number'];$i++){
+                        //获取排名
+                        $rank = getRanking($c_id)+1;
+                        $tag = getTag($c_id,$rank,$info['inventory']);
+                        saveRanking($c_id);
+                        $company = '纪元部落有限公司';
+                        $hash = getCompanyHash($c_id);
+                        $company_hash = $hash['hash'];
+                        $company_hash_time = $hash['create_at'];
+                        Db::name('hash')->where('hash',$hash['hash'])->update(['status'=>1]);
+                        $collectors_hash = '';
+                        $date = [
+                            'order_no'=>get_order_sn(),
+                            'tag'=>$tag,
+                            'mid'=>$member['id'],
+                            'c_id'=>$c_id,
+                            'name'=>$info['name'],
+                            'cover'=>$info['cover'],
+                            'pro_info'=>json_encode($info,true),
+                            'company'=>$company,
+                            'company_hash'=>$company_hash,
+                            'company_hash_time'=>$company_hash_time,
+                            'collectors_hash'=>$collectors_hash,
+                            'collectors_hash_time'=>''
+                        ];
+                        $array1[] = $date;
+                    }
+                    if (Db::name('store_order_info')->insertAll($array1)){
+                        loseCollectionInventory($c_id,$v['number']);
+                        $success +=1;
+                    }else{
+                        $error = $error+1;
+                    }
+                }
+            }
+            if ($error<1){
+                $this->success('成功');
+            }else{
+                $this->error('失败',['error'=>$error,'success'=>$success],2);
+            }
+
+        } catch (\think\exception\ValidateException $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+    public function detail(){
+        $id=$this->request->get('id');
+        $this->title = Db::name($this->table)->where('id',$id)->value('name').'--铸造明细';
+        $query = $this->_query('hash')->where('goods_id',$id);
+        $query->dateBetween('create_at')->order('id desc')->page();
+        $this->fetch();
+    }
+
+
+    public function curlRequest($url, $headers = [], $body = [], $method = "GET")
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//设置请求头
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $body);//设置请求体
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //定义请求类型
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($ch, CURLOPT_HTTP_VERSION, 'CURL_HTTP_VERSION_1_1');
+        $output = curl_exec($ch);
+        curl_close($ch);
+        return $output;
+    }
+
+
+
+
+    /**
+     * 下载文件到服务器
+     * addtime 2020年8月28日 18:38:43
+     */
+    function getFile($url, $save_dir = '', $filename = '', $type = 0)
+    {
+        if (trim($url) == '') {
+            return false;
+        }
+        if (trim($save_dir) == '') {
+            $save_dir = './';
+        }
+        if (0 !== strrpos($save_dir, '/')) {
+            $save_dir.= '/';
+        }
+        //创建保存目录
+        if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) {
+            return false;
+        }
+        //获取远程文件所采用的方法
+        if ($type) {
+            $ch = curl_init();
+            $timeout = 5;
+            curl_setopt($ch, CURLOPT_URL, $url);
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+            $content = curl_exec($ch);
+            curl_close($ch);
+        } else {
+            ob_start();
+            readfile($url);
+            $content = ob_get_contents();
+            ob_end_clean();
+        }
+        $size = strlen($content);
+        //文件大小
+        $fp2 = @fopen($save_dir . $filename, 'a');
+        fwrite($fp2, $content);
+        fclose($fp2);
+        unset($content, $url);
+        return $filename;
+    }
+
+}

+ 637 - 0
application/store/controller/Goods2.php

@@ -0,0 +1,637 @@
+<?php
+namespace app\store\controller;
+use library\Controller;
+use think\cache\driver\Redis;
+use think\Db;
+
+/**
+ * 商品
+ * Class Goods
+ * @package app\store\controller
+ */
+class Goods2 extends Controller
+{
+
+    /**
+     * 绑定数据表
+     * @var string
+     */
+    protected $table = 'store_collection';
+
+    /**
+     * 商品列表
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function index()
+    {
+        checkSynCollectionState();
+        $this->title = '合成藏品管理';
+        $query = $this->_query($this->table)->where('is_deleted',0)->like('name');
+        $query->dateBetween('create_at')->where('type',2)->order('id desc')->page();
+    }
+
+    /**
+     * 数据列表处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     */
+    protected function _index_page_filter(&$data)
+    {
+        foreach ($data as &$v){
+            $checksell = $this->checkSellTime($v['id']);
+            if (!$checksell){
+                $v['is_save'] = 0;
+            }else{
+                $v['is_save'] = 1;
+            }
+
+            $v['zz']=Db::table('hash')->where('goods_id',$v['id'])->count();
+            $now_inventory = getCollectionInventory($v['id']);
+            $v['now_inventory'] = $now_inventory<=0 ? 0 : $now_inventory;
+            $v['shengyu'] = Db::name('hash')->where('goods_id',$v['id'])->where('status',0)->count();
+        }
+    }
+
+
+
+    /**
+     * 添加商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add()
+    {
+        $this->title = '添加藏品';
+        $this->_form($this->table, 'form');
+    }
+
+
+    /**
+     * 编辑商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    function edit()
+    {
+        $this->title = '编辑商品';
+        $id = $this->request->get('id');
+        $checksell = $this->checkSellTime($id);
+//        if (!$checksell)   $this->error('藏品已经开始抢购或已过期,无法修改');
+        $this->_form($this->table, 'form');
+    }
+
+
+
+
+
+    /**
+     * 表单数据处理
+     * @auth true
+     * @menu true
+     * @param array $data
+     */
+    protected function _form_filter(&$data)
+    {
+        if($this->request->post()){
+//            if (isset($data['id']) || !empty($data['id'])){
+//                $checksell = $this->checkSellTime($data['id']);
+//                if (!$checksell)   $this->error('藏品已经开始抢购或已过期,无法修改');
+//            }
+            if ($data['cover'] == '') $this->error('请上传藏品图片');
+            if ($data['price']<=0) $this->error('藏品价格错误');
+            if ($data['auth_img'] == '') $this->error('请上传作者头像');
+            if ($data['describe'] == '') $this->error('请上传商品描述');
+//            if ($data['buy_count']<1) $this->error('限购数量不能小于1');
+            //if ($data['share_img'] == '') $this->error('请上传分享二维码');
+            $data['date'] = date('Y-m-d',strtotime($data['sell_time']));
+            if (isset($data['id'])){
+                $buy_count = Db::name('store_order_info')
+                    ->whereIn('status','1,3')
+                    ->where('c_id',$data['id'])
+                    ->count();
+            }else{
+                $buy_count = 0;
+            }
+            $data['type'] = 2;
+            $data['now_inventory'] = $data['inventory']-$buy_count;
+        }else{
+            if (!empty($data)){
+                $data['covers'] = $data['cover'];
+                $data['auth_imgs'] = $data['auth_img'];
+                $data['describes'] = $data['describe'];
+                $data['share_imgs'] = $data['share_img'];
+            }
+
+            $list = Db::name('store_collection')->field('id,name,cover')->select();
+            $this->list = $list;
+        }
+    }
+
+    /**
+     * 处理成功回调
+     */
+    public function _form_result($result,$data){
+        if ($result) {
+            setCollectionInfoHash($result);
+            $redis = new Redis();
+            $count = Db::name($this->table)->where('id',$result)->value('now_inventory');
+            $redis->set('collection_count_'.$result,$count);
+            $this->success('操作成功',url('/#/store/goods2/index'));
+        }
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品上架
+     */
+    public function up()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['status'=>1])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品下架
+     */
+    public function down()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['status'=>0])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+        //$this->_save($this->table, ['status' => '0']);
+    }
+
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品删除
+     */
+    public function del()
+    {
+        $data = $this->request->post();
+        if (Db::name($this->table)->where('id',$data['id'])->update(['is_deleted'=>1])){
+            setCollectionInfoHash($data['id']);
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+        //$this->_save($this->table, ['is_deleted' => '1']);
+    }
+
+//    public function _save_result($result){
+//        if ($result){
+//            setCollectionInfoHash($result);
+//        }
+//    }
+
+    //判断是否已经抢购开始
+    function checkSellTime($id){
+        $sell_time = Db::name($this->table)->where('id',$id)->value('sell_time');
+        $advance_minutes = getAdvanceMinutes();
+        if ($advance_minutes>0){
+            $sell_time = strtotime($sell_time)-($advance_minutes*60);
+        }else{
+            $sell_time = strtotime($sell_time);
+        }
+        if ($sell_time<=time()) return false;
+        return true;
+    }
+
+
+    public function send(){
+        if($this->request->post()){
+            $data = $this->request->post();
+            if (!isset($data['mid']) || $data['mid']==''){
+                $this->error('请选择用户');
+            }
+            $inventory = Db::name($this->table)->where('id',$data['id'])->value('inventory');
+            $info = Db::name($this->table)->where('id',$data['id'])->find();
+
+            $redis = new Redis();
+            $zhuzao_count = $redis->Llen('collectionHash_'.$data['id']);
+            if ($zhuzao_count<$data['number']){
+                $this->error('铸造的的数量不足,无法赠送');
+            }
+
+            $com = true;
+            Db::startTrans();
+            try {
+                $array = [];
+                for ($i=0;$i<$data['number'];$i++){
+                    //获取排名
+                    $rank = getRanking($data['id'])+1;
+                    $tag = getTag($data['id'],$rank,$inventory);
+                    saveRanking($data['id']);
+                    $company = '纪元部落有限公司';
+                    $hash = getCompanyHash($data['id']);
+                    $company_hash = $hash['hash'];
+                    $company_hash_time = $hash['create_at'];
+                    Db::name('hash')->where('hash',$hash['hash'])->update(['status'=>1]);
+                    $collectors_hash = '';
+                    $date = [
+                        'order_no'=>get_order_sn(),
+                        'tag'=>$tag,
+                        'mid'=>$data['mid'],
+                        'c_id'=>$data['id'],
+                        'name'=>$info['name'],
+                        'cover'=>$info['cover'],
+                        'pro_info'=>json_encode($info,true),
+                        'company'=>$company,
+                        'company_hash'=>$company_hash,
+                        'company_hash_time'=>$company_hash_time,
+                        'collectors_hash'=>$collectors_hash,
+                        'collectors_hash_time'=>''
+                    ];
+                    $array[] = $date;
+                }
+                Db::name('store_order_info')->insertAll($array);
+
+                Db::commit();
+            } catch (\Exception $e){
+                Db::rollback();
+                $com = false;
+            }
+            if ($com){
+                //减掉库存
+                loseCollectionInventory($data['id'],$data['number']);
+                $this->success('赠送成功');
+            }else{
+                $this->error('赠送失败');
+            }
+        }else{
+            $id=$this->request->get('id');
+            $this->assign('id',$id);
+            $user = Db::name('store_member')->where('is_deleted',0)->field('id,name,phone')->select();
+            $this->assign('user',$user);
+            $this->fetch();
+
+        }
+    }
+
+
+    public function hash(){
+
+        if($this->request->post()){
+            $id = $this->request->post('id');
+            $number = $this->request->post('number');
+
+            if ($number<=0){
+                $this->error('数量错误');
+            }
+            if (Db::name('store_collection')->where('id',$id)->setInc('casting_num',$number)){
+                $redis = new Redis();
+                $redis->Incrby('castingHash_'.$id,$number);
+                $this->success('增加成功,正在铸造中');
+            }
+            $this->error('增加失败,请稍后重试');
+
+        }else{
+
+            $id=$this->request->get('id');
+            $this->assign('id',$id);
+            $this->fetch();
+
+        }
+
+    }
+
+
+
+    /**
+     * 批量赠送
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function import()
+    {
+        list($msec, $sec) = explode(' ', microtime());
+        $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);  //毫秒值
+        $get = $this->request->get();
+        $import_path = $_SERVER['DOCUMENT_ROOT'].'/'.$get['path'];
+        $url = $get['url'];
+        $c_id = $get['c_id'];
+        if (getConfigValue('storage_type')=='oss'){
+            $save_dir = "./upload/excle/"; // 服务资源目录
+            $filename = date('Ymd').time().".xlsx"; // 自定义名称
+            $res = $this->getFile($url,$save_dir,$filename,1);
+            $import_path = $_SERVER['DOCUMENT_ROOT'].'/upload/excle/'.$res;
+        }
+        $info = getCollectionInfoHash($c_id);
+        $num = 1;
+        try {
+            $objReader =\PHPExcel_IOFactory::createReader('Excel2007');
+            $objExcel = $objReader->load($import_path);
+            $list = $objExcel->getActiveSheet()->toArray();
+            $result = 0;
+            $success = 0;
+            $number = 0;
+            $array = array();
+            foreach ($list as $k=>$v){
+                if($k>$num-1){
+                    if(array_filter($v)){
+                        $data=[];
+                        foreach ($v as $kk=>$vv){
+                            $data[IntToChr($kk)]=trim($vv);
+                        }
+                        $a['phone'] = $data['A'];
+                        $a['number'] = $data['B'];
+                        array_push($array,$a);
+                        $number = $number+$data['B'];
+                    }
+                }
+            }
+            $redis = new Redis();
+            $zhuzao_count = $redis->Llen('collectionHash_'.$c_id);
+            if ($zhuzao_count<$number){
+                $this->error('铸造的的数量不足,无法赠送',[],3);
+            }
+            $error = 0;
+            foreach ($array as &$v){
+                $member = Db::name('store_member')->where('phone',$v['phone'])->find();
+                if (!$member){
+                    $error = $error+1;
+                }else{
+                    $array1 = [];
+                    for ($i=0;$i<$v['number'];$i++){
+                        //获取排名
+                        $rank = getRanking($c_id)+1;
+                        $tag = getTag($c_id,$rank,$info['inventory']);
+                        saveRanking($c_id);
+                        $company = '纪元部落有限公司';
+                        $hash = getCompanyHash($c_id);
+                        $company_hash = $hash['hash'];
+                        $company_hash_time = $hash['create_at'];
+                        Db::name('hash')->where('hash',$hash['hash'])->update(['status'=>1]);
+                        $collectors_hash = '';
+                        $date = [
+                            'order_no'=>get_order_sn(),
+                            'tag'=>$tag,
+                            'mid'=>$member['id'],
+                            'c_id'=>$c_id,
+                            'name'=>$info['name'],
+                            'cover'=>$info['cover'],
+                            'pro_info'=>json_encode($info,true),
+                            'company'=>$company,
+                            'company_hash'=>$company_hash,
+                            'company_hash_time'=>$company_hash_time,
+                            'collectors_hash'=>$collectors_hash,
+                            'collectors_hash_time'=>''
+                        ];
+                        $array1[] = $date;
+                    }
+                    if (Db::name('store_order_info')->insertAll($array1)){
+                        loseCollectionInventory($c_id,$v['number']);
+                        $success +=1;
+                    }else{
+                        $error = $error+1;
+                    }
+                }
+            }
+            if ($error<1){
+                $this->success('成功');
+            }else{
+                $this->error('失败',['error'=>$error,'success'=>$success],2);
+            }
+
+        } catch (\think\exception\ValidateException $e) {
+            $this->error($e->getMessage());
+        }
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+    public function detail(){
+        $id=$this->request->get('id');
+        $this->title = Db::name($this->table)->where('id',$id)->value('name').'--铸造明细';
+        $query = $this->_query('hash')->where('goods_id',$id);
+        $query->dateBetween('create_at')->order('id desc')->page();
+        $this->fetch();
+    }
+
+
+    public function curlRequest($url, $headers = [], $body = [], $method = "GET")
+    {
+        $ch = curl_init();
+        curl_setopt($ch, CURLOPT_URL, $url);
+        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);//设置请求头
+        curl_setopt($ch, CURLOPT_POSTFIELDS, $body);//设置请求体
+        curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method); //定义请求类型
+        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
+        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
+        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+        curl_setopt($ch, CURLOPT_HTTP_VERSION, 'CURL_HTTP_VERSION_1_1');
+        $output = curl_exec($ch);
+        curl_close($ch);
+        return $output;
+    }
+
+
+    /**
+     * 合成材料
+     * @auth true
+     * @throws \think\Exception
+     * @throws \think\exception\PDOException
+     */
+    public function material(){
+        $id=$this->request->get('id');
+        $this->assign('cid',$id);
+        $this->title = Db::name($this->table)->where('id',$id)->value('name').'--合成材料';
+        $query = $this->_query('store_collection_material')->alias('a')->join('store_collection b','a.c_id=b.id');
+        $query->where('a.cid',$id) ->field('a.*,b.name,b.cover')->order('id desc')->page();
+
+    }
+
+    /**
+     * 添加商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add_mater()
+    {
+        $cid = $this->request->get('cid');
+        $this->assign('cid',$cid);
+        $this->title = '添加材料';
+        $list = Db::name('store_collection')->where('type','neq',2)->field('id,name')->select();
+        $this->list = $list;
+        $this->_form($this->table);
+    }
+
+    /**
+     * 添加商品
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function edit_mater()
+    {
+        $cid = $this->request->get('cid');
+        $this->assign('cid',$cid);
+        $id = $this->request->get('id');
+        $this->title = '编辑材料';
+        $list = Db::name('store_collection')->where('type','neq',2)->field('id,name')->select();
+        $this->list = $list;
+        $vo = Db::name('store_collection_material')->where('id',$id)->find();
+        $this->vo = $vo;
+        $this->_form($this->table,'add_mater');
+    }
+
+
+
+    /**
+     * 处理
+     * @auth true
+     * @menu true
+     * @throws \think\Exception
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\ModelNotFoundException
+     * @throws \think\exception\DbException
+     * @throws \think\exception\PDOException
+     */
+    public function add_edit_mater(){
+        $data = $this->request->post();
+        if ($data['c_id']==''){
+            $this->error('请选择材料');
+        }
+        if (isset($data['id'])){
+            $info = Db::name('store_collection_material')->where('id','neq',$data['id'])->where('cid',$data['cid'])->where('c_id',$data['c_id'])->find();
+            if ($info) $this->error('材料已存在');
+            $data['update_at'] = date('Y-m-d H:i:s');
+            if (Db::name('store_collection_material')->where('id',$data['id'])->update($data)){
+                $this->success('编辑成功');
+            }
+            $this->error('编辑失败,请稍后重试');
+        }else{
+            $info = Db::name('store_collection_material')->where('cid',$data['cid'])->where('c_id',$data['c_id'])->find();
+            if ($info) $this->error('材料已存在');
+            if (Db::name('store_collection_material')->insert($data)){
+                $this->success('添加成功');
+            }
+            $this->error('添加失败,请稍后重试');
+        }
+
+    }
+
+    /**
+     * @auth true
+     * @menu true
+     * 商品删除
+     */
+    public function del_mater()
+    {
+        $data = $this->request->post();
+        if (Db::name('store_collection_material')->where('id',$data['id'])->delete()){
+            $this->success('恭喜您,数据更新成功');
+        }else{
+            $this->error('数据更新失败');
+        }
+
+    }
+
+
+
+
+
+
+
+
+
+
+
+    /**
+     * 下载文件到服务器
+     * addtime 2020年8月28日 18:38:43
+     */
+    function getFile($url, $save_dir = '', $filename = '', $type = 0)
+    {
+        if (trim($url) == '') {
+            return false;
+        }
+        if (trim($save_dir) == '') {
+            $save_dir = './';
+        }
+        if (0 !== strrpos($save_dir, '/')) {
+            $save_dir.= '/';
+        }
+        //创建保存目录
+        if (!file_exists($save_dir) && !mkdir($save_dir, 0777, true)) {
+            return false;
+        }
+        //获取远程文件所采用的方法
+        if ($type) {
+            $ch = curl_init();
+            $timeout = 5;
+            curl_setopt($ch, CURLOPT_URL, $url);
+            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
+            curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
+            $content = curl_exec($ch);
+            curl_close($ch);
+        } else {
+            ob_start();
+            readfile($url);
+            $content = ob_get_contents();
+            ob_end_clean();
+        }
+        $size = strlen($content);
+        //文件大小
+        $fp2 = @fopen($save_dir . $filename, 'a');
+        fwrite($fp2, $content);
+        fclose($fp2);
+        unset($content, $url);
+        return $filename;
+    }
+
+}

+ 0 - 14
application/store/view/goods/form.html

@@ -19,20 +19,6 @@
         </div>
 
         <div class="layui-form-item layui-row layui-col-space15">
-            <label class="layui-col-xs12 relative">
-                <label class="layui-col-xs3 relative" >
-                    <span class="color-green">类型</span>
-                    <select name="type" required class="province-selector" id="type"  lay-filter="type" data-value="">
-                        <option value="">请选择类型</option>
-                        <option value="1" {if isset($vo.id) && $vo.type eq 1}selected{/if}>售卖</option>
-                        <option value="2" {if isset($vo.id) && $vo.type eq 2}selected{/if}>合成</option>
-                        <option value="3" {if isset($vo.id) && $vo.type eq 3}selected{/if}>盲盒</option>
-                    </select>
-                </label>
-            </label>
-        </div>
-
-        <div class="layui-form-item layui-row layui-col-space15">
             <label class="layui-col-xs3 relative">
                 <span class="color-green">藏品名称</span>
                 <input name="name" required class="layui-input" placeholder="请输入藏品名称" value="{$vo.name|default=''}">

+ 5 - 7
application/store/view/goods/index.html

@@ -19,7 +19,6 @@
             <th class='text-left nowrap'>铸造数量<br />(成功数/总数)</th>
             <th class="text-left nowrap">发行时间</th>
             <th class="text-left nowrap">添加时间</th>
-            <th class="text-left nowrap">类型</th>
             <th class="text-left nowrap">状态</th>
             <th class="text-left nowrap">操作</th>
         </tr>
@@ -40,11 +39,6 @@
             <td class='text-left nowrap'>{$vo.sell_time|default=''}</td>
             <td class='text-left nowrap'>{$vo.create_at}</td>
             <td class='text-left nowrap'>
-                {eq name='vo.type' value='1'}售卖藏品{/eq}
-                {eq name='vo.type' value='2'}合成藏品{/eq}
-                {eq name='vo.type' value='3'}盲盒藏品{/eq}
-            </td>
-            <td class='text-left nowrap'>
                 {if $vo.status eq 0}已下架{else/}
                 {eq name='vo.state' value='1'}抢购中{/eq}
                 {eq name='vo.state' value='2'}即将开售{/eq}
@@ -137,6 +131,10 @@
                                         // $.form.href('{:url("admin/main_project/index")}');
                                     }});
                             }else if (result.code==2){
+                                // layer.msg('成功:'+result.data.success+',失败:'+result.data.error+'<br />'+
+                                //         '错误号码'+result.data.phone_error
+                                //
+                                //     ,{icon: 5});
                                 layer.open({
                                     type:1,
                                     area:['500px', '500px'],
@@ -147,7 +145,7 @@
                                         var url = '/store/goods/get_excl';
                                         var params = {'phone': result.data.phone_error};
                                         jsSubmit(url, params);
-                                        // layer.msg('的确很重要', {icon: 1});
+                                       // layer.msg('的确很重要', {icon: 1});
                                     }
                                 });
                             }else if (result.code==3){

+ 53 - 0
application/store/view/goods1/detail.html

@@ -0,0 +1,53 @@
+{extend name='admin@main'}
+
+
+{block name="content"}
+<div class="think-box-shadow">
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>hash</th>
+            <th class="text-left nowrap">铸造时间</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+
+            <td class='text-left nowrap'>{$vo.hash|default=''}</td>
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+
+
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/goods/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+</script>
+{/block}
+
+
+

+ 210 - 0
application/store/view/goods1/form.html

@@ -0,0 +1,210 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">藏品图片</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <td width="90px" class="text-left"><input name="cover" lay-verify="required" type="hidden" value="{$vo.covers|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="cover"]').uploadOneImage(), $('[name="covers"]').uploadMultipleImage()</script>
+        </div>
+
+
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品名称</span>
+                <input name="name" required class="layui-input" placeholder="请输入藏品名称" value="{$vo.name|default=''}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品标签</span>
+                <input name="label" required class="layui-input" placeholder="请输入藏品标签" value="{$vo.label|default=''}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品库存</span>
+                <input name="inventory" required type="number" class="layui-input" placeholder="请输入库存" value="{$vo.inventory|default='1'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品价格</span>
+                <input name="price" required type="number" step="1" class="layui-input" placeholder="请输入价格" value="{$vo.price|default='0'}">
+            </label>
+        </div>
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">转赠天数(第一次转赠限制天数,0为不限制)</span>
+                <input name="one_given_day" required type="number" class="layui-input" placeholder="请输入转赠天数(第一次转赠限制天数,0为不限制)" value="{$vo.one_given_day|default='0'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">转赠天数(后续转赠限制天数,0为不限制)</span>
+                <input name="other_given_day" required type="number" step="1" class="layui-input" placeholder="请输入转赠天数(后续转赠限制天数,0为不限制)" value="{$vo.other_given_day|default='0'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">作者姓名</span>
+                <input name="auth_name" required class="layui-input" placeholder="请输入作者姓名" value="{$vo.auth_name|default=''}">
+            </label>
+
+        </div>
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">作者头像</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <td width="90px" class="text-left"><input name="auth_img" type="hidden" value="{$vo.auth_imgs|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="auth_img"]').uploadOneImage(), $('[name="auth_imgs"]').uploadMultipleImage()</script>
+        </div>
+
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">作品介绍</span>
+                <textarea placeholder="请输入作品介绍" required class="layui-textarea" name="intro">{$vo.intro|default=""}</textarea>
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">权益说明</span>
+                <textarea placeholder="请输入权益说明" required class="layui-textarea" name="instructions">{$vo.instructions|default=""}</textarea>
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">购买须知</span>
+                <textarea placeholder="请输入购买须知" required class="layui-textarea" name="buy_notice">{$vo.buy_notice|default=""}</textarea>
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">温馨提示</span>
+                <textarea placeholder="请输入温馨提示" required class="layui-textarea" name="warm_prompt">{$vo.warm_prompt|default=""}</textarea>
+            </label>
+        </div>
+
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">商品描述(多张图片)</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <!--<td width="90px" class="text-center"><input name="logo" type="hidden" value="{$vo.logo|default=''}"></td>-->
+                    <td width="auto" class="text-left"><input name="describe" type="hidden" value="{$vo.describes|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="logo"]').uploadOneImage(), $('[name="describe"]').uploadMultipleImage()</script>
+        </div>
+
+<!--        <div class="layui-form-item">-->
+<!--            <span class="color-green label-required-prev">分享二维码</span>-->
+<!--            <table class="layui-table">-->
+<!--                <thead>-->
+<!--                <tr>-->
+<!--                    <td width="90px" class="text-left"><input name="share_img" type="hidden" value="{$vo.share_imgs|default=''}"></td>-->
+<!--                </tr>-->
+<!--                </thead>-->
+<!--            </table>-->
+<!--            <script>$('[name="share_img"]').uploadOneImage(), $('[name="share_imgs"]').uploadMultipleImage()</script>-->
+<!--        </div>-->
+
+        <div class="layui-form-item text-center">
+            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+<textarea class="layui-hide" id="goods-specs">{$vo.specs|raw|default=''}</textarea>
+<textarea class="layui-hide" id="goods-value">{$defaultValues|raw|default=''}</textarea>
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+        var form = layui.form
+            ,layer = layui.layer
+            ,layedit = layui.layedit
+            ,laydate = layui.laydate;
+
+        laydate.render({
+            elem: '#sell_time'
+            ,type: 'datetime'
+            ,min:new Date().toLocaleString()
+        });
+        form.render();
+        //日期
+        laydate.render({
+            elem: '#date'
+        });
+        laydate.render({
+            elem: '#date1'
+        });
+
+        form.on('select(province)', function (data) {
+            var val = data.value;
+            // console.log(val)
+            $.ajax({
+                type:"get",
+                url:"{:url('member/get_city')}",  //数据传输的控制器方法
+                data: {id:val},//这里data传递过去的是序列化以后的字符串
+                success:function(data){
+                   // console.log(data)
+                    var arr = data.data;
+                    //console.log(arr)
+                    if (arr.length>0){
+                        //$("#tow").attr("style","display:block;");//显示div
+                        var options='<option value="">请选择市</option>';
+                        for (var i = 0; i < arr.length; i++) {
+                            var tag = arr[i];
+                            options+=' <option value="'+tag.id+'">'+tag.name+'</option>';
+                        }
+                        $("select[name='city']").html(options)
+                        form.render('select');
+                    }else {
+                        var options='<option value="">请选择市</option>';
+                        $("select[name='city']").html(options)
+                        form.render('select');
+                    }
+                }
+            });
+        });
+
+        form.on('select(city)', function (data) {
+            var val = data.value;
+            // console.log(val)
+            $.ajax({
+                type:"get",
+                url:"{:url('member/get_area')}",  //数据传输的控制器方法
+                data: {id:val},//这里data传递过去的是序列化以后的字符串
+                success:function(data){
+                    //console.log(data)
+                    var arr = data.data;
+                   // console.log(arr)
+                    if (arr.length>0){
+                        var options='<option value="">请选择区</option>';
+                        for (var i = 0; i < arr.length; i++) {
+                            var tag = arr[i];
+                            options+=' <option value="'+tag.id+'">'+tag.name+'</option>';
+                        }
+                        $("select[name='area']").html(options)
+                        form.render('select');
+                    }else {
+                        var options='<option value="">请选择区</option>';
+                        $("select[name='area']").html(options)
+                        form.render('select');
+                    }
+                }
+            });
+        });
+
+
+
+    });
+</script>
+{/block}

+ 479 - 0
application/store/view/goods1/form2.html

@@ -0,0 +1,479 @@
+
+<link rel="stylesheet" href="/static/plugs/layui/css/layui.css"  media="all">
+
+<style>
+    .layui-form-item {
+        width: 80%;
+        height: 90%;
+    }
+    .layui-form-radio{
+       width: 10px !important;
+    }
+
+</style>
+
+<div class="think-box-shadow" style="height: 100%">
+    <form class="layui-form layui-card" id="subForm" action="{:request()->url()}"  data-auto="true" method="post" autocomplete="off">
+        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
+            <legend>商品编辑</legend>
+        </fieldset>
+        <div class="layui-tab">
+            <ul class="layui-tab-title">
+                <li class="layui-this">基础设置</li>
+                <li >其他</li>
+            </ul>
+            <div class="layui-tab-content ">
+                <!--基础设置-->
+                <div class="layui-tab-item layui-show">
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品名称</label>
+                        <div class="layui-input-block">
+                            <input name="name" lay-verify="required" maxlength="50"  value='{$vo.name|default=""}' placeholder="请输入商品名称" class="layui-input">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item" style="display: none">
+                        <label class="layui-form-label">商品简介</label>
+                        <div class="layui-input-block">
+                            <input name="desc" maxlength="50"  value='{$vo.desc|default=""}' placeholder="请输入商品简介" class="layui-input">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品封面</label>
+                        <div class="layui-input-block">
+                            <input name="cover" type="hidden" value="{$vo.cover|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品类型</label>
+                        <div class="layui-input-inline">
+                            <input type="hidden" id="goods_type" value="{$vo.type|default='1'}"/>
+                            <select name="type" {if isset($vo.id)}disabled{/if} lay-filter ="type">
+                                {foreach  $goods_type as $gk=>$gv}
+                                    <option value="{$gk}"  {if isset($vo.id) && $vo.type ==  $gk}selected{/if}>{$gv}</option>
+                                {/foreach}
+                            </select>
+                        </div>
+                    </div>
+
+                    <div class="goods_type">
+                        <div class="layui-form-item type1">
+                            <label class="layui-form-label label-required">商品售价</label>
+                            <div class="layui-input-block">
+                                <input name="goods_price" type="number" step="1" class="layui-input"  value="{$vo.goods_price|default=''}">
+                            </div>
+                        </div>
+                        <div class="layui-form-item type3">
+                            <label class="layui-form-label">邀请人数</label>
+                            <div class="layui-input-block">
+                                <input name="invite_num" type="number" step="1" class="layui-input"  value="{$vo.invite_num|default='0'}">
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">是否转赠</label>
+
+                        <div class="layui-input-block">
+                            <input type="hidden" id="is_gift" value="{$vo.is_gift|default='0'}"/>
+                            <div>
+                                {foreach [0=>'否',1=>'是'] as $sk=>$sv}
+                                <!--{if (isset($vo.id) && $vo.is_gift eq $sk) || ($sk== 0 && !isset($vo.id)) }-->
+                                <label>
+                                    <input checked type="radio"  name="is_gift" value="{$sk}"  lay-filter="is_gift">
+                                </label>
+                                <!--{else}-->
+                                <label >
+                                    <input type="radio" name="is_gift" value="{$sk}"  lay-filter="is_gift" >
+                                </label>
+                                <!--{/if}-->
+                                <span class="" style="line-height: 22px">{$sv}</span>
+                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                                {/foreach}
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item type4 ">
+                        <label class="layui-form-label">转赠元石</label>
+                        <div class="layui-input-block">
+                            <input name="crystal" type="number" step="1" class="layui-input"  value="{$vo.crystal|default='0'}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item type4">
+                        <label class="layui-form-label">转赠时间限制(天)</label>
+                        <div class="layui-input-block">
+                            <input name="gift_day" type="number" step="1" class="layui-input"  value="{$vo.gift_day|default='0'}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品库存</label>
+                        <div class="layui-input-block">
+                            <input name="stock"type="number" step="1" class="layui-input"  value="{$vo.stock|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">收藏量</label>
+                        <div class="layui-input-block">
+                            <input name="vir_num"type="number" step="1" class="layui-input"  value="{$vo.vir_num|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">藏品介绍</label>
+                        <div class="layui-input-block">
+                            <input name="coll_intro"type=""  class="layui-input"  value="{$vo.coll_intro|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label ">上架时间</label>
+                        <div class="layui-input-block">
+                            <input name="sell_time" id="sell_time" value='{$vo.sell_time|default=""}' placeholder="" class="layui-input">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">展示类型</label>
+                        <div class="layui-input-inline">
+                            <input id="adv_type" type="hidden" value="{$vo.adv_type|default='1'}" />
+                            <select name="adv_type" lay-filter ="adv_type">
+                                <option value="1" {if isset($vo.adv_type) && $vo.adv_type == 1}selected{/if}>图片</option>
+                                <option value="3" {if isset($vo.adv_type) && $vo.adv_type == 3}selected{/if}>视频</option>
+                            </select>
+                        </div>
+                    </div>
+
+                    <div class="adv_box">
+                        <div class="layui-form-item adv_box1">
+                            <label class="layui-form-label">展示封面</label>
+                            <div class="layui-input-block">
+                                <input name="adv_cover" type="hidden" value="{$vo.adv_cover|default=''}">
+                            </div>
+                        </div>
+
+                        <div class="layui-form-item adv_box2">
+                            <label class="layui-form-label">展示音频</label>
+                            <div class="layui-input-block">
+                                <div class="audio_box" style="float:left;">
+                                    <audio   style='' controls>
+                                        <source  src="" >
+                                        <source id="mp3" src="{$vo.mp3_url|default=''}" >
+                                    </audio>
+                                </div>
+                                <div  class ='up_img' style='color: blue;line-height:50px;margin-left:30px;float: left; width: 60px ;'>选 择</div >
+                                <input  style="display: none"  type="file" name="file" accept="mp3" value="" onchange="upload_img(this)" class="layui-input"/>
+                                <input  style="display: none"  value="{$vo.mp3_url|default=''}" name="mp3_url" class="layui-input"/>
+                                <div></div>
+                            </div>
+                        </div>
+
+
+
+
+
+                        <div class="layui-form-item adv_box3">
+                            <label class="layui-form-label ">展示视频</label>
+                            <div class="layui-input-block">
+                                <input name="audio_url" type="hidden" value="{$vo.audio_url|default=''}">
+                            </div>
+                        </div>
+
+                        <div class="layui-form-item adv_box3">
+                            <label class="layui-form-label ">进度显示</label>
+                            <div class="layui-input-block">
+                                <input type="hidden" id="audio_line" value="{$vo.audio_line|default='0'}"/>
+                                <div>
+                                    {foreach [0=>'否',1=>'是'] as $sk=>$sv}
+                                    <!--{if (isset($vo.id) && $vo.audio_line eq $sk) || ($sk== 0 && !isset($vo.id)) }-->
+                                    <label>
+                                        <input checked type="radio"  name="audio_line" value="{$sk}"  lay-filter="audio_line">
+                                    </label>
+                                    <!--{else}-->
+                                    <label >
+                                        <input type="radio" name="audio_line" value="{$sk}"  lay-filter="audio_line" >
+                                    </label>
+                                    <!--{/if}-->
+                                    <span class="" style="line-height: 22px">{$sv}</span>
+                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                                    {/foreach}
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label">购买须知</label>
+                        <div class="layui-input-block">
+                            <textarea name="buy_notice" style="height: 150px;width: 100%;border-color: #e6e6e6" >{$vo.buy_notice|default=""}</textarea>
+                        </div>
+                    </div>
+
+                </div>
+                <!--其他设置-->
+                <div class="layui-tab-item">
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">分享图片</label>
+                        <div class="layui-input-block">
+                            <input name="share_img" type="hidden" value="{$vo.share_img|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">支付图片</label>
+                        <div class="layui-input-block">
+                            <input name="pay_pic" type="hidden" value="{$vo.pay_pic|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">支付内容</label>
+                        <div class="layui-input-block">
+                            <input name="pay_content" maxlength="30" type=""  class="layui-input"  value="{$vo.pay_content|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">发行方头像</label>
+                        <div class="layui-input-block">
+                            <input name="auth_img" type="hidden" value="{$vo.auth_img|default=''}">
+                        </div>
+                    </div>
+
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">发行方</label>
+                        <div class="layui-input-block">
+                            <input name="issuer" class="layui-input"  value="{$vo.issuer|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label">商品详情</label>
+                        <div class="layui-input-block">
+                            <textarea name="detail">{$vo.detail|default=""}</textarea>
+                        </div>
+                    </div>
+                    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+                    <div class="layui-form-item text-center">
+                        <span class="layui-btn" type='submit' id ="submit">保 存</span>
+                        <button class="layui-btn layui-btn-danger" type='button' onclick="history.go(-1);">取消编辑</button>
+                    </div>
+                </div>
+            </div>
+
+        </div>
+    </form>
+</div>
+<script src="/static/plugs/layui/layui.all.js" charset="utf-8"></script>
+<script>
+    window.form.render();
+    require(['ckeditor', 'angular'], function () {
+        window.createEditor('[name="detail"]', {height: 500,width:1000});
+    })
+    layui.use('laydate', function(){
+        var laydate = layui.laydate;
+        laydate.render({
+            elem: '#sell_time'
+            ,type: 'datetime'
+        });
+        laydate.render({
+            elem: '#end_time'
+            ,type: 'datetime'
+        });
+    })
+    $('[name="cover"]').uploadOneImage();
+    $('[name="share_img"]').uploadOneImage();
+    $('[name="adv_cover"]').uploadOneImage();
+    $('[name="auth_img"]').uploadOneImage();
+    $('[name="pay_pic"]').uploadOneImage();
+    $('[name="audio_url"]').uploadOneVideo()
+    /**
+     * 表单验证
+     */
+    $(document).on('click','#submit',function () {
+        if($('#submit').hasClass('is_sub')) {
+            return false;
+        }
+
+        var goods_name = $('input[name="name"]').val();
+        if(!goods_name){
+            layer.msg('请填写商品名称!')
+            return false;
+        }
+
+        var goods_cover = $('input[name="cover"]').val();
+        if(!goods_cover){
+            layer.msg('请上传商品封面!')
+            return false;
+        }
+
+        var goods_type = $('select[name="type"]').val();
+        var goods_price = $('input[name="goods_price"]').val();
+        if(!goods_type == 1 && !goods_price){
+            layer.msg('请输入商品价格!')
+            return false;
+        }
+
+        var  vir_num =  $('input[name="vir_num"]').val();
+        if(!vir_num){
+            layer.msg('请输入商品收藏量!')
+            return false;
+        }
+
+
+
+        $('#submit').addClass('is_sub');
+        $("#subForm").submit();
+    })
+    layui.use('element', function(){
+        var $ = layui.jquery
+            ,element = layui.element;
+        var active = {
+            tabAdd: function(){
+                element.tabAdd('demo', {
+                    title: '新选项'+ (Math.random()*1000|0)
+                    ,content: '内容'+ (Math.random()*1000|0)
+                    ,id: new Date().getTime()
+                })
+            }
+            ,tabDelete: function(othis){
+                element.tabDelete('demo', '44');
+                othis.addClass('layui-btn-disabled');
+            }
+            ,tabChange: function(){
+                element.tabChange('demo', '22');
+            }
+        };
+
+        $('.site-demo-active').on('click', function(){
+            var othis = $(this), type = othis.data('type');
+            active[type] ? active[type].call(this, othis) : '';
+        });
+
+        //Hash地址的定位
+        var layid = location.hash.replace(/^#test=/, '');
+        element.tabChange('test', layid);
+
+        element.on('tab(test)', function(elem){
+            location.hash = 'test='+ $(this).attr('lay-id');
+        });
+
+    });
+
+
+    // 商品类型
+    var goods_type = $("#goods_type").val();
+    type_listen(goods_type)
+    // 商品类型选择监听
+    form.on('select(type)', function(data){
+        type_listen(data.value)
+    })
+    function type_listen(val) {
+        $(".goods_type .layui-form-item").hide();
+        $(".type"+val).show();
+        window.form.render();
+    }
+    // 单选按钮
+    var  is_gift = $("#is_gift").val();
+    gift_listen(is_gift);
+    function gift_listen(is_gift){
+        if(is_gift == 1){
+            $(".type4").show();
+        }else{
+            $(".type4").hide();
+        }
+    }
+    form.on('radio(is_gift)', function(data){
+        if($("input[name='is_gift']:checked").val() == 1){
+            $(".type4").show();
+        }else{
+            $(".type4").hide();
+        }
+    })
+
+    // 广告
+    var adv_type = $("#adv_type").val();
+    sel_listen(adv_type)
+    // 分类选择监听
+    form.on('select(adv_type)', function(data){
+        sel_listen(data.value)
+    })
+    function sel_listen(val) {
+        $(".adv_box .layui-form-item").hide();
+        $(".adv_box"+val).show();
+        window.form.render();
+    }
+
+    //mp3上传
+    $(document).on("click",'.up_img',function () {
+        $(this).siblings('[name="file"]').click();
+    })
+
+    function upload_img(e,k) {
+        var file = e.files[0]; //获取图片资源
+        var fileTypes = ['mp3'];
+        var bTypeMatch = false
+        for (var i = 0; i < fileTypes.length; i++) {
+            var start = file.name.lastIndexOf(".");
+            var fileType = file.name.substring(start + 1);
+            if (fileType.toLowerCase() == fileTypes[i]) {
+                bTypeMatch = true;
+                break;
+            }
+        }
+        if (bTypeMatch) {
+            if (file.size <= 1024 * 1024 * 50) {
+                var farmData = new FormData();
+                farmData.append("file", file)
+                $.ajax("/api/Upload/upload", {
+                    data: farmData,
+                    processData: false,
+                    contentType: false,
+                    dataType: 'json',
+                    type: 'post', //HTTP请求类型
+                    headers: {
+                        'zbtoken': localStorage.getItem("token"),
+                        'enctype': 'multipart/form-data',
+                    },
+                    success: function (data) {
+                        console.log(data)
+                        if(data.code == 1) {
+                            $("#mp3").attr('src',data.data);
+                            $(".audio_box").html($(".audio_box").html());
+                            $("input[name='mp3_url']").attr('value',data.data)
+                            window.form.render();
+                        }
+                        layer.msg(data.msg);
+                    },
+                    error: function (xhr, type, errorThrown) {
+                        console.log(type);
+                    }
+                });
+            } else {
+                alert('仅支持不超过50M的MP3');
+                return false;
+            }
+        } else {
+            alert("格式有误!请上传mp3格式");
+            return false;
+        }
+    }
+
+
+
+</script>
+

+ 39 - 0
application/store/view/goods1/hash.html

@@ -0,0 +1,39 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;"  action="{:url('hash')}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+
+        <div class="layui-form-item layui-row layui-col-space15">
+
+            <label class=" relative">
+                <span class="color-green">铸造数量</span>
+                <input name="number" required type="number" class="layui-input" placeholder="请输铸造数量" value="{$vo.inventory|default='1'}">
+            </label>
+
+        </div>
+
+
+        <div class="layui-form-item text-center">
+            {notempty name='id'}<input type="hidden" name="id" value="{$id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+
+    });
+</script>
+{/block}

+ 150 - 0
application/store/view/goods1/index.html

@@ -0,0 +1,150 @@
+{extend name='admin@main'}
+
+{block name="button"}
+<a data-dbclick class="layui-btn layui-btn-sm" data-open='{:url("add")}'>添加藏品</a>
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+    {include file='goods/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>商品名称</th>
+            <th class='text-left nowrap'>封面</th>
+            <th class='text-left nowrap'>价格</th>
+            <th class='text-left nowrap'>库存</th>
+            <th class='text-left nowrap'>剩余库存</th>
+            <th class='text-left nowrap'>铸造数量<br />(成功数/总数)</th>
+<!--            <th class="text-left nowrap">发行时间</th>-->
+            <th class="text-left nowrap">添加时间</th>
+            <th class="text-left nowrap">状态</th>
+            <th class="text-left nowrap">操作</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+
+            <td class='text-left nowrap'>{$vo.name|default=''}</td>
+            <td class='text-left nowrap'>
+                <img data-tips-image="{$vo.cover|default=''}"  src="{$vo.cover|default=''}" width="50px">
+            </td>
+            <td class='text-left nowrap'>{$vo.price|default=''}</td>
+            <td class='text-left nowrap'>{$vo.inventory|default=''}</td>
+            <td class='text-left nowrap'>{$vo.now_inventory|default=''}</td>
+            <td class='text-left nowrap'>{$vo.zz|default=''}/{$vo.casting_num|default=''}</td>
+<!--            <td class='text-left nowrap'>{$vo.sell_time|default=''}</td>-->
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+            <td class='text-left nowrap'>
+                {if $vo.status eq 0}已下架{else/}
+                正常
+                {/if}
+            </td>
+            <td class='text-left nowrap'>
+                <a data-title="铸造明细" class="layui-btn layui-btn-sm" data-open='{:url("detail")}?id={$vo.id}'>铸造明细</a>
+                <a data-title="铸造" class="layui-btn layui-btn-sm" data-modal='{:url("hash")}?id={$vo.id}'>铸造</a>
+                <a data-title="赠送" class="layui-btn layui-btn-sm" data-modal='{:url("send")}?id={$vo.id}'>赠送</a>
+                <a class='layui-btn layui-btn-normal layui-btn-sm dr' id="dr" style="background-color:#DC2219;margin-right: 10px;width: 65px " onclick="changename('{$vo.id}')">
+                     批量赠送
+                </a>
+                <a data-title="编辑商品" class="layui-btn layui-btn-sm" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
+                {if $vo.status eq 1}
+                <span class="layui-btn layui-btn-sm layui-btn-warm"   onclick="btn_confirm('下架','down','{$vo.id}');">下 架</span>
+                {else}
+                <span class="layui-btn layui-btn-sm layui-btn-warm" onclick="btn_confirm('上架','up','{$vo.id}');">上 架</span>
+                {/if}
+
+                <span data-title="删除商品" class="layui-btn layui-btn-sm layui-btn-danger"   onclick="btn_confirm('删除','del','{$vo.id}');" >删 除</span>
+
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+
+
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/goods/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+
+    var co_id = ''
+    function changename(val){
+        co_id = val
+    }
+    layui.use('upload', function(){
+        var upload = layui.upload;
+
+        //执行实例
+        var uploadInst = upload.render({
+            elem: '.dr' //绑定元素
+            ,url: 'admin/api.plugs/upload'
+            ,accept: 'file', //普通文件,
+            // ,data:{
+            //     id:function () {
+            //         return project_id
+            //     }
+            // },
+            before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
+                console.log(obj)
+                // layer.load(); //上传loading
+            }
+            ,done: function(res){
+                console.log(co_id)
+                console.log(res)
+                if (res.uploaded == true){
+                    var value = {path:res.key,c_id:co_id,url:res.url}
+                    $.ajax({
+                        url:"/store/goods/import",
+                        type:'get',
+                        data:value
+                        ,success:function(result){
+                            console.log(result);
+                            if (result.code==1){
+                                layer.msg('赠送成功',{time:2000,end:function () {
+                                        location.reload();
+                                        // $.form.href('{:url("admin/main_project/index")}');
+                                    }});
+                            }else if (result.code==2){
+                                layer.msg('成功:'+result.data.success+',失败:'+result.data.error,{icon: 5});
+                            }else if (result.code==3){
+                                layer.msg(result.info,{icon: 5});
+                            }
+                        }
+                    });
+                }else {
+                    layer.msg(res.error.message,{icon: 5});
+                }
+                // layer.closeAll('loading'); //关闭loading
+            }
+            ,error: function(){
+                layer.msg('上传失败');
+            }
+        });
+    });
+</script>
+{/block}
+
+
+

+ 16 - 0
application/store/view/goods1/index_search.html

@@ -0,0 +1,16 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">藏品名称</label>
+            <div class="layui-input-inline">
+                <input name="name" value="{$Think.get.name|default=''}" placeholder="请输入藏品名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 52 - 0
application/store/view/goods1/send.html

@@ -0,0 +1,52 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;"  action="{:url('send')}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+        <div class="layui-row margin-bottom-15">
+            <label class=" relative">
+                <label class="layui-col-xs10">
+                    <span class="color-green">选择用户</span>
+                    <select class="layui-select" required name="mid" lay-search>
+                        <option selected value="">请选择用户</option>
+                        {foreach $user as $v}
+                          <option value="{$v.id}">{$v.name|default=''}({$v.phone})</option>
+                        {/foreach}
+                    </select>
+                </label>
+            </label>
+        </div>
+
+        <div class="layui-form-item layui-row layui-col-space15">
+
+            <label class=" relative">
+                <span class="color-green">赠送数量</span>
+                <input name="number" required type="number" class="layui-input" placeholder="请输赠送数量" value="{$vo.inventory|default='1'}">
+            </label>
+
+        </div>
+
+
+        <div class="layui-form-item text-center">
+            {notempty name='id'}<input type="hidden" name="id" value="{$id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+
+    });
+</script>
+{/block}

+ 52 - 0
application/store/view/goods2/add_mater.html

@@ -0,0 +1,52 @@
+
+
+{block name="content"}
+
+<form onsubmit="return false;" action="{:url('add_edit_mater')}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+        <div class="layui-row margin-bottom-15">
+            <label class=" relative">
+                <label class="layui-col-xs10">
+                    <span class="color-green">选择材料</span>
+                    <select class="layui-select" required name="c_id" lay-search>
+                        <option value="">请选择材料</option>
+                        {foreach $list as $v}
+                        <option value="{$v.id}" {if isset($vo.id) && $vo.c_id eq $v.id}selected{/if}>{$v.name|default=''}</option>
+                        {/foreach}
+                    </select>
+                </label>
+            </label>
+        </div>
+
+        <div class="layui-form-item layui-row layui-col-space15">
+
+            <label class=" relative">
+                <span class="color-green">数量</span>
+                <input name="num" required type="number" class="layui-input" placeholder="数量" value="{$vo.num|default='1'}">
+            </label>
+
+        </div>
+
+
+        <div class="layui-form-item text-center">
+            <input type="hidden" name="cid" value="{$cid}">
+            {if isset($vo.id)}<input type="hidden" name="id" value="{$vo.id}">{/if}
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+
+    });
+</script>
+{/block}

+ 53 - 0
application/store/view/goods2/detail.html

@@ -0,0 +1,53 @@
+{extend name='admin@main'}
+
+
+{block name="content"}
+<div class="think-box-shadow">
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>hash</th>
+            <th class="text-left nowrap">铸造时间</th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+
+            <td class='text-left nowrap'>{$vo.hash|default=''}</td>
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+
+
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/goods/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+</script>
+{/block}
+
+
+

+ 221 - 0
application/store/view/goods2/form.html

@@ -0,0 +1,221 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;" id="GoodsForm" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">藏品图片</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <td width="90px" class="text-left"><input name="cover" lay-verify="required" type="hidden" value="{$vo.covers|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="cover"]').uploadOneImage(), $('[name="covers"]').uploadMultipleImage()</script>
+        </div>
+
+
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品名称</span>
+                <input name="name" required class="layui-input" placeholder="请输入藏品名称" value="{$vo.name|default=''}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品标签</span>
+                <input name="label" required class="layui-input" placeholder="请输入藏品标签" value="{$vo.label|default=''}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品库存</span>
+                <input name="inventory" required type="number" class="layui-input" placeholder="请输入库存" value="{$vo.inventory|default='1'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">藏品价格</span>
+                <input name="price" required type="number" step="1" class="layui-input" placeholder="请输入价格" value="{$vo.price|default='0'}">
+            </label>
+        </div>
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">开始时间</span>
+                <input name="sell_time" required id="sell_time" readonly value='{$vo.sell_time|default=""}' placeholder="" class="layui-input">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">结束时间</span>
+                <input name="end_time" required id="end_time" readonly value='{$vo.end_time|default=""}' placeholder="" class="layui-input">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">转赠天数(第一次转赠限制天数,0为不限制)</span>
+                <input name="one_given_day" required type="number" class="layui-input" placeholder="请输入转赠天数(第一次转赠限制天数,0为不限制)" value="{$vo.one_given_day|default='0'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">转赠天数(后续转赠限制天数,0为不限制)</span>
+                <input name="other_given_day" required type="number" step="1" class="layui-input" placeholder="请输入转赠天数(后续转赠限制天数,0为不限制)" value="{$vo.other_given_day|default='0'}">
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">作者姓名</span>
+                <input name="auth_name" required class="layui-input" placeholder="请输入作者姓名" value="{$vo.auth_name|default=''}">
+            </label>
+
+        </div>
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">作者头像</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <td width="90px" class="text-left"><input name="auth_img" type="hidden" value="{$vo.auth_imgs|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="auth_img"]').uploadOneImage(), $('[name="auth_imgs"]').uploadMultipleImage()</script>
+        </div>
+
+        <div class="layui-form-item layui-row layui-col-space15">
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">作品介绍</span>
+                <textarea placeholder="请输入作品介绍" required class="layui-textarea" name="intro">{$vo.intro|default=""}</textarea>
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">权益说明</span>
+                <textarea placeholder="请输入权益说明" required class="layui-textarea" name="instructions">{$vo.instructions|default=""}</textarea>
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">购买须知</span>
+                <textarea placeholder="请输入购买须知" required class="layui-textarea" name="buy_notice">{$vo.buy_notice|default=""}</textarea>
+            </label>
+            <label class="layui-col-xs3 relative">
+                <span class="color-green">温馨提示</span>
+                <textarea placeholder="请输入温馨提示" required class="layui-textarea" name="warm_prompt">{$vo.warm_prompt|default=""}</textarea>
+            </label>
+        </div>
+
+
+        <div class="layui-form-item">
+            <span class="color-green label-required-prev">商品描述(多张图片)</span>
+            <table class="layui-table">
+                <thead>
+                <tr>
+                    <!--<td width="90px" class="text-center"><input name="logo" type="hidden" value="{$vo.logo|default=''}"></td>-->
+                    <td width="auto" class="text-left"><input name="describe" type="hidden" value="{$vo.describes|default=''}"></td>
+                </tr>
+                </thead>
+            </table>
+            <script>$('[name="logo"]').uploadOneImage(), $('[name="describe"]').uploadMultipleImage()</script>
+        </div>
+
+<!--        <div class="layui-form-item">-->
+<!--            <span class="color-green label-required-prev">分享二维码</span>-->
+<!--            <table class="layui-table">-->
+<!--                <thead>-->
+<!--                <tr>-->
+<!--                    <td width="90px" class="text-left"><input name="share_img" type="hidden" value="{$vo.share_imgs|default=''}"></td>-->
+<!--                </tr>-->
+<!--                </thead>-->
+<!--            </table>-->
+<!--            <script>$('[name="share_img"]').uploadOneImage(), $('[name="share_imgs"]').uploadMultipleImage()</script>-->
+<!--        </div>-->
+
+        <div class="layui-form-item text-center">
+            {notempty name='vo.id'}<input type="hidden" name="id" value="{$vo.id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+        var form = layui.form
+            ,layer = layui.layer
+            ,layedit = layui.layedit
+            ,laydate = layui.laydate;
+
+        laydate.render({
+            elem: '#sell_time'
+            ,type: 'datetime'
+            ,min:new Date().toLocaleString()
+        });
+        laydate.render({
+            elem: '#end_time'
+            ,type: 'datetime'
+            ,min:new Date().toLocaleString()
+        });
+        form.render();
+        //日期
+        laydate.render({
+            elem: '#date'
+        });
+        laydate.render({
+            elem: '#date1'
+        });
+
+        form.on('select(province)', function (data) {
+            var val = data.value;
+            // console.log(val)
+            $.ajax({
+                type:"get",
+                url:"{:url('member/get_city')}",  //数据传输的控制器方法
+                data: {id:val},//这里data传递过去的是序列化以后的字符串
+                success:function(data){
+                   // console.log(data)
+                    var arr = data.data;
+                    //console.log(arr)
+                    if (arr.length>0){
+                        //$("#tow").attr("style","display:block;");//显示div
+                        var options='<option value="">请选择市</option>';
+                        for (var i = 0; i < arr.length; i++) {
+                            var tag = arr[i];
+                            options+=' <option value="'+tag.id+'">'+tag.name+'</option>';
+                        }
+                        $("select[name='city']").html(options)
+                        form.render('select');
+                    }else {
+                        var options='<option value="">请选择市</option>';
+                        $("select[name='city']").html(options)
+                        form.render('select');
+                    }
+                }
+            });
+        });
+
+        form.on('select(city)', function (data) {
+            var val = data.value;
+            // console.log(val)
+            $.ajax({
+                type:"get",
+                url:"{:url('member/get_area')}",  //数据传输的控制器方法
+                data: {id:val},//这里data传递过去的是序列化以后的字符串
+                success:function(data){
+                    //console.log(data)
+                    var arr = data.data;
+                   // console.log(arr)
+                    if (arr.length>0){
+                        var options='<option value="">请选择区</option>';
+                        for (var i = 0; i < arr.length; i++) {
+                            var tag = arr[i];
+                            options+=' <option value="'+tag.id+'">'+tag.name+'</option>';
+                        }
+                        $("select[name='area']").html(options)
+                        form.render('select');
+                    }else {
+                        var options='<option value="">请选择区</option>';
+                        $("select[name='area']").html(options)
+                        form.render('select');
+                    }
+                }
+            });
+        });
+
+
+
+    });
+</script>
+{/block}

+ 479 - 0
application/store/view/goods2/form2.html

@@ -0,0 +1,479 @@
+
+<link rel="stylesheet" href="/static/plugs/layui/css/layui.css"  media="all">
+
+<style>
+    .layui-form-item {
+        width: 80%;
+        height: 90%;
+    }
+    .layui-form-radio{
+       width: 10px !important;
+    }
+
+</style>
+
+<div class="think-box-shadow" style="height: 100%">
+    <form class="layui-form layui-card" id="subForm" action="{:request()->url()}"  data-auto="true" method="post" autocomplete="off">
+        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 30px;">
+            <legend>商品编辑</legend>
+        </fieldset>
+        <div class="layui-tab">
+            <ul class="layui-tab-title">
+                <li class="layui-this">基础设置</li>
+                <li >其他</li>
+            </ul>
+            <div class="layui-tab-content ">
+                <!--基础设置-->
+                <div class="layui-tab-item layui-show">
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品名称</label>
+                        <div class="layui-input-block">
+                            <input name="name" lay-verify="required" maxlength="50"  value='{$vo.name|default=""}' placeholder="请输入商品名称" class="layui-input">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item" style="display: none">
+                        <label class="layui-form-label">商品简介</label>
+                        <div class="layui-input-block">
+                            <input name="desc" maxlength="50"  value='{$vo.desc|default=""}' placeholder="请输入商品简介" class="layui-input">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品封面</label>
+                        <div class="layui-input-block">
+                            <input name="cover" type="hidden" value="{$vo.cover|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品类型</label>
+                        <div class="layui-input-inline">
+                            <input type="hidden" id="goods_type" value="{$vo.type|default='1'}"/>
+                            <select name="type" {if isset($vo.id)}disabled{/if} lay-filter ="type">
+                                {foreach  $goods_type as $gk=>$gv}
+                                    <option value="{$gk}"  {if isset($vo.id) && $vo.type ==  $gk}selected{/if}>{$gv}</option>
+                                {/foreach}
+                            </select>
+                        </div>
+                    </div>
+
+                    <div class="goods_type">
+                        <div class="layui-form-item type1">
+                            <label class="layui-form-label label-required">商品售价</label>
+                            <div class="layui-input-block">
+                                <input name="goods_price" type="number" step="1" class="layui-input"  value="{$vo.goods_price|default=''}">
+                            </div>
+                        </div>
+                        <div class="layui-form-item type3">
+                            <label class="layui-form-label">邀请人数</label>
+                            <div class="layui-input-block">
+                                <input name="invite_num" type="number" step="1" class="layui-input"  value="{$vo.invite_num|default='0'}">
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">是否转赠</label>
+
+                        <div class="layui-input-block">
+                            <input type="hidden" id="is_gift" value="{$vo.is_gift|default='0'}"/>
+                            <div>
+                                {foreach [0=>'否',1=>'是'] as $sk=>$sv}
+                                <!--{if (isset($vo.id) && $vo.is_gift eq $sk) || ($sk== 0 && !isset($vo.id)) }-->
+                                <label>
+                                    <input checked type="radio"  name="is_gift" value="{$sk}"  lay-filter="is_gift">
+                                </label>
+                                <!--{else}-->
+                                <label >
+                                    <input type="radio" name="is_gift" value="{$sk}"  lay-filter="is_gift" >
+                                </label>
+                                <!--{/if}-->
+                                <span class="" style="line-height: 22px">{$sv}</span>
+                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                                {/foreach}
+                            </div>
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item type4 ">
+                        <label class="layui-form-label">转赠元石</label>
+                        <div class="layui-input-block">
+                            <input name="crystal" type="number" step="1" class="layui-input"  value="{$vo.crystal|default='0'}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item type4">
+                        <label class="layui-form-label">转赠时间限制(天)</label>
+                        <div class="layui-input-block">
+                            <input name="gift_day" type="number" step="1" class="layui-input"  value="{$vo.gift_day|default='0'}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">商品库存</label>
+                        <div class="layui-input-block">
+                            <input name="stock"type="number" step="1" class="layui-input"  value="{$vo.stock|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">收藏量</label>
+                        <div class="layui-input-block">
+                            <input name="vir_num"type="number" step="1" class="layui-input"  value="{$vo.vir_num|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">藏品介绍</label>
+                        <div class="layui-input-block">
+                            <input name="coll_intro"type=""  class="layui-input"  value="{$vo.coll_intro|default=''}">
+                        </div>
+                    </div>
+
+
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label ">上架时间</label>
+                        <div class="layui-input-block">
+                            <input name="sell_time" id="sell_time" value='{$vo.sell_time|default=""}' placeholder="" class="layui-input">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label label-required">展示类型</label>
+                        <div class="layui-input-inline">
+                            <input id="adv_type" type="hidden" value="{$vo.adv_type|default='1'}" />
+                            <select name="adv_type" lay-filter ="adv_type">
+                                <option value="1" {if isset($vo.adv_type) && $vo.adv_type == 1}selected{/if}>图片</option>
+                                <option value="3" {if isset($vo.adv_type) && $vo.adv_type == 3}selected{/if}>视频</option>
+                            </select>
+                        </div>
+                    </div>
+
+                    <div class="adv_box">
+                        <div class="layui-form-item adv_box1">
+                            <label class="layui-form-label">展示封面</label>
+                            <div class="layui-input-block">
+                                <input name="adv_cover" type="hidden" value="{$vo.adv_cover|default=''}">
+                            </div>
+                        </div>
+
+                        <div class="layui-form-item adv_box2">
+                            <label class="layui-form-label">展示音频</label>
+                            <div class="layui-input-block">
+                                <div class="audio_box" style="float:left;">
+                                    <audio   style='' controls>
+                                        <source  src="" >
+                                        <source id="mp3" src="{$vo.mp3_url|default=''}" >
+                                    </audio>
+                                </div>
+                                <div  class ='up_img' style='color: blue;line-height:50px;margin-left:30px;float: left; width: 60px ;'>选 择</div >
+                                <input  style="display: none"  type="file" name="file" accept="mp3" value="" onchange="upload_img(this)" class="layui-input"/>
+                                <input  style="display: none"  value="{$vo.mp3_url|default=''}" name="mp3_url" class="layui-input"/>
+                                <div></div>
+                            </div>
+                        </div>
+
+
+
+
+
+                        <div class="layui-form-item adv_box3">
+                            <label class="layui-form-label ">展示视频</label>
+                            <div class="layui-input-block">
+                                <input name="audio_url" type="hidden" value="{$vo.audio_url|default=''}">
+                            </div>
+                        </div>
+
+                        <div class="layui-form-item adv_box3">
+                            <label class="layui-form-label ">进度显示</label>
+                            <div class="layui-input-block">
+                                <input type="hidden" id="audio_line" value="{$vo.audio_line|default='0'}"/>
+                                <div>
+                                    {foreach [0=>'否',1=>'是'] as $sk=>$sv}
+                                    <!--{if (isset($vo.id) && $vo.audio_line eq $sk) || ($sk== 0 && !isset($vo.id)) }-->
+                                    <label>
+                                        <input checked type="radio"  name="audio_line" value="{$sk}"  lay-filter="audio_line">
+                                    </label>
+                                    <!--{else}-->
+                                    <label >
+                                        <input type="radio" name="audio_line" value="{$sk}"  lay-filter="audio_line" >
+                                    </label>
+                                    <!--{/if}-->
+                                    <span class="" style="line-height: 22px">{$sv}</span>
+                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
+                                    {/foreach}
+                                </div>
+                            </div>
+                        </div>
+
+                    </div>
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label">购买须知</label>
+                        <div class="layui-input-block">
+                            <textarea name="buy_notice" style="height: 150px;width: 100%;border-color: #e6e6e6" >{$vo.buy_notice|default=""}</textarea>
+                        </div>
+                    </div>
+
+                </div>
+                <!--其他设置-->
+                <div class="layui-tab-item">
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">分享图片</label>
+                        <div class="layui-input-block">
+                            <input name="share_img" type="hidden" value="{$vo.share_img|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">支付图片</label>
+                        <div class="layui-input-block">
+                            <input name="pay_pic" type="hidden" value="{$vo.pay_pic|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">支付内容</label>
+                        <div class="layui-input-block">
+                            <input name="pay_content" maxlength="30" type=""  class="layui-input"  value="{$vo.pay_content|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">发行方头像</label>
+                        <div class="layui-input-block">
+                            <input name="auth_img" type="hidden" value="{$vo.auth_img|default=''}">
+                        </div>
+                    </div>
+
+
+
+                    <div class="layui-form-item">
+                        <label class="layui-form-label">发行方</label>
+                        <div class="layui-input-block">
+                            <input name="issuer" class="layui-input"  value="{$vo.issuer|default=''}">
+                        </div>
+                    </div>
+
+                    <div class="layui-form-item" >
+                        <label class="layui-form-label">商品详情</label>
+                        <div class="layui-input-block">
+                            <textarea name="detail">{$vo.detail|default=""}</textarea>
+                        </div>
+                    </div>
+                    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
+                    <div class="layui-form-item text-center">
+                        <span class="layui-btn" type='submit' id ="submit">保 存</span>
+                        <button class="layui-btn layui-btn-danger" type='button' onclick="history.go(-1);">取消编辑</button>
+                    </div>
+                </div>
+            </div>
+
+        </div>
+    </form>
+</div>
+<script src="/static/plugs/layui/layui.all.js" charset="utf-8"></script>
+<script>
+    window.form.render();
+    require(['ckeditor', 'angular'], function () {
+        window.createEditor('[name="detail"]', {height: 500,width:1000});
+    })
+    layui.use('laydate', function(){
+        var laydate = layui.laydate;
+        laydate.render({
+            elem: '#sell_time'
+            ,type: 'datetime'
+        });
+        laydate.render({
+            elem: '#end_time'
+            ,type: 'datetime'
+        });
+    })
+    $('[name="cover"]').uploadOneImage();
+    $('[name="share_img"]').uploadOneImage();
+    $('[name="adv_cover"]').uploadOneImage();
+    $('[name="auth_img"]').uploadOneImage();
+    $('[name="pay_pic"]').uploadOneImage();
+    $('[name="audio_url"]').uploadOneVideo()
+    /**
+     * 表单验证
+     */
+    $(document).on('click','#submit',function () {
+        if($('#submit').hasClass('is_sub')) {
+            return false;
+        }
+
+        var goods_name = $('input[name="name"]').val();
+        if(!goods_name){
+            layer.msg('请填写商品名称!')
+            return false;
+        }
+
+        var goods_cover = $('input[name="cover"]').val();
+        if(!goods_cover){
+            layer.msg('请上传商品封面!')
+            return false;
+        }
+
+        var goods_type = $('select[name="type"]').val();
+        var goods_price = $('input[name="goods_price"]').val();
+        if(!goods_type == 1 && !goods_price){
+            layer.msg('请输入商品价格!')
+            return false;
+        }
+
+        var  vir_num =  $('input[name="vir_num"]').val();
+        if(!vir_num){
+            layer.msg('请输入商品收藏量!')
+            return false;
+        }
+
+
+
+        $('#submit').addClass('is_sub');
+        $("#subForm").submit();
+    })
+    layui.use('element', function(){
+        var $ = layui.jquery
+            ,element = layui.element;
+        var active = {
+            tabAdd: function(){
+                element.tabAdd('demo', {
+                    title: '新选项'+ (Math.random()*1000|0)
+                    ,content: '内容'+ (Math.random()*1000|0)
+                    ,id: new Date().getTime()
+                })
+            }
+            ,tabDelete: function(othis){
+                element.tabDelete('demo', '44');
+                othis.addClass('layui-btn-disabled');
+            }
+            ,tabChange: function(){
+                element.tabChange('demo', '22');
+            }
+        };
+
+        $('.site-demo-active').on('click', function(){
+            var othis = $(this), type = othis.data('type');
+            active[type] ? active[type].call(this, othis) : '';
+        });
+
+        //Hash地址的定位
+        var layid = location.hash.replace(/^#test=/, '');
+        element.tabChange('test', layid);
+
+        element.on('tab(test)', function(elem){
+            location.hash = 'test='+ $(this).attr('lay-id');
+        });
+
+    });
+
+
+    // 商品类型
+    var goods_type = $("#goods_type").val();
+    type_listen(goods_type)
+    // 商品类型选择监听
+    form.on('select(type)', function(data){
+        type_listen(data.value)
+    })
+    function type_listen(val) {
+        $(".goods_type .layui-form-item").hide();
+        $(".type"+val).show();
+        window.form.render();
+    }
+    // 单选按钮
+    var  is_gift = $("#is_gift").val();
+    gift_listen(is_gift);
+    function gift_listen(is_gift){
+        if(is_gift == 1){
+            $(".type4").show();
+        }else{
+            $(".type4").hide();
+        }
+    }
+    form.on('radio(is_gift)', function(data){
+        if($("input[name='is_gift']:checked").val() == 1){
+            $(".type4").show();
+        }else{
+            $(".type4").hide();
+        }
+    })
+
+    // 广告
+    var adv_type = $("#adv_type").val();
+    sel_listen(adv_type)
+    // 分类选择监听
+    form.on('select(adv_type)', function(data){
+        sel_listen(data.value)
+    })
+    function sel_listen(val) {
+        $(".adv_box .layui-form-item").hide();
+        $(".adv_box"+val).show();
+        window.form.render();
+    }
+
+    //mp3上传
+    $(document).on("click",'.up_img',function () {
+        $(this).siblings('[name="file"]').click();
+    })
+
+    function upload_img(e,k) {
+        var file = e.files[0]; //获取图片资源
+        var fileTypes = ['mp3'];
+        var bTypeMatch = false
+        for (var i = 0; i < fileTypes.length; i++) {
+            var start = file.name.lastIndexOf(".");
+            var fileType = file.name.substring(start + 1);
+            if (fileType.toLowerCase() == fileTypes[i]) {
+                bTypeMatch = true;
+                break;
+            }
+        }
+        if (bTypeMatch) {
+            if (file.size <= 1024 * 1024 * 50) {
+                var farmData = new FormData();
+                farmData.append("file", file)
+                $.ajax("/api/Upload/upload", {
+                    data: farmData,
+                    processData: false,
+                    contentType: false,
+                    dataType: 'json',
+                    type: 'post', //HTTP请求类型
+                    headers: {
+                        'zbtoken': localStorage.getItem("token"),
+                        'enctype': 'multipart/form-data',
+                    },
+                    success: function (data) {
+                        console.log(data)
+                        if(data.code == 1) {
+                            $("#mp3").attr('src',data.data);
+                            $(".audio_box").html($(".audio_box").html());
+                            $("input[name='mp3_url']").attr('value',data.data)
+                            window.form.render();
+                        }
+                        layer.msg(data.msg);
+                    },
+                    error: function (xhr, type, errorThrown) {
+                        console.log(type);
+                    }
+                });
+            } else {
+                alert('仅支持不超过50M的MP3');
+                return false;
+            }
+        } else {
+            alert("格式有误!请上传mp3格式");
+            return false;
+        }
+    }
+
+
+
+</script>
+

+ 39 - 0
application/store/view/goods2/hash.html

@@ -0,0 +1,39 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;"  action="{:url('hash')}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+
+        <div class="layui-form-item layui-row layui-col-space15">
+
+            <label class=" relative">
+                <span class="color-green">铸造数量</span>
+                <input name="number" required type="number" class="layui-input" placeholder="请输铸造数量" value="{$vo.inventory|default='1'}">
+            </label>
+
+        </div>
+
+
+        <div class="layui-form-item text-center">
+            {notempty name='id'}<input type="hidden" name="id" value="{$id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+
+    });
+</script>
+{/block}

+ 158 - 0
application/store/view/goods2/index.html

@@ -0,0 +1,158 @@
+{extend name='admin@main'}
+
+{block name="button"}
+<a data-dbclick class="layui-btn layui-btn-sm" data-open='{:url("add")}'>添加藏品</a>
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+    {include file='goods/index_search'}
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>商品名称</th>
+            <th class='text-left nowrap'>封面</th>
+            <th class='text-left nowrap'>价格</th>
+            <th class='text-left nowrap'>库存</th>
+            <th class='text-left nowrap'>剩余库存</th>
+            <th class='text-left nowrap'>铸造数量<br />(成功数/总数)</th>
+            <th class="text-left nowrap">开始时间</th>
+            <th class="text-left nowrap">结束时间</th>
+            <th class="text-left nowrap">添加时间</th>
+            <th class="text-left nowrap">状态</th>
+            <th class="text-right"></th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+
+            <td class='text-left nowrap'>{$vo.name|default=''}</td>
+            <td class='text-left nowrap'>
+                <img data-tips-image="{$vo.cover|default=''}"  src="{$vo.cover|default=''}" width="50px">
+            </td>
+            <td class='text-left nowrap'>{$vo.price|default=''}</td>
+            <td class='text-left nowrap'>{$vo.inventory|default=''}</td>
+            <td class='text-left nowrap'>{$vo.now_inventory|default=''}</td>
+            <td class='text-left nowrap'>{$vo.zz|default=''}/{$vo.casting_num|default=''}</td>
+            <td class='text-left nowrap'>{$vo.sell_time|default=''}</td>
+            <td class='text-left nowrap'>{$vo.end_time|default=''}</td>
+            <td class='text-left nowrap'>{$vo.create_at}</td>
+            <td class='text-left nowrap'>
+                {if $vo.status eq 0}已下架{else/}
+                {eq name='vo.sy_state' value='1'}合成中{/eq}
+                {eq name='vo.sy_state' value='2'}即将开售{/eq}
+                {eq name='vo.sy_state' value='3'}已结束{/eq}
+                {eq name='vo.sy_state' value='4'}已售罄{/eq}
+                {/if}
+            </td>
+            <td class='text-right'>
+                <a data-title="合成材料"  class="layui-btn layui-btn-sm" data-open='{:url("material")}?id={$vo.id}'>合成材料</a>
+                <a data-title="铸造明细" class="layui-btn layui-btn-sm" data-open='{:url("detail")}?id={$vo.id}'>铸造明细</a>
+                <a data-title="铸造" class="layui-btn layui-btn-sm" data-modal='{:url("hash")}?id={$vo.id}'>铸造</a>
+                {if $vo.sy_state eq 2}
+                <a data-title="赠送" class="layui-btn layui-btn-sm" data-modal='{:url("send")}?id={$vo.id}'>赠送</a>
+                <a class='layui-btn layui-btn-normal layui-btn-sm dr' id="dr" style="background-color:#DC2219;margin-right: 10px;width: 65px " onclick="changename('{$vo.id}')">
+                     批量赠送
+                </a>
+                <a data-title="编辑商品" class="layui-btn layui-btn-sm" data-open='{:url("edit")}?id={$vo.id}'>编 辑</a>
+                {/if}
+                {if $vo.status eq 1}
+                <span class="layui-btn layui-btn-sm layui-btn-warm"   onclick="btn_confirm('下架','down','{$vo.id}');">下 架</span>
+                {else}
+                <span class="layui-btn layui-btn-sm layui-btn-warm" onclick="btn_confirm('上架','up','{$vo.id}');">上 架</span>
+                {/if}
+
+                <span data-title="删除商品" class="layui-btn layui-btn-sm layui-btn-danger"   onclick="btn_confirm('删除','del','{$vo.id}');" >删 除</span>
+
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+
+
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/goods/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+
+    var co_id = ''
+    function changename(val){
+        co_id = val
+    }
+    layui.use('upload', function(){
+        var upload = layui.upload;
+
+        //执行实例
+        var uploadInst = upload.render({
+            elem: '.dr' //绑定元素
+            ,url: 'admin/api.plugs/upload'
+            ,accept: 'file', //普通文件,
+            // ,data:{
+            //     id:function () {
+            //         return project_id
+            //     }
+            // },
+            before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
+                console.log(obj)
+                // layer.load(); //上传loading
+            }
+            ,done: function(res){
+                console.log(co_id)
+                console.log(res)
+                if (res.uploaded == true){
+                    var value = {path:res.key,c_id:co_id,url:res.url}
+                    $.ajax({
+                        url:"/store/goods/import",
+                        type:'get',
+                        data:value
+                        ,success:function(result){
+                            console.log(result);
+                            if (result.code==1){
+                                layer.msg('赠送成功',{time:2000,end:function () {
+                                        location.reload();
+                                        // $.form.href('{:url("admin/main_project/index")}');
+                                    }});
+                            }else if (result.code==2){
+                                layer.msg('成功:'+result.data.success+',失败:'+result.data.error,{icon: 5});
+                            }else if (result.code==3){
+                                layer.msg(result.info,{icon: 5});
+                            }
+                        }
+                    });
+                }else {
+                    layer.msg(res.error.message,{icon: 5});
+                }
+                // layer.closeAll('loading'); //关闭loading
+            }
+            ,error: function(){
+                layer.msg('上传失败');
+            }
+        });
+    });
+</script>
+{/block}
+
+
+

+ 16 - 0
application/store/view/goods2/index_search.html

@@ -0,0 +1,16 @@
+<fieldset>
+    <legend>条件搜索</legend>
+    <form class="layui-form layui-form-pane form-search" action="{:request()->url()}" onsubmit="return false" method="get" autocomplete="off">
+        <div class="layui-form-item layui-inline">
+            <label class="layui-form-label">藏品名称</label>
+            <div class="layui-input-inline">
+                <input name="name" value="{$Think.get.name|default=''}" placeholder="请输入藏品名称" class="layui-input">
+            </div>
+        </div>
+
+        <div class="layui-form-item layui-inline">
+            <button class="layui-btn layui-btn-primary"><i class="layui-icon">&#xe615;</i> 搜 索</button>
+        </div>
+    </form>
+    <script>form.render()</script>
+</fieldset>

+ 124 - 0
application/store/view/goods2/material.html

@@ -0,0 +1,124 @@
+{extend name='admin@main'}
+
+{block name="button"}
+<a data-title="添加" class="layui-btn layui-btn-sm" data-modal='{:url("add_mater")}?cid={$cid}'>添加</a>
+{/block}
+
+{block name="content"}
+<div class="think-box-shadow">
+
+    <table class="layui-table margin-top-10" lay-skin="line">
+        {notempty name='list'}
+        <thead>
+        <tr>
+            <th class='text-left nowrap'>藏品</th>
+            <th class='text-left nowrap'>封面</th>
+            <th class='text-left nowrap'>数量</th>
+            <th class="text-left nowrap">添加时间</th>
+            <th class="text-right"></th>
+        </tr>
+        </thead>
+        {/notempty}
+        <tbody>
+        {foreach $list as $key=>$vo}
+        <tr>
+
+            <td class='text-left nowrap'>{$vo.name|default=''}</td>
+            <td class='text-left nowrap'>
+                <img data-tips-image="{$vo.cover|default=''}"  src="{$vo.cover|default=''}" width="50px">
+            </td>
+            <td class='text-left nowrap'>{$vo.num|default=''}</td>
+            <td class='text-left nowrap'>{$vo.create_at|default=''}</td>
+            <td class='text-right'>
+                <a data-title="编辑" class="layui-btn layui-btn-sm" data-modal='{:url("edit_mater")}?id={$vo.id}&cid={$cid}'>编 辑</a>
+                <span data-title="删除" class="layui-btn layui-btn-sm layui-btn-danger"   onclick="btn_confirm('删除','del_mater','{$vo.id}');" >删 除</span>
+
+            </td>
+        </tr>
+        {/foreach}
+        </tbody>
+    </table>
+    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
+</div>
+<script>
+
+
+    function btn_confirm(msg,fun,id) {
+        layer.confirm('请确定是否'+msg, {btn: ['确定', '取消'], title: "提示"}, function () {
+            var url = "/store/goods2/"+fun;
+            layer.closeAll();
+            $.ajax({
+                type: "post",
+                url: url,
+                data: {id:id},
+                dataType: "json",
+                async: false,
+                success: function (data) {
+                    layer.msg(data.info);
+                    setTimeout(function () {
+                        window.location.reload();
+                    },1000)
+                }
+            });
+        });
+    }
+
+    var co_id = ''
+    function changename(val){
+        co_id = val
+    }
+    layui.use('upload', function(){
+        var upload = layui.upload;
+
+        //执行实例
+        var uploadInst = upload.render({
+            elem: '.dr' //绑定元素
+            ,url: 'admin/api.plugs/upload'
+            ,accept: 'file', //普通文件,
+            // ,data:{
+            //     id:function () {
+            //         return project_id
+            //     }
+            // },
+            before: function(obj){ //obj参数包含的信息,跟 choose回调完全一致,可参见上文。
+                console.log(obj)
+                // layer.load(); //上传loading
+            }
+            ,done: function(res){
+                console.log(co_id)
+                console.log(res)
+                if (res.uploaded == true){
+                    var value = {path:res.key,c_id:co_id,url:res.url}
+                    $.ajax({
+                        url:"/store/goods/import",
+                        type:'get',
+                        data:value
+                        ,success:function(result){
+                            console.log(result);
+                            if (result.code==1){
+                                layer.msg('赠送成功',{time:2000,end:function () {
+                                        location.reload();
+                                        // $.form.href('{:url("admin/main_project/index")}');
+                                    }});
+                            }else if (result.code==2){
+                                layer.msg('成功:'+result.data.success+',失败:'+result.data.error,{icon: 5});
+                            }else if (result.code==3){
+                                layer.msg(result.info,{icon: 5});
+                            }
+                        }
+                    });
+                }else {
+                    layer.msg(res.error.message,{icon: 5});
+                }
+                // layer.closeAll('loading'); //关闭loading
+            }
+            ,error: function(){
+                layer.msg('上传失败');
+            }
+        });
+    });
+</script>
+{/block}
+
+
+

+ 52 - 0
application/store/view/goods2/send.html

@@ -0,0 +1,52 @@
+{extend name='admin@main'}
+
+{block name="content"}
+
+<form onsubmit="return false;"  action="{:url('send')}" data-auto="true" method="post" class='layui-form layui-card' autocomplete="off">
+
+    <div class="layui-card-body think-box-shadow padding-left-40">
+
+        <div class="layui-row margin-bottom-15">
+            <label class=" relative">
+                <label class="layui-col-xs10">
+                    <span class="color-green">选择用户</span>
+                    <select class="layui-select" required name="mid" lay-search>
+                        <option selected value="">请选择用户</option>
+                        {foreach $user as $v}
+                          <option value="{$v.id}">{$v.name|default=''}({$v.phone})</option>
+                        {/foreach}
+                    </select>
+                </label>
+            </label>
+        </div>
+
+        <div class="layui-form-item layui-row layui-col-space15">
+
+            <label class=" relative">
+                <span class="color-green">赠送数量</span>
+                <input name="number" required type="number" class="layui-input" placeholder="请输赠送数量" value="{$vo.inventory|default='1'}">
+            </label>
+
+        </div>
+
+
+        <div class="layui-form-item text-center">
+            {notempty name='id'}<input type="hidden" name="id" value="{$id}">{/notempty}
+            <button class="layui-btn layui-btn-danger" onclick="history.go(-1);" type="button">取消编辑</button>
+            <button class="layui-btn" type="submit">保存</button>
+        </div>
+
+    </div>
+</form>
+{/block}
+
+{block name='script'}
+
+<script>
+    layui.form.render();
+    layui.use(['form', 'layedit', 'laydate'], function(){
+
+
+    });
+</script>
+{/block}