wkw 3 nedēļas atpakaļ
vecāks
revīzija
17b10fd0ba

+ 1 - 1
api/other.js

@@ -71,6 +71,7 @@ export function sharePoster() {
     method: 'GET'
   });
 }
+// 参赛记录
 export function registrationRecord() {
   return request({
     loading: false,
@@ -82,4 +83,3 @@ export function registrationRecord() {
 
 
 
-

+ 1 - 1
app.json

@@ -10,7 +10,7 @@
     "pages/registrationRecords/registrationRecords",
     "pages/coupon/coupon",
     "pages/couponDetail/couponDetail",
-    "pages/registrationRecordList/registrationRecordList"
+    "pages/competitionRecords/competitionRecords"
   ],
   "window": {
     "navigationBarTextStyle": "black",

+ 9 - 4
pages/registrationRecordList/registrationRecordList.js → pages/competitionRecords/competitionRecords.js

@@ -1,4 +1,4 @@
-import { enrollRecord } from '../../api/other';
+import { registrationRecord } from '../../api/other';
 import { uploadImage } from '../../utils/upload.js';
 Page({
   data: {
@@ -8,6 +8,7 @@ Page({
     loadingMore: false,
     noMore: false,
     refreshing: false,
+    activeItem:{},
     filePath: '',  // 上传成功的文件路径
     fileType: '',   // image / pdf
   },
@@ -22,7 +23,7 @@ Page({
     let page = isRefresh ? 1 : this.data.page;
     this.setData({ loadingMore: true });
     try {
-      const res = await enrollRecord({ page, pageSize: this.data.pageSize });
+      const res = await registrationRecord({ page, pageSize: this.data.pageSize });
       const statusImgMap = {
         0: '/static/image/register/wks.png',
         1: '/static/image/register/yjs.png',
@@ -66,7 +67,11 @@ Page({
     this.loadData(true);
   },
   // 点击上传区域
-  chooseFile() {
+  chooseFile(e) {
+    // 选中的item数据
+    this.setData({
+      activeItem:e.currentTarget.dataset.item
+    })
     wx.showActionSheet({
       itemList: ['图片', 'PDF'],
       success: res => {
@@ -112,7 +117,7 @@ Page({
       return;
     }
     try {
-      const res = await uploadImage(path);
+      const res = await uploadImage({filePath:path,marathonId:this.data.activeItem.mv_id,competitionNo:this.data.activeItem.competition_no},'/api/upload/finish-certificate','file');
       console.log('上传成功:', res);
       this.setData({
         filePath: res.url,

+ 0 - 0
pages/registrationRecordList/registrationRecordList.json → pages/competitionRecords/competitionRecords.json


+ 2 - 2
pages/registrationRecordList/registrationRecordList.wxml → pages/competitionRecords/competitionRecords.wxml

@@ -25,7 +25,7 @@
               <image class="cell-img" src="/static/image/register/cshm.png" mode="aspectFit"/>
               <view class="cell-bg"></view>
             </view>
-            <view class="cell-text">9810201902</view>
+            <view class="cell-text">{{item.competition_no}}</view>
           </view>
           <view>
             <view class="cell-item">
@@ -53,7 +53,7 @@
 
               <!-- 未选择文件 -->
               <block wx:if="{{!filePath}}">
-                <view class="uploader-text" bindtap="chooseFile">
+                <view class="uploader-text" bindtap="chooseFile" data-item="{{item}}">
                   <image class="uploader-img" src="/static/image/xj.png" mode="aspectFit"/>
                   <view>完赛证明上传</view>
                 </view>

+ 0 - 0
pages/registrationRecordList/registrationRecordList.wxss → pages/competitionRecords/competitionRecords.wxss


+ 2 - 2
pages/mine/mine.js

@@ -44,7 +44,7 @@ Page({
       2: `/pages/registrationRecords/registrationRecords`,
       3: `/pages/coupon/coupon`,
       4: `/pages/setting/setting`,
-      5:`/pages/registrationRecordList/registrationRecordList`,
+      5:`/pages/competitionRecords/competitionRecords`,
     };
     if (pageMap[index]) {
       wx.navigateTo({ url: pageMap[index] });
@@ -59,7 +59,7 @@ Page({
   // 头像选择
   async onChooseAvatar(e) {
     const { avatarUrl } = e.detail;
-    const res = await uploadImage(avatarUrl);
+    const res = await uploadImage({filePath:avatarUrl});
     this.setData({ "userInfo.avatar": avatarUrl });
     this.onSave(res.path);
   },

+ 2 - 2
pages/register/register.js

@@ -99,7 +99,7 @@ Page({
       return;
     }
     try {
-      const res = await uploadImage(path);
+      const res = await uploadImage({filePath:path});
       console.log('上传成功:', res);
       this.setData({
         filePath: res.url,
@@ -134,7 +134,7 @@ Page({
       }
     }
     if (field === 'race_number') {
-      const regIdCard = /^\d{18}$/;
+      const regIdCard = /^[1-9]\d{5}(18|19|20)\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\d|3[01])\d{3}[\dXx]$/;
       if (value && !regIdCard.test(value)) {
         this.setData({ raceNumberError: '身份证号格式不正确' });
       }else{

+ 1 - 1
pages/setting/setting.js

@@ -21,7 +21,7 @@ Page({
   async onChooseAvatar(e) {
     const { avatarUrl } = e.detail;
     // 上传到服务器
-    const res = await uploadImage(avatarUrl);
+    const res = await uploadImage({filePath:avatarUrl});
     this.setData({
       "userInfo.avatar":avatarUrl,
       pathUrl: res.path

+ 19 - 14
utils/upload.js

@@ -1,17 +1,20 @@
-import {BASE_URL} from './request';
+import { BASE_URL } from './request';
+
 /**
- * 上传图片
- * @param {string} filePath 本地文件路径
- * @param {string} url 上传接口路径(默认 /api/upload/image)
- * @param {string} name 后端接收文件字段名(默认 file)
+ * 上传报名证明图片
+ * @param {Object} params 参数对象
+ * @param {string} params.filePath 本地文件路径
+ * @param {number} params.marathonId 比赛ID
+ * @param {string} params.competitionNo 参赛号
+ * @param {string} [url='/api/upload/image'] 上传接口路径
+ * @param {string} [name='file'] 后端接收文件字段名
  */
-export function uploadImage(filePath, url = '/api/upload/image', name = 'file') {
+export function uploadImage(
+  { filePath, marathonId = '', competitionNo = '' },
+  url = '/api/upload/image',
+  name = 'file'
+) {
   return new Promise((resolve, reject) => {
-    // wx.showLoading({
-    //   title: '上传中...',
-    //   mask: true
-    // });
-
     wx.uploadFile({
       url: BASE_URL + url,
       filePath,
@@ -19,11 +22,14 @@ export function uploadImage(filePath, url = '/api/upload/image', name = 'file')
       header: {
         'Authorization': wx.getStorageSync('token') || ''
       },
+      formData: {
+        marathon_id: marathonId,
+        competition_no: competitionNo,
+        file:filePath
+      },
       success(res) {
-        // wx.hideLoading();
         try {
           const data = JSON.parse(res.data);
-          console.log(data)
           if (data.code === 200 && data.ret) {
             wx.showToast({
               title: '上传成功',
@@ -42,7 +48,6 @@ export function uploadImage(filePath, url = '/api/upload/image', name = 'file')
         }
       },
       fail(err) {
-        // wx.hideLoading();
         wx.showToast({
           title: '网络异常,请重试',
           icon: 'none'