Python flask实战订餐系统微信小程序-39会员的删除和恢复

wechat xuhss 581℃ 0评论

会员的删除和恢复

根据状态显示恢复和删除

                <td>
                    <a href="{{ buildUrl('/member/info') }}?id={{item.id}}">
                        <i class="fa fa-eye fa-lzg"></i>
                    </a>
                    {% if item.status == 1 %}
                    <a class="m-l" href="{{ buildUrl('/member/set') }}?id={{item.id}}">
                        <i class="fa fa-edit fa-lg"></i>
                    </a>

                    <a class="m-l remove" href="javascript:void(0);" data = {{item.id}}>
                        <i class="fa fa-trash fa-lg"></i>
                    </a>
                    {% else %}
                    <a class="m-l recover" href="javascript:void(0);" data = {{item.id}}>
                        <i class="fa fa-rotate-left fa-lg"></i>
                    </a>
                    {% endif  %}
                </td>

index.js改成member

20210822104723 - Python flask实战订餐系统微信小程序-39会员的删除和恢复

T添加后端的处理接口:

@route_member.route( "/ops",methods = ["POST"] )
def ops():
    resp = {'code': 200, 'msg': '账户添加成功', 'data': {}}
    req = request.values
    id = req['id'] if 'id' in req else 0
    act = req['act'] if 'act' in req else ''

    if not id:
        resp['code'] = -1
        resp['msg'] = "请选择要操作的账号"
        return jsonify(resp)

    if act not in ['remove', 'recover']:
        resp['code'] = -1
        resp['msg'] = "操作有误 青菜此测试"
        return jsonify(resp)

    member_info = Member.query.filter_by(id=id).first()
    if not member_info:
        resp['code'] = -1
        resp['msg'] = "指定的会员不存在数据库当中"
        return jsonify(resp)

    if act == "remove":
        member_info.status = 0
    elif act == "recover":
        member_info.status = 1

    member_info.update_time = getCurrentDate()
    db.session.add(member_info)
    db.session.commit()

    return jsonify(resp)

编辑按钮处理

member/info.html

{% if info.status == 1 %}

                <div class="m-b-md">
                    {% if info.status == 1 %}
                    <a class="btn btn-outline btn-primary pull-right" href="{{ buildUrl('/member/set') }}?id={{info.id}}">
                        <i class="fa fa-pencil"></i>编辑
                    </a>
                    {% endif %}
                    <h2>会员信息</h2>
                </div>

转载请注明:xuhss » Python flask实战订餐系统微信小程序-39会员的删除和恢复

喜欢 (0)

您必须 登录 才能发表评论!