[周五福利订阅]
This commit is contained in:
@@ -20,7 +20,7 @@ Page({
|
||||
longitude : 0, //经度
|
||||
latitude : 0, //纬度
|
||||
adverts : [], //轮播图
|
||||
stateType : "silver",
|
||||
stateType : "shaky",
|
||||
cardArr : [], //权益数组
|
||||
activities : [], //周五福利
|
||||
isUser : false, //用户登录状态
|
||||
@@ -70,6 +70,7 @@ Page({
|
||||
indexInfo() {
|
||||
if(this.data.stateType == 'shaky') {
|
||||
wx.$api.index.index(this.data.city, this.data.longitude, this.data.latitude).then(res=>{
|
||||
console.log(res.data.adverts)
|
||||
this.setData({
|
||||
adverts : res.data.adverts,
|
||||
cardArr : res.data.rights,
|
||||
@@ -95,6 +96,7 @@ Page({
|
||||
})
|
||||
} else {
|
||||
wx.$api.index.choice(this.data.stateType,this.data.city, this.data.longitude, this.data.latitude).then(res=>{
|
||||
console.log(res.data.adverts)
|
||||
this.setData({
|
||||
adverts : res.data.adverts,
|
||||
cardArr : res.data.categorys,
|
||||
@@ -166,15 +168,39 @@ Page({
|
||||
},
|
||||
|
||||
/**
|
||||
* 点击图片放大
|
||||
* 点击轮播图片
|
||||
*/
|
||||
clickImg(e) {
|
||||
if(e.currentTarget.dataset.img == "") return
|
||||
let imgUrl = [e.currentTarget.dataset.img]
|
||||
wx.previewImage({
|
||||
urls : imgUrl, //需要预览的图片http链接列表,注意是数组
|
||||
current : imgUrl[0] // 当前显示图片的http链接,默认是第一个
|
||||
})
|
||||
console.log(e.currentTarget.dataset)
|
||||
let newChannel = e.currentTarget.dataset.channel,
|
||||
newImg = e.currentTarget.dataset.img,
|
||||
newUrl = e.currentTarget.dataset.url
|
||||
|
||||
// 点击图片放大
|
||||
if (newChannel == 'image') {
|
||||
if(newImg == "") return
|
||||
let imgUrl = [newImg]
|
||||
wx.previewImage({
|
||||
urls : imgUrl, //需要预览的图片http链接列表,注意是数组
|
||||
current : imgUrl[0] // 当前显示图片的http链接,默认是第一个
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转内网
|
||||
if (newChannel == 'pages') {
|
||||
wx.navigateTo({
|
||||
url: newUrl
|
||||
})
|
||||
}
|
||||
|
||||
// 跳转外网
|
||||
if (newChannel == 'url') {
|
||||
let url= encodeURIComponent(newUrl)
|
||||
wx.redirectTo({
|
||||
// 跳转到webview页面
|
||||
url: `/pages/webView/webView?url=${url}`
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
@@ -293,6 +319,32 @@ Page({
|
||||
else {//正常轮转时,记录正确页码索引
|
||||
this.setData({ swiperCurrent: e.detail.current });
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* 订阅
|
||||
*/
|
||||
subscribeTap() {
|
||||
wx.requestSubscribeMessage({
|
||||
tmplIds: ['g8cEL-Tf2_Pdh8VyBdsYbhv09VVm8om-ZblhXIaVDiY'],
|
||||
success: res=> {
|
||||
if(res.errMsg == "requestSubscribeMessage:ok") {
|
||||
wx.$api.index.subscribe(1).then(res=>{
|
||||
wx.showLoading({
|
||||
title: res.data,
|
||||
icon : 'none',
|
||||
})
|
||||
setTimeout(function () {
|
||||
wx.hideLoading();
|
||||
}, 1000)
|
||||
}).catch(err=>{
|
||||
|
||||
})
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
console.log(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user