1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace app\index\logic;
- use app\common\model\wxusermodel;
- /**
- * 微信用户类
- *
- * @author wj
- * @date 2022-07-22
- */
- class wxuserlogic extends baselogic
- {
- /**
- * 设置请求数据规则
- * 20220107
- * wj
- */
- protected function setrules()
- {
- $list = [
- /*'getinfobyopenid' => [
- ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
- ],*/
- 'saveinfo' => [
- ['name' => 'openid', 'title' => 'openid', 'require' => true, 'type' => 'string'],
- ['name' => 'sfzid', 'title' => '身份证号', 'require' => true, 'type' => 'string'],
- ['name' => 'real_name', 'title' => '真实姓名', 'require' => true, 'type' => 'string'],
- ['name' => 'union_id', 'title' => 'union_id', 'require' => false, 'type' => 'string'],
- ['name' => 'nick_name', 'title' => '昵称', 'require' => false, 'type' => 'string'],
- ['name' => 'avatar_url', 'title' => '头像', 'require' => false, 'type' => 'string'],
- ['name' => 'gender', 'title' => '性别', 'require' => false, 'type' => 'string'],
- ['name' => 'province', 'title' => '省', 'require' => false, 'type' => 'string'],
- ['name' => 'city', 'title' => '市', 'require' => false, 'type' => 'string'],
- ['name' => 'country', 'title' => '县', 'require' => false, 'type' => 'string'],
- ['name' => 'telno', 'title' => '手机号', 'require' => false, 'type' => 'string'],
- ['name' => 'address', 'title' => '地址', 'require' => false, 'type' => 'string'],
- ],
- ];
- return $list;
- }
- /**
- * 根据openid获取信息
- *
- * @param [type] $arr
- * @return void
- * @author wj
- * @date 2022-07-22
- */
- /*public function getinfobyopenid($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $data = $result['data'];
- $openid = $data['openid'];
- $m_wu = new wxusermodel();
- $info = $m_wu->getinfobyopenid($openid);
- if (empty($info)) {
- return backarr(0, "无用户信息");
- }
- return backarr(1, "success", $info);
- }*/
- /**
- * 保存用户信息
- *
- * @param [type] $arr
- * @return void
- * @author wj
- * @date 2022-07-22
- */
- public function saveinfo($arr)
- {
- $result = $this->checkparam(__FUNCTION__, $arr);
- if (1 != $result['status']) {
- return $result;
- }
- $data = $result['data'];
- $m_wu = new wxusermodel();
- $id = $m_wu->insertData($data);
- if (empty($id)) {
- return backarr(0, "添加失败");
- }
- return backarr(1, "添加成功", ['id' => $id]);
- }
- }
|