浏览代码

获取已报名信息

liyongli 1 年之前
父节点
当前提交
af29aea750
共有 4 个文件被更改,包括 24 次插入3 次删除
  1. 17 1
      pages/userData/index.js
  2. 2 1
      pages/userData/index.json
  3. 1 0
      pages/userData/index.wxml
  4. 4 1
      utils/util.js

+ 17 - 1
pages/userData/index.js

@@ -1,4 +1,7 @@
 // pages/userData/index.js
+import {
+  ajax
+} from "../../utils/util";
 Page({
 
   /**
@@ -34,11 +37,24 @@ Page({
     ]
   },
 
+  phone: wx.getStorageSync('phone') || '',
+
   /**
    * 生命周期函数--监听页面加载
    */
   onLoad(options) {
-
+    ajax({
+      urlType: "apiurl",
+      api: "/article/list",
+    }).then(res => {
+      if (res.code !== 0) return wx.showToast({
+        title: res.message || '请求失败',
+        icon: 'none'
+      })
+      this.setData({
+        list: res.data || []
+      })
+    })
   },
 
   /**

+ 2 - 1
pages/userData/index.json

@@ -5,6 +5,7 @@
     "van-row": "@vant/weapp/row/index",
     "van-icon": "@vant/weapp/icon/index",
     "van-search": "@vant/weapp/search/index",
-    "van-col": "@vant/weapp/col/index"
+    "van-col": "@vant/weapp/col/index",
+    "van-empty": "@vant/weapp/empty/index"
   }
 }

+ 1 - 0
pages/userData/index.wxml

@@ -22,6 +22,7 @@
           </view>
           <image class="list_right" src="../../images/del.png" style="width: 29rpx;height: 29rpx;" />
         </view>
+        <van-empty wx:if="{{!list.length}}" description="暂无数据" />
       </view>
     </Container>
   </view>

+ 4 - 1
utils/util.js

@@ -29,7 +29,10 @@ export const ajax = data => {
     wx.request({
       url: base[data.urlType || 'apiurl'] + (data.api || ''),
       data: data.data,
-      header: data.header,
+      header: {
+        Authorization: wx.getStorageSync('token') || undefined,
+        ...(data.header || {})
+      },
       timeout: data.timeout || 60000,
       method: (data.method || 'get').toUpperCase(),
       responseType: data.responseType || 'text',