Quellcode durchsuchen

wesmiler 更新第5期更新代码合并

wesmiler vor 4 Jahren
Ursprung
Commit
9885453214

+ 32 - 1
app/api/controller/MemberController.php

@@ -123,7 +123,7 @@ class MemberController extends BaseController
 
             // 是否已经认证
             if ($type == 2 || $type == 4 || $type == 1) {
-                $field = 'idcard_check,education_check,position_check';
+                $field = 'idcard_check,education_check,position_check,wechat_code';
                 $authData = UserProfile::where(['userid' => $userId])
                     ->field($field)
                     ->find();
@@ -131,6 +131,7 @@ class MemberController extends BaseController
                 $memberInfo['idcard_check'] = isset($authData['idcard_check']) ? intval($authData['idcard_check']) : 0;
                 $memberInfo['education_check'] = isset($authData['education_check']) ? intval($authData['education_check']) : 0;
                 $memberInfo['position_check'] = isset($authData['position_check']) ? intval($authData['position_check']) : 0;
+                $memberInfo['wechat_code'] = isset($authData['wechat_code']) ? $authData['wechat_code'] : '';
                 if ($memberInfo['idcard_check'] == 2 && $memberInfo['education_check'] == 2 && $memberInfo['position_check'] == 2) {
                     $memberInfo['is_auth'] = 1;
                 }
@@ -881,6 +882,36 @@ class MemberController extends BaseController
     }
 
     /**
+     * 设置微信号
+     */
+    public function setWechat(){
+        $params = input();
+        $validate = new MemberValidate();
+        if (!$validate->scene('wechat')->check($params)) {
+            showJson(1004, $validate->getError());
+        }
+
+        // 验证
+        $this->checkUser();
+
+        if (UserProfile::where(['userid' => $this->userId])->value('idcard_check') != 2) {
+            showJson(1006, 2132, ['url' => Wechat::makeRedirectUrl(url('/weixin/auth/idcard', '', '', true))]);
+        }
+
+        $cacheKey = "cache:wechat:account:{$this->userId}";
+        if(PRedis::get($cacheKey)){
+            showJson(1004, 2049);
+        }
+        $wechatCode = input('wechat_code','');
+        if(UserProfile::where(['userid'=> $this->userId])->update(['wechat_code'=>$wechatCode,'updated_at'=>date('Y-m-d H:i:s')])){
+            PRedis::set($cacheKey, ['params'=> $params], 300);
+            showJson(1005, 2047);
+        }else{
+            showJson(1004,2048);
+        }
+    }
+
+    /**
      * 关注用户
      */
     public function collect()

+ 9 - 0
app/weixin/controller/MemberController.php

@@ -65,6 +65,15 @@ class MemberController extends BaseController
     }
 
     /**
+     * 设置微信
+     * @return mixed]
+     */
+    public function wechat()
+    {
+        return $this->fetch();
+    }
+
+    /**
      * 个人主页
      * @return mixed
      */

+ 2 - 0
app/weixin/validate/MemberValidate.php

@@ -68,6 +68,7 @@ class MemberValidate extends Validate
         'company.require' => '请填写工作单位名称',
         'company.length' => '工作单位名称长度为2-30位',
         'occupation.require' => '请选择职业',
+        'wechat_code.length' => '微信号格式错误,建议2-30个字符',
     ];
 
     protected $regex = [
@@ -84,6 +85,7 @@ class MemberValidate extends Validate
         'login'  => ['mobile','password'],
         'forget'  => ['mobile','code','password'],
         'code'  => ['mobile'],
+        'wechat'  => ['wechat_code'],
         // 认证
         'idcard'  => ['realname','idcard'],
         'education'  => ['graduate','education'],

+ 4 - 0
public/themes/default/weixin/member/index.html

@@ -107,6 +107,10 @@
                         <img src="__TMPL__/weixin/public/assets/img/new-privacy.png">
                         <span>隐私设置</span>
                     </a>
+                    <a href="/weixin/member/wechat" class="icon-wechat">
+                        <img src="__TMPL__/weixin/public/assets/img/new-wechat.png">
+                        <span>我的微信</span>
+                    </a>
                     <a href="/weixin/page/rule">
                         <img src="__TMPL__/weixin/public/assets/img/new-rule.png">
                         <span>违规处罚规则</span>

+ 17 - 0
public/themes/default/weixin/member/wechat.html

@@ -0,0 +1,17 @@
+<include file="weixin@block:header"/>
+<link rel="stylesheet" href="__TMPL__/weixin/public/assets/css/member-wechat.css?v={$version}">
+<div id="app" v-cloak>
+    <div class="fanhui2">
+        <h1>修改微信</h1>
+        <a href="/weixin/member/index"><img src="__TMPL__/weixin/public/assets/img/tubiao37.png"></a>
+    </div>
+    <div class="main">
+        <div class="bjzil_bt"><h1>我的微信号</h1></div>
+        <div class="input">
+            <input type="text" placeholder="请填写您的加好友微信号" v-model="memberInfo.wechat_code">
+        </div>
+        <div class="baoc_ann"><h1 @click="saveData()">提交</h1></div>
+    </div>
+</div>
+<script src="__TMPL__/weixin/public/assets/js/member-wechat.js?v={$version}"></script>
+<include file="weixin@block:footer"/>

+ 20 - 0
public/themes/default/weixin/public/assets/css/member-wechat.css

@@ -0,0 +1,20 @@
+.bjzil_bt{background: #fff;border-radius:4px;margin: 0 15px;margin-top: 10px;padding-left: 10px;}
+.bjzil_bt h1{font-size: 16px;line-height:50px;}
+
+.main {
+    margin-top: 50px;
+}
+
+.baoc_ann{margin: 0 15px;margin-top: 50px;}
+
+.baoc_ann h1{font-size: 18px;height: 45px;line-height: 45px;text-align: center;background: #ffd132;color: #333;border-radius: 6px;margin-top: 20px;}
+
+
+.input {position:relative;margin: 0 15px;margin-top: 10px;padding: 10px;background: #fff;border-radius: 4px;}
+.input input {
+    width: 100%;
+    border: none;
+    padding: 4px 0px;
+    padding-left: 4px;
+    font-size: 16px;
+}

+ 5 - 0
public/themes/default/weixin/public/assets/css/member.css

@@ -60,6 +60,11 @@ body {
     color: #666;
 }
 
+.menu-list .menu-box .icon-wechat img {
+    height: 36px;
+    width: 42px;
+    max-width: 42px;
+}
 /* 菜单样式 end */
 
 .zhobu_box{width: 100%;height:86px;overflow: hidden;background: #fff;margin-top: -2px;}

BIN
public/themes/default/weixin/public/assets/img/new-wechat.png


+ 56 - 0
public/themes/default/weixin/public/assets/js/member-wechat.js

@@ -0,0 +1,56 @@
+var app = new Vue({
+    'el': '#app',
+    'data': {
+        // 信息
+        memberInfo: {},
+    },
+    created: function(){
+        this.getInfo();
+    },
+    methods: {
+        // 初始化参数
+        getInfo: function () {
+            var _this = this;
+            $.post('/api/member/getInfo', {type:2}, function (res) {
+                if (res.code == 'success') {
+                    _this.memberInfo = res.data
+                } else {
+                    $.toast(res.message, 'text');
+                }
+            }, "json");
+        },
+        // 保存提交信息
+        saveData: function () {
+            var _this = this;
+            if(_this.memberInfo.wechat_code == '' || !_this.memberInfo.wechat_code){
+                $.toast('请填写您添加好友的微信号', 'text');
+                return false;
+            }
+            $.modal({
+                id: "status",
+                title: "操作提示",
+                text: '确定修改您添加好友使用的微信号?',
+                buttons: [
+                    {
+                        text: "取消", className: "default", onClick: function () {
+                            return false;
+                        }
+                    }, {
+                        text: "确定修改", className: "warning", onClick: function () {
+                            $.showLoading("数据保存中...");
+                            $.post('/api/member/setWechat', {wechat_code: _this.memberInfo.wechat_code}, function (res) {
+                                $.hideLoading();
+                                if (res.code == 'success') {
+                                    $.toast(res.message, 'text');
+                                } else {
+                                    $.toast(res.message, 'text');
+                                }
+                            }, "json");
+                        }
+                    }]
+            });
+
+
+        },
+    }
+})

+ 3 - 0
vendor/thinkcmf/cmf/src/lang/zh-cn.php

@@ -134,6 +134,9 @@ return [
     '2044'=> '红娘账号正在审核中,请耐心等候处理',
     '2045'=> '抱歉,您尚未完善个人主页资料,请先确认前往完成资料填写',
     '2046'=> '抱歉,您已经报名过,请过期后重新报名',
+    '2047'=> '修改加好友微信号成功',
+    '2048'=> '修改加好友微信号失败',
+    '2049'=> '请10分钟后再试',
 
     '2100'=>'账号错误',
     '2101'=>'登录密码错误',