优化界面展示

pull/16/head
youngS 4 years ago
parent c45aeed34e
commit ed3cc532d6
  1. 4
      fir_client/src/components/FirUserProfileBase.vue
  2. 57
      fir_client/src/components/FirUserProfileCertification.vue
  3. 42
      fir_client/src/components/FirUserProfileChangePwd.vue
  4. 131
      fir_client/src/components/FirUserProfileInfo.vue
  5. 3
      fir_ser/api/models.py
  6. 51
      fir_ser/api/utils/storage/caches.py
  7. 9
      fir_ser/api/views/download.py
  8. 2
      fir_ser/api/views/login.py
  9. 5
      fir_ser/fir_ser/settings.py

@ -200,8 +200,8 @@
} }
.user_pro_tabs a.active { .user_pro_tabs a.active {
color: #e2644c; color: #7e5ef8;
border-bottom-color: #e2644c border-bottom-color: #7e5ef8
} }

@ -2,8 +2,8 @@
<div v-if="certification && certification.code === 0"> <div v-if="certification && certification.code === 0">
<el-form style="max-width: 400px"> <el-form style="max-width: 400px">
<el-form-item> <el-form-item>
<el-row :gutter="36"> <el-row>
<el-col :span="18"> <el-col :span="24">
<el-link :underline="false" type="success" style="font-size: x-large" <el-link :underline="false" type="success" style="font-size: x-large"
v-if="certification.status === 1">已经认证 v-if="certification.status === 1">已经认证
</el-link> </el-link>
@ -57,9 +57,9 @@
</el-form-item> </el-form-item>
<el-form-item v-if="certification.status === 2"> <el-form-item v-if="certification.status === 2">
<el-row :gutter="36"> <el-row>
<el-col :span="18"> <el-col :span="24">
<el-button type="danger" @click="recommit">重新提交审核</el-button> <el-button type="primary" @click="recommit">重新提交审核</el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
@ -72,7 +72,7 @@
<el-row :gutter="36"> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="18">
<el-input v-model="form.name" autofocus="true" prefix-icon="el-icon-user" <el-input v-model="form.name" autofocus="true" prefix-icon="el-icon-user"
placeholder="请输入真实姓名" clearable></el-input> placeholder="请输入真实姓名" clearable/>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
@ -80,7 +80,7 @@
<el-row :gutter="36"> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="18">
<el-input v-model="form.card" clearable prefix-icon="el-icon-s-order" <el-input v-model="form.card" clearable prefix-icon="el-icon-s-order"
placeholder="请输入身份证号"></el-input> placeholder="请输入身份证号"/>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
@ -89,7 +89,7 @@
<el-row :gutter="36"> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="18">
<el-input v-model="form.addr" clearable prefix-icon="el-icon-house" <el-input v-model="form.addr" clearable prefix-icon="el-icon-house"
placeholder="请输入现居住地址"></el-input> placeholder="请输入现居住地址"/>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
@ -99,7 +99,7 @@
<el-row :gutter="36"> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="18">
<el-input v-model="form.mobile" ref="phone" clearable <el-input v-model="form.mobile" ref="phone" clearable
prefix-icon="el-icon-mobile" placeholder="请输入手机号码" maxlength="11"></el-input> prefix-icon="el-icon-mobile" placeholder="请输入手机号码" maxlength="11"/>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
@ -109,7 +109,7 @@
<el-row :gutter="11"> <el-row :gutter="11">
<el-col :span="12"> <el-col :span="12">
<el-input v-model="form.auth_key" prefix-icon="el-icon-mobile" placeholder="请输入您收到的验证码" <el-input v-model="form.auth_key" prefix-icon="el-icon-mobile" placeholder="请输入您收到的验证码"
maxlength="6"></el-input> maxlength="6" clearable/>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-button type="info" @click="getsmsemailcode('sms',form.mobile)" plain <el-button type="info" @click="getsmsemailcode('sms',form.mobile)" plain
@ -124,7 +124,7 @@
<el-form-item label="图片验证码" v-if="cptch.cptch_image"> <el-form-item label="图片验证码" v-if="cptch.cptch_image">
<el-row :gutter="11"> <el-row :gutter="11">
<el-col :span="12"> <el-col :span="12">
<el-input placeholder="请输入图片验证码" v-model="form.authcode" maxlength="6"></el-input> <el-input placeholder="请输入图片验证码" v-model="form.authcode" maxlength="6" clearable/>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="6">
<el-image <el-image
@ -155,7 +155,7 @@
<el-tooltip v-if="user_certification.one" placement="top"> <el-tooltip v-if="user_certification.one" placement="top">
<div slot="content">上传身份证<i style="color: #2abb9d!important;">国徽面</i>照片</div> <div slot="content">上传身份证<i style="color: #2abb9d!important;">国徽面</i>照片</div>
<img :src="user_certification.one" <img :src="user_certification.one"
class="avatar"> class="avatar" alt="国徽面照片">
</el-tooltip> </el-tooltip>
<i v-else class="avatar-uploader-icon" style="text-align: center"> <i v-else class="avatar-uploader-icon" style="text-align: center">
上传身份证<i style="color: #2abb9d!important;">国徽面</i>照片 上传身份证<i style="color: #2abb9d!important;">国徽面</i>照片
@ -173,7 +173,7 @@
<el-tooltip v-if="user_certification.two" placement="top"> <el-tooltip v-if="user_certification.two" placement="top">
<div slot="content">上传身份证<i style="color: #2abb9d!important;">人像面</i>照片</div> <div slot="content">上传身份证<i style="color: #2abb9d!important;">人像面</i>照片</div>
<img :src="user_certification.two" <img :src="user_certification.two"
class="avatar"> class="avatar" alt="人像面照片">
</el-tooltip> </el-tooltip>
<i v-else class="avatar-uploader-icon" style="text-align: center"> <i v-else class="avatar-uploader-icon" style="text-align: center">
上传身份证<i style="color: #2abb9d!important;">人像面</i>照片 上传身份证<i style="color: #2abb9d!important;">人像面</i>照片
@ -191,7 +191,7 @@
<el-tooltip v-if="user_certification.three" placement="top"> <el-tooltip v-if="user_certification.three" placement="top">
<div slot="content">上传<i style="color: #2abb9d!important;">手持身份证</i>照片</div> <div slot="content">上传<i style="color: #2abb9d!important;">手持身份证</i>照片</div>
<img :src="user_certification.three" <img :src="user_certification.three"
class="avatar"> class="avatar" alt="手持身份证照片">
</el-tooltip> </el-tooltip>
<i v-else class="avatar-uploader-icon" style="text-align: center"> <i v-else class="avatar-uploader-icon" style="text-align: center">
上传<i style="color: #2abb9d!important;">手持身份证</i>照片 上传<i style="color: #2abb9d!important;">手持身份证</i>照片
@ -205,8 +205,8 @@
<el-form-item> <el-form-item>
<el-row> <el-row>
<el-col :span="22"> <el-col :span="24" style="margin-top: 20px">
<el-button type="danger" @click="commit">提交</el-button> <el-button type="primary" @click="commit">提交</el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
@ -262,10 +262,10 @@
this.get_user_certification({methods: 'POST', data: this.form}) this.get_user_certification({methods: 'POST', data: this.form})
}, },
get_user_certification(parmas) { get_user_certification(params) {
user_certification(res => { user_certification(res => {
if (res.code === 1000) { if (res.code === 1000) {
if (parmas.methods === 'POST') { if (params.methods === 'POST') {
this.$message.success("信息提交成功,正在审核中") this.$message.success("信息提交成功,正在审核中")
} }
const ft = ['one', 'two', 'three']; const ft = ['one', 'two', 'three'];
@ -280,7 +280,7 @@
} else { } else {
this.$message.error(res.msg) this.$message.error(res.msg)
} }
}, parmas) }, params)
}, },
getsmsemailcode(act, target) { getsmsemailcode(act, target) {
@ -288,7 +288,10 @@
"authcode": this.form.authcode, "authcode": this.form.authcode,
"cptch_key": this.cptch.cptch_key, "cptch_key": this.cptch.cptch_key,
}; };
if (!this.form.authcode) {
this.$message.error("图片验证码输入有误");
return;
}
let cptch_flag = this.form.authcode.length === this.cptch.length; let cptch_flag = this.form.authcode.length === this.cptch.length;
if (this.cptch.cptch_key === '' || !this.cptch.cptch_key) { if (this.cptch.cptch_key === '' || !this.cptch.cptch_key) {
cptch_flag = true cptch_flag = true
@ -296,18 +299,12 @@
if (cptch_flag) { if (cptch_flag) {
let checkp = checkphone(this.form.mobile); let checkp = checkphone(this.form.mobile);
if (!checkp) { if (!checkp) {
this.$message({ this.$message.error("手机号输入有误");
message: '手机号输入有误',
type: 'error'
});
return return
} }
} else { } else {
this.$message({ this.$message.error("图片验证码输入有误");
message: '图片验证码有误',
type: 'error'
});
return return
} }
let params = {'act': act, 'target': target, 'ext': picode, 'user_id': target, 'ftype': 'certification'}; let params = {'act': act, 'target': target, 'ext': picode, 'user_id': target, 'ftype': 'certification'};
@ -372,7 +369,7 @@
'ext': {'ptype': ptype} 'ext': {'ptype': ptype}
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
}, res => { }, res => {
this.get_user_certification({methods: 'GET'}); this.get_user_certification({methods: 'GET', data: {act: 'certpic'}});
}); });
}, },
@ -403,7 +400,7 @@
} }
.el-form-item .el-button { .el-form-item .el-button {
max-width: 360px; max-width: 260px;
width: 100%; width: 100%;
height: 50px; height: 50px;
} }

@ -2,36 +2,36 @@
<div> <div>
<el-form ref="form" :model="form"> <el-form ref="form" :model="form">
<el-form-item> <el-form-item label="当前密码">
<el-row> <el-row :gutter="36">
<el-col :span="22"> <el-col :span="18">
<el-input v-model="form.oldpassword" show-password autofocus="true" prefix-icon="el-icon-unlock" <el-input v-model="form.oldpassword" show-password autofocus prefix-icon="el-icon-unlock"
placeholder="当前密码"></el-input> placeholder="当前密码" clearable/>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="新密码">
<el-row> <el-row :gutter="36">
<el-col :span="22"> <el-col :span="18">
<el-input v-model="form.newpassword" show-password prefix-icon="el-icon-lock" <el-input v-model="form.newpassword" show-password prefix-icon="el-icon-lock"
placeholder="新密码"></el-input> placeholder="新密码" clearable/>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="确认密码">
<el-row> <el-row :gutter="36">
<el-col :span="22"> <el-col :span="18">
<el-input v-model="form.surepassword" show-password prefix-icon="el-icon-lock" <el-input v-model="form.surepassword" show-password prefix-icon="el-icon-lock"
placeholder="确认密码"></el-input> placeholder="确认密码" clearable/>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-row> <el-row :gutter="36">
<el-col :span="22"> <el-col :span="24">
<el-button type="danger" @click="updatepasswd">更新密码</el-button> <el-button type="primary" @click="updatepasswd">更新密码</el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
@ -84,14 +84,20 @@
<style scoped> <style scoped>
.el-form { .el-form {
max-width: 360px; max-width: 500px;
margin: 0 auto; margin: 0 auto;
} }
.el-form-item .el-button { .el-form-item .el-button {
max-width: 360px; margin-top: 20px;
max-width: 260px;
width: 100%; width: 100%;
height: 50px; height: 50px;
/*margin-left: 40px;*/
}
/deep/ .el-form-item__label {
width: 90px;
} }

@ -2,21 +2,21 @@
<div> <div>
<el-form ref="form" :model="userinfo"> <el-form ref="form" :model="userinfo">
<el-form-item> <el-form-item label="用户名">
<el-row> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="13">
<el-input v-model="userinfo.username" :readonly="edituser_name !== true" <el-input v-model="userinfo.username" :readonly="edituser_name !== true"
prefix-icon="el-icon-user" placeholder="用户名" ref="user_name" prefix-icon="el-icon-user" placeholder="用户名" ref="user_name"
></el-input> clearable/>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="1">
<el-button icon="el-icon-edit" @click="changeUsernameValue"> <el-button icon="el-icon-edit" @click="changeUsernameValue">
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="4" v-if="edituser_name === true"> <el-col :span="4" v-if="edituser_name === true">
<el-button type="success" @click="saveUsername" plain <el-button type="success" @click="saveUsername" plain
style="margin:0 4px;border-radius:4px;cursor:pointer;height: 36px;background-color: #f56c6c;color: wheat"> class="save-button">
保存 保存
</el-button> </el-button>
</el-col> </el-col>
@ -25,33 +25,33 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="手机号码">
<el-row> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="13">
<el-input v-model="userinfo.mobile" ref="phone" :readonly="editphone !== true" <el-input v-model="userinfo.mobile" ref="phone" :readonly="editphone !== true"
prefix-icon="el-icon-mobile" placeholder="手机" maxlength="11"></el-input> prefix-icon="el-icon-mobile" placeholder="手机" maxlength="11" clearable/>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="1">
<el-button icon="el-icon-edit" @click="changePhoneValue"> <el-button icon="el-icon-edit" @click="changePhoneValue">
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="4" v-if="editphone === true"> <el-col :span="4" v-if="editphone === true">
<el-button type="success" @click="savePhone" plain <el-button type="success" @click="savePhone" plain
style="margin:0 4px;border-radius:4px;cursor:pointer;height: 36px;background-color: #f56c6c;color: wheat"> class="save-button">
保存 保存
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item style="height: 40px" v-if="editphone === true && cptch.cptch_image"> <el-form-item label="图片验证码" style="height: 40px" v-if="editphone === true && cptch.cptch_image">
<el-row style="height: 40px" :gutter="10"> <el-row style="height: 40px" :gutter="36">
<el-col :span="11"> <el-col :span="10">
<el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6"></el-input> <el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6" clearable/>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-image <el-image
style="margin:0px 4px;border-radius:4px;cursor:pointer;height: 40px" style="margin:0 4px;border-radius:4px;cursor:pointer;height: 40px"
:src="cptch.cptch_image" :src="cptch.cptch_image"
fit="contain" @click="get_auth_code"> fit="contain" @click="get_auth_code">
</el-image> </el-image>
@ -59,15 +59,15 @@
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item v-if="editphone === true"> <el-form-item label="手机验证码" v-if="editphone === true">
<el-row :gutter="10"> <el-row :gutter="36">
<el-col :span="12"> <el-col :span="10">
<el-input v-model="userinfo.auth_key" prefix-icon="el-icon-mobile" placeholder="验证码" <el-input v-model="userinfo.auth_key" prefix-icon="el-icon-mobile" placeholder="验证码"
maxlength="6"></el-input> maxlength="6" clearable/>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="8">
<el-button type="info" @click="getsmsemailcode('sms',userinfo.mobile)" plain <el-button type="info" @click="getsmsemailcode('sms',userinfo.mobile)" plain
style="margin:0 4px;border-radius:4px;cursor:pointer;height: 40px;background-color: #ecf5ff;color: #dd6161"> class="save-button">
获取验证码 获取验证码
</el-button> </el-button>
</el-col> </el-col>
@ -76,19 +76,19 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="邮箱地址">
<el-row> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="13">
<el-input v-model="userinfo.email" ref="email" :readonly="editemail !== true" <el-input v-model="userinfo.email" ref="email" :readonly="editemail !== true"
prefix-icon="el-icon-bank-card" placeholder="邮箱" maxlength="20"></el-input> prefix-icon="el-icon-bank-card" placeholder="邮箱" maxlength="20" clearable/>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="1">
<el-button icon="el-icon-edit" @click="changeemailValue"> <el-button icon="el-icon-edit" @click="changeemailValue">
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="4" v-if="editemail === true"> <el-col :span="4" v-if="editemail === true">
<el-button type="success" @click="saveemail" plain <el-button type="success" @click="saveemail" plain
style="margin:0 4px;border-radius:4px;cursor:pointer;height: 36px;background-color: #f56c6c;color: wheat"> class="save-button">
保存 保存
</el-button> </el-button>
</el-col> </el-col>
@ -96,14 +96,14 @@
</el-form-item> </el-form-item>
<el-form-item style="height: 40px" v-if="editemail === true && cptch.cptch_image"> <el-form-item label="图片验证码" style="height: 40px" v-if="editemail === true && cptch.cptch_image">
<el-row style="height: 40px" :gutter="10"> <el-row style="height: 40px" :gutter="36">
<el-col :span="11"> <el-col :span="10">
<el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6"></el-input> <el-input placeholder="请输入图片验证码" v-model="userinfo.authcode" maxlength="6" clearable/>
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-image <el-image
style="margin:0px 4px;border-radius:4px;cursor:pointer;height: 40px" style="margin:0 4px;border-radius:4px;cursor:pointer;height: 40px"
:src="cptch.cptch_image" :src="cptch.cptch_image"
fit="contain" @click="get_auth_code"> fit="contain" @click="get_auth_code">
</el-image> </el-image>
@ -111,15 +111,15 @@
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item v-if="editemail === true"> <el-form-item label="邮箱验证码" v-if="editemail === true">
<el-row :gutter="10"> <el-row :gutter="36">
<el-col :span="12"> <el-col :span="10">
<el-input v-model="userinfo.auth_key" prefix-icon="el-icon-mobile" placeholder="验证码" <el-input v-model="userinfo.auth_key" prefix-icon="el-icon-mobile" placeholder="验证码"
maxlength="6"></el-input> maxlength="6" clearable/>
</el-col> </el-col>
<el-col :span="6"> <el-col :span="8">
<el-button type="info" @click="getsmsemailcode('email',userinfo.email)" plain <el-button type="info" @click="getsmsemailcode('email',userinfo.email)" plain
style="margin:0 4px;border-radius:4px;cursor:pointer;height: 40px;background-color: #ecf5ff;color: #dd6161"> class="save-button">
获取验证码 获取验证码
</el-button> </el-button>
</el-col> </el-col>
@ -128,39 +128,39 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="下载域名">
<el-row> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="13">
<el-input v-model="userinfo.domain_name" :readonly="editdomain_name !== true" ref="domain_name" <el-input v-model="userinfo.domain_name" :readonly="editdomain_name !== true" ref="domain_name"
prefix-icon="el-icon-download" prefix-icon="el-icon-download"
placeholder="下载页域名"></el-input> placeholder="下载页域名" clearable/>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="1">
<el-button icon="el-icon-edit" @click="changeDomainValue"> <el-button icon="el-icon-edit" @click="changeDomainValue">
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="4" v-if="editdomain_name === true"> <el-col :span="4" v-if="editdomain_name === true">
<el-button type="success" @click="saveDomain" plain <el-button type="success" @click="saveDomain" plain
style="margin:0 4px;border-radius:4px;cursor:pointer;height: 36px;background-color: #f56c6c;color: wheat"> class="save-button">
保存 保存
</el-button> </el-button>
</el-col> </el-col>
</el-row> </el-row>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item label="职位">
<el-row> <el-row :gutter="36">
<el-col :span="18"> <el-col :span="13">
<el-input v-model="userinfo.job" ref="position" :readonly="editposition !== true" <el-input v-model="userinfo.job" ref="position" :readonly="editposition !== true"
prefix-icon="el-icon-postcard" placeholder="职位"></el-input> prefix-icon="el-icon-postcard" placeholder="职位" clearable/>
</el-col> </el-col>
<el-col :span="2"> <el-col :span="1">
<el-button icon="el-icon-edit" @click="changePositionValue"> <el-button icon="el-icon-edit" @click="changePositionValue">
</el-button> </el-button>
</el-col> </el-col>
<el-col :span="4" v-if="editposition === true"> <el-col :span="4" v-if="editposition === true">
<el-button type="success" @click="savePositionValue" plain <el-button type="success" @click="savePositionValue" plain
style="margin:0 4px;border-radius:4px;cursor:pointer;height: 36px;background-color: #f56c6c;color: wheat"> class="save-button">
保存 保存
</el-button> </el-button>
@ -361,31 +361,34 @@
<style scoped> <style scoped>
.el-form { .el-form {
max-width: 360px; max-width: 500px;
margin: 0 auto; margin: 0 auto;
} }
.el-form-item .el-button { /deep/ .el-form-item__label {
max-width: 360px; width: 90px;
width: 100%;
position: relative;
height: 50px;
} }
.el-button { .el-button {
padding: 0; padding: 0;
border: none; border: none;
background-color: transparent; background-color: transparent;
color: #e2644c; color: #7e5ef8;
} }
.el-button:hover { .save-button {
background-color: #bfe7f9; margin: 0 4px;
border-radius: 4px;
cursor: pointer;
height: 36px;
background-color: #409eff;
color: #f9f9f9;
max-width: 360px;
width: 100%;
position: relative;
} }
.el-button:focus { .save-button:focus {
background-color: #bfe7f9; background-color: #bfe7f9;
} }

@ -397,7 +397,8 @@ class Price(models.Model):
class UserCertificationInfo(models.Model): class UserCertificationInfo(models.Model):
user_id = models.ForeignKey(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE) user_id = models.OneToOneField(to="UserInfo", verbose_name="用户ID", on_delete=models.CASCADE,
related_name='certification')
name = models.CharField(max_length=128, null=False, verbose_name="真实姓名") name = models.CharField(max_length=128, null=False, verbose_name="真实姓名")
card = models.CharField(max_length=128, null=False, verbose_name="身份证号码") card = models.CharField(max_length=128, null=False, verbose_name="身份证号码")
addr = models.CharField(max_length=128, null=False, verbose_name="居住地") addr = models.CharField(max_length=128, null=False, verbose_name="居住地")

@ -9,7 +9,7 @@ from api.models import Apps, UserInfo, AppReleaseInfo, AppUDID, APPToDeveloper,
import time, os import time, os
from django.utils import timezone from django.utils import timezone
from fir_ser.settings import CACHE_KEY_TEMPLATE, SERVER_DOMAIN, SYNC_CACHE_TO_DATABASE, DEFAULT_MOBILEPROVISION, \ from fir_ser.settings import CACHE_KEY_TEMPLATE, SERVER_DOMAIN, SYNC_CACHE_TO_DATABASE, DEFAULT_MOBILEPROVISION, \
USER_FREE_DOWNLOAD_TIMES USER_FREE_DOWNLOAD_TIMES, AUTH_USER_FREE_DOWNLOAD_TIMES
from api.utils.storage.storage import Storage, LocalStorage from api.utils.storage.storage import Storage, LocalStorage
from api.utils.utils import file_format_path from api.utils.utils import file_format_path
import logging import logging
@ -95,12 +95,14 @@ def get_download_url_by_cache(app_obj, filename, limit, isdownload=True, key='',
def get_app_instance_by_cache(app_id, password, limit, udid): def get_app_instance_by_cache(app_id, password, limit, udid):
if udid: if udid:
return Apps.objects.filter(app_id=app_id).values("pk", 'user_id', 'type', 'password', 'issupersign').first() return Apps.objects.filter(app_id=app_id).values("pk", 'user_id', 'type', 'password', 'issupersign',
'user_id__certification__status').first()
app_key = "_".join([CACHE_KEY_TEMPLATE.get("app_instance_key"), app_id]) app_key = "_".join([CACHE_KEY_TEMPLATE.get("app_instance_key"), app_id])
app_obj_cache = cache.get(app_key) app_obj_cache = cache.get(app_key)
if not app_obj_cache: if not app_obj_cache:
app_obj_cache = Apps.objects.filter(app_id=app_id).values("pk", 'user_id', 'type', 'password', app_obj_cache = Apps.objects.filter(app_id=app_id).values("pk", 'user_id', 'type', 'password',
'issupersign').first() 'issupersign',
'user_id__certification__status').first()
cache.set(app_key, app_obj_cache, limit) cache.set(app_key, app_obj_cache, limit)
app_password = app_obj_cache.get("password") app_password = app_obj_cache.get("password")
@ -314,7 +316,10 @@ def set_user_download_times_flag(user_id, act):
return cache.set(user_can_download_key, act, 3600 * 24) return cache.set(user_can_download_key, act, 3600 * 24)
def get_user_free_download_times(user_id, act='get', amount=1): def get_user_free_download_times(user_id, act='get', amount=1, auth_status=False):
free_download_times = USER_FREE_DOWNLOAD_TIMES
if auth_status:
free_download_times = AUTH_USER_FREE_DOWNLOAD_TIMES
now = timezone.now() now = timezone.now()
user_free_download_times_key = "_".join( user_free_download_times_key = "_".join(
[CACHE_KEY_TEMPLATE.get("user_free_download_times_key"), str(now.year), str(now.month), str(now.day), [CACHE_KEY_TEMPLATE.get("user_free_download_times_key"), str(now.year), str(now.month), str(now.day),
@ -326,17 +331,17 @@ def get_user_free_download_times(user_id, act='get', amount=1):
else: else:
return user_free_download_times return user_free_download_times
else: else:
cache.set(user_free_download_times_key, USER_FREE_DOWNLOAD_TIMES, 3600 * 24) cache.set(user_free_download_times_key, free_download_times, 3600 * 24)
if act == 'set': if act == 'set':
return cache.incr(user_free_download_times_key, -amount) return cache.incr(user_free_download_times_key, -amount)
else: else:
return USER_FREE_DOWNLOAD_TIMES return free_download_times
def consume_user_download_times(user_id, app_id, amount=1): def consume_user_download_times(user_id, app_id, amount=1, auth_status=False):
with cache.lock("%s_%s" % ('consume_user_download_times', user_id)): with cache.lock("%s_%s" % ('consume_user_download_times', user_id)):
if get_user_free_download_times(user_id, 'get', amount) > 0: if get_user_free_download_times(user_id, 'get', amount, auth_status) > 0:
get_user_free_download_times(user_id, 'set', amount) get_user_free_download_times(user_id, 'set', amount, auth_status)
else: else:
if not check_user_can_download(user_id): if not check_user_can_download(user_id):
return False return False
@ -350,18 +355,34 @@ def consume_user_download_times(user_id, app_id, amount=1):
return True return True
def enable_user_download(user_id):
enable_user_download_times_flag(user_id)
for app_obj in Apps.objects.filter(pk=user_id):
del_cache_response_by_short(app_obj.app_id)
return True
def add_user_download_times(user_id, download_times=0): def add_user_download_times(user_id, download_times=0):
with cache.lock("%s_%s" % ('consume_user_download_times', user_id)): with cache.lock("%s_%s" % ('consume_user_download_times', user_id)):
try: try:
UserInfo.objects.filter(pk=user_id).update(download_times=F('download_times') + download_times) UserInfo.objects.filter(pk=user_id).update(download_times=F('download_times') + download_times)
enable_user_download_times_flag(user_id) return enable_user_download(user_id)
for app_obj in Apps.objects.filter(pk=user_id):
del_cache_response_by_short(app_obj.app_id)
return True
except Exception as e: except Exception as e:
logger.error("%s download_times less then 0. Exception:%s" % (user_id, e)) logger.error("%s download_times less then 0. Exception:%s" % (user_id, e))
return False return False
def check_user_has_all_download_times(user_id): def check_user_has_all_download_times(app_obj):
return get_user_free_download_times(user_id) > 0 or check_user_can_download(user_id) user_id = app_obj.user_id_id
auth_status = app_obj.user_id__certification__status
return get_user_free_download_times(user_id, auth_status=auth_status) > 0 or check_user_can_download(user_id)
def user_auth_success(user_id):
'''
认证成功需要调用该方法增加次数
:param user_id:
:return:
'''
get_user_free_download_times(user_id, 'set', USER_FREE_DOWNLOAD_TIMES - AUTH_USER_FREE_DOWNLOAD_TIMES)
return enable_user_download(user_id)

@ -155,7 +155,7 @@ class ShortDownloadView(APIView):
res.msg = "该应用不存在" res.msg = "该应用不存在"
return Response(res.dict) return Response(res.dict)
if not check_user_has_all_download_times(app_obj.user_id_id): if not check_user_has_all_download_times(app_obj):
res.code = 1009 res.code = 1009
res.msg = "可用下载额度不足,请联系开发者" res.msg = "可用下载额度不足,请联系开发者"
return Response(res.dict) return Response(res.dict)
@ -244,8 +244,11 @@ class InstallView(APIView):
# 超级签需要消耗2个下载次数 # 超级签需要消耗2个下载次数
if app_obj.get("issupersign"): if app_obj.get("issupersign"):
amount += 1 amount += 1
auth_status = False
if not consume_user_download_times(app_obj.get("user_id"), app_id, amount): status = app_obj.get('user_id__certification__status', None)
if status and status == 1:
auth_status = True
if not consume_user_download_times(app_obj.get("user_id"), app_id, amount, auth_status):
res.code = 1009 res.code = 1009
res.msg = "可用下载额度不足" res.msg = "可用下载额度不足"
del res.data del res.data

@ -257,7 +257,7 @@ class LoginView(APIView):
response = BaseResponse() response = BaseResponse()
user_id = request.data.get('user_id', None) user_id = request.data.get('user_id', None)
if user_id: if user_id:
sha = hashlib.sha1(user_id.encode("utf-8")) sha = hashlib.sha1(str(user_id).encode("utf-8"))
response.data = first_register(sha.hexdigest(), request.META.get('REMOTE_ADDR')) response.data = first_register(sha.hexdigest(), request.META.get('REMOTE_ADDR'))
else: else:
response.code = 1002 response.code = 1002

@ -329,11 +329,12 @@ CACHE_KEY_TEMPLATE = {
DATA_DOWNLOAD_KEY = "d_token" DATA_DOWNLOAD_KEY = "d_token"
FILE_UPLOAD_TMP_KEY = ".tmp" FILE_UPLOAD_TMP_KEY = ".tmp"
USER_FREE_DOWNLOAD_TIMES = 10 USER_FREE_DOWNLOAD_TIMES = 20
AUTH_USER_FREE_DOWNLOAD_TIMES = 60
SYNC_CACHE_TO_DATABASE = { SYNC_CACHE_TO_DATABASE = {
'download_times': 10, # 下载次数同步时间 'download_times': 10, # 下载次数同步时间
'try_login_times': (5, 24 * 60 * 60), # 当天登录失败次数,超过该失败次数,锁定24小时 'try_login_times': (10, 12 * 60 * 60), # 当天登录失败次数,超过该失败次数,锁定24小时
'auto_clean_tmp_file_times': 60 * 30, # 定时清理上传失误生成的临时文件 'auto_clean_tmp_file_times': 60 * 30, # 定时清理上传失误生成的临时文件
'auto_clean_local_tmp_file_times': 60 * 30, # 定时清理临时文件,现在包含超级签名描述临时文件 'auto_clean_local_tmp_file_times': 60 * 30, # 定时清理临时文件,现在包含超级签名描述临时文件
'auto_clean_apscheduler_log': 100000, # 定时清理定时任务执行的日志,该日志存在数据库中,该参数为日志保留的数量 'auto_clean_apscheduler_log': 100000, # 定时清理定时任务执行的日志,该日志存在数据库中,该参数为日志保留的数量

Loading…
Cancel
Save