RegData.php
4.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
<?php
namespace LibModels\Web\Passport;
use Api\Sign;
use Api\Yohobuy;
/**
* 注册的数据模型
*
* @name RegData
* @package LibModels/Web/Passport
* @copyright yoho.inc
* @version 1.0 (2015-10-12 14:04:55)
*/
class RegData
{
/**
* 获取地区数据
*
* 备注:
* 考虑到该接口数据很少发生变化,改成静态配置,不调用接口.
* 以后有需要,可以打开注释,改成调用接口.
*
* @return array 地区数据
*/
public static function getAreasData()
{
// $param = Yohobuy::param();
// $param['method'] = 'app.passport.getArea';
// $param['client_secret'] = Sign::getSign($param);
// $data = Yohobuy::get(Yohobuy::API_URL, $param);
// $result = array();
// if (!empty($data['data'])) {
// $build = array();
// foreach ($data['data'] as $value) {
// $build = array();
// $build['areaCode'] = '+' . $value['area'];
// $build['selected'] = ($value['area'] === '86');
// $build['name'] = $value['name'];
// $result[] = $build;
// }
// $data = array();
// }
// return $result;
return array(
0 => array(
'areaCode' => '+61',
'selected' => false,
'name' => '澳大利亚',
),
1 => array(
'areaCode' => '+82',
'selected' => false,
'name' => '韩国',
),
2 => array(
'areaCode' => '+1',
'selected' => false,
'name' => '加拿大',
),
3 => array(
'areaCode' => '+60',
'selected' => false,
'name' => '马来西亚',
),
4 => array(
'areaCode' => '+1',
'selected' => false,
'name' => '美国',
),
5 => array(
'areaCode' => '+81',
'selected' => false,
'name' => '日本',
),
6 => array(
'areaCode' => '+65',
'selected' => false,
'name' => '新加坡',
),
7 => array(
'areaCode' => '+44',
'selected' => false,
'name' => '英国',
),
8 => array(
'areaCode' => '+86',
'selected' => true,
'name' => '中国',
),
9 => array(
'areaCode' => '+853',
'selected' => false,
'name' => '中国澳门',
),
10 => array(
'areaCode' => '+886',
'selected' => false,
'name' => '中国台湾',
),
11 => array(
'areaCode' => '+852',
'selected' => false,
'name' => '中国香港',
),
);
}
/**
* 发送手机注册验证码
*
* @param string $area 地区号 如"86"
* @param string $mobile 手机号
* @return array
*/
public static function sendCodeToMobile($area, $mobile)
{
$param = Yohobuy::param();
$param['method'] = 'app.register.sendRegCodeToMobile';
$param['area'] = $area;
$param['mobile'] = $mobile;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
* 验证手机注册的识别码
*
* @param string $area 地区号 如"86"
* @param string $mobile 手机号
* @param string $code 验证码
* @return array
*/
public static function validMobileCode($area, $mobile, $code)
{
$param = Yohobuy::param();
$param['method'] = 'app.register.validRegCode';
$param['area'] = $area;
$param['mobile'] = $mobile;
$param['code'] = $code;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
/**
* 通过手机注册
*
* @param string $area 地区号 如"86"
* @param string $mobile 手机号
* @param string $password 登录密码
* @return array
*/
public static function regMobile($area, $mobile, $password)
{
$param = Yohobuy::param();
$param['method'] = 'app.passport.register';
$param['area'] = $area;
$param['profile'] = $mobile;
$param['password'] = $password;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::post(Yohobuy::API_URL, $param);
}
}