點選存快取並跳轉頁面併到跳轉頁面取快取
阿新 • • 發佈:2018-11-11
之前頁面的
html:
<image bindtap='ontTapdetails' data-item_data='{{item}}' class="videoVideo2" src="{{item.wapimg}}" }};"></image>
js:
ontTapdetails: function(e) {
console.log(e)
//存快取
var item_data = e.currentTarget.dataset.item_data
wx.setStorageSync('item_data', item_data)
wx.navigateTo({
url: '../details/details',
})
},
跳轉之後的頁面
HTML:
<view class='windo'>
<view>
<view class='vdieo_box'>
<view class='block' style='margin-left:20rpx;'> <view class="cover"> <!-- 視訊圖層 --> <image class="videoVideo2" src="{{show_data.wapimg}}" mode="scaleToFill" id="show_data{{vid}}" style="display: {{ _index == index ? 'block' : 'none'}};"></image> <!-- 視訊按鈕 --> <image id="{{index}}" class="videoPlay" src="/img/bf.png" mode="scaleToFill" bindtap="videoPlay" style="display: {{ _index == index ? 'block' : 'none'}};"></image>
</view>
</view> <video src='{{show_data.videourl}}' class='vdieo' id="{{index}}"></video> <view class='child'>{{show_data.typename}}</view>
</view> <view class='_'></view> <view class='__'></view> <view class='text'>這個作品好看嗎</view> <view class='box1'> <view class='box' bindtap="onChangeShowState"> <image src="{{isPlaying?'/img/cai1.png':'/img/cai2.png'}}" class='had had1' ></image> <text class='had_text'>不好看</text> </view> <view class='box' bindtap="onChangeShowState2"> <image src="{{isPlaying1?'/img/zan1.png':'/img/zan2.png'}}" class='had'></image> <text class='had_text'>好看</text> </view> </view> </view> </view> js: onLoad: function(options) {
//讀取快取 var show_data = wx.getStorageSync('item_data'); console.log(show_data) this.setData({ show_data })
},
<view>
<view class='vdieo_box'>
<view class='block' style='margin-left:20rpx;'> <view class="cover"> <!-- 視訊圖層 --> <image class="videoVideo2" src="{{show_data.wapimg}}" mode="scaleToFill" id="show_data{{vid}}" style="display: {{ _index == index ? 'block' : 'none'}};"></image> <!-- 視訊按鈕 --> <image id="{{index}}" class="videoPlay" src="/img/bf.png" mode="scaleToFill" bindtap="videoPlay" style="display: {{ _index == index ? 'block' : 'none'}};"></image>
</view>
</view> <video src='{{show_data.videourl}}' class='vdieo' id="{{index}}"></video> <view class='child'>{{show_data.typename}}</view>
</view> <view class='_'></view> <view class='__'></view> <view class='text'>這個作品好看嗎</view> <view class='box1'> <view class='box' bindtap="onChangeShowState"> <image src="{{isPlaying?'/img/cai1.png':'/img/cai2.png'}}" class='had had1' ></image> <text class='had_text'>不好看</text> </view> <view class='box' bindtap="onChangeShowState2"> <image src="{{isPlaying1?'/img/zan1.png':'/img/zan2.png'}}" class='had'></image> <text class='had_text'>好看</text> </view> </view> </view> </view> js: onLoad: function(options) {
//讀取快取 var show_data = wx.getStorageSync('item_data'); console.log(show_data) this.setData({ show_data })
},