作者 刘晓艳

分享链接判断是否授权

... ... @@ -36,6 +36,28 @@ Page({
*/
onLoad: function(options) {
this.cardInfo()
wx.getSetting({
success: (res) => {
console.log(res)
if (res.authSetting['scope.userInfo'] == undefined) {
wx.navigateTo({
url: '/pages/start/start',
})
}
// console.log(res)
// console.log('是否授权', res.authSetting['scope.userInfo'] !== undefined);
// this.setData({
// weixinLogin: res.authSetting['scope.userInfo'] !== undefined
// })
},
fail: (res) => {
console.log(res)
wx.navigateTo({
url: '/pages/start/start',
})
}
})
},
/**
... ...
// pages/groupBuy/groupBuy.js
const app = getApp()
const time=require('../../../utils/util.js');
const time = require('../../../utils/util.js');
Page({
/**
... ... @@ -13,7 +14,13 @@
groupList: [],
recordList: [],
pay_info: [],
is_agree: false
is_agree: false,
countDownList: [],
actEndTimeList: [],
goodsList: [{
actEndTime: ''
}]
},
//tab切换
... ... @@ -62,10 +69,15 @@
// 长按复制
copy: function(e) {
console.log(e)
var index=e.currentTarget.dataset.index
var recordList = this.data.recordList
var chargenum = recordList[index].redeem_code
var that = this;
wx.setClipboardData({
data: that.data.chargenum,
data: chargenum,
success: function(res) {
console.log(res)
wx.showToast({
title: '复制成功',
});
... ... @@ -73,6 +85,7 @@
});
},
//参与的组团
takeGroup() {
let url = '/portal/Group/group_list'
... ... @@ -83,9 +96,18 @@
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((res) => {
console.log(res)
var groupList = res.list
var goodsList = this.data.goodsList
console.log(groupList.length)
for (var i = 0; i < groupList.length; i++) {
goodsList.push({
actEndTime:''
})
goodsList[i].actEndTime = groupList[i].over_time
}
this.setData({
groupList: res.list
groupList: res.list,
goodsList: goodsList
})
})
},
... ... @@ -100,12 +122,10 @@
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((res) => {
console.log(res)
var recordList= res.list
for(var i=0;i<recordList.length;i++){
var recordList = res.list
for (var i = 0; i < recordList.length; i++) {
var chargeTime = recordList[i].create_time
chargeTime = time.formatTimeTwo(chargeTime, 'Y-M-D')
console.log(chargeTime)
recordList[i].create_time = chargeTime
}
this.setData({
... ... @@ -122,7 +142,7 @@
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((res) => {
// console.log(res)
console.log('团购配置人数加个:',res)
this.setData({
pay_info: res.info
})
... ... @@ -201,6 +221,50 @@
},
timeFormat(param) { //小于10的格式化函数
return param < 10 ? '0' + param : param;
},
countDown() { //倒计时函数
// 获取当前时间,同时得到活动结束时间数组
let newTime = new Date().getTime();
let endTimeList = this.data.actEndTimeList;
let countDownArr = [];
// 对结束时间进行处理渲染到页面
endTimeList.forEach(o => {
let endTime = new Date(o).getTime();
let obj = null;
// 如果活动未结束,对时间进行处理
if (endTime - newTime > 0) {
let time = (endTime - newTime) / 1000;
// 获取天、时、分、秒
let day = parseInt(time / (60 * 60 * 24));
let hou = parseInt(time % (60 * 60 * 24) / 3600);
let min = parseInt(time % (60 * 60 * 24) % 3600 / 60);
let sec = parseInt(time % (60 * 60 * 24) % 3600 % 60);
obj = {
day: this.timeFormat(day),
hou: this.timeFormat(hou),
min: this.timeFormat(min),
sec: this.timeFormat(sec)
}
} else { //活动已结束,全部设置为'00'
obj = {
day: '00',
hou: '00',
min: '00',
sec: '00'
}
}
countDownArr.push(obj);
})
// 渲染,然后每隔一秒执行一次倒计时函数
this.setData({
countDownList: countDownArr
})
setTimeout(this.countDown, 1000);
},
/**
* 生命周期函数--监听页面加载
*/
... ... @@ -208,6 +272,17 @@
this.takeGroup()
this.record()
this.PayDetail()
let endTimeList = [];
// 将活动的结束时间参数提成一个单独的数组,方便操作
this.data.goodsList.forEach(o => {
endTimeList.push(o.actEndTime)
})
this.setData({
actEndTimeList: endTimeList
});
// 执行倒计时函数
this.countDown();
},
/**
... ...
... ... @@ -60,9 +60,28 @@
<text>{{item.num}}</text>人,已参与:
<text>{{item.count}}</text> 人,快呼唤伙伴参与吧!</view>
<view class='list_info'>
<view class='list_info_item'>剩余
<text>{{item.surplus_time}}</text> 结束</view>
</view>
<view class='list_info_item'>
剩余
<!-- <text>{{item.surplus_time}}</text> -->
<text wx:for="{{countDownList}}" wx:key="countDownList">
<text class=''>{{item.hou}}</text>
<text>:</text>
<text class=''>{{item.min}}</text>
<text>:</text>
<text class=' '>{{item.sec}}</text>
</text>
结束
</view>
</view>
<!--
<view class='tui-countdown-content' wx:for="{{countDownList}}" wx:key="countDownList">
剩余
<!-- <text class='tui-conutdown-box'>{{item.day}}</text>天
<text class='tui-conutdown-box'>{{item.hou}}</text>时
<text class='tui-conutdown-box'>{{item.min}}</text>分
<text class='tui-conutdown-box tui-countdown-bg'>{{item.sec}}</text>秒
</view> -->
<view>
<view class='user_info_box'>
<view class='user_info'>
... ... @@ -99,10 +118,10 @@
<view class='list_label'>长按兑换码即可复制</view>
</view>
</view>
<view class='list_tab list_content' wx:for='{{recordList}}' wx:key=''>
<view class='list_tab list_content' wx:for='{{recordList}}' wx:key='' data-index='{{index}}'>
<view class='list_tab_item'>{{item.create_time}}</view>
<view class='list_tab_item'>{{item.is_used == 1?'已完成':'未完成'}}</view>
<view class='list_tab_item' selectable='true' bindlongtap='copy'>{{item.redeem_code}}</view>
<text class='list_tab_item' selectable='true' bindlongtap='copy' data-index='{{index}}'>{{item.redeem_code}}</text>
</view>
</view>
</view>
... ...
... ... @@ -11,6 +11,8 @@ Page({
swipercurrent: 0,
current_student: 0,
},
//获取轮播当前页
swiperCharge(e) {
console.log(e.detail.current)
... ... @@ -31,6 +33,7 @@ Page({
this.setData({imgsUrl: res.list, service: res.service})
})
},
//畅玩卡说明
card() {
let url = '/wxapp/public/arc_card'
... ... @@ -50,18 +53,21 @@ Page({
url: '../appointmentRecord/appointmentRecord?student_id=' + this.data.imgsUrl[this.data.current_student].id,
})
},
//立即购买
buyCard() {
wx.navigateTo({
url: '../buyCard/buyCard',
})
},
//团购畅玩卡
groupBuy() {
wx.navigateTo({
url: '../groupBuy/groupBuy',
})
},
/**
* 生命周期函数--监听页面加载
*/
... ...
// pages/my/takeGroupBuy/takeGroupBuy.js
const app=getApp()
const app = getApp()
Page({
/**
... ... @@ -7,10 +7,10 @@ Page({
*/
data: {
group_info: "",
take_info:'',
is_agree:false,
rule:'',
group_id:''
take_info: '',
is_agree: false,
rule: '',
group_id: ''
},
... ... @@ -24,7 +24,7 @@ Page({
//参与的组团
takeGroup() {
var that=this
var that = this
let url = '/portal/Group/group_detail'
let params = {
// id: wx.getStorageSync('group_id')
... ... @@ -135,10 +135,24 @@ Page({
this.setData({
group_id: options.group_id
})
// if (options.group_id !== '' || options.group_id!=undefined){
this.takeGroup()
// }
this.getRule()
wx.getSetting({
success: (res) => {
console.log(res)
if (res.authSetting['scope.userInfo'] == undefined) {
wx.navigateTo({
url: '/pages/start/start',
})
}
},
fail: (res) => {
console.log(res)
wx.navigateTo({
url: '/pages/start/start',
})
}
})
},
/**
... ...
... ... @@ -36,7 +36,7 @@
"list": []
},
"miniprogram": {
"current": 1,
"current": 2,
"list": [
{
"id": -1,
... ... @@ -49,6 +49,11 @@
"name": "card",
"pathName": "pages/my/takeGroupBuy/takeGroupBuy",
"query": "group_id=60"
},
{
"id": -1,
"name": "share",
"pathName": "pages/my/cardIntroduction/cardIntroduction"
}
]
}
... ...