| @@ -12,6 +12,7 @@ Page({ | |||||
| answerflag: "", | answerflag: "", | ||||
| flagsex: 0, | flagsex: 0, | ||||
| useImg:0, | useImg:0, | ||||
| showReceiptUrl:false, | |||||
| items: [{ | items: [{ | ||||
| name: 1, | name: 1, | ||||
| value: '男', | value: '男', | ||||
| @@ -191,19 +192,45 @@ Page({ | |||||
| wx.chooseImage({ | wx.chooseImage({ | ||||
| success(res) { | success(res) { | ||||
| const tempFilePaths = res.tempFilePaths | const tempFilePaths = res.tempFilePaths | ||||
| console.log(config.api.imgUpload) | |||||
| console.log(res) | |||||
| wx.uploadFile({ | wx.uploadFile({ | ||||
| url: config.api.imgUpload, // 仅为示例,非真实的接口地址 | |||||
| url: config.url+config.api.imgUpload, | |||||
| filePath: tempFilePaths[0], | filePath: tempFilePaths[0], | ||||
| name: 'file', | name: 'file', | ||||
| header: { | header: { | ||||
| 'token': app.globalData.token | 'token': app.globalData.token | ||||
| }, | }, | ||||
| success(res) { | success(res) { | ||||
| const data = res.data | |||||
| console.log(res) | |||||
| if (res.statusCode == 200) { | |||||
| that.setData({ | |||||
| receiptUrl: JSON.parse(res.data).data.url, | |||||
| showReceiptUrl: true | |||||
| }) | |||||
| } else if (res.statusCode == 413) { | |||||
| wx.showToast({ | |||||
| title: '上传的图片太大,请重新上传', | |||||
| icon: "none" | |||||
| }) | |||||
| that.setData({ | |||||
| showReceiptUrl: false | |||||
| }) | |||||
| } else { | |||||
| wx.showToast({ | |||||
| title: '请上传正确的图片', | |||||
| icon: "none" | |||||
| }) | |||||
| that.setData({ | |||||
| showReceiptUrl: false | |||||
| }) | |||||
| } | |||||
| }, | |||||
| fail(error) { | |||||
| wx.showToast({ | |||||
| title: "上传图片失败", | |||||
| icon: "none" | |||||
| }) | |||||
| that.setData({ | that.setData({ | ||||
| receiptUrl: JSON.parse(res.data).data.url | |||||
| showReceiptUrl: false | |||||
| }) | }) | ||||
| } | } | ||||
| }) | }) | ||||
| @@ -220,7 +247,8 @@ Page({ | |||||
| }).then(res => { | }).then(res => { | ||||
| if (res && res.data && res.data.activity) { | if (res && res.data && res.data.activity) { | ||||
| this.setData({ | this.setData({ | ||||
| useImg: res.data.activity.useImg | |||||
| useImg: res.data.activity.useImg, | |||||
| imgDetail: res.data.activity.imgDetail | |||||
| }) | }) | ||||
| if (res.data && res.data.activity && res.data.activity.question) { | if (res.data && res.data.activity && res.data.activity.question) { | ||||
| that.setData({ | that.setData({ | ||||
| @@ -28,14 +28,18 @@ | |||||
| <text class='questionTitle'>调查问卷</text> | <text class='questionTitle'>调查问卷</text> | ||||
| <view class='answer' wx:for="{{question}}" wx:key="index"> | <view class='answer' wx:for="{{question}}" wx:key="index"> | ||||
| <text>{{index+1}}.{{item.ques}}</text> | <text>{{index+1}}.{{item.ques}}</text> | ||||
| <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 wx:if="{{useImg==1}}"> | |||||
| <view class='quesTitle'>请上传您需要上传的图片</view> | |||||
| <view class='quesTitle'>{{imgDetail}}</view> | |||||
| <view class='up-img' wx:if="{{showReceiptUrl}}"> | |||||
| <image src='{{receiptUrl}}' mode="widthFix"></image> | |||||
| </view> | |||||
| <view class='camera' bindtap='uploadImg'> | |||||
| <text>+</text> | |||||
| </view> | |||||
| </view> | </view> | ||||
| <button class='btn' formType="submit" hover-class='active'>提交</button> | <button class='btn' formType="submit" hover-class='active'>提交</button> | ||||
| </form> | </form> | ||||
| @@ -21,7 +21,7 @@ input { | |||||
| width: 400rpx; | width: 400rpx; | ||||
| height: 400rpx; | height: 400rpx; | ||||
| line-height: 400rpx; | line-height: 400rpx; | ||||
| margin: 30rpx auto 0; | |||||
| margin: 30rpx auto 140rpx; | |||||
| border: 1px dotted orange; | border: 1px dotted orange; | ||||
| } | } | ||||
| .camera text{ | .camera text{ | ||||
| @@ -101,7 +101,7 @@ radio { | |||||
| } | } | ||||
| .ques{ | .ques{ | ||||
| padding-left: 20rpx; | padding-left: 20rpx; | ||||
| margin-bottom:140rpx; | |||||
| margin-bottom:70rpx; | |||||
| } | } | ||||
| .ques text{ | .ques text{ | ||||
| display: block; | display: block; | ||||
| @@ -127,4 +127,14 @@ radio { | |||||
| padding: 10rpx 0; | padding: 10rpx 0; | ||||
| margin-top: 10rpx; | margin-top: 10rpx; | ||||
| padding-left: 10rpx; | padding-left: 10rpx; | ||||
| } | |||||
| .quesTitle{ | |||||
| text-align: center; | |||||
| font-size:32rpx; | |||||
| text-indent: 1em; | |||||
| } | |||||
| .up-img image{ | |||||
| display: block; | |||||
| width: 90%; | |||||
| margin: 20rpx auto 0; | |||||
| } | } | ||||
| @@ -58,8 +58,6 @@ button::after{ border: none; } | |||||
| padding-top: 30rpx; | padding-top: 30rpx; | ||||
| padding-left: 30rpx; | padding-left: 30rpx; | ||||
| line-height: 50rpx; | line-height: 50rpx; | ||||
| border-radius:20rpx 20rpx 0px 0px; | |||||
| margin-top: -25rpx; | |||||
| opacity: 1; | opacity: 1; | ||||
| font-size:32rpx; | font-size:32rpx; | ||||
| font-weight:bold; | font-weight:bold; | ||||
| @@ -3,7 +3,7 @@ | |||||
| <view class='coupons' style='background:{{data.bgColor}};height:{{winHeight}}'> | <view class='coupons' style='background:{{data.bgColor}};height:{{winHeight}}'> | ||||
| <view class="coupons-body"> | <view class="coupons-body"> | ||||
| <view class='banner'> | <view class='banner'> | ||||
| <image src='{{data.advert}}'></image> | |||||
| <image src='{{data.advert}}' mode='widthFix'></image> | |||||
| </view> | </view> | ||||
| <view class='act'> | <view class='act'> | ||||
| <text class='txt001'>{{data.name}}</text> | <text class='txt001'>{{data.name}}</text> | ||||
| @@ -13,8 +13,6 @@ | |||||
| .banner { | .banner { | ||||
| position: relative; | position: relative; | ||||
| width: 750rpx; | width: 750rpx; | ||||
| height: 280rpx; | |||||
| overflow: hidden; | |||||
| } | } | ||||
| .banner image { | .banner image { | ||||
| @@ -28,7 +26,7 @@ | |||||
| background: #fff; | background: #fff; | ||||
| border-radius: 12rpx; | border-radius: 12rpx; | ||||
| width: 705rpx; | width: 705rpx; | ||||
| margin: -30rpx auto 0; | |||||
| margin: 30rpx auto 0; | |||||
| padding-bottom: 20rpx; | padding-bottom: 20rpx; | ||||
| } | } | ||||
| @@ -33,12 +33,10 @@ function wxParse(bindName = 'wxParseData', type='html', data='<div class="color: | |||||
| var transData = {};//存放转化后的数据 | var transData = {};//存放转化后的数据 | ||||
| if (type == 'html') { | if (type == 'html') { | ||||
| transData = HtmlToJson.html2json(data, bindName); | transData = HtmlToJson.html2json(data, bindName); | ||||
| console.log(JSON.stringify(transData, ' ', ' ')); | |||||
| } else if (type == 'md' || type == 'markdown') { | } else if (type == 'md' || type == 'markdown') { | ||||
| var converter = new showdown.Converter(); | var converter = new showdown.Converter(); | ||||
| var html = converter.makeHtml(data); | var html = converter.makeHtml(data); | ||||
| transData = HtmlToJson.html2json(html, bindName); | transData = HtmlToJson.html2json(html, bindName); | ||||
| console.log(JSON.stringify(transData, ' ', ' ')); | |||||
| } | } | ||||
| transData.view = {}; | transData.view = {}; | ||||
| transData.view.imagePadding = 0; | transData.view.imagePadding = 0; | ||||