123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362 |
- <?php
- namespace h5wap\wap\controller;
- use cmf\lib\Upload;
- use h5wap\common\controller\V2BaseController;
- use huo\controller\address\Address;
- use huo\controller\member\Member;
- use huo\controller\member\MemCache;
- use huo\controller\sign\Sign;
- use huolib\sms\Sms;
- use huolib\sms\SmsType;
- use huolib\status\CommonStatus;
- use huolib\status\IdentifyStatus;
- use huolib\status\MemberStatus;
- use huolib\tool\StrUtils;
- use huoIdentify\controller\Identify;
- class MemberController extends V2BaseController {
-
- public function index() {
- $_data = (new Member())->getMemInfo($this->mem_id);
- $_data['encrypt_real_name'] = StrUtils::encryptName($_data['real_name']);
- $_data['encrypt_id_card'] = StrUtils::encryptIdCard($_data['id_card']);
- $_data['encrypt_mobile'] = StrUtils::encryptPhone($_data['mobile']);
- $_data['encrypt_alipay_account'] = StrUtils::encryptName($_data['alipay_account']);
- $_rdata['userinfo'] = $_data;
- $this->assign('userinfo', $_rdata['userinfo']);
- $_sign_conf = (new Sign())->getSignConf();
- $_sign_list['count'] = count($_sign_conf);
- $_sign_list['list'] = $_sign_conf;
- $this->assign('sign_list', $_sign_list);
- return $this->fetch('user/index');
- }
-
- public function login() {
- $_back_url = $this->request->server('HTTP_REFERER');
- $this->assign('back_url', $_back_url);
- return $this->fetch('user/login');
- }
- public function address() {
- $_list = (new Address())->getMemAddress($this->mem_id);
- $this->assign('list', $_list);
- return $this->fetch('user/address');
- }
- public function addAddress() {
- return $this->fetch('user/add_address');
- }
- public function addAddressPost() {
- $address['mem_id'] = $this->mem_id;
- $address['consignee'] = $this->request->param('consignee/s', '');
- $address['mobile'] = $this->request->param('mobile/s', '');
- $address['country'] = $this->request->param('country/d', 0);
- $address['province'] = $this->request->param('province/d', 0);
- $address['city'] = $this->request->param('city/d', 0);
- $address['district'] = $this->request->param('district/d', 0);
- $address['town'] = $this->request->param('town/d', 0);
- $address['address'] = $this->request->param('address/s', '');
- $address['zipcode'] = $this->request->param('zipcode/s', '');
- $address['is_default'] = $this->request->param('is_default/s', '');
- $_res = (new Address())->addAddress($address);
- if (!$_res) {
- $_rdata = [
- 'code' => CommonStatus::INNER_ERROR,
- 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR),
- 'data' => [],
- ];
- } else {
- $_rdata = [
- 'code' => CommonStatus::NO_ERROR,
- 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR),
- 'data' => [],
- ];
- }
- $this->returnData($_rdata);
- }
- public function editAddressPost() {
- $address['mem_id'] = $this->mem_id;
- $id = $this->request->param('id/s', '');
- $address['consignee'] = $this->request->param('consignee/s', '');
- $address['mobile'] = $this->request->param('mobile/s', '');
- $address['country'] = $this->request->param('country/d', 0);
- $address['province'] = $this->request->param('province/d', 0);
- $address['city'] = $this->request->param('city/d', 0);
- $address['district'] = $this->request->param('district/d', 0);
- $address['town'] = $this->request->param('town/d', 0);
- $address['address'] = $this->request->param('address/s', '');
- $address['zipcode'] = $this->request->param('zipcode/s', '');
- $address['is_default'] = $this->request->param('is_default/s', '');
- $_res = (new Address())->editMemAddress($id, $address);
- if (!$_res) {
- $_rdata = [
- 'code' => CommonStatus::INNER_ERROR,
- 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR),
- 'data' => [],
- ];
- } else {
- $_rdata = [
- 'code' => CommonStatus::NO_ERROR,
- 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR),
- 'data' => [],
- ];
- }
- $this->returnData($_rdata);
- }
- public function getAddressDetail() {
- $id = $this->request->param('id/s', '');
- $_detail = (new Address())->getAddressDetail($id);
- $_rdata = [
- 'code' => CommonStatus::NO_ERROR,
- 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR),
- 'data' => $_detail,
- ];
- $this->returnData($_rdata);
- }
- public function deleteAddress() {
- $id = $this->request->param('id/s', '');
- $_res = (new Address())->deleteAddress($id);
- if (!$_res) {
- $_rdata = [
- 'code' => CommonStatus::INNER_ERROR,
- 'msg' => CommonStatus::getMsg(CommonStatus::INNER_ERROR),
- 'data' => [],
- ];
- } else {
- $_rdata = [
- 'code' => CommonStatus::NO_ERROR,
- 'msg' => CommonStatus::getMsg(CommonStatus::NO_ERROR),
- 'data' => [],
- ];
- }
- $this->returnData($_rdata);
- }
-
- public function bindAlipay() {
- $_mem_data = MemCache::ins()->getInfoById($this->mem_id);
- $_real_name = get_val($_mem_data, 'real_name', '');
- $_id_card = get_val($_mem_data, 'id_card', '');
- $_mobile = get_val($_mem_data, 'mobile', '');
- $_alipay_account = get_val($_mem_data, 'alipay_account', '');
- $_data = [
- 'real_name' => StrUtils::encryptName($_real_name),
- 'id_card' => StrUtils::encryptIdCard($_id_card),
- 'mobile' => StrUtils::encryptPhone($_mobile),
- 'real_mobile' => $_mobile,
- 'alipay_account' => StrUtils::encryptIdCard($_alipay_account),
- ];
- $this->assign('data', $_data);
- return $this->fetch('user/bind_alipay');
- }
-
- public function bindAlipayPost() {
- $_param = $this->request->post();
- $_alipay_account = get_val($_param, 'alipay_account', '');
- if (empty($_alipay_account)) {
- $_code = MemberStatus::INVALID_PARAMS;
- $this->error(IdentifyStatus::getMsg($_code), [], $_code);
- }
-
- $_id = (new Member())->getMemIdByAlipayAccount($_alipay_account);
- if (!empty($_id) && $_id != $this->mem_id) {
- $_code = MemberStatus::ALIPAY_IS_BIND;
- $this->error(IdentifyStatus::getMsg($_code), [], $_code);
- }
- $_mem_data['alipay_account'] = $_alipay_account;
- $_rs = MemCache::ins()->updateMem($this->mem_id, $_mem_data);
- if (false === $_rs) {
- $_code = IdentifyStatus::INNER_ERROR;
- $this->error(IdentifyStatus::getMsg($_code), [], $_code);
- }
- $_code = IdentifyStatus::NO_ERROR;
- $this->success(IdentifyStatus::getMsg($_code), [], $_code);
- }
-
- public function updateAvatar() {
- $_avatar = $this->request->param('avatar/s', '');
- if (empty($_avatar)) {
- $_code = CommonStatus::INVALID_PARAMS;
- $this->error(CommonStatus::getMsg($_code), [], $_code);
- }
- $_rdata = (new Member())->updateAvatar($this->mem_id, $_avatar);
- return $this->returnData($_rdata);
- }
-
- public function updateNickname() {
- $_data = $this->request->param();
- $result = $this->validate(
- $_data, [
- 'nickname' => 'require|chsDash|max:32',
- ], [
- 'nickname.require' => lang('nickname is null'),
- 'nickname.chsDash' => '昵称只能是汉字、字母、数字和下划线_及破折号-',
- 'nickname.max' => lang('nickname Up to 32 characters'),
- ]
- );
- if (true !== $result) {
- $this->error($result, [], CommonStatus::INVALID_PARAMS);
- }
- $_nickname = get_val($_data, 'nickname');
- $_rs = (new Member())->updateNickname($this->mem_id, $_nickname);
- if (MemberStatus::NO_ERROR != $_rs['code']) {
- $this->error($_rs['msg'], [], $_rs['code']);
- }
- $this->success($_rs['msg'], [], $_rs['code']);
- }
-
- public function updatePwd() {
- $_data = $this->request->param();
- $_status = get_val($_data, 'status', 2);
- if (1 == $_status) {
- $result = $this->validate(
- $_data, [
- 'newpwd' => 'require|length:6,32',
- ], [
- 'newpwd.require' => lang('newpwd is null'),
- 'newpwd.length' => lang('newpwd length is 6~32 characters'),
- ]
- );
- if (true !== $result) {
- $this->error($result, [], CommonStatus::INVALID_PARAMS);
- }
- $_newpwd = get_val($_data, 'newpwd');
- $_mem_class = new Member();
- $_rs = $_mem_class->updatePassword($this->mem_id, $_newpwd);
- if (is_numeric($_rs)) {
- $_code = $_rs;
- } elseif (false !== $_rs) {
- $_code = MemberStatus::NO_ERROR;
- } else {
- $_code = MemberStatus::UNKNOWN_ERROR;
- }
- $this->success(MemberStatus::getMsg($_code), [], $_code);
- }
- $result = $this->validate(
- $_data, [
- 'oldpwd' => 'require',
- 'newpwd' => 'require|length:6,32',
- ], [
- 'oldpwd.require' => lang('oldpwd is null'),
- 'newpwd.require' => lang('newpwd is null'),
- 'newpwd.length' => lang('newpwd length is 6~32 characters'),
- ]
- );
- if (true !== $result) {
- $this->error($result, [], CommonStatus::INVALID_PARAMS);
- }
- $_oldpwd = get_val($_data, 'oldpwd');
- $_newpwd = get_val($_data, 'newpwd');
- $_mem_class = new Member();
- $_rs = $_mem_class->updatePwd($this->mem_id, $_oldpwd, $_newpwd);
- if (MemberStatus::NO_ERROR != $_rs['code']) {
- $this->error($_rs['msg'], [], $_rs['code']);
- }
- $this->success($_rs['msg'], [], $_rs['code']);
- }
-
- public function detail() {
- $_mem_id = $this->mem_id;
- $_rdata = (new Member())->getMemInfo($_mem_id);
- $_game_rq = $this->setGameData();
- $_device_rq = $this->setDeviceData();
- $_auth_info = (new Identify())->getMemIdentifyInfo(
- $_game_rq->getHAppId(), $this->mem_id, $_device_rq->getDeviceId()
- );
- $_rdata['url'] = get_val($_auth_info, 'url', '');
- $_rdata['auth_info'] = get_val($_auth_info, 'auth_info', null);
- $siteInfo = cmf_get_site_info();
- $_rdata['wap_app_down_url'] = get_val($siteInfo, 'wap_app_down_url', '');
- $_code = MemberStatus::NO_ERROR;
- $this->success(MemberStatus::getMsg($_code), $_rdata);
- }
- }
|