Kaynağa Gözat

[图片上传][修改]:[活动报名的图片上传]

tags/C.7.1.0
meo 6 yıl önce
ebeveyn
işleme
51b7757f81
4 değiştirilmiş dosya ile 50 ekleme ve 0 silme
  1. +2
    -0
      config/config.js
  2. +29
    -0
      pages/radetail/joinActivity/edit.js
  3. +6
    -0
      pages/radetail/joinActivity/edit.wxml
  4. +13
    -0
      pages/radetail/joinActivity/edit.wxss

+ 2
- 0
config/config.js Dosyayı Görüntüle

@@ -14,6 +14,8 @@ var config = {
* 授权后获取用户的昵称,unionId等信息 * 授权后获取用户的昵称,unionId等信息
*/ */
getUserInfo: "/user/getUserInfo", getUserInfo: "/user/getUserInfo",
//图片上传
imgUpload: '/upload/awsFileUpload',
/** /**
* 接口用途:授权后获取用户的手机号 * 接口用途:授权后获取用户的手机号
*/ */


+ 29
- 0
pages/radetail/joinActivity/edit.js Dosyayı Görüntüle

@@ -1,6 +1,7 @@
const util = require("../../../utils/util.js"); const util = require("../../../utils/util.js");
const Http = require("../../../utils/HttpBasics"); const Http = require("../../../utils/HttpBasics");
const config = require("../../../config/config"); const config = require("../../../config/config");
let app = getApp();
Page({ Page({
/** /**
* 页面的初始数据 * 页面的初始数据
@@ -10,6 +11,7 @@ Page({
flag: 1, flag: 1,
answerflag: "", answerflag: "",
flagsex: 0, flagsex: 0,
useImg:0,
items: [{ items: [{
name: 1, name: 1,
value: '男', value: '男',
@@ -184,6 +186,30 @@ Page({
that.getDetail(options.activityId); that.getDetail(options.activityId);
} }
}, },
uploadImg() {
let that = this;
wx.chooseImage({
success(res) {
const tempFilePaths = res.tempFilePaths
console.log(config.api.imgUpload)
console.log(res)
wx.uploadFile({
url: config.api.imgUpload, // 仅为示例,非真实的接口地址
filePath: tempFilePaths[0],
name: 'file',
header: {
'token': app.globalData.token
},
success(res) {
const data = res.data
that.setData({
receiptUrl: JSON.parse(res.data).data.url
})
}
})
}
})
},
getDetail(activityId) { getDetail(activityId) {
let that = this; let that = this;
Http.get({ Http.get({
@@ -193,6 +219,9 @@ Page({
} }
}).then(res => { }).then(res => {
if (res && res.data && res.data.activity) { if (res && res.data && res.data.activity) {
this.setData({
useImg: res.data.activity.useImg
})
if (res.data && res.data.activity && res.data.activity.question) { if (res.data && res.data.activity && res.data.activity.question) {
that.setData({ that.setData({
question: JSON.parse(res.data.activity.question) question: JSON.parse(res.data.activity.question)


+ 6
- 0
pages/radetail/joinActivity/edit.wxml Dosyayı Görüntüle

@@ -31,5 +31,11 @@
<textarea name="answer{{index}}" bindinput='change' type="textarea" placeholder='请填写您的回答?'></textarea> <textarea name="answer{{index}}" bindinput='change' type="textarea" placeholder='请填写您的回答?'></textarea>
</view> </view>
</view> </view>
<view class='up-img'>
<image src='{{receiptUrl}}' mode="widthFix"></image>
</view>
<view class='camera' bindtap='uploadImg'>
<text>+</text>
</view>
<button class='btn' formType="submit" hover-class='active'>提交</button> <button class='btn' formType="submit" hover-class='active'>提交</button>
</form> </form>

+ 13
- 0
pages/radetail/joinActivity/edit.wxss Dosyayı Görüntüle

@@ -17,6 +17,19 @@ input {
margin: 0 auto; margin: 0 auto;
border-bottom: 1px solid #eee; border-bottom: 1px solid #eee;
} }
.camera{
width: 400rpx;
height: 400rpx;
line-height: 400rpx;
margin: 30rpx auto 0;
border: 1px dotted orange;
}
.camera text{
display: block;
text-align: center;
font-size: 200rpx;
color: orange;
}
.address{ .address{
width: 710rpx; width: 710rpx;
margin: 0 auto; margin: 0 auto;


Yükleniyor…
İptal
Kaydet