소스 검색

fix(招聘) 添加接口签名 上传图片接口不需要添加

xing.li 3 년 전
부모
커밋
79b833e8e0
7개의 변경된 파일103개의 추가작업 그리고 34개의 파일을 삭제
  1. 2 2
      pages/person/person.js
  2. 11 1
      pages/record/record.wxml
  3. 6 4
      pages/resume/resume.js
  4. 0 1
      pages/sociology/sociology.js
  5. 1 1
      pages/sociology/sociology.wxml
  6. 31 24
      utils/request.js
  7. 52 1
      utils/util.js

+ 2 - 2
pages/person/person.js

@@ -33,7 +33,7 @@ Page({
    */
   onShow: async function () {
     let userInfo = await app.getWxUserInfo()
-    console.log(userInfo)
+    // console.log(userInfo)
     if (userInfo) {
       userInfo.avatarUrl = userInfo.headerImg
       this.setData({
@@ -139,7 +139,7 @@ Page({
   // },
   userRecruitInfo:async function(openId) {
     var result = await recruitApi.userRecruitInfo(openId);
-    console.log(result);
+    // console.log(result);
     this.setData({
       collectionNum:result.collectionNum,
       deliveryNum:result.deliveryNum,

+ 11 - 1
pages/record/record.wxml

@@ -15,9 +15,19 @@
      </view>
      <view class="info_mid_right">{{item.recruitInfo.releaseTime}}</view>
    </view>
-   <view class="info_bottom">
+   <view class="info_bottom" style="justify-content:space-between">
+   <view style="display:flex;flex-flow:row nowarp;justify-content:left">
      <image src="/images/new/depart.png" class="info_bottom_img"></image>
      <view class="info_bottom_2">{{item.recruitInfo.demandDepartment}}</view>
+    </view>
+     <view style="font-size: 24rpx;color: #6C6C6C;">
+    <span wx:if="{{item.status==1}}">待处理</span>
+     <span wx:elif="{{item.status==2}}" style="color:#FF8364">待面试</span>
+    <span wx:elif="{{item.status==3}}">很抱歉</span> 
+    <span wx:elif="{{item.status==4}}" style="color:#FF8364">通过面试</span>
+    <span wx:elif="{{item.status==5}}">很遗憾</span> 
+   
+    </view>
    </view>
    <view class="info_bottom_date">
     <view>投递时间:{{item.addTs}}</view>

+ 6 - 4
pages/resume/resume.js

@@ -1,4 +1,5 @@
 import recruitApi from '../../api/recruit'
+import request from '../../utils/request'
 const app = getApp()
 Page({
 
@@ -230,10 +231,11 @@ Page({
     })
   },
   uploadFile: function(temFile){
-    console.log(temFile)
+    // console.log(temFile)
+    // console.log(request.BASE_URL)
     var self = this;
     wx.uploadFile({
-      url: "https://oapi.shpr.top/open/upload/upload-pic",   //上传的路径
+      url:request.BASE_URL+"open/upload/upload-pic",   //上传的路径
       filePath:temFile, //刚刚在data保存的文件路径
       name: 'file',   //后台获取的凭据
       formData: {
@@ -241,8 +243,8 @@ Page({
       },
       success (res){
         const result = JSON.parse(res.data)
-        console.log(result)
-        console.log(result.data.destPath)
+        // console.log(result)
+        // console.log(result.data.destPath)
         self.setData({
           resumeFile:result.data.url,
           fileColor:"#000",

+ 0 - 1
pages/sociology/sociology.js

@@ -91,7 +91,6 @@ Page({
   },
   getRecruitList: async function(name='') {
     var result = await recruitApi.getRecruitList(name,this.data.type,this.data.page,this.data.pageNum);
-    console.log(result)
     if(this.data.page!=1){
       var nowResult = this.data.recruitList.concat(result.list)
     }else{

+ 1 - 1
pages/sociology/sociology.wxml

@@ -25,7 +25,7 @@
        
       </view> -->
   </view>
-  <view class="info" bindtap="goToInfo" data-id="{{item.id}}" wx:for="{{recruitList}}" wx:if="{{recruitList.length>0}}">
+  <view class="info" bindtap="goToInfo" data-id="{{item.id}}" wx:for="{{recruitList}}" wx:if="{{recruitList.length>0}}" wx:key="unique">
     <view class="info_top">
       <view class="info_top_left">{{item.name}}</view>
       <view class="info_top_right">{{item.salary}}</view>

+ 31 - 24
utils/request.js

@@ -1,11 +1,15 @@
-
+import util from './util.js'
 class request {
 
-//   static BASE_URL = 'http://www.hsay.com:81/'
-  static BASE_URL = 'https://oapi.shpr.top/'//pre环境的
+  static BASE_URL = 'http://www.lx.com:81/'
+//   static BASE_URL = 'https://oapi.shpr.top/'//pre环境的
+//   @todo需要修改正式的域名
+
   static HEAD = {
       "Content-Type": "application/json",
-      "token":'',
+      "SIGN":'',
+      "NONCE":'',
+      "TIMESTAMP":'',
   }
   static constructor() {
 
@@ -21,13 +25,9 @@ class request {
   /**
    * GET类型的网络请求
    */
-  static getRequest(url, data, header = this.HEAD ) {
-
-      const token = wx.getStorageSync('token')
-      if (token) {
-          header.token = token
-      }
-      return this.requestAll(url, data, header, 'GET')
+  static getRequest(url, data ) {
+     let  headerSign = this.getSignHead();
+      return this.requestAll(url, data, headerSign, 'GET')
   }
 
   
@@ -35,19 +35,13 @@ class request {
   /**
    * POST类型的网络请求
    */
-  static postRequest(url, data, header = this.HEAD) {
-      const token = wx.getStorageSync('token')
-      if (token) {
-          header.token = token
-      }
-      return this.requestAll(url, data, header, 'POST')
+  static postRequest(url, data) {
+      let  headerSign = this.getSignHead();
+      return this.requestAll(url, data, headerSign, 'POST')
   }
 
   static upload(url, name, path, ortherData, header = this.HEAD){
-      const token = wx.getStorageSync('token')
-      if (token) {
-          header.token = token
-      }
+     
       return new Promise((resolve, reject) => {
           wx.uploadFile({
               url: url,
@@ -62,7 +56,7 @@ class request {
                       resolve(res.data)
                   } else {
                         wx.showToast({
-                            title: res.data.message,
+                            title: res.data.msg,
                         })
                       //其它错误,提示用户错误信息
                       if (this._errorHandler != null) {
@@ -84,12 +78,25 @@ class request {
           })
       })
   }
-
+  static getSignHead(){
+    let timestamp = parseInt(Date.now()/1000);
+    let nonce = Math.floor(Math.random() * 1000).toString()
+    let signStr = timestamp+nonce+""+"U6Watb875eCiX4Lq";
+    let sign =  util.sha1(signStr).toString();
+    
+    let signHeadInfo = {
+        "SIGN":sign,
+        "NONCE":nonce,
+        "TIMESTAMP":timestamp,
+        "Content-Type": "application/json"
+    }
+    return signHeadInfo;
+  }
   /**
    * 网络请求
    */
   static requestAll(url, data, header, method) {
-      const _self = this
+     
       wx.showLoading()
       return new Promise((resolve, reject) => {
           wx.request({

+ 52 - 1
utils/util.js

@@ -14,6 +14,57 @@ const formatNumber = n => {
   return n[1] ? n : `0${n}`
 }
 
+function encodeUTF8(s) {
+  var i, r = [], c, x;
+  for (i = 0; i < s.length; i++)
+    if ((c = s.charCodeAt(i)) < 0x80) r.push(c);
+    else if (c < 0x800) r.push(0xC0 + (c >> 6 & 0x1F), 0x80 + (c & 0x3F));
+    else {
+      if ((x = c ^ 0xD800) >> 10 == 0) //对四字节UTF-16转换为Unicode
+        c = (x << 10) + (s.charCodeAt(++i) ^ 0xDC00) + 0x10000,
+          r.push(0xF0 + (c >> 18 & 0x7), 0x80 + (c >> 12 & 0x3F));
+      else r.push(0xE0 + (c >> 12 & 0xF));
+      r.push(0x80 + (c >> 6 & 0x3F), 0x80 + (c & 0x3F));
+    };
+  return r;
+}
+
+// 字符串加密成 hex 字符串
+function sha1(s) {
+  var data = new Uint8Array(encodeUTF8(s))
+  var i, j, t;
+  var l = ((data.length + 8) >>> 6 << 4) + 16, s = new Uint8Array(l << 2);
+  s.set(new Uint8Array(data.buffer)), s = new Uint32Array(s.buffer);
+  for (t = new DataView(s.buffer), i = 0; i < l; i++)s[i] = t.getUint32(i << 2);
+  s[data.length >> 2] |= 0x80 << (24 - (data.length & 3) * 8);
+  s[l - 1] = data.length << 3;
+  var w = [], f = [
+    function () { return m[1] & m[2] | ~m[1] & m[3]; },
+    function () { return m[1] ^ m[2] ^ m[3]; },
+    function () { return m[1] & m[2] | m[1] & m[3] | m[2] & m[3]; },
+    function () { return m[1] ^ m[2] ^ m[3]; }
+  ], rol = function (n, c) { return n << c | n >>> (32 - c); },
+    k = [1518500249, 1859775393, -1894007588, -899497514],
+    m = [1732584193, -271733879, null, null, -1009589776];
+  m[2] = ~m[0], m[3] = ~m[1];
+  for (i = 0; i < s.length; i += 16) {
+    var o = m.slice(0);
+    for (j = 0; j < 80; j++)
+      w[j] = j < 16 ? s[i + j] : rol(w[j - 3] ^ w[j - 8] ^ w[j - 14] ^ w[j - 16], 1),
+        t = rol(m[0], 5) + f[j / 20 | 0]() + m[4] + w[j] + k[j / 20 | 0] | 0,
+        m[1] = rol(m[1], 30), m.pop(), m.unshift(t);
+    for (j = 0; j < 5; j++)m[j] = m[j] + o[j] | 0;
+  };
+  t = new DataView(new Uint32Array(m).buffer);
+  for (var i = 0; i < 5; i++)m[i] = t.getUint32(i << 2);
+
+  var hex = Array.prototype.map.call(new Uint8Array(new Uint32Array(m).buffer), function (e) {
+    return (e < 16 ? "0" : "") + e.toString(16);
+  }).join("");
+  return hex;
+}
+
 module.exports = {
-  formatTime
+  formatTime,
+  sha1
 }