Browse Source

修改密码

linwu 7 tháng trước cách đây
mục cha
commit
2c185ec68e

+ 37 - 16
app/matchmaker/controller/MyController.php

@@ -40,54 +40,75 @@ class MyController extends MatchmakerBaseController
         $this->success();
     }
 
+    public function password()
+    {
+        return $this->fetch();
+    }
+
+    public function passwordPost()
+    {
+        $data = $this->request->post();
+        if ($data['new_pass'] != $data['re_pass']) {
+            $this->error('两次密码不一致!');
+        }
+
+        if ($data['old_pass'] != $this->matchmaker['password']) {
+            $this->error('旧密码错误!');
+        }
+
+        MatchmakerModel::update(['password' => $data['new_pass']], ['id' => $this->matchmaker['id']]);
+
+        $this->success();
+    }
+
     public function statistics()
     {
-        $data          = [];
-        $data['total']   = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data                   = [];
+        $data['total']          = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->count();
-        $data['sex_man']   = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['sex_man']        = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('sex', 1)
             ->count();
-        $data['sex_woman'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['sex_woman']      = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('sex', 2)
             ->count();
         $data['education_bkyx'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('education', '本科以下')
             ->count();
-        $data['education_bk'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['education_bk']   = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('education', '本科')
             ->count();
-        $data['education_ss'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['education_ss']   = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('education', '硕士')
             ->count();
-        $data['education_bs'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['education_bs']   = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('education', '博士')
             ->count();
-        $data['marry_wh'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['marry_wh']       = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('marry', '未婚')
             ->count();
-        $data['marry_lh'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['marry_lh']       = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('marry', '离婚')
             ->count();
-        $data['marry_so'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['marry_so']       = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('marry', '丧偶')
             ->count();
-        $data['status_1'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['status_1']       = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('status', 1)
             ->count();
-        $data['status_2'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['status_2']       = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('status', 2)
             ->count();
-        $data['status_3'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['status_3']       = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('status', 3)
             ->count();
-        $data['status_4'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['status_4']       = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('status', 4)
             ->count();
-        $data['status_5'] = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
+        $data['status_5']       = MatchmakerUserModel::where('matchmaker_id', $this->matchmaker->id)
             ->where('status', 5)
             ->count();
 
-        return view('',$data);
+        return view('', $data);
     }
 }

+ 8 - 0
public/themes/simpleboot3/matchmaker/my/index.html

@@ -55,6 +55,11 @@
             <h2>我的资料</h2>
             <van-icon style="margin-left: 216px" name="arrow" />
         </li>
+        <li @click="toPassword">
+            <img src="__TMPL__/public/assets/images/matchmaker/myIcon6.png" alt="">
+            <h2>修改密码</h2>
+            <van-icon style="margin-left: 216px" name="arrow" />
+        </li>
         <li @click="showQrcode">
             <img src="__TMPL__/public/assets/images/matchmaker/myIcon4.png" alt="">
             <h2>我的邀请码</h2>
@@ -121,6 +126,9 @@
                 toInfo() {
                     location.href = '{:url("matchmaker/my/info")}';
                 },
+                toPassword() {
+                    location.href = '{:url("matchmaker/my/password")}';
+                },
                 toStatistics() {
                     location.href = '{:url("matchmaker/my/statistics")}';
                 },

+ 103 - 0
public/themes/simpleboot3/matchmaker/my/password.html

@@ -0,0 +1,103 @@
+<extend name="public/base"/>
+<block name="css">
+    <style>
+        .van-nav-bar--fixed {z-index:100;}
+        .van-nav-bar .van-icon,.van-nav-bar__text {color:white;}
+        .van-step--horizontal .van-step__title {font-size:16px;}
+        .van-step--horizontal .van-step__icon {font-size:16px;}
+        .van-step__circle {width:10px;height:10px;}
+
+        .van-row {width:100%;}
+        .btn_search_item{background:#f2f6ff;display:inline-block;border-radius:5px;line-height:35px;height:35px;text-align:center;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;position:relative;font-size:13px;width:100%;color:#666;margin-bottom:10px;}
+        .btn_search_item.active{color:var(--pink);background:#fff7fa;}
+        .btn_search_icon{position:absolute;bottom:-3px;right:-3px;font-size:30px;}
+        .van-uploader__input-wrapper {width:100%;}
+    </style>
+</block>
+<block name="body">
+    <!--头部-->
+    <van-nav-bar
+            class="bg-pink"
+            left-text="返回"
+            left-arrow
+            @click-left="onBack"
+            fixed="true"
+    >
+        <template #title>
+            <span style="color:white;">修改密码</span>
+        </template>
+    </van-nav-bar>
+    <div style="width:100%;height:46px;"></div>
+
+    <!--增空-->
+    <van-field
+            v-model="form.old_pass"
+            type="password"
+            label="旧密码"
+            placeholder="请输入旧密码"
+            required
+    ></van-field>
+    <van-field
+            v-model="form.new_pass"
+            type="password"
+            label="新密码"
+            placeholder="请输入新密码"
+            required
+    ></van-field>
+    <van-field
+            v-model="form.re_pass"
+            type="password"
+            label="确认密码"
+            placeholder="请输入确认密码"
+            required
+    ></van-field>
+
+
+    <div style="padding:16px;">
+        <van-button block class="bg-pink" @click="onSubmit">提交</van-button>
+    </div>
+</block>
+<block name="script">
+    <script>
+        new Vue({
+            el: '#app',
+            data() {
+                return {
+                    form: {},
+                };
+            },
+            methods: {
+                onBack() {
+                    history.back();
+                },
+                onSubmit() {
+                    if (this.form.old_pass == '') {
+                        this.$toast('请输入旧密码');
+                        return false;
+                    }
+                    if (this.form.new_pass == '') {
+                        this.$toast('请输入新密码');
+                        return false;
+                    }
+                    if (this.form.re_pass == '') {
+                        this.$toast('请输入确认密码');
+                        return false;
+                    }
+                    if (this.form.new_pass !== this.form.re_pass) {
+                        this.$toast('两次密码不一致!');
+                        return false;
+                    }
+
+                    let self = this;
+                    $.post("{:url('passwordPost')}", this.form, function (json) {
+                        if (json.code == 0) {
+                            self.$toast(json.msg);
+                            return false;
+                        }
+                        location.href = "{:url('index')}";
+                    }, 'json');
+                },
+            },
+        });
+    </script>
+</block>

BIN
public/themes/simpleboot3/public/assets/images/matchmaker/myIcon6.png