enter($url); return self::outsuccess(['direct_uri' => $url],"redirect"); } if($common_id <= 0 || empty($batch_code)) { return self::outerr(errcode::ErrParamter,"错误的参数","fcode/error"); } $oper = new fcode\operator($common_id,$batch_code,$mobile,session_helper::session_id()); $fcode = $oper->grabed(); $goods = $this->goods($common_id); if($fcode == false) { if(empty($goods)) { return self::outsuccess(array('error' => "商品已经下架,请关注其它F码"),"fcode/error",'wap'); } elseif($status < 0) { return self::outsuccess(array('error' => "该商品F码已经被抢光~"),"fcode/error",'wap'); } else { $name = $goods['goods_name']; $price = $goods['goods_price']; $image = $goods['goods_image']; $image = cthumb($image, 1280, 6); return self::outsuccess(array('name' => $name,'price' => $price,'image' => $image, 'common_id' => $common_id,'batch_code' => $batch_code), "fcode/index",'wap'); } } else { $name = $goods['goods_name']; $price = $goods['goods_price']; $image = $goods['goods_image']; $image = cthumb($image, 1280, 6); $fcoder = new fcode\mfcode($fcode); if($fcoder->binded()) { return self::outsuccess(['fcode' => $fcode,'name' => $name,'price' => $price,'image' => $image], "fcode/success",'wap'); } else { if(session_helper::logined()) { $oper->bind($fcode); $fcode = $oper->grabed(); return self::outsuccess(['fcode' => $fcode,'name' => $name,'price' => $price,'image' => $image], "fcode/success",'wap'); } else { return self::outsuccess(['fcode' => $fcode,'name' => $name,'price' => $price,'image' => $image], "fcode/bind",'wap'); } } } } private function goods($common_id) { $goods_id = commonid_helper::instance()->one_goods($common_id); if($goods_id == false) return []; $mod = Model('goods'); $goods = $mod->find($goods_id); return $goods; } public function openOp() { $common_id = intval($_GET['common_id']); $batch_code = $_GET['batch_code']; if($common_id <= 0 || empty($batch_code)) { $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}"; return self::outsuccess(['url' => $url]); } $oper = new fcode\operator($common_id,$batch_code,session_helper::mobile(),session_helper::session_id()); $fcode = $oper->grabed(); if($fcode == false) { $fcode = $oper->grab(); if($fcode == false) { $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}&status=-1"; return self::outsuccess(['url' => $url]); } } $url = BASE_SITE_URL . "/mobile/index.php?act=fcode&op=index&common_id={$common_id}&batch_code={$batch_code}"; return self::outsuccess(['url' => $url]); } public function bindOp() { $common_id = intval($_GET['common_id']); $batch_code = $_GET['batch_code']; if($common_id <= 0 || empty($batch_code)) { return self::outerr(errcode::ErrParamter,"错误的参数"); } $mobile = $_GET['mobile']; $validator = new Validator(); $validator->setValidate(Validator::verify_mobile($mobile)); $err = $validator->validate(); if ($err != '') { return self::outerr(errcode::ErrParamter, $err); } $oper = new fcode\operator($common_id,$batch_code,$mobile,session_helper::session_id()); $fcode = $oper->grabed(); if($fcode == false) { return self::outerr(errcode::ErrParamter, "您没有该批次商品的F码."); } $fcoder = new fcode\mfcode($fcode); if($fcoder->binded()) { return self::outsuccess(null); } if(!isset($_GET['code']) || empty($_GET['code'])) { return self::outerr(errcode::ErrParamter, "请输入验证码."); } $code = $_GET['code']; $ret = sms_helper::check_code(sms_helper::getfcode,$code,$mobile); if(is_array($ret)) { return self::outerr($ret['code'], $ret['msg']); } else { login_helper::onBinded($mobile,session_helper::relay_id()); $oper->bind($fcode); return self::outsuccess(null); } } }