作者 刘晓艳

团购调整

... ... @@ -6,8 +6,8 @@ Page({
* 页面的初始数据
*/
data: {
info:[],
thumb:''
info: [],
thumb: ''
},
//畅玩卡介绍
... ... @@ -25,7 +25,7 @@ Page({
},
//前往团购
goBuy(){
goBuy() {
wx.navigateTo({
url: '/pages/my/groupBuy/groupBuy',
})
... ... @@ -84,6 +84,26 @@ Page({
* 用户点击右上角分享
*/
onShareAppMessage: function() {
let that = this;
// 设置菜单中的转发按钮触发转发事件时的转发内容
var shareObj = {
title: '科学队长', // 默认是小程序的名称(可以写slogan等)
path: '/pages/my/cardIntroduction/cardIntroduction', // 默认是当前页面,必须是以‘/’开头的完整路径
imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
success: function(res) {
if (res.errMsg == 'shareAppMessage:ok') {}
},
fail: function() {
// 转发失败之后的回调
if (res.errMsg == 'shareAppMessage:fail cancel') {
// 用户取消转发
} else if (res.errMsg == 'shareAppMessage:fail') {
// 转发失败,其中 detail message 为详细失败信息
}
},
complete: function() {
// 转发结束之后的回调(转发成不成功都会执行)
}
}
}
})
\ No newline at end of file
... ...
// pages/groupBuy/groupBuy.js
const app = getApp()
const time=require('../../../utils/util.js');
Page({
/**
... ... @@ -7,12 +8,12 @@
*/
data: {
current: 0,
chargenum: "2059788797",
chargenum: "",
page: 0,
groupList: [],
recordList: [],
pay_info: [],
is_agree:false
is_agree: false
},
//tab切换
... ... @@ -27,12 +28,14 @@
})
}
},
//同意协议按钮
agree() {
this.setData({
is_agree: !this.data.is_agree
})
},
//服务协议
serviceProtocol() {
wx.navigateTo({
... ... @@ -98,26 +101,19 @@
}
app.post(url, params, header).then((res) => {
console.log(res)
this.setData({
recordList: res.list
})
})
},
//发起团购
goPay() {
let url = '/portal/Group/group_create'
let params = {}
let header = {
"XX-Token": wx.getStorageSync('token')
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
}
app.post(url, params, header).then((res) => {
this.setData({
group_info: res.pay
recordList: recordList
})
this.wxPay(res.pay)
})
},
//团购配置人数价格
PayDetail() {
let url = '/portal/Group/group_option'
... ... @@ -126,7 +122,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
})
... ... @@ -140,46 +136,65 @@
"XX-Token": wx.getStorageSync('token')
}
app.post(url, {}, {}).then((res) => {
console.log('团购规则',res)
// console.log('团购规则', res)
this.setData({
rule: res
})
})
},
//发起团购
goPay(e) {
// var id=e.currentTarget.dataset.id
let url = '/portal/Group/group_create'
let params = {}
let header = {
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((res) => {
// wx.setStorageSync('group_id', res.group_id)
this.setData({
group_info: res.pay,
group_id: res.group_id
})
this.wxPay(res.pay)
})
},
//发起团购支付
wxPay(data) {
const self = this;
if (self.data.is_agree){
if (self.data.is_agree) {
wx.requestPayment({
'timeStamp': data.timeStamp,
'nonceStr': data.nonceStr,
'package': data.package,
'signType': 'MD5',
'paySign': data.paySign,
'success': function (res) {
'success': function(res) {
console.log(res)
wx.showToast({
title: '支付成功',
icon: 'success',
success: function () {
setTimeout(function () {
success: function() {
setTimeout(function() {
const params = {
rule: self.data.rule,
pay_info: self.data.pay_info,
}
wx.navigateTo({
url: '/pages/my/shareGroupBuy/shareGroupBuy?params=' + JSON.stringify(params),
url: '/pages/my/shareGroupBuy/shareGroupBuy?params=' + JSON.stringify(params) + '&group_id=' + self.data.group_id,
})
}, 500)
}
});
},
'fail': function (res) { }
'fail': function(res) {}
})
}else{
} else {
wx.showToast({
title: '请同意服务协议',
icon:'none'
icon: 'none'
})
}
... ...
... ... @@ -100,12 +100,9 @@
</view>
</view>
<view class='list_tab list_content' wx:for='{{recordList}}' wx:key=''>
<view class='list_tab_item' wx:if="{{item.group_status == 1}}">{{item.complete_time}}</view>
<view class='list_tab_item' wx:if="{{item.group_status == 0}}">{{item.over_time}}</view>
<view class='list_tab_item'>{{item.group_status == 1?'已完成':'未完成'}}</view>
<view class='list_tab_item'>
<text selectable='true' bindlongtap='copy'>{{chargenum}}</text>
</view>
<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>
</view>
</view>
</view>
... ... @@ -137,7 +134,7 @@
</view>
<view class='service_btn_box'>
<view>单价:¥{{pay_info.price}}</view>
<view class='pay_btn' bindtap='goPay'>支付</view>
<view class='pay_btn' bindtap='goPay' data-id='{{pay_info.id}}'>支付</view>
</view>
</view>
</view>
... ...
// pages/groupBuyDetail/groupBuyDetail.js
const app=getApp()
const app = getApp()
Page({
/**
... ... @@ -8,9 +8,10 @@ Page({
data: {
isFolded: true,
imgUrls: ['../../../images/img1.png', '../../../images/img1.png', '../../../images/img1.png', '../../../images/img1.png', '../../../images/img1.png', '../../../images/img1.png', '../../../images/img1.png', '../../../images/img1.png', '../../../images/img1.png'],
id:'',
list_info:{}
id: '',
list_info: {}
},
//查看全部
listMore(e) {
this.setData({
... ... @@ -18,27 +19,28 @@ Page({
})
},
listDetail(){
let url ='/portal/Group/group_detail'
let params={
id:this.data.id
listDetail() {
let url = '/portal/Group/group_detail'
let params = {
id: this.data.id
}
let header={
"XX-Token":wx.getStorageSync('token')
let header = {
"XX-Token": wx.getStorageSync('token')
}
app.post(url,params,header).then((res)=>{
app.post(url, params, header).then((res) => {
console.log(res)
this.setData({
list_info: res.info
})
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
id:options.id
id: options.id
})
this.listDetail()
},
... ... @@ -88,18 +90,19 @@ Page({
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
let that = this;
var id=wx.getStorageSync('id')
var id = wx.getStorageSync('group_id')
console.log(id)
// 设置菜单中的转发按钮触发转发事件时的转发内容
var shareObj = {
title: '科学队长', // 默认是小程序的名称(可以写slogan等)
path: '/pages/my/takeGroupBuy/takeGroupBuy?id=' + id, // 默认是当前页面,必须是以‘/’开头的完整路径
imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
success: function (res) {
if (res.errMsg == 'shareAppMessage:ok') { }
success: function(res) {
if (res.errMsg == 'shareAppMessage:ok') {}
},
fail: function () {
fail: function() {
// 转发失败之后的回调
if (res.errMsg == 'shareAppMessage:fail cancel') {
// 用户取消转发
... ... @@ -107,7 +110,7 @@ Page({
// 转发失败,其中 detail message 为详细失败信息
}
},
complete: function () {
complete: function() {
// 转发结束之后的回调(转发成不成功都会执行)
}
}
... ...
... ... @@ -5,74 +5,78 @@ Page({
* 页面的初始数据
*/
data: {
group_id:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
console.log('options', options);
this.setData({params: options.params?JSON.parse(options.params):''})
this.setData({
params: options.params ? JSON.parse(options.params) : '',
group_id:options.group_id
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
let that = this;
var id=wx.getStorageSync('id')
// var group_id = wx.getStorageSync('group_id')
var group_id = this.data.group_id
// 设置菜单中的转发按钮触发转发事件时的转发内容
var shareObj = {
title: '科学队长', // 默认是小程序的名称(可以写slogan等)
path: '/pages/my/takeGroupBuy/takeGroupBuy?id=' + id, // 默认是当前页面,必须是以‘/’开头的完整路径
path: '/pages/my/takeGroupBuy/takeGroupBuy?group_id=' + group_id, // 默认是当前页面,必须是以‘/’开头的完整路径
imageUrl: '', //自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
success: function (res) {
if (res.errMsg == 'shareAppMessage:ok') { }
success: function(res) {
if (res.errMsg == 'shareAppMessage:ok') {}
},
fail: function () {
fail: function() {
// 转发失败之后的回调
if (res.errMsg == 'shareAppMessage:fail cancel') {
// 用户取消转发
... ... @@ -80,7 +84,7 @@ Page({
// 转发失败,其中 detail message 为详细失败信息
}
},
complete: function () {
complete: function() {
// 转发结束之后的回调(转发成不成功都会执行)
}
}
... ...
// pages/my/takeGroupBuy/takeGroupBuy.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
group_info: "",
take_info:'',
is_agree:false,
rule:'',
group_id:''
},
//查看详情
listDetail(e) {
var id = e.currentTarget.dataset.id
// wx.setStorageSync('id', id)
wx.navigateTo({
url: '/pages/my/groupBuyDetail/groupBuyDetail?id=' + id,
})
},
//参与的组团
takeGroup() {
var that=this
let url = '/portal/Group/group_detail'
let params = {
// id: wx.getStorageSync('group_id')
id: this.data.group_id
}
let header = {
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((res) => {
console.log(res)
that.setData({
group_info: res.info
})
})
},
//团购规则
getRule() {
let url = '/wxapp/public/arc_group'
let params = {}
let header = {
"XX-Token": wx.getStorageSync('token')
}
app.post(url, {}, {}).then((res) => {
console.log('团购规则', res)
this.setData({
rule: res
})
})
},
//发起团购
goPay() {
let url = '/portal/Group/group_join'
let params = {
// id: wx.getStorageSync('group_id')
id: this.data.group_id
}
let header = {
"XX-Token": wx.getStorageSync('token')
}
app.post(url, params, header).then((res) => {
console.log(res)
this.setData({
take_info: res.info
})
this.wxPay(res.pay)
})
},
//发起团购支付
wxPay(data) {
const self = this;
if (self.data.is_agree) {
wx.requestPayment({
'timeStamp': data.timeStamp,
'nonceStr': data.nonceStr,
'package': data.package,
'signType': 'MD5',
'paySign': data.paySign,
'success': function(res) {
console.log(res)
wx.showToast({
title: '支付成功',
icon: 'success',
success: function() {
setTimeout(function() {
const params = {
rule: self.data.rule,
pay_info: self.data.pay_info,
}
wx.navigateTo({
url: '/pages/my/groupBuy/groupBuy',
})
}, 500)
}
});
},
'fail': function(res) {}
})
} else {
wx.showToast({
title: '请同意服务协议',
icon: 'none'
})
}
},
//同意协议按钮
agree() {
this.setData({
is_agree: !this.data.is_agree
})
},
//服务协议
serviceProtocol() {
wx.navigateTo({
url: '/pages/my/protocol/protocol',
})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
console.log(options.group_id)
this.setData({
group_id: options.group_id
})
// if (options.group_id !== '' || options.group_id!=undefined){
this.takeGroup()
// }
this.getRule()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
... ... @@ -5,13 +5,13 @@
<view class='content_box'>
<view>
<view class='item_list' wx:for='{{groupList}}' wx:key=''>
<view class='list_title_box' data-id='{{item.id}}' bindtap='listDetail'>
<view class='item_list'>
<view class='list_title_box' data-id='{{group_info.id}}' bindtap='listDetail'>
<view>查看详情</view>
<view class='iconfont icon-fanhui'></view>
</view>
<view class='list_info_box'>
<block wx:for='{{item.group_detail}}' wx:for-item='sub_item' wx:key=''>
<block wx:for='{{group_info.group_detail}}' wx:for-item='sub_item' wx:key=''>
<view class='info_item'>
<view class='info_box'>
<block>
... ... @@ -49,26 +49,26 @@
</view> -->
</view>
<view class='list_info'>成团人数:最低
<text>{{item.num}}</text>人,已参与:
<text>{{item.count}}</text> 人,快呼唤伙伴参与吧!</view>
<text>{{group_info.num}}</text>人,已参与:
<text>{{group_info.count}}</text> 人,快呼唤伙伴参与吧!</view>
<view class='list_info'>
<view class='list_info_item'>剩余
<text>{{item.surplus_time}}</text> 结束</view>
<text>{{group_info.surplus_time}}</text> 结束</view>
</view>
<view>
<view class='user_info_box'>
<view class='user_info'>
<view class='info_box'>
<image src='{{item.avatar}}'></image>
<image src='{{group_info.avatar}}'></image>
<view class='info_label'>发起人</view>
</view>
<view>{{item.user_nickname}}</view>
<view>{{group_info.user_nickname}}</view>
</view>
<view class='state_box'>
<view>{{item.start_time}}开团</view>
<view class='info_state' wx:if='{{item.group_status==1}}'>团购中</view>
<view class='info_state' wx:if='{{item.group_status==2}}'>团购失败</view>
<view class='info_state' wx:if='{{item.group_status==3}}'>团购成功</view>
<view>{{group_info.start_time}}开团</view>
<view class='info_state' wx:if='{{group_info.group_status==1}}'>团购中</view>
<view class='info_state' wx:if='{{group_info.group_status==2}}'>团购失败</view>
<view class='info_state' wx:if='{{group_info.group_status==3}}'>团购成功</view>
</view>
</view>
</view>
... ... @@ -78,25 +78,25 @@
<view class='list_title_info'>
<view class='iconfont icon-zhongdian'> </view>
<view>
<view>团购规则说明</view>
<view class='content_info'>如果因为环境网络问题或者其他原因导致无法打卡,请上传照 片及文字申诉内容,证明您已到场并已经参与活动。</view>
<view>{{rule.title}}</view>
<view class='content_info'>{{rule.description}}</view>
</view>
</view>
<view class='service_box'>
<view class='service_info_box'>
<text class='iconfont icon-xuanzhong'></text>
<view class='service_info_box' bindtap="agree">
<text class='iconfont icon-xuanze1' wx:if="{{!is_agree}}"></text>
<text class='iconfont icon-xuanzhong' wx:if="{{is_agree}}"></text>
<text>服务协议</text>
<!-- <text class='service_info' bindtap='serviceProtocol'>服务协议</text> -->
<text class='service_info' catchtap='serviceProtocol'>服务协议</text>
</view>
<view class='service_btn_box'>
<view>单价:¥188.00</view>
<view>单价:¥{{take_info.price}}</view>
<view class='pay_btn' bindtap='goPay'>参与并支付</view>
</view>
</view>
<view class='null_box'></view>
<!-- <view class='null_box'></view> -->
<!-- <view class='bottom_box'>
<text class='iconfont icon-fenxiang'></text> 分享的文案,50汉字以内提示分享的文案,50汉字以内提示分 享的文案,50汉字以内
</view> -->
</view>
\ No newline at end of file
... ...
... ... @@ -36,12 +36,19 @@
"list": []
},
"miniprogram": {
"current": 0,
"current": 1,
"list": [
{
"id": -1,
"name": "card",
"pathName": "pages/my/myCard/myCard"
"pathName": "pages/my/myCard/myCard",
"query": ""
},
{
"id": -1,
"name": "card",
"pathName": "pages/my/takeGroupBuy/takeGroupBuy",
"query": "group_id=60"
}
]
}
... ...