Commit 3cbcaca22bd5a8d9333e18d3d154b70cdea5aca7

Authored by pengye
1 parent 661adcc5

七牛上传图片或者视频以及删除

@@ -25,7 +25,7 @@ Component({ @@ -25,7 +25,7 @@ Component({
25 observers: { 25 observers: {
26 'post': function(post) { 26 'post': function(post) {
27 this.setData({ 27 this.setData({
28 - enclosure:JSON.parse(post.enclosure||null) 28 + enclosure:this.isJSON(post.enclosure)
29 }) 29 })
30 } 30 }
31 }, 31 },
@@ -33,6 +33,14 @@ Component({ @@ -33,6 +33,14 @@ Component({
33 * 组件的方法列表 33 * 组件的方法列表
34 */ 34 */
35 methods: { 35 methods: {
  36 + isJSON(str) {
  37 + try {
  38 + let data=JSON.parse(str);
  39 + return data;
  40 + } catch (e) {
  41 + return str;
  42 + }
  43 + },
36 displayImage(e){ 44 displayImage(e){
37 let index=util.attr(e,'index') 45 let index=util.attr(e,'index')
38 if(this.data.enclosure[index].avinfo){//video 46 if(this.data.enclosure[index].avinfo){//video
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 class="videoBox" 22 class="videoBox"
23 src="{{item.url}}" 23 src="{{item.url}}"
24 controls='{{false}}' 24 controls='{{false}}'
  25 + show-center-play-btn='{{false}}'
25 enable-progress-gesture='{{false}}' 26 enable-progress-gesture='{{false}}'
26 /> 27 />
27 <view class="bg-image-video view" wx:if="{{item.avinfo}}"></view> 28 <view class="bg-image-video view" wx:if="{{item.avinfo}}"></view>