candidate search

This commit is contained in:
caoqianming 2020-08-02 16:43:57 +08:00
parent 0542bf40db
commit 0dcfa331b6
11 changed files with 150 additions and 87 deletions

View File

@ -33,9 +33,12 @@ App({
}
}).then(res=>{
api.request('/crm/consumer/process/', 'GET').then(res => {
for (var key in res.data) {
for (var key in res.data.process) {
try {
wx.setStorageSync(key, res.data.key)
if(res.data.process[key]){
wx.setStorageSync(key.toString(), res.data.process[key])
}
} catch (e) { }
}
})

View File

@ -25,8 +25,7 @@
"pages/quota/quota",
"pages/material/index",
"pages/question/detail",
"pages/candidate/index",
"pages/candidate/form.js"
"pages/candidate/index"
],
"window": {
"backgroundTextStyle": "light",
@ -74,6 +73,7 @@
"l-toast": "/miniprogram_npm/lin-ui/toast/index",
"l-message": "/miniprogram_npm/lin-ui/message/index",
"l-button": "/miniprogram_npm/lin-ui/button/index"
},
"style": "v2",
"sitemapLocation": "sitemap.json"

View File

@ -1,66 +0,0 @@
// pages/candidate/form.js.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})

View File

@ -1,3 +0,0 @@
{
"usingComponents": {}
}

View File

@ -1,2 +0,0 @@
<!--pages/candidate/form.js.wxml-->
<text>pages/candidate/form.js.wxml</text>

View File

@ -1 +0,0 @@
/* pages/candidate/form.js.wxss */

View File

@ -1,21 +1,27 @@
// pages/candidate/index.js
const api = require("../../utils/request.js");
Page({
/**
* 页面的初始数据
*/
data: {
form:{
ID_number:null,
realname:null
}
ID_number:null,
realname:null,
candidates:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
if(getApp().globalData.userinfo.ID_number && getApp().globalData.userinfo.realname){
this.setData({
ID_number:getApp().globalData.userinfo.ID_number,
realname:getApp().globalData.userinfo.realname,
})
this.search()
}
},
/**
@ -65,5 +71,53 @@ Page({
*/
onShareAppMessage: function () {
}
},
bindinput1: function(e){
this.data.realname = e.detail.value
},
bindinput2: function(e){
this.data.ID_number = e.detail.value
},
search: function() {
if(this.data.realname && this.data.ID_number){
var data = {
realname:this.data.realname,
ID_number:this.data.ID_number
}
wx.showLoading({
title: '查询中..',
mask:true
})
api.request('/crm/consumer/candidate/', 'GET', data).then(res => {
wx.hideLoading({
success: (res) => {},
})
console.log(res.data.candidates)
this.setData({
candidates:res.data.candidates
})
}).catch(e=>{
wx.hideLoading({
success: (res) => {},
})
})
api.request('/crm/consumer/realinfo/', 'POST', data).then(res=>{
})
}else{
wx.showToast({
title: '请填写姓名和身份证号',
icon: 'none',
duration: 1500
})
}
},
prImg: function (e) {
var current = e.target.dataset.src
wx.previewImage({
current: current,
urls: [current]
})
},
})

View File

@ -1,2 +1,39 @@
<!--pages/candidate/index.wxml-->
<text>pages/candidate/index.wxml</text>
<view class="weui-cells__title">查询信息</view>
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell" >
<view class="weui-cell__hd"><label class="weui-label">真实姓名</label></view>
<view class="weui-cell__bd">
<input class="weui-input" placeholder="填写真实姓名" placeholder-class="weui-input__placeholder"
bindinput="bindinput1" value="{{realname}}"/>
</view>
</view>
<view class="weui-cell" >
<view class="weui-cell__hd"><label class="weui-label">身份证号</label></view>
<view class="weui-cell__bd">
<input class="weui-input" type="idcard" placeholder="填写身份证号" placeholder-class="weui-input__placeholder"
bindinput="bindinput2" value="{{ID_number}}"/>
</view>
</view>
</view>
<view style="text-align:center;margin-top:4px;">
<l-button bind:lintap="search">查询</l-button>
</view>
<view class="weui-cells__title">查询结果</view>
<view wx:if="{{candidates}}">
<block wx:for="{{candidates}}" wx:key="unique">
<view class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg" style="width:96px">
<image class="weui-media-box__thumb" src="{{item.img}}" bindtap="prImg" data-src="{{item.img}}"></image>
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">
单号:{{item.report_number}}</view>
<view class="weui-media-box__desc">
<span style="color:darkblue">发证日期:{{item.issue_date}}</span>
</view>
</view>
</view>
</block>
</view>
<view wx:else style="text-align:center">暂无证书信息</view>

View File

@ -88,11 +88,13 @@ Page({
try {
const res = wx.getStorageInfoSync()
const keys = res.keys
console.log(keys)
for(var i=0;i<keys.length;i++){
if(keys[i].indexOf('cat')!=-1){
try{
process[keys[i]] = wx.getStorageSync(keys[i])
if(wx.getStorageSync(keys[i]) ){
process[keys[i]] = wx.getStorageSync(keys[i])
}
}catch(e){}
}
}

View File

@ -25,7 +25,8 @@
},
"useIsolateContext": true,
"useCompilerModule": false,
"userConfirmedUseCompilerModuleSwitch": false
"userConfirmedUseCompilerModuleSwitch": false,
"compileHotReLoad": false
},
"compileType": "miniprogram",
"libVersion": "2.10.3",

View File

@ -30,6 +30,8 @@ from .filters import ConsumerFilter
from .exports import export_consumer
from .models import Company, Consumer, PaySubject, SendCode, ConsumerPerm, ConsumerRole
from .serializers import CompanySerializer, ConsumerSerializer, ConsumerPermSerializer, ConsumerRoleSerializer, ConsumerDetailSerializer
import requests
from lxml import etree
appid = 'wxf1e9471c93f05ad6'
secret = '4bf7f9bd6c52634586bbe792a1f0a834'
@ -226,6 +228,42 @@ class ConsumerViewSet(ModelViewSet):
request.user.save()
return Response(status=status.HTTP_200_OK)
@action(methods=['post'], detail=False,
url_path='realinfo', url_name='get_realinfo', perms_map=[{'*':'*'}])
def realinfo(self, request):
'''
修改真实信息
'''
if isinstance(request.user, Consumer):
request.user.ID_number = request.data['ID_number']
request.user.realname = request.data['realname']
request.user.save()
return Response(status=status.HTTP_200_OK)
@action(methods=['get'], detail=False,
url_path='candidate', url_name='consumer_candidate', perms_map=[{'*':'*'}])
def candidate(self, request):
'''
证书查询
'''
print(request.data)
payload = {'IndexModel[name]': request.query_params['realname'], 'IndexModel[identityNumber]': request.query_params['ID_number'], 'IndexModel[certNumber]':'', 'IndexModel[candidateNumber]':''}
r = requests.post('https://fushe.chinansc.cn/open/candidate-list',data=payload)
html = etree.HTML(r.text)
results = html.xpath('//td/text()')
img = html.xpath('//a/@href')
candidates = []
try:
jsondata = {
'report_number':results[4],
'issue_date':results[5],
'img':'https://fushe.chinansc.cn'+ img[1]
}
candidates.append(jsondata)
except:
pass
return Response({'candidates':candidates}, status=status.HTTP_200_OK)
@action(methods=['post'], detail=False,
url_path='import', url_name='import_consumer')
def import_consumer(self, request):