<template>
  <div class="app-container">
    <el-form ref="form11" :model="form11" label-width="180px">
      <el-row>
        <el-col :span="12">
          <el-form-item  label="注册任务积分" prop="integralRegister">
            <el-tooltip class="item" effect="dark" content="完成手机号绑定注册，赠送多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralRegister"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="完成专家咨询获得积分" prop="integralFinishConsultation">
            <el-tooltip class="item" effect="dark" content="首次完成专家咨询，赠送多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralFinishConsultation"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="填写就诊人信息获得积分" prop="integralAddPatient">
            <el-tooltip class="item" effect="dark" content="首次填写就诊人信息，赠送多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralAddPatient"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="填写收货地址获得积分" prop="integralAddUserAddress">
            <el-tooltip class="item" effect="dark" content="首次填写收货地址，赠送多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralAddUserAddress"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="邀请新用户获得积分" prop="integralInvite">
            <el-tooltip class="item" effect="dark" content="邀请新用户，赠送多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralInvite"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="被邀请获得积分" prop="integralInvited">
            <el-tooltip class="item" effect="dark" content="填写用户邀请码，赠送多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralInvited"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="新手任务积分" prop="integralNewTask">
            <el-tooltip class="item" effect="dark" content="首次app内下单公域疗法，赠送多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralNewTask"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="购买消费获得" prop="integralRatio">
            <el-tooltip class="item" effect="dark" content="实付1元得多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralRatio"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="分享获得积分" prop="integralShare">
            <el-tooltip class="item" effect="dark" content="分享获得多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralShare"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="完成随访获得积分" prop="integralFollow">
            <el-tooltip class="item" effect="dark" content="完成随访获得多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralFollow"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item  label="观看课程获得积分" prop="integralCourse">
            <el-tooltip class="item" effect="dark" content="每小节观看>=90%获得多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralCourse"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="浏览商品获得积分" prop="integralProduct">
            <el-tooltip class="item" effect="dark" content="浏览商品每30秒获得多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralProduct"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="短视频/直播 获得积分" prop="integralFirstVideo">
            <el-tooltip class="item" effect="dark" content="首次浏览每10秒获得多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralFirstVideo"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="短视频/直播 获得积分" prop="integralFinishVideo">
            <el-tooltip class="item" effect="dark" content="每10秒获得最低多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralFinishVideo"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="付费课程订阅" prop="integralSubscriptCourse">
            <el-tooltip class="item" effect="dark" content="实付1元得多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralSubscriptCourse"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item  label="首单立返积分" prop="integralFirstOrderPoint">
            <el-tooltip class="item" effect="dark" content="首次在积分商城下单，返多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralFirstOrderPoint"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-col :span="12">
          <el-form-item  label="单日可获总积分" prop="integralByOneDay">
            <el-tooltip class="item" effect="dark" content="每天最多可获得多少积分" placement="top-end">
              <el-input-number  v-model="form11.integralByOneDay"   ></el-input-number>
            </el-tooltip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-form-item label="单日可获总积分类型" prop="integralTypeByOneDay">
        <el-select v-model="form11.integralTypeByOneDay" multiple placeholder="请选择类型" filterable clearable size="small">
          <el-option
            v-for="dict in integralLogTypeOptions"
            :key="dict.dictValue"
            :label="dict.dictLabel"
            :value="dict.dictValue"
          />
        </el-select>
      </el-form-item>
      <div style="display: flex; justify-content: flex-end;">
        <el-button type="primary" :disabled="saveLoading" :loading="saveLoading" @click="submitForm11">提  交</el-button>
      </div>
    </el-form>
  </div>
</template>

<script>
import { getConfigByKey, updateConfigByKey } from '@/api/system/config'

export default {
  name: "IntegralConfig",
  data() {
    return {
      integralLogTypeOptions: [],
      form11: {
        integralRegister: null,
        integralFinishConsultation: null,
        integralAddPatient: null,
        integralAddUserAddress: null,
        integralInvite: null,
        integralInvited: null,
        integralNewTask: null,
        integralRatio: null,
        integralShare: null,
        integralFollow: null,
        integralCourse: null,
        integralProduct: null,
        integralFirstVideo: null,
        integralFinishVideo: null,
        integralByOneDay: null,
        integralFirstOrderPoint: null,
        integralTypeByOneDay: null,
        integralSubscriptCourse: null,
      },
      saveLoading: false,
    }
  },
  created() {
    this.getConfigByKey("his.integral");
    this.getDicts("sys_integral_log_type").then(response => {
      this.integralLogTypeOptions = response.data;
    });
  },
  methods: {
    getConfigByKey(key){
      getConfigByKey(key).then(response => {
        this.configId=response.data.configId;
        this.configKey=response.data.configKey;
        this.form11 =JSON.parse(response.data.configValue);
      });
    },
    submitForm11(){
      this.saveLoading = true
      const param={configId:this.configId,configValue:JSON.stringify(this.form11)}
      updateConfigByKey(param).then(response => {
        const {code} = response
        if (code === 200) {
          this.msgSuccess("修改成功");
        }
        this.saveLoading = false
      });
    },
  }
}
</script>

<style scoped>

</style>
