123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?php
- namespace app\api\controller;
- /**
- * ============================================================================
- *
- * ============================================================================
- * 版权所有 2014-2028 浙江惠利玛产业互联网有限公司,并保留所有权利。
- * 网站地址: https://www.valimart.net/
- * ----------------------------------------------------------------------------
- *
- * ============================================================================
- * 控制器
- */
- class MobileMember extends MobileHome {
- public function initialize() {
- parent::initialize();
- $key = request()->header('X-DS-KEY');
- if(!$key){
- $key=input('param.key');//微信支付需要
- }
- if (!empty($key)) {
- $mbusertoken_model = model('mbusertoken');
- $mb_user_token_info = $mbusertoken_model->getMbusertokenInfoByToken($key);
- if (empty($mb_user_token_info)) {
- ds_json_encode(11001, lang('please_login'));
- }
- $member_model = model('member');
- $this->member_info = $member_model->getMemberInfoByID($mb_user_token_info['member_id']);
- if (empty($this->member_info)) {
- ds_json_encode(11001, lang('please_login'));
- } else {
- if (!$this->member_info['member_state']) {
- ds_json_encode(11001, lang('please_login'));
- }
- $this->member_info['member_clienttype'] = $mb_user_token_info['member_clienttype'];
- $this->member_info['member_openid'] = $mb_user_token_info['member_openid'];
- $this->member_info['member_token'] = $mb_user_token_info['member_token'];
- $level_name = $member_model->getOneMemberGrade($mb_user_token_info['member_id']);
- $this->member_info['level_name'] = $level_name['level_name'];
- //读取卖家信息
- $seller_info = model('seller')->getSellerInfo(array('member_id' => $this->member_info['member_id']));
- $this->member_info['store_id'] = $seller_info['store_id'];
- //考虑到模型中session
- if (session('member_id') != $this->member_info['member_id']) {
- //避免重复查询数据库
- $member_model->createSession(array_merge($this->member_info, $level_name), true);
- }
- }
- }else{
- ds_json_encode(11001, lang('please_login'));
- }
- }
- public function getOpenId() {
- return $this->member_info['member_openid'];
- }
- public function setOpenId($openId) {
- $this->member_info['member_openid'] = $openId;
- model('mbusertoken')->editMemberOpenId($this->member_info['member_token'], $openId);
- }
- }
- ?>
|