yukangzhe 3 лет назад
Родитель
Сommit
d1e2ab594f
3 измененных файлов с 78 добавлено и 15 удалено
  1. 6 4
      pages/classTotalList/classTotalList.js
  2. 70 9
      pages/forBack/forBack.js
  3. 2 2
      pages/forBack/forBack.wxml

+ 6 - 4
pages/classTotalList/classTotalList.js

@@ -110,10 +110,12 @@ Page({
           cancelColor: '#999999', //取消文字的颜色
           confirmText: "确定", //默认是“确定”
           confirmColor: 'skyblue', //确定文字的颜色
-          success(){
-            wx.navigateBack({
-              delta: -1,
-            })
+          success(res){
+            if(res.confirm){
+              wx.navigateBack({
+                delta: -1,
+              })
+            }
           }
         })
       }

+ 70 - 9
pages/forBack/forBack.js

@@ -1,18 +1,34 @@
 // pages/forBack/forBack.js
+const app = getApp()
+const util = require("../../utils/util")
+const urlDef = require("../../utils/urls")
+const urls = urlDef.urls;
+
 Page({
 
   /**
    * 页面的初始数据
    */
   data: {
-    radioList:[
-      {name: '学校不满意',type: 'school'},
-      {name: '课程不满意',type: 'school'},
-      {name: '产品建议/功能优化',type: 'select'},
-      {name: '其他问题',type: 'select'},
+    radioList: [{
+        name: '学校不满意',
+        type: 'school'
+      },
+      {
+        name: '课程不满意',
+        type: 'school'
+      },
+      {
+        name: '产品建议/功能优化',
+        type: 'select'
+      },
+      {
+        name: '其他问题',
+        type: 'select'
+      },
     ],
     curRadioIndex: '-1',
-    plateList:[
+    plateList: [
       '我的课表',
       '提交作业',
       '课堂点评',
@@ -23,10 +39,11 @@ Page({
       '调课',
     ],
     plateIndex: 0,
-    radioType: ''
+    radioType: '',
+    imgList:[]
   },
 
-  getRadio:function(e){
+  getRadio: function (e) {
     const type = this.data.radioList[e.currentTarget.dataset.index].type
     this.setData({
       curRadioIndex: e.currentTarget.dataset.index,
@@ -34,12 +51,56 @@ Page({
     })
   },
 
-  bindPickerChange: function(e) {
+  bindPickerChange: function (e) {
     this.setData({
       plateIndex: e.detail.value
     })
   },
 
+  uploadTap: function () {
+    const that = this
+    wx.chooseImage({
+      count: 6,
+      sourceType: ['album', 'camera'],
+      success(res) {
+        wx.showLoading({
+          title: '上传中...',
+        })
+        for (var i in res.tempFilePaths) {console.log(i)
+          wx.uploadFile({
+            filePath: res.tempFilePaths[i],
+            name: 'name',
+            url: urls.file_upload,
+            header: util.getHeaders(),
+            success(res) {
+              wx.showToast({
+                title: '上传成功',
+              })
+              const rs = JSON.parse(JSON.parse(JSON.stringify(res.data)))
+              const list = [{
+                url: rs.data[0].url
+              }]
+              that.setData({
+                imgList: that.data.imgList.concat(list)
+              })
+            },
+            fail(res) {
+              wx.showToast({
+                title: '上传失败',
+                icon: none
+              })
+            },
+            complete(res) {
+              wx.hideLoading({
+                success: (res) => {},
+              })
+            }
+          })
+        }
+      }
+    })
+  },
+
   /**
    * 生命周期函数--监听页面加载
    */

+ 2 - 2
pages/forBack/forBack.wxml

@@ -26,9 +26,9 @@
 
   <view class="title">上传图片</view>
   <view class="uploadImg-task-view">
-      <view class="my-img-view" wx:for="{{1}}" wx:key="index">
+      <view class="my-img-view" wx:for="{{imgList}}" wx:key="index">
         <view class="new-task-img">
-          <image src="/images/logo.png"></image>
+          <image src="{{item.url}}"></image>
         </view>
         <view class="del-btn">X</view>
       </view>