liyongli 1 жил өмнө
parent
commit
3cdd785ad1

+ 115 - 16
pages/application/index.js

@@ -3,6 +3,9 @@ import {
   ajax,
   ele_height
 } from "../../utils/util";
+import {
+  base
+} from "../../config/index"
 const {
   globalData: {
     systemInfo
@@ -18,11 +21,26 @@ Page({
     multiArray: [],
     uploadheight: 0,
     local_image_url: '',
-    fileList: []
+    group_class: '幼儿组',
+    works_class: '中国画',
+    author: "",
+    phone: "",
+    schoolClass: "",
+    teacher: "",
+    teacherPhone: "",
+    area: "",
+    article: "",
+    brief: ""
   },
   area: [],
   changeSelectArea: [0, 0, 0],
-
+  change(e) {
+    const key = e.target.dataset.key || '';
+    const value = e.detail.value;
+    const p = {};
+    p[key] = value;
+    this.setData(p);
+  },
   bindMultiPickerChange: function (e) {
     this.setData({
       multiIndex: e.detail.value
@@ -76,29 +94,110 @@ Page({
       multiArray: [this.data.multiArray[0], multiArray1, multiArray2]
     })
   },
-  /**
-   * 生命周期函数--监听页面加载
-   */
-  onLoad(options) {
+  getArea() {
     ajax({
       urlType: "fileurl",
       api: "/topic/tool/img/%E5%B0%91%E5%84%BF%E4%B9%A6%E7%94%BB%E5%A4%A7%E8%B5%9B/narea.json?data=" +
         Date.now()
     }).then(res => {
       this.area = res || [];
-      const a0 = this.area[0] || {
-        child: []
+      this.initArea();
+    })
+  },
+  initArea() {
+    const a0 = this.area[0] || {
+      child: []
+    }
+    const multiArray0 = this.area.map(v => v.name);
+    const multiArray1 = a0.child.map(v => v.name);
+    const multiArray2 = (a0.child[0] || {
+      child: []
+    }).child.map(v => v.name);
+    this.setData({
+      multiArray: [multiArray0, multiArray1, multiArray2]
+    })
+  },
+  updata() {
+    const {
+      group_class,
+      works_class,
+      author,
+      phone,
+      schoolClass,
+      teacher,
+      teacherPhone,
+      area,
+      local_image_url,
+      article,
+      brief
+    } = this.data;
+    let baseArea = this.data.multiArray[0][this.data.multiIndex[0]] + this.data.multiArray[1][this.data.multiIndex[1]];
+    if (this.data.multiArray[2] && this.data.multiArray[2][this.data.multiIndex[2]]) baseArea += this.data.multiArray[2][this.data.multiIndex[2]]
+    if (isNaN(teacherPhone) || isNaN(phone)) return wx.showToast({
+      title: '手机号需填入数字',
+      icon: "none"
+    })
+    console.log("group_class:", !group_class);
+    console.log("works_class:", !works_class);
+    console.log("author:", !author);
+    console.log("schoolClass:", !schoolClass);
+    console.log("area:", !area);
+    console.log("local_image_url:", !local_image_url);
+    console.log("article:", !article);
+    console.log("brief:", !brief);
+    if (!group_class || !works_class || !author || !schoolClass || !area || !local_image_url || !article || !brief) return wx.showToast({
+      title: '请输入完整信息',
+      icon: "none"
+    })
+    wx.showLoading({
+      title: '加载中',
+    })
+    wx.uploadFile({
+      filePath: local_image_url,
+      name: 'file',
+      header: {
+        Authorization: wx.getStorageSync('token') || undefined,
+      },
+      formData: {
+        name: author,
+        teacherPhone,
+        school: schoolClass,
+        teacher,
+        area: baseArea + area,
+        articleGroup: works_class,
+        birthday: group_class,
+        articleName: article,
+        articleDescribe: brief
+      },
+      url: base.apiurl + '/article/save',
+      complete: () => {
+        wx.hideLoading()
+      },
+      success: res => {
+        if (res.code === 0) return wx.showToast({
+          title: '上传成功',
+          icon: "none"
+        });
+        else return wx.showToast({
+          title: res.message || "上传失败",
+          icon: "error"
+        });
+      },
+      fail() {
+        wx.showToast({
+          title: res.message || "上传失败",
+          icon: "error"
+        });
       }
-      const multiArray0 = this.area.map(v => v.name);
-      const multiArray1 = a0.child.map(v => v.name);
-      const multiArray2 = (a0.child[0] || {
-        child: []
-      }).child.map(v => v.name);
-      this.setData({
-        multiArray: [multiArray0, multiArray1, multiArray2]
-      })
     })
   },
+  /**
+   * 生命周期函数--监听页面加载
+   */
+  onLoad(options) {
+    this.getArea();
+
+  },
 
   /**
    * 生命周期函数--监听页面初次渲染完成

+ 2 - 1
pages/application/index.json

@@ -3,6 +3,7 @@
   "usingComponents": {
     "Container": "../../component/container/index",
     "van-radio": "@vant/weapp/radio/index",
-    "van-radio-group": "@vant/weapp/radio-group/index"
+    "van-radio-group": "@vant/weapp/radio-group/index",
+    "van-button": "@vant/weapp/button/index"
   }
 }

+ 26 - 14
pages/application/index.wxml

@@ -4,13 +4,19 @@
     <Container style="margin-top: -100rpx;">
       <view style="margin: 0 44rpx;font-size: 28rpx;">
         <view class="top_label">作者姓名*</view>
-        <input class="top_input" placeholder="请输入姓名" />
+        <input class="top_input" value="{{author}}" bindinput="change" data-key="author" type="text" placeholder="请输入姓名" />
         <view class="top_label">联系电话*</view>
-        <input class="top_input" placeholder="请输入联系电话" />
+        <input class="top_input" value="{{phone}}" bindinput="change" data-key="phone" type="number" placeholder="请输入联系电话" />
         <view class="top_label">学校班级*</view>
-        <input class="top_input" placeholder="请输入学校班级" />
+        <input class="top_input" value="{{schoolClass}}" bindinput="change" data-key="schoolClass" type="text" placeholder="请输入学校班级" />
         <view class="top_label">指导老师*</view>
-        <input class="top_input" placeholder="请输入指导老师" />
+        <input class="top_input" value="{{teacher}}" bindinput="change" data-key="teacher" type="text" placeholder="请输入指导老师" />
+        <view class="top_label">指导老师电话*</view>
+        <input class="top_input" value="{{teacherPhone}}" bindinput="change" data-key="teacherPhone" type="number" placeholder="请输入指导老师电话" />
+        <view class="top_label">作品名称*</view>
+        <input class="top_input" value="{{article}}" bindinput="change" data-key="article" type="text" placeholder="请输入作品名称" />
+        <view class="top_label">作品简介*</view>
+        <textarea class="top_input" style="height: 5em;" value="{{brief}}" bindinput="change" data-key="brief" placeholder="请输入作品简介" />
         <view class="top_label" style="margin-bottom: 17rpx;">联系地址*</view>
         <picker mode="multiSelector" bindchange="bindMultiPickerChange" bindcolumnchange="bindMultiPickerColumnChange" value="{{multiIndex}}" range="{{multiArray}}">
           <view class="picker">
@@ -19,22 +25,24 @@
             <view wx:if="{{multiArray[2][multiIndex[2]]}}" class="picker_item">{{multiArray[2][multiIndex[2]]}}</view>
           </view>
         </picker>
-        <textarea class="top_input" style="height: 5em;" bindblur="bindTextAreaBlur" placeholder="请输入地址" />
+        <textarea class="top_input" style="height: 5em;" value="{{area}}" bindinput="change" data-key="area" placeholder="请输入地址" />
         <view class="top_label">组别*</view>
         <view class="top_input" style="background-color: #ffffff00;height: auto;">
-          <van-radio-group value="{{ radio }}" bind:change="onChange">
-            <van-radio name="1" checked-color="#91725D">幼儿组(6岁以下)</van-radio>
-            <van-radio name="2" checked-color="#91725D">儿童组(7-10岁)</van-radio>
-            <van-radio name="3" checked-color="#91725D">少儿组(11-14岁)</van-radio>
-            <van-radio name="4" checked-color="#91725D">少年组(15-18岁)</van-radio>
+          <van-radio-group value="{{ group_class }}">
+            <van-radio name="幼儿组" checked-color="#91725D">幼儿组(6岁以下)</van-radio>
+            <van-radio name="儿童组" checked-color="#91725D">儿童组(7-10岁)</van-radio>
+            <van-radio name="少儿组" checked-color="#91725D">少儿组(11-14岁)</van-radio>
+            <van-radio name="少年组" checked-color="#91725D">少年组(15-18岁)</van-radio>
+            <van-radio name="青年组" checked-color="#91725D">青年组(18岁以上)</van-radio>
           </van-radio-group>
         </view>
         <view class="top_label">作品类别*</view>
         <view class="top_input" style="background-color: #ffffff00;height: auto;">
-          <van-radio-group value="{{ radio }}" bind:change="onChange">
-            <van-radio name="1" checked-color="#91725D">国画组</van-radio>
-            <van-radio name="2" checked-color="#91725D">西洋画组</van-radio>
-            <van-radio name="3" checked-color="#91725D">书法组</van-radio>
+          <van-radio-group value="{{ works_class }}">
+            <van-radio name="中国画" checked-color="#91725D">中国画</van-radio>
+            <van-radio name="西洋画" checked-color="#91725D">西洋画</van-radio>
+            <van-radio name="书法" checked-color="#91725D">书法</van-radio>
+            <van-radio name="其他" checked-color="#91725D">其他</van-radio>
           </van-radio-group>
         </view>
 
@@ -43,6 +51,10 @@
           <image src="{{local_image_url}}" style="width: 100px; height: 100px;" />
           <image class="del" src="../../images/del.png" style="width: 30px;height: 30px" />
         </view>
+
+        <view style="padding-top: 15rpx;text-align: center;">
+          <van-button round type="info" bind:tap="updata" size="large" color="#91725D">提交</van-button>
+        </view>
       </view>
     </Container>
   </view>

+ 0 - 13
pages/userData/index.js

@@ -20,19 +20,6 @@ Page({
         articleGroup: "书法",
         articleName: "兰亭序",
         articleDescribe: "展现了中国传统艺术的魅力。墨色浓淡相间,笔触流畅而有力,每一字之间形成和谐的整体。作品中融入了经典诗句,传递出深邃的哲理和人生感悟。每一个字都经过精心构思和书写,字体大小和间距恰到好处,整个作品看起来平衡而舒适。",
-      },
-      {
-        works: "https://cxzx.smcic.net/topic/tool/img/%E5%B0%91%E5%84%BF%E4%B9%A6%E7%94%BB%E5%A4%A7%E8%B5%9B/R-C.jfif",
-        name: "张云翔",
-        group: "少儿组",
-        lever: 2,
-        groupType: "国画组",
-        birthday: "2015-03-03",
-        teacher: "李勇利",
-        school: "清华",
-        articleGroup: "书法",
-        articleName: "兰亭序",
-        articleDescribe: "展现了中国传统艺术的魅力。墨色浓淡相间,笔触流畅而有力,每一字之间形成和谐的整体。作品中融入了经典诗句,传递出深邃的哲理和人生感悟。每一个字都经过精心构思和书写,字体大小和间距恰到好处,整个作品看起来平衡而舒适。",
       }
     ]
   },

+ 1 - 1
pages/userData/index.wxml

@@ -17,7 +17,7 @@
               <image wx:if="{{item.lever > 1}}" class="tag" style="width: 67rpx;" src="../../images/jj.png" />
             </view>
             <view style="color: #555;">
-              {{item.school + " " + item.groupType + " " + item.group}}
+              {{item.school + " " + item.articleGroup + " " + item.birthday}}
             </view>
           </view>
           <image class="list_right" src="../../images/del.png" style="width: 29rpx;height: 29rpx;" />

+ 13 - 1
project.private.config.json

@@ -5,5 +5,17 @@
     "compileHotReLoad": true,
     "urlCheck": true
   },
-  "condition": {}
+  "condition": {
+    "miniprogram": {
+      "list": [
+        {
+          "name": "pages/userData/index",
+          "pathName": "pages/userData/index",
+          "query": "",
+          "launchMode": "default",
+          "scene": null
+        }
+      ]
+    }
+  }
 }