Browse Source

modify By@Lb

feature/v1.1.0
xpz2018 7 years ago
parent
commit
7a28fc1dcb
5 changed files with 86 additions and 39 deletions
  1. 78
      pages/activity_list/activity_list.js
  2. 4
      pages/activity_list/activity_list.json
  3. 2
      pages/activity_list/activity_list.wxml
  4. 2
      pages/mcenter/mcenter.js
  5. 39
      pages/pay_result/pay_result.js

78
pages/activity_list/activity_list.js

@ -7,24 +7,30 @@ Page({
*/
data: {
repos: [],
pageNum: 1,
pageSize: 10,
hasMoreData: true,
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.loadData();
this.loadActivityLists();
},
loadData: function () {//定义函数名称
wx.showLoading();
loadActivityLists: function () {
wx.showLoading({
title: '正在加载',
mask: true,
});
var that = this;
wx.request({
url: getApp().gw.hostUrl + '/mall/wxa/activity/group/list',
method: 'get',
data: {
pageNum: 1,
pageSize: 2
pageNum: that.data.pageNum,
pageSize: that.data.pageSize
},
header: {
'Content-Type': 'application/x-www-form-urlencoded',
@ -33,14 +39,30 @@ Page({
success: function (res) {
console.log(res);
wx.hideLoading();
if (res.data.code == 0) {
that.setData({
repos: res.data.response.map((n) => Object.assign({}, n, {
createdAt: util.formatTime(new Date(n.createdAt)).substr(0, 16),
img: that.switchImg(n.status),
activityTypeStr: that.switchType(n.activityType),
})),
})
if (res.data.code == 0 && res.data.response.length > 0) {
var lists = that.data.repos;
if (that.data.pageNum == 1) {
//刷新清空数据
lists = [];
}
var respList = res.data.response.map((n) => Object.assign({}, n, {
createdAt: util.formatTime(new Date(n.createdAt)).substr(0, 16),
img: that.switchImg(n.status),
activityTypeStr: that.switchType(n.activityType),
}));
if (respList.length < that.data.pageSize) {
//最后一页数据添加
that.setData({
repos: lists.concat(respList),
hasMoreData: false
});
} else {
that.setData({
repos: lists.concat(respList),
hasMoreData: true,
pageNum: that.data.pageNum + 1
});
}
} else {
wx.showToast({
title: res.data.msg,
@ -49,7 +71,6 @@ Page({
});
}
},
fail: function (e) {
wx.hideLoading();
wx.showToast({
@ -58,14 +79,37 @@ Page({
duration: 1000
});
},
complete: function (res) {
// complete
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
})
},
onPullDownRefresh: function () {
this.data.pageNum = 1;
this.loadActivityLists();
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
if (this.data.hasMoreData) {
this.loadActivityLists();
} else {
wx.showToast({
title: '没有更多数据',
})
}
},
itemClick: function (event) {
var groupNo = event.currentTarget.dataset.testid;
var activityNo = event.currentTarget.dataset.activityno;
var groupNo = event.currentTarget.dataset.groupno;
wx.navigateTo({
url: '../pay_result/pay_result?groupNo=' + groupNo
url: '../activity_detail/activity_detail?activityNo=' + activityNo + '&groupNo=' + groupNo
})
},

4
pages/activity_list/activity_list.json

@ -1,3 +1,5 @@
{
"navigationBarTitleText": "活动记录"
"navigationBarTitleText": "活动记录",
"enablePullDownRefresh": true,
"backgroundColor": "#F3F3F3"
}

2
pages/activity_list/activity_list.wxml

@ -3,7 +3,7 @@
<view wx:for="{{repos}}" wx:key="">
<view class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active" bindtap="itemClick" data-testId="{{item.groupNo}}">
<view class="weui-media-box weui-media-box_appmsg" hover-class="weui-cell_active" bindtap="itemClick" data-activityNo="{{item.activityNo}}" data-groupNo="{{item.groupNo}}">
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">

2
pages/mcenter/mcenter.js

@ -25,7 +25,7 @@ Page({
},
goActivity: function (e) {
wx.navigateTo({
url: '../pay_result/pay_result'
url: '../activity_list/activity_list'
})
},
goLogin: function (e) {

39
pages/pay_result/pay_result.js

@ -19,14 +19,12 @@ Page({
}],
txtmoment: '保存图片,分享到朋友圈',
qrImageUrl: "",
avatarPath: '',
imgPath: '',
qrCodePath: '',
bgImageUrl: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527496410439&di=54c111d35f3ca9d1e9b193834785c264&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F013c81583fa08ea8012060c864c3b7.jpg',
},
onLoad: function (options) {
this.groupNo = options.groupNo;
console.log("groupNo>>" + this.groupNo);
this.data.groupNo = options.groupNo;
console.log('options>' + this.data.groupNo);
wx.getSystemInfo({
success: (res) => {
this.setData({
@ -40,9 +38,9 @@ Page({
url: getApp().gw.hostUrl + '/mall/wxa/activity/group/wxa_code',
method: 'get',
data: {
groupNo: that.groupNo,
width: 120,
// page: ''
groupNo: that.data.groupNo,
width: 80,
page: 'index/index'
},
header: {
'Content-Type': 'application/x-www-form-urlencoded',
@ -50,7 +48,7 @@ Page({
},
success: function (res) {
if (res.statusCode == 200) {
that.qrImageUrl = res.data.msg;
that.data.qrImageUrl = res.data.msg;
}
}
})
@ -67,9 +65,9 @@ Page({
url: getApp().gw.hostUrl + '/mall/wxa/activity/group/wxa_code',
method: 'get',
data: {
groupNo: that.groupNo,
width: 120,
page: ''
groupNo: that.data.groupNo,
width: 80,
page: 'index/index'
},
header: {
'Content-Type': 'application/x-www-form-urlencoded',
@ -115,7 +113,8 @@ Page({
onShareAppMessage: function () {
return {
title: '1号家政',
imageUrl: this.qrImageUrl
imageUrl: this.data.qrImageUrl,
path: '/pages/index/index',
};
},
@ -233,12 +232,11 @@ Page({
mask: true,
});
console.log(getApp().globalData.userInfo);
//先从服务器获取要分享的图片,保存到本地;
//下载微信头像,保存到本地;
wx.downloadFile({
url: getApp().globalData.userInfo.avatarUrl,
success: (res) => {
if (res.statusCode == 200 && res.tempFilePath != undefined && res.tempFilePath.length > 0) {
console.log(res);
avatarPath = res.tempFilePath;
that.drawMomentImage(avatarPath, imgPath, qrCodePath);
} else {
@ -251,12 +249,13 @@ Page({
toast = true;
}
});
//下载小程序的二维码,保存到本地;
wx.downloadFile({
url: 'https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1527496410439&di=54c111d35f3ca9d1e9b193834785c264&imgtype=0&src=http%3A%2F%2Fimg.zcool.cn%2Fcommunity%2F013c81583fa08ea8012060c864c3b7.jpg',
url: that.data.qrImageUrl,
success: (res) => {
if (res.statusCode == 200 && res.tempFilePath != undefined && res.tempFilePath.length > 0) {
console.log(res);
imgPath = res.tempFilePath;
qrCodePath = res.tempFilePath;
that.drawMomentImage(avatarPath, imgPath, qrCodePath);
} else {
that.handleErr(err, toast);
@ -268,12 +267,13 @@ Page({
toast = true;
}
});
//下载背景图片,保存到本地;
wx.downloadFile({
url: that.qrImageUrl,
url: that.data.bgImageUrl,
success: (res) => {
if (res.statusCode == 200 && res.tempFilePath != undefined && res.tempFilePath.length > 0) {
console.log(res);
qrCodePath = res.tempFilePath;
imgPath = res.tempFilePath;
that.drawMomentImage(avatarPath, imgPath, qrCodePath);
} else {
that.handleErr(err, toast);
@ -285,6 +285,7 @@ Page({
toast = true;
}
});
// wx.downloadFile({
// url: getApp().globalData.userInfo.avatarUrl,
// success: (aRes) => {

Loading…
Cancel
Save