修改产品列表、授权问题

master
chen 2021-12-09 16:54:23 +08:00
parent b05c3a3132
commit 5aadec3963
4 changed files with 159 additions and 150 deletions

View File

@ -119,6 +119,24 @@ Page({
url: '../../img/background/1.png' url: '../../img/background/1.png'
}); });
this.getBottleCategories(); this.getBottleCategories();
// 换取token
wx.login({
success: res => {
wx.request({
url: urlPath.getopenid,
method: 'post',
data: {code: res.code},
success(res) {
console.log(res);
if (res.data.code == 0) {
wx.setStorageSync('token', res.data.data.token);
wx.setStorageSync('username', res.data.data.user.wx_name);
console.log(wx.getStorageSync('username'));
}
}
});
}
})
}, },
// 上传图片 // 上传图片
uploadImg() { uploadImg() {
@ -372,11 +390,17 @@ Page({
}, },
// 打开遮罩层 // 打开遮罩层
openMask() { openMask() {
if (wx.getStorageSync('username')!='' && wx.getStorageSync('username')!=undefined ) {
this.synthesis(); this.synthesis();
this.setData({ this.setData({
showCanvas: true, showCanvas: true,
showTitle:true showTitle:true
}) })
} else {
this.setData({
isLogin: true
})
}
}, },
downLoadImg(netUrl, storageKeyUrl) { downLoadImg(netUrl, storageKeyUrl) {
wx.getImageInfo({ wx.getImageInfo({
@ -428,7 +452,6 @@ Page({
}, },
// 保存图片到系统相册 // 保存图片到系统相册
saveImg: function() { saveImg: function() {
if (wx.getStorageSync('token')) {
wx.saveImageToPhotosAlbum({ wx.saveImageToPhotosAlbum({
filePath: this.data.canvasTemImg, filePath: this.data.canvasTemImg,
success: res => { success: res => {
@ -461,11 +484,6 @@ Page({
}) })
} }
}) })
} else {
this.setData({
isLogin: true
})
}
}, },
// 保存图片接口 // 保存图片接口
saveImgEv(imgSrc) { saveImgEv(imgSrc) {
@ -498,7 +516,6 @@ Page({
}, },
// 分享图片 // 分享图片
shareImg() { shareImg() {
if (wx.getStorageSync('token')) {
if(this.data.times==0){ if(this.data.times==0){
wx.showToast({ wx.showToast({
title:'正在调起分享', title:'正在调起分享',
@ -540,11 +557,6 @@ Page({
} }
}) })
} }
} else {
this.setData({
isLogin: true
})
}
}, },
// 分享事件 // 分享事件
shareEv(id) { shareEv(id) {
@ -599,15 +611,14 @@ Page({
wx_name: this.data.userInfo.nickName, wx_name: this.data.userInfo.nickName,
avater: this.data.userInfo.avatarUrl, avater: this.data.userInfo.avatarUrl,
}, },
success(res) { success:(res)=> {
console.log(res, 1234); console.log(this.data.userInfo.nickName,);
console.log(res);
if (res.data.code == 0) { if (res.data.code == 0) {
wx.setStorageSync('token', res.data.data wx.setStorageSync('token', res.data.data.token);
.token); wx.setStorageSync('openid', res.data.data.openid);
wx.setStorageSync('openid', res.data.data wx.setStorageSync('username', res.data.data.user.wx_name);
.openid); console.log(wx.getStorageSync('username'));
wx.setStorageSync('user', res.data.data
.user);
} }
} }
}); });

View File

@ -16,6 +16,7 @@ Page({
vote(e){ vote(e){
var that = this; var that = this;
var id = e.currentTarget.dataset.id; var id = e.currentTarget.dataset.id;
let newIndex = e.currentTarget.dataset.index;
if(id > 0){ if(id > 0){
wx.request({ wx.request({
url: urlPath.vote, url: urlPath.vote,
@ -30,7 +31,11 @@ Page({
wx.showToast({ wx.showToast({
title: '投票成功' title: '投票成功'
}); });
that.onLoad(); that.data.works_list[newIndex].number++;
that.setData({
works_list:that.data.works_list
})
// that.onLoad();
}else{ }else{
wx.showToast({ wx.showToast({
title:res.data.msg, title:res.data.msg,
@ -94,14 +99,11 @@ Page({
rule_text:['1、本次活动不收任何费用不退稿。2、参赛作品需附有作品介绍字数限100字以内。3、每位参赛者仅限提交不超过5幅3、每位参赛者仅限提交不超过5幅'],//活动规则 rule_text:['1、本次活动不收任何费用不退稿。2、参赛作品需附有作品介绍字数限100字以内。3、每位参赛者仅限提交不超过5幅3、每位参赛者仅限提交不超过5幅'],//活动规则
//列表 //列表
works_list: [], works_list: [],
page : 1,
pageSize : 20, pageSize : 20,
}); });
//登录状态 //登录状态
wx.checkSession({ wx.checkSession({
success: function (res) { success: function (res) {
console.log("DDDDDDD");
that.getVoteList();
that.getSlideList(); that.getSlideList();
that.saveVisit(); that.saveVisit();
that.getBaseInfo(); that.getBaseInfo();
@ -110,14 +112,12 @@ Page({
fail: function(){ fail: function(){
wx.login({ wx.login({
success: res => { success: res => {
console.log(res);
wx.request({ wx.request({
url: urlPath.getopenid, url: urlPath.getopenid,
data: { data: {
code: res.code code: res.code
}, },
success(res) { success(res) {
console.log(res);
if(res.data.code == 0){ if(res.data.code == 0){
wx.setStorageSync('token', res.data.data.token); wx.setStorageSync('token', res.data.data.token);
wx.setStorageSync('openid', res.data.data.openid); wx.setStorageSync('openid', res.data.data.openid);
@ -208,9 +208,15 @@ Page({
}, },
getVoteList:function(){ getVoteList:function(){
var that = this; var that = this;
if(that.data.page==1) {
that.setData({
works_list:[]
})
} else {
if(!that.data.forMore){ if(!that.data.forMore){
return; return;
} }
}
var vote_list = []; var vote_list = [];
wx.request({ wx.request({
url: urlPath.getVoteList, url: urlPath.getVoteList,
@ -222,6 +228,7 @@ Page({
page_size:that.data.pageSize page_size:that.data.pageSize
}, },
success(res){ success(res){
console.log(res,9000);
if(res.data.code == 0){ if(res.data.code == 0){
if(res.data.data.length > 0){ if(res.data.data.length > 0){
res.data.data.forEach(function(item){ res.data.data.forEach(function(item){
@ -237,9 +244,6 @@ Page({
that.setData({ that.setData({
works_list:that.data.works_list.concat(vote_list) works_list:that.data.works_list.concat(vote_list)
}); });
that.setData({
page : that.data.page + 1
})
}else{ }else{
that.setData({ that.setData({
forMore:false forMore:false
@ -256,6 +260,7 @@ Page({
if(that.data.for_search){ if(that.data.for_search){
that.search(); that.search();
}else{ }else{
that.data.page++
that.getVoteList(); that.getVoteList();
} }
}, },
@ -273,18 +278,14 @@ Page({
onReady: function () { onReady: function () {
}, },
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { onHide: function () {
this.setData({
page:1
})
this.getVoteList();
}, },
/** /**
@ -321,6 +322,8 @@ Page({
selected: 1 selected: 1
}) })
} }
this.setData({page:1})
this.getVoteList();
}, },
getBaseInfo:function(){ getBaseInfo:function(){
var that = this; var that = this;

View File

@ -63,7 +63,7 @@
<view class="name" bindtap="personal" data-uid="{{item.uid}}"> <view class="name" bindtap="personal" data-uid="{{item.uid}}">
{{item.name}} <text>{{item.number}}</text> {{item.name}} <text>{{item.number}}</text>
</view> </view>
<button class="add" bindtap='vote' data-id="{{item.ids}}"> <button class="add" bindtap='vote' data-id="{{item.ids}}" data-index="{{index}}">
投票 投票
</button> </button>
</view> </view>

View File

@ -8,29 +8,10 @@ Page({
data: { data: {
workTitleArr: ['保存的作品', '分享的作品'], workTitleArr: ['保存的作品', '分享的作品'],
workIndex: 0, workIndex: 0,
imgArr: [{ imgArr: [],
imgSrc: '../../img/background/1.png',
workName: '饺子吃肉肉饺子吃肉肉饺子吃肉肉饺子吃'
},
{
imgSrc: '../../img/background/1.png',
workName: '饺子吃肉肉'
},
{
imgSrc: '../../img/background/1.png',
workName: '饺子吃肉肉'
},
{
imgSrc: '../../img/background/1.png',
workName: '饺子吃肉肉'
},
{
imgSrc: '../../img/background/1.png',
workName: '饺子吃肉肉'
},
],
page: 1, page: 1,
size: 200 size: 200,
times:0
}, },
/** /**
@ -77,11 +58,24 @@ Page({
this.setData({ this.setData({
imgArr: newArr imgArr: newArr
}) })
} else {
wx.showToast({
title:'暂无作品数据',
icon:'none'
})
} }
} }
}); });
}, },
shareEv(e) { shareEv(e) {
if(this.data.times==0){
wx.showToast({
title:'正在调起分享',
duration:5000
})
this.setData({
times:this.data.times++
})
wx.downloadFile({ wx.downloadFile({
url: this.data.imgArr[e.currentTarget.dataset.index].imgSrc, url: this.data.imgArr[e.currentTarget.dataset.index].imgSrc,
success: (res) => { success: (res) => {
@ -96,6 +90,7 @@ Page({
}) })
} }
}) })
}
}, },
shareImg(id,index){ shareImg(id,index){
wx.request({ wx.request({