修改产品列表、授权问题

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

View File

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

View File

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

View File

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