y595705120 3 years ago
parent
commit
9cd9d165e5

+ 26 - 31
app.js

@@ -8,7 +8,7 @@ App({
   globalData: {
     pageSize: 10,
     userInfo: {},
-    departments: false,
+    departments: [],
     studyInfo: {},
   },
   onLaunch: function () {
@@ -45,18 +45,25 @@ App({
     }
   },
   gotoLogin: function(){
+    console.log("gologin")
     wx.navigateTo({
       url: `/pages/user/identify/index`,
     })
   },
   checkLogin: function(cb){
-    if( this.globalData.userInfo){
+    if( this.globalData.userInfo && this.globalData.userInfo.userId ){
       cb&&cb( this.globalData.userInfo );
     }else{
-      this.formPost("user/info", {}).then( res=>{
-        if( res.code == 200){
-          this.setUserInfo( res.data )
-          cb&&cb( this.data.user )
+      let token = wx.getStorageSync('@token');
+      console.log("get token", token)
+      if( !token ) {
+        this.gotoLogin()
+        return;
+      }
+      this.formPost('weixin/info', {}).then( res =>{
+        if (res.code == 200) {
+          this.setUserInfo(res.data);
+          cb && cb( this.globalData.userInfo )
         }else{
           this.gotoLogin()
         }
@@ -69,7 +76,7 @@ App({
       type: type
     });
   },
-  formPost: function (action, data) {
+  formPost: function (action, data, showErr= true) {
     let uid = wx.getStorageSync('@userId')||0;
     let token = wx.getStorageSync('@token')||'';
     let timestamp = Date.now()
@@ -93,10 +100,17 @@ App({
           if (res.statusCode !== 200 || typeof res.data !== 'object') {
             showMsg( "请求异常" )
           }
+          let newToken = res.header["new-token"];
+          if( newToken ) {
+            wx.setStorageSync( "@token", newToken )
+          }
           if( res.data.data && res.data.data.reload  ){
+            wx.clearStorageSync("@token")
             wx.navigateTo({
               url: '/pages/user/identify/index',
             })
+          }else if( res.data.code != 200 && showErr ){
+            util.showMsg(res.data.msg)
           }
           resolve(res.data);
         },
@@ -110,26 +124,6 @@ App({
       })
     })
   },
-  getUserInfo: function ( cb ) {
-    let userInfo = this.globalData.userInfo
-    if( userInfo && userInfo.token ){
-      cb && cb( userInfo);
-      return
-    }
-    let openid = wx.getStorageSync('@openid');
-    // let openid="oG3Fi5ait37qL-3edzAkzysH5apU"
-    if( !openid ) {
-      cb && cb({});
-      return
-    }
-    let param = {"openid": openid};
-    this.formPost('Auth.wxLogin', param).then( res =>{
-      if (res.code == 200) {
-        this.setUserInfo(res.data);
-      }
-      cb && cb(res.data||{});
-    })
-  },
   getSystemInfo(  cb ){
     wx.getSystemInfo({
       success: function(res) {
@@ -143,8 +137,8 @@ App({
     wx.navigateTo({url})
   },
   getDepartments: function( cb  ){
-    if( this.globalData.departments ){
-      cb&&cb( this.globalData.departments||[])
+    if( this.globalData.departments.length > 0 ){
+      cb&&cb( this.globalData.departments )
     }else{
       this.loadDepartments( cb )
     }
@@ -153,14 +147,15 @@ App({
     this.formPost( 'base/loadDepartmentList', {}).then( res=>
       {
         if( res.code == 200){
-          this.globalData.departments = res.data
-          cb && cb( this.globalData.departments)
+          this.globalData.departments = res.data;
+          cb && cb( res.data );
         }
       }
     )
   },
   setUserInfo: function (info) {
     let {token, user} = info
+    console.log("setUserInfo", token, user)
     this.globalData.userInfo = user;
     wx.setStorageSync('@token', token)
     wx.setStorageSync('@userId', user.userId )

+ 5 - 5
app.json

@@ -1,13 +1,13 @@
 {
   "pages": [
-    "pages/artical/info/index",
-    "pages/user/index/index",
     "pages/index/index",
+    "pages/user/filelist/index",
+    "pages/user/index/index",
+    "pages/artical/info/index",
     "pages/department/artical/index",
+    "pages/department/account/index",
     "pages/user/identify/index",
-    "pages/search/file/index",
-    "pages/department/account/index"
-    
+    "pages/search/file/index"  
   ],
   "tabBar": {
     "color": "#6e6d6b",

+ 8 - 0
assets/css/style.wxss

@@ -45,4 +45,12 @@
 .f-header .icon-you {
     font-size: 34rpx;
     color: #909399;
+}
+
+.bline{
+    border: 1px dashed #ccc;
+}
+
+.btline{
+    border-top: 1px dashed #ccc;
 }

+ 110 - 47
pages/artical/info/index.js

@@ -6,70 +6,133 @@ Page({
     articalId:0,
     isLike:0,
     info:{},
+    confirmModal: false,
+    publishModal: false,
+    content:'',
+    categorys:{},
+    userInfo:{},
+    isLeader:0,
     logs:[]
   },
-
+  preview( e ){
+    var imgs = [];
+    let brirf = this.data.info.brief||''
+    brirf.replace(/<img [^>]*src=['"]([^'"]+)[^>]*>/gi, function (match, capture) {
+      imgs.push(capture);
+    });
+    if( imgs.length > 0 ){
+      wx.previewImage({
+        current: imgs[0],
+        urls: imgs
+      })
+    }
+  },
+  openDialog( e ){
+    let param = {content:''}
+    param[e.currentTarget.dataset.id] =true
+    this.setData( param )
+  },
+  closeDialog( e ){
+    let param = {content:''}
+    param[e.currentTarget.dataset.id] =false
+    this.setData( param )
+  },
   onLoad: function (options) {
-    let articalId = options.articalId||2135;
+    let articalId = +options.articalId||2135;
     this.setData({articalId})
-    this.loadData()
   },
-
-  loadData(){
-    let articalId = this.data.articalId
-    app.formPost( "artical/getArticalInfo", {articalId}).then( res=>{
+  onShow: function(){
+    app.checkLogin( this.loadData )
+  },
+  inputContent(e){
+    let content = e.detail.value
+    this.setData({ content });
+  },
+  confirmArtical: function (e) {
+    let articalId = this.data.info.articalId
+    let content = this.data.content;
+    let action = 1
+    if( !content ){
+      util.showMsg("请留下宝贵意见")
+      return 
+    }
+    let info = this.data.info;
+    app.formPost( "artical/confirmArtical", {articalId,content,action}).then( res=>{
       if( res.code == 200 ){
-        let {isLike,info,logs} = res.data
-        this.setData({isLike,info,logs})
+        info.status = 2
+        app.showMsg( "确认成功")
+        this.setData({info, confirmModal:false})
       }
     })
   },
-  /**
-   * 生命周期函数--监听页面初次渲染完成
-   */
-  onReady: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面显示
-   */
-  onShow: function () {
-
-  },
-
-  /**
-   * 生命周期函数--监听页面隐藏
-   */
-  onHide: function () {
-
+  publishArtical:function (e) {
+    let articalId = this.data.info.articalId
+    let content = this.data.content;
+    let action = 1
+    if( !content ){
+      util.showMsg("请留下宝贵意见")
+      return 
+    }
+    app.formPost( "artical/publishArtical", {articalId,content,action}).then( res=>{
+      if( res.code == 200 ){
+        info.status = 3
+        app.showMsg( "发布成功")
+        this.setData({info, confirmModal:false})
+      }
+    })
   },
-
-  /**
-   * 生命周期函数--监听页面卸载
-   */
-  onUnload: function () {
-
+  loadData(){
+    let articalId = this.data.articalId
+    app.formPost( "weixin/getArticalInfo", {articalId}).then( res=>{
+      if( res.code == 200 ){
+        let {isLike,info,logs, isLeader} = res.data
+        this.setData({isLike,info,logs,isLeader})
+      }
+    })
   },
-
-  /**
-   * 页面相关事件处理函数--监听用户下拉动作
-   */
-  onPullDownRefresh: function () {
-
+  downloadUrl( url ){
+    wx.downloadFile({
+      url: url,
+      timeout: 0,
+      success: (res) => {
+        var rr=res.tempFilePath;
+        wx.openDocument({
+          filePath:rr,
+          showMenu: true,
+          success(res) {
+            wx.showToast({
+              title: '保存成功',
+              icon: 'success',
+              duration: 2000
+            })
+          }
+        })
+      },
+      fail: (res) => {
+        console.log("res_fail", res)
+      },
+      complete: (res) => {
+        console.log("res_complete", res)
+      },
+    })
   },
 
-  /**
-   * 页面上拉触底事件的处理函数
-   */
-  onReachBottom: function () {
-
+  download(){
+    let articalId = this.data.info.articalId;
+    app.formPost( "artical/downloadFile", {articalId}).then( res=>{
+      if( res.code == 200 ){
+        this.downloadUrl( res.data )
+      }
+    })
   },
-
   /**
    * 用户点击右上角分享
    */
   onShareAppMessage: function () {
-
+    let {title, articalId} = this.data.info;
+    return {
+      title: title,
+      path: `/pages/artical/info/index?articalId=${articalId}`
+    }
   }
 })

+ 1 - 0
pages/artical/info/index.json

@@ -8,6 +8,7 @@
     "i-message": "/component/iView/message/index",
     "i-spin": "/component/iView/spin/index",
     "i-icon": "/component/iView/icon/index",
+    "i-modal": "/component/iView/modal/index",
     "i-badge": "/component/iView/badge/index",
     "i-card": "../../../component/iView/card/index",
     "i-avatar": "/component/iView/avatar/index"

+ 83 - 6
pages/artical/info/index.wxml

@@ -1,18 +1,95 @@
 <wxs src="../../../wxs/util-fun.wxs" module="util"></wxs>
 
 <view>
-    <view class="bg-white p20 fc" style="text-align:center;font-size:40rpx;margin-top:10rpx" > {{info.title}}</view>
+  <view class="artical-title fc">
+    {{info.title}}
+  </view>
+  <view class=" tc">
+    <text> {{info.department}}</text>-
+    <text> {{info.category}}</text>
+    <i-icon type="flashlight" size="20" color="#80848f" />
+    {{info.downloadCount}}
+    <i-icon type="browse" size="20" color="#80848f" />
+    {{info.viewCount}}
+  </view>
+  
+  <view class="tc mt10 ">
+    <i-button  bindtap="preview" class="bsmall"> 预览文件 </i-button>
+    <i-button  bindtap="download" class="ml20 bsmall"> 下载文件</i-button>
+    <i-button class="ml20 bsmall" bindtap="openDialog" data-id="confirmModal" wx:if="{{info.status==1 && isLeader == 2}}"> 审核文章</i-button>
+    <i-button class="ml20 bsmall" bindtap="openDialog" data-id="publishModal" wx:if="{{info.status==2 && isLeader == 3}}"> 发布文章</i-button>
+  </view>
 
-    <view class="wxParse tc">
-      <rich-text nodes="{{info.brief}}"></rich-text>
-    </view>
-    
+  <view class="wxParse tc">
+    <rich-text nodes="{{info.brief}}" space="emsp" ></rich-text>
+  </view>
+
+  <view wx:for="{{logs}}" wx:key="articalId" wx:for-index="index" class="mt20">
+    <view wx:if="{{ index==0}}">
+      <i-card extra="{{item.nickname}}" title="{{item.action}}" full wx:if="{{isLeader==2 && info.status==1}}">
+        <view slot="content">操作描述: {{item.content}}
+          <button class="fr" bindtap="confirm">审核</button>
+        </view>
+        <view slot="footer">
+          操作时间:{{util.getDatetime(item.createAt)}}
+        </view>
+      </i-card>
 
+      <i-card extra="{{item.nickname}}" title="{{item.action}}" full wx:elif="{{isLeader==3 && info.status==2}}">
+        <view slot="content">操作描述: {{item.content}}
+          <button class="fr" bindtap="publish">发布</button>
+        </view>
+        <view slot="footer">
+          操作时间:{{util.getDatetime(item.createAt)}}
+        </view>
+      </i-card>
 
-    <view wx:for="{{logs}}" wx:key="articalId" wx:for-index="index" bindtap="getDetail" class="mt20" >
+      <i-card extra="{{item.nickname}}" title="{{item.action}}" full wx:else>
+        <view slot="content">操作描述: {{item.content}}
+          <button class="fr" bindtap="confirm">审核</button>
+        </view>
+        <view slot="footer">操作时间:{{util.getDatetime(item.createAt)}}</view>
+      </i-card>
+    </view>
+
+    <view wx:else>
       <i-card extra="{{item.nickname}}" title="{{item.action}}" full>
         <view slot="content">操作描述: {{item.content}}</view>
         <view slot="footer">操作时间:{{util.getDatetime(item.createAt)}}</view>
       </i-card>
     </view>
+  </view>
 </view>
+
+<i-modal title="审核文章" 
+  visible="{{ confirmModal }}" 
+  bind:ok="confirmArtical" bind:cancel="closeDialog" data-id="confirmModal">
+  <view class="btline">{{info.username||'管理员'}}:{{info.lastMsg||'添加文章'}}</view>
+  <form>
+    <textarea 
+        bindinput='inputContent'
+        class="tc p20 m10 w80"
+        name="content" 
+        type="textarea" 
+        placeholder-style="color:red;"
+        style="color:#f00;"
+        placeholder="审核意见" />
+    </form>
+</i-modal>
+
+
+<i-modal title="发布文章" 
+  visible="{{ publishModal }}" 
+  bind:ok="publishArtical" bind:cancel="closeDialog" data-id="publishModal">
+  <view class="btline">{{info.username||'管理员'}}:{{info.lastMsg||'添加文章'}}</view>
+  <form>
+    <textarea 
+        bindinput='inputContent'
+        class="tc p20 m10 w80"
+        name="content" 
+        type="textarea" 
+        style="color:#f00;"
+        placeholder-style="color:red;"
+        placeholder="发布意见" />
+    </form>
+</i-modal>

+ 18 - 1
pages/artical/info/index.wxss

@@ -1 +1,18 @@
-/* pages/artical/info/index.wxss */
+/* pages/artical/info/index.wxss */
+page{
+  background:white;
+}
+.artical-title{
+  text-align:center;
+  font-size:36rpx;
+  font-weight: 800;
+  margin-top:10rpx;
+  padding:20rpx;
+  background: #ffffff;
+}
+
+.bsmall{
+  color:#409eff;
+}
+
+.w80{ width:90%}

+ 26 - 20
pages/department/artical/index.js

@@ -13,20 +13,29 @@ Page({
     keyword:'',
     from:0,
     size:10,
+    isLogin: false,
     department:{departmentId:0},
+    departments:[],
     articalList:[]
   },
   onLoad: function (options) {
-    let departmentId = +options.departmentId
+    let departmentId = +options.departmentId||21
     if( departmentId ){
       wx.setStorageSync('@departmentId', departmentId)
       this.setData({departmentId})
     }
-    app.checkLogin( this.loadData )
+  },
+  onShow(){
+    if( this.data.isLogin ) return
+    app.checkLogin( userInfo=>{
+      this.setData({isLogin:true})
+      console.log( "checkLogin", userInfo) 
+      this.loadData()
+    } )
   },
   loadData(){
     let departmentId = this.data.departmentId;
-    app.getDepartments( departments=>{
+    app.getDepartments( departments =>{
       let department = {}
       for( let i in departments){
         if( departments[i].departmentId == departmentId){
@@ -34,14 +43,23 @@ Page({
           break
         }
       }
-      this.setData({department, from:0})
+      this.setData({department, from:0, departments})
       // 
-      wx.setNavigationBarTitle({
-        title: department.department
-      })
+      console.log("department", departments)
+      if( department.department){
+        wx.setNavigationBarTitle({
+          title: department.department
+        })
+      }
     })
     this.loadArtical(   )
   },
+  getDetail(e){
+    let id = e.currentTarget.dataset.id;
+    wx.navigateTo({
+      url: `/pages/artical/info/index?articalId=${id}`,
+    })
+  },
   loadArtical(  cb ){
     let {from, size, departmentId,keyword, articalList} = this.data
     let param = { from, size, departmentId, keyword }
@@ -59,20 +77,8 @@ Page({
     let {value} = e.detail;
     if( this.data.keyword == value) return;
     this.setData({keyword: value, from:0})
+    this.loadArtical(   )
   },
-  onReady: function () {
-
-  },
-  onShow: function () {
-  },
-  onHide: function () {
-
-  },
-
-  onUnload: function () {
-
-  },
-
   onPullDownRefresh: function () {
     wx.showNavigationBarLoading();
     this.setData( {from:0})

+ 3 - 1
pages/department/artical/index.json

@@ -1,6 +1,8 @@
 {
   "usingComponents": {
-    "i-card": "../../../component/iView/card/index"
+    "i-card": "../../../component/iView/card/index",
+    "i-icon": "/component/iView/icon/index",
+    "i-button": "../../../component/iView/button/index"
   },
   "navigationBarTitleText": "内业管理系统"
 }

+ 25 - 5
pages/department/artical/index.wxml

@@ -7,11 +7,31 @@
     </view>
   </view>
   <view class="mt120">
-    <view wx:for="{{articalList}}" wx:key="articalId" wx:for-index="index" bindtap="getDetail" class="mt10">
-      <i-card title="{{item.department}}" extra="{{util.getCategory(item.category)}}">
-        <view slot="content">{{item.title}}</view>
-        <view slot="footer">创建时间: {{util.getDatetime(item.createAt)}}</view>
-      </i-card>
+    <view wx:for="{{articalList}}" wx:key="articalId"  class="mt20">
+      <view class="i-class i-card i-card-full" data-id="{{item.articalId}}"  bindtap="getDetail">
+        <view class="i-class i-card-header">
+          <view class="i-card-header-title">
+            编号:{{item.articalId}}
+          </view>
+
+          <view class="i-card-header-extra" >
+            {{item.department}}-{{item.category}}
+          </view>
+        </view>
+        <view class="i-class i-card-body"  >
+          【{{item.isOpen?'公开':'私有'}}】{{item.title}}
+        </view>
+
+        <view class="i-card-footer">
+          时间:{{util.getDatetime(item.createAt)}}  
+
+          <i-icon type="flashlight" size="20" color="#80848f" />
+          {{item.downloadCount}}
+          <i-icon type="browse" size="20" color="#80848f" />
+          {{item.viewCount}}
+
+        </view>
+      </view>
     </view>
   </view>
 

+ 28 - 1
pages/department/artical/index.wxss

@@ -1,3 +1,4 @@
+@import '/component/iView/card/index.wxss';
 .fs10{
   font-size: 5rpx;
 }
@@ -33,4 +34,30 @@
   min-height: 40rpx;
   height: 40rpx;
   font-size: 14px;
-}
+}
+
+.bsmall{
+  margin: 10rpx;
+  padding:0px;
+  /* box-shadow: inset 0 0 0 1rpx rgba(0,0,0,.1); */
+  color:#409eff;
+  background:#fff;
+  text-align: center;
+  vertical-align: middle;
+  touch-action: manipulation;
+  cursor: pointer;
+  background-image: none;
+  white-space: nowrap;
+  user-select: none;
+  font-size: 14px;
+  height: 60rpx;
+  min-width: 60rpx;
+}
+
+/* 
+.i-card-header-title {
+  flex: 1;
+  font-size: 32rpx;
+  text-align: left;
+  color: #80848f;
+} */

+ 96 - 0
pages/user/filelist/index.js

@@ -0,0 +1,96 @@
+const util = require("../../../utils/util")
+
+//获取应用实例
+const app = getApp()
+
+Page({
+
+  data: {
+    departmentId:0,
+    keyword:'',
+    api:'',
+    from:0,
+    size:10,
+    isLogin: false,
+    userInfo:{},
+    apis:{
+      'getViewArticalList':'浏览记录',
+      'getLikeArticalList':'收藏记录',
+      'getDownloadArticalList':'下载记录',
+      'waitConfirmArticalList':'审核审批',
+      'waitDownloadArticalList':'下载审批',
+      'waitPublishArticalList':'发布审批'
+    },
+    department:{departmentId:0},
+    departments:[],
+    articalList:[]
+  },
+  onLoad: function (options) {
+    let api = options.api||'getViewArticalList'
+    let title = this.data.apis[api]||'浏览记录'
+    console.log( title, api, this.data.apis)
+    wx.setNavigationBarTitle({
+      title: title,
+    })
+    this.setData({api})
+  },
+  onShow(){
+    if( this.data.isLogin ) return
+    app.checkLogin( userInfo=>{
+      this.setData({userInfo})
+      this.loadData()
+    } )
+  },
+  loadData(){
+    this.loadArtical(   )
+  },
+  getDetail(e){
+    let id = e.currentTarget.dataset.id;
+    wx.navigateTo({
+      url: `/pages/artical/info/index?articalId=${id}`,
+    })
+  },
+  loadArtical(  cb ){
+    let {from, size, api,keyword, articalList} = this.data
+    let param = { from, size, keyword }
+    app.formPost( `weixin/${api}`, param).then( res=>{
+      if( res.code == 200 ){
+        if( from == 0) articalList = []
+        from= res.data.from;
+        articalList = articalList.concat( res.data.list||[] );
+        this.setData( {from, articalList})
+      }
+      cb &&cb()
+    })
+  },
+  onInputEvent(e){
+    let {value} = e.detail;
+    if( this.data.keyword == value) return;
+    this.setData({keyword: value, from:0})
+    this.loadArtical(   )
+  },
+  onPullDownRefresh: function () {
+    wx.showNavigationBarLoading();
+    this.setData( {from:0})
+    this.loadArtical( ()=>{
+      wx.hideNavigationBarLoading(); 
+      wx.stopPullDownRefresh();
+    })
+  },
+  onReachBottom: function () {
+    var that = this
+    let newFrom = that.data.from
+    if (newFrom == -1) {
+      wx.stopPullDownRefresh();
+      return;
+    }
+    this.loadArtical( );
+  },
+
+  /**
+   * 用户点击右上角分享
+   */
+  onShareAppMessage: function () {
+
+  }
+})

+ 8 - 0
pages/user/filelist/index.json

@@ -0,0 +1,8 @@
+{
+  "usingComponents": {
+    "i-card": "../../../component/iView/card/index",
+    "i-icon": "/component/iView/icon/index",
+    "i-button": "../../../component/iView/button/index"
+  },
+  "navigationBarTitleText": "内业管理系统"
+}

+ 43 - 0
pages/user/filelist/index.wxml

@@ -0,0 +1,43 @@
+<wxs src="../../../wxs/util-fun.wxs" module="util"></wxs>
+<scroll-view scroll-y class="scrollPage">
+
+  <view class='searchbar'>
+    <view class='search-input-group'>
+      <input class='search-input' placeholder="搜一搜" bindinput="onInputEvent"></input>
+    </view>
+  </view>
+  <view class="mt120">
+    <view wx:for="{{articalList}}" wx:key="index"  class="mt20">
+      <view class="i-class i-card i-card-full" data-id="{{item.articalId}}"  bindtap="getDetail">
+        <view class="i-class i-card-header">
+          <view class="i-card-header-title">
+            编号:{{item.articalId}}
+          </view>
+
+          <view class="i-card-header-extra" >
+            {{item.department}}-{{item.category}}
+          </view>
+        </view>
+        <view class="i-class i-card-body"  >
+          【{{item.isOpen?'公开':'私有'}}】{{item.title}}
+        </view>
+
+        <view class="i-card-footer">
+          时间:{{util.getDatetime(item.createAt)}}  
+        </view>
+      </view>
+    </view>
+  </view>
+
+  <view wx:if="{{from==-1}}" class="fc tc mt10" >
+    <view class="padding">没有更多了</view>
+    <view class='cu-tabbar-height'></view>
+  </view>
+  <view class='cu-tabbar-height'></view>
+</scroll-view>
+
+
+<view class='cu-load load-modal' wx:if="{{loadModal}}">
+  <view class='cuIcon-emojifill text-orange'></view>
+  <view class='gray-text'>加载中...</view>
+</view>

File diff suppressed because it is too large
+ 21 - 0
pages/user/filelist/index.wxss


+ 5 - 4
pages/user/identify/index.js

@@ -5,20 +5,21 @@ Page({
   data: {
     hidden: true,
   },
-  wxLogin(){
+  wxLogin( e ){
+    let {avatarUrl} = e.detail.userInfo;
     let that = this
     wx.login({
       success(wxres) {
         if( !wxres.code){
           util.showMsg("登入失败")
         }else{
-          that.doLoginByCode( wxres.code )
+          that.doLoginByCode( wxres.code, avatarUrl )
         }
       }
     })
   },
-  doLoginByCode( code ){
-    app.formPost( "base/wxLogin", {code}).then( (res)=>{
+  doLoginByCode( code, avatarUrl ){
+    app.formPost( "base/wxLogin", {code, avatarUrl}).then( (res)=>{
       if( res.code == 200){
         app.setUserInfo(  res.data )
         util.showSuccess("登入成功")

+ 1 - 1
pages/user/identify/index.wxml

@@ -25,7 +25,7 @@
   <view>
     <text> 已经绑定过可以快捷登入 </text>
   </view>
-  <button class="mt20" type="primary" bindtap="wxLogin" size="mini">
+  <button class="mt20" type="primary" bindgetuserinfo="wxLogin" size="mini" open-type="getUserInfo">
     快捷登入
   </button>
 </view>

+ 9 - 6
pages/user/index/index.js

@@ -28,20 +28,23 @@ Page({
       }
     })
   },
+  goLogin( e){
+    wx.navigateTo({
+      url: '/pages/user/identify/index',
+    })
+  },
   logOut() {
     wx.setStorageSync('userId', '')
-    wx.setStorageSync('token', '')
+    wx.setStorageSync('@token', '')
     wx.setStorageSync('@openid', '')
     let userInfo = {}
     this.setData({userInfo})
     app.setUserInfo( userInfo )
-    wx.navigateTo({
-      url: '/pages/index/index',
-    })
   },
-  gotoIdentify(){
+  gotoFileList( e  ){
+    let api = e.currentTarget.dataset.api;
     wx.navigateTo({
-      url: '/pages/user/identify/index',
+      url: `/pages/user/filelist/index?api=${api}`,
     })
   }
 })

+ 2 - 0
pages/user/index/index.json

@@ -2,6 +2,8 @@
   "usingComponents": {
     "i-cell-group": "/component/iView/cell-group/index",
     "i-cell": "/component/iView/cell/index",
+    "i-avatar": "/component/iView/avatar/index",
+    "i-button": "/component/iView/button/index",
     "i-icon": "/component/iView/icon/index",
     "i-message": "/component/iView/message/index",
     "i-spin": "/component/iView/spin/index"

+ 27 - 23
pages/user/index/index.wxml

@@ -2,50 +2,54 @@
 
 <wxs module="filter" src="../../../wxs/exam-fun.wxs"></wxs>
 
-<view class='userinfo'>
+<view class='userinfo' wx:if="{{userInfo.userId}}">
   <view class='userinfo-avatar'>
-    <open-data type="userAvatarUrl"></open-data>
+    <image src="{{userInfo.headerImg}}" mode="widthFix" style="width:100%"></image>
   </view>
   <view class='userinfo-name'>
-    <open-data type="userNickName"></open-data>
+    <view> {{userInfo.nickname}}</view>
+  </view>
+</view>
+
+<view class='userinfo ' wx:else>
+  <view class='userinfo-avatar'>
+    <image src="/assets/icon/1.jpg" mode="widthFix" style="width:100%"></image>
+  </view>
+  <view class='userinfo-name'>
+    <i-button inline="true"  size="small" type="success" shape="square" bindtap="goLogin" >
+      微信登录
+    </i-button>
   </view>
 </view>
 
 <view>
   <i-cell-group i-class="my-group-margin">
-    <i-cell title="我的文件" is-link>
-      <i-icon type="mobilephone_fill" slot="icon" size="20" />
-    </i-cell>
 
-    <i-cell title="我的文件" is-link>
+    <i-cell title="历史记录" is-link bindtap="gotoFileList" data-api="getViewArticalList">
       <i-icon type="mine_fill" slot="icon" size="20" />
     </i-cell>
 
-    <i-cell title="申请记录" is-link>
+    <i-cell title="下载记录" is-link bindtap="gotoFileList" data-api="getDownloadArticalList">
       <i-icon type="businesscard_fill" slot="icon" size="20" />
     </i-cell>
 
-    <i-cell title="我的收藏" >
-      <i-icon type="setup_fill" slot="icon" size="20" />
-    </i-cell>
-  </i-cell-group>
-  
-  
-  <i-cell-group i-class="my-group-margin" style="margin-top:20rpx" >
-    <i-cell title="审核文件" >
-      <i-icon type="setup_fill" slot="icon" size="20" />
+    <i-cell title="收藏记录" is-link bindtap="gotoFileList" data-api="getLikeArticalList">
+      <i-icon type="like_fill" slot="icon" size="20" />
     </i-cell>
 
-    <i-cell title="发布文件" >
-      <i-icon type="setup_fill" slot="icon" size="20" />
+    
+    <i-cell title="下载审批" >
+      <i-icon type="task_fill" slot="icon" size="20" />
     </i-cell>
 
+    <i-cell title="审核审批" is-link bindtap="gotoFileList" data-api="waitConfirmArticalList">
+      <i-icon type="barrage_fill" slot="icon" size="20" />
+    </i-cell>
 
-  </i-cell-group>
-</view>
+    <i-cell title="发布审批" is-link bindtap="gotoFileList" data-api="waitPublishArticalList">
+      <i-icon type="success_fill" slot="icon" size="20" />
+    </i-cell>
 
-<view>
-  <i-cell-group i-class="my-group-margin">
     <i-cell title="退出登入" bind:click="logOut">
       <i-icon type="flashlight_fill" slot="icon" size="20" />
     </i-cell>

+ 0 - 2
pages/user/index/index.wxss

@@ -15,8 +15,6 @@
   margin-left: 300rpx;
 }
 
-
-
 .copyright{
   color: #8c8c8c;
   text-align: center;

+ 2 - 2
utils/util.js

@@ -1,5 +1,5 @@
-const baseUrl = "http://192.168.3.2:8000/"
-// const baseUrl = "https://edu.ndjsxh.cn:8443/"
+// const baseUrl = "http://192.168.3.2:8000/"
+const baseUrl = "https://oa.hqedust.com:8443/"
 const ossUrl = "https://sm-sign.oss-cn-shanghai.aliyuncs.com/cert/"
 const md5 = require('./md5.js');
 

+ 9 - 3
wxs/util-fun.wxs

@@ -17,12 +17,18 @@ var filter = {
     return status[item];
   },
   getDatetime: function( item ){
-    return item;
-  }
+    var strItem  = item.toString();
+    return strItem.substring(0, 10) + " " +strItem.substring(11, 19);;
+  },
+  getDate: function( item ){
+    var strItem  = item.toString()
+    return strItem.substring(0, 10);
+  },
 }
 module.exports = {
   getPercent: filter.getPercent,
   getCategory:filter.getCategory,
   getDatetime: filter.getDatetime,
-  getStatus: filter.getStatus
+  getStatus: filter.getStatus,
+  getDate: filter.getDate
 }

Some files were not shown because too many files changed in this diff