public function chooseAddressAction() { //取OPENID,并送入模板 $openid = I('get.openid'); $this->assign('openid', $openid); //取用户收货地址信息 $address = new CustomerAddressModel(); $address->setOpenid($openid); $addressList = $address->getAddress(); $this->assign('address', $addressList); //计算用户还可以添加的数量 $count = count($addressList); $allowAddCount = $this->maxAddressCount - count($addressList); $data['allowAddressNo'] = $allowAddCount; $this->assign('data', $data); $tpl = T("OrderForm@Address/address"); $this->display($tpl); }
public function indexAction() { // // 判断当前URL是否传入了code和state值 $checkBrower = C('WECHAT_BROWER'); if ($checkBrower == true) { $code = I('get.code', 'defaultCode'); $state = I('get.state', ''); //无授权code,则跳转获取 if ($code == 'defaultCode' || $state == '' || $code == session('code')) { goto_auth(); return; } //通过微信返回的CODE值,获取用户信息 $userInfo = get_user_info($code); $userToken = $userInfo['access_token']; $this->openid = $userInfo['openid']; session('openid', $this->openid); session('openidTime', time()); // //判断用户权限,未注册跳转到提示页面 // $customerInfo = get_customer_info($this->openid); // $customerType = $customerInfo['subscribe_state']; // if($customerType == 0) // { //// 转到注册界面 //// $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; //// $url = "$protocol$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; //// $url = U('Register/Index/index'); // //转至提示如果成为分销商的界面 // $id = 1; // $reply = new ReplyModel(); // $reply->setId($id); // $replyInfo = $reply->getInfoById(); // redirect($replyInfo['url']); // } session('code', $code); //获取调用收货地址配置信息 //获取调用微信JSSDK签名信息 $jssdk = new JSSDKController(); $jssdk->setCode($code); $jssdk->setState($state); $jssdk->setUserToken($userToken); // echo 'pay中当前code值' . $code . "<br />"; // echo 'pay中当前state值' . $state . "<br />"; // echo 'pay中当前userToken值' . $userToken . '<br />'; $addressPackage = $jssdk->getAddressPackage(); $signPackage = $jssdk->getSignPackage(); } $openid = get_openid(); $this->assign('openid', $openid); $title = '确认订单'; $this->assign('title', $title); //获取get信息,去除html过滤.数据类型为JSON格式的字符串 $ids = I('get.ids', ''); //字符串转为数组 $this->assign('ids', $ids); $ids = explode("-", $ids); $shoppingCart = new ShoppingCartModel(); $counts = $shoppingCart->getCounts($ids, $openid); $this->assign('counts', implode('-', $counts)); //取用户收货地址信息 $address = new CustomerAddressModel(); $address->setOpenid($openid); $customerAddress = $address->getLastUseAdderss(); $this->assign('address', $customerAddress); //设置GET收货地址管理的URL $customerAddress['chooseAddressUrl'] = U('Address/chooseAddress'); $this->assign('address', $customerAddress); //取收货地址信息HTML $this->assign('indexAddress', $this->fetch('indexAddress')); /* 进行数据处理,添加商品详情,按不同来源、物流方式进行分组,并将分组后数组的信息返回 */ $data = $this->dataAccess($ids, $counts); $product = $data[0]; $totalInfo = $data[1]; //传用户id,优惠券表里取对应的优惠券 $couponM = D('Coupon'); $coupon = $couponM->getCoupon($openid); $freightM = D('System/Config'); $freight = $freightM->freightCount(); //取运费的五个字段 $this->assign('freight', $freight); //给出收货地址URL信息 $data['addUrl'] = U('OrderForm/Address/add?openid=' . $openid); $data['editUrl'] = U('OrderForm/Address/edit?openid=' . $openid); $data['saveAddressUrl'] = U('OrderForm/Address/save'); $data['uploadImageUrl'] = U('OrderForm/Address/uploadImage'); $data['updateAddressUrl'] = U('OrderForm/Address/updateAddress'); $data['deleteUrl'] = U('OrderForm/Address/delete'); $this->assign('data', $data); //给出可以定制的header信息 $this->assign('header', $this->fetch('indexHeader')); $this->assign('coupon', $coupon); $this->assign('total', $totalInfo); //地址下面的条纹图片路径 $guoduUrl = add_root_path('/theme/wemall/images/guodu.png'); $this->assign('guoduUrl', $guoduUrl); $this->assign('css', $this->fetch('indexCss')); $this->assign('signPackage', $signPackage); $this->assign('addressPackage', $addressPackage); $updateUrl = U('Index/payNow'); $this->assign('url', $updateUrl); $wxJs = $this->fetch('wxJs'); $this->assign('wxJs', $wxJs); $js = $this->fetch('js'); $this->assign('js', $js); $this->assign('product', $product); //送入首页URL $indexUrl = U('Home/Index/index'); $this->assign('indexUrl', $indexUrl); //定制底部菜单 $this->assign('footer', $this->fetch('footer')); $this->assign('YZBody', $this->fetch('index')); $this->display(YZ_TEMPLATE); }