• 禾匠二开系列之兑换码禁用以后启用功能


    兑换码后台逻辑所在位置plugins/exchange

    创建兑换码的模型在plugins/exchange/forms/common/CreateCode.php

    表zjhj_bd_exchange_code

    字段status   0为禁用 1为可用 2为兑换 3为结束

    新增禁用以后启用

    前端修改:plugins/exchange/view/library/edit.php

    1. <el-button @click="opend(scope.row)" v-if="scope.row.status == 0" circle size="mini" type="text">
    2. <el-tooltip effect="dark" content="启用" placement="top">
    3. <img src="statics/img/mall/order/send.png" alt="">
    4. el-tooltip>
    5. el-button>
    1. opend(row) {
    2. this.$confirm('启用该条兑换码, 是否继续?', '提示', {
    3. confirmButtonText: '确定',
    4. cancelButtonText: '取消',
    5. type: 'warning'
    6. }).then(() => {
    7. request({
    8. params: {
    9. r: 'plugin/exchange/mall/code/opend'
    10. },
    11. data: {
    12. id: row.id
    13. },
    14. method: 'post'
    15. }).then(e => {
    16. if (e.data.code === 0) {
    17. this.$message({
    18. message: e.data.msg,
    19. type: 'success'
    20. });
    21. this.listLoading = true;
    22. this.getCode();
    23. } else {
    24. this.$message.error(e.data.msg);
    25. }
    26. })
    27. })
    28. },

    后端修改:plugins/exchange/Controller/mall/CodeController.php

    1. public function actionOpend()
    2. {
    3. if (\Yii::$app->request->isPost) {
    4. $form = new CodeEditForm();
    5. $form->id = \Yii::$app->request->post('id');
    6. return $this->asJson($form->opend());
    7. }
    8. }

    后端模型修改plugins/exchange/forms/mall/CodeEditForm.php

    1. public function opend()
    2. {
    3. try {
    4. if (empty($this->id)) {
    5. throw new \Exception('请求错误');
    6. }
    7. $model = ExchangeCode::findOne([
    8. 'mall_id' => \Yii::$app->mall->id,
    9. 'id' => $this->id,
    10. 'status' => 0,
    11. ]);
    12. if (!$model) {
    13. throw new \Exception('数据不存在');
    14. }
    15. $model->status = 1;
    16. $model->save();
    17. return [
    18. 'code' => ApiCode::CODE_SUCCESS,
    19. 'msg' => '启用成功',
    20. ];
    21. } catch (\Exception $e) {
    22. return [
    23. 'code' => ApiCode::CODE_ERROR,
    24. 'msg' => $e->getMessage(),
    25. ];
    26. }
    27. }

  • 相关阅读:
    微服务实战 01 Nacos 入门
    基于萤火虫算法优化的BP神经网络预测模型(Matlab代码实现)
    .9图片详解
    【JMeter】jmeter测试 - 上传多个图片/批量上传图片接口 CSV文件参数化方法
    电子版证件照怎么制作并改大小
    Git命令(持续更新中...)
    【银角大王——Django课程Day1】
    Linux 下使用 cron 定时任务
    【JAVA-1】EditPlus安装及配置,有手就会!
    Unity UGUI的Toggle(复选框)组件的介绍及使用
  • 原文地址:https://blog.csdn.net/u014692298/article/details/126621507