const app = getApp();
Page({
data: {
ad_swiper: [],
nickname: '',
livename: '',
cate_list: [{
type: 0,
name: '分类1'
},
{
type: 1,
name: '分类2'
}
],
cate_index: -1,
upload_images: [],
info: {}
},
onPreviewTap: function (e) {
let src = e.currentTarget.dataset.src;
app.onPreviewTap(src);
},
onLoad(o) {
// this.checkPageLogin();
app.api.apiAdGetAd({
type: 60
}).then(res => {
console.log(res);
this.setData({
ad_swiper: res.data ? res.data : [],
imgRoot: res.other.img_root ? res.other.img_root : ''
});
});
},
checkPageLogin() {
this.checkLogin(user => {
this.setData({
user
});
}, '/pages/test/test');
},
onSwiperTap(e) {
let id = 0;
let urls = e.currentTarget.dataset.url;
let store_id = e.currentTarget.dataset.store_id;
let diy_id = e.currentTarget.dataset.diy_id;
if (urls == '/base/merchantsinfo/merchantsinfo' || urls == '/base/electricityinfo/electricityinfo') {
urls = urls + '?id=' + store_id;
} else if (urls == '/pages/define/define') {
urls = urls + '?id=' + diy_id;
}
app.navTo(urls);
},
toSubmit: function (e) {
var md5 = require('../../we7/js/md5.js');
var url = "https://zhyframe.fzh.fun/1.pptx";
var key = md5(url);
var store = wx.getStorageSync(key);
if (store) {
this.opeFile(store);
} else {
var that = this;
wx.downloadFile({
// 示例 url,并非真实存在
url: 'https://zhyframe.fzh.fun/1.pptx',
success: function (res) {
console.log(res);
const filePath = res.tempFilePath
wx.saveFile({
tempFilePath: filePath,
success(res) {
const savedFilePath = res.savedFilePath;
wx.setStorageSync(key, savedFilePath);
that.opeFile(savedFilePath);
}
})
}
})
}
},
opeFile(filePath){
wx.openDocument({
filePath: filePath,
fileType: 'pptx',
showMenu: true,
success: function (res) {
console.log('打开文档成功')
}
})
},
getNickname: function (e) {
console.log('getNickname');
this.setData({
nickname: e.detail.value
});
},
getLivename: function (e) {
console.log('getLivename');
this.setData({
livename: e.detail.value
});
},
toChangeCate: function (e) {
this.setData({
cate_index: e.detail.value
});
},
getUploadImages: function (e) {
console.log('getUploadImages');
this.setData({
upload_images: e.detail
});
}
});
<view style="{{themeColor}}">
<view class="page">
<view class="group_4">
<view class="button">
<view class="submit" bindtap="toSubmit">
<text class="test_linson2">打开文档</text>
</view>
</view>
</view>
</view>
</view>