Commit 57b40dee authored by 石盼盼's avatar 石盼盼

颁发徽章跟删除徽章

parent fb858ca5
...@@ -4,9 +4,15 @@ const base = new Base() ...@@ -4,9 +4,15 @@ const base = new Base()
Page({ Page({
data: { data: {
list: [], list: [],
selectlist:[] status: false,
num: 0,
arr:[]
}, },
onLoad: function (options) { onLoad: function (options) {
var arr1 = JSON.parse(options.listData)
this.setData({
arr : arr1
})
this.getList() this.getList()
}, },
getList() { getList() {
...@@ -16,46 +22,62 @@ Page({ ...@@ -16,46 +22,62 @@ Page({
let params = { let params = {
url: 'badges/all', url: 'badges/all',
callback: (data) => { callback: (data) => {
console.log(data)
wx.hideLoading() wx.hideLoading()
data.map((item, index) => {
Object.assign(item, { status: false })
});
this.setData({ this.setData({
list: data list: data
}) })
// for (let i = 0; i < this.data.list.length; i++) { for(var i =0; i< this.data.list.length;i++){
// console.log(this.data.list) for(var j =0; j< this.data.arr.length;j++) {
if (this.data.arr[j].id == this.data.list[i].id) {
// } this.data.list[i].status = this.data.arr[j].status
}
}
}
this.setData({
list: this.data.list
})
} }
} }
base.newRequest(params) base.newRequest(params)
}, },
chooseOne: function(e){ chooseOne: function (e) {
let index = e.currentTarget.dataset.index let index = e.currentTarget.dataset.index;
console.log(index) var list = this.data.list;
if(this.data.selectlist.length<=2){ if (list[index].status) {
// if(this.data.selectlist.length>1){ list[index].status = false
// // for( var i=0 ;i<this.data.selectlist.length;i++){ } else {
// // if(index == this.data.selectlist[i]){ list[index].status = true
// // console.log(11111,index) }
// // } //点击图片把status==true的组成新的数组
// // else{ var arr = [];
// // this.data.selectlist.push(index) for (var i = 0; i < list.length; i++) {
// // console.log(this.data.selectlist,22222) if(list[i].status==true){
// // } arr.push(list[i])
// // } }
// }else{ }
// this.data.selectlist.push(index) this.setData({
// } list: list,
this.data.selectlist.push(index); arr: arr
this.setData({ })
selectlist: this.data.selectlist },
})
save: function (e) {
var pages = getCurrentPages();
var prevPage = pages[pages.length - 2]; //上一个页面
if (this.data.arr.length == 0) {
base.toast('请至少选择一个徽章')
} else if (this.data.arr.length > 3) {
base.toast('最多选择三个徽章')
} else {
prevPage.setData({
arr: this.data.arr
})
wx.navigateBack({
delta: 1
})
} }
console.log(this.data.selectlist)
} }
}) })
\ No newline at end of file
...@@ -3,14 +3,13 @@ ...@@ -3,14 +3,13 @@
<view class="top"> <view class="top">
<view class="title">运动大满贯</view> <view class="title">运动大满贯</view>
<view class="imgbox flex-h flex-vc flex-hw"> <view class="imgbox flex-h flex-vc flex-hw">
<view wx:for="{{list}}" wx:key='index' wx:for-item='item_a' data-index="{{index}}" bindtap="chooseOne" > <view wx:for="{{list}}" wx:key='index' wx:for-item='item_a' data-index="{{index}}" bindtap="chooseOne" data-id="{{item_a.id}}">
<!-- <view wx:for="{{selectlist}}" wx:key='index' wx:for-item='selectlistOne'></view> --> <image wx:if="{{item_a.status}}" class="bigimg" src="{{item_a.icon_active}}"></image>
<image wx:if="{{selectlist==item_a.id}}" class="bigimg" src="{{item_a.icon.active}}" ></image>
<image wx:else class="bigimg" src="{{item_a.icon}}"></image> <image wx:else class="bigimg" src="{{item_a.icon}}"></image>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view class="button"> <view class="button">
<view class="apply" bindtap="goapplyResult">保存</view> <view class="apply" bindtap="save">保存</view>
</view> </view>
\ No newline at end of file
...@@ -10,6 +10,9 @@ page{ ...@@ -10,6 +10,9 @@ page{
font-size: 24rpx; font-size: 24rpx;
line-height: 53rpx; line-height: 53rpx;
} }
.top{
margin-bottom: 120rpx;
}
.title { .title {
padding-left: 52rpx; padding-left: 52rpx;
height: 100rpx; height: 100rpx;
......
// pages/index/evaluation/evaluation.js const app = getApp()
import { Base } from '../../../utils/base.js';
const base = new Base()
Page({ Page({
/** /**
...@@ -9,12 +11,20 @@ Page({ ...@@ -9,12 +11,20 @@ Page({
min: 0,//最少字数 min: 0,//最少字数
max: 300, //最多字数 max: 300, //最多字数
currentWordNumber:0, currentWordNumber:0,
chooseBadge:true,
imgBox:[],
}, },
onLoad: function (options) { onLoad: function (options) {
}, },
onShow: function(){
this.setData({
imgBox: this.data.arr?this.data.arr: []
})
},
inputs: function (e) { inputs: function (e) {
var value = e.detail.value; var value = e.detail.value;
var len = parseInt(value.length); var len = parseInt(value.length);
...@@ -41,10 +51,21 @@ Page({ ...@@ -41,10 +51,21 @@ Page({
currentValue: event.detail.value, currentValue: event.detail.value,
}); });
}, },
gobadgelist:function(){ gobadgelist:function(e){
var model = JSON.stringify(this.data.imgBox)
wx.navigateTo({ wx.navigateTo({
url: '../../index/badgelist/badgelist', url: '../../index/badgelist/badgelist?listData=' + model,
}) })
} },
//删除徽章
deleteBadge: function (e) {
var imgs = this.data.imgBox
var index = e.currentTarget.dataset.index
console.log(index)
imgs.splice(index, 1)
this.setData({
imgBox: imgs
})
},
}) })
\ No newline at end of file
...@@ -18,7 +18,17 @@ ...@@ -18,7 +18,17 @@
</view> </view>
<view class="badge"> <view class="badge">
<view class="title">颁发徽章</view> <view class="title">颁发徽章</view>
<image src="/images/add.png" bindtap="gobadgelist"></image> <view class="imgBox flex-h flex-hw">
<view class="img" wx:for="{{imgBox}}" wx:for-item="item" wx:key="idx">
<image src="{{item.icon_active}}" data-index="{{index}}" mode="aspectFill"></image>
<view class="delete-btn" data-index="{{index}}" catchtap="deleteBadge">
<text class='iconfont iconguanbi'></text>
</view>
</view>
<view class='addBox flex-h flex-vc flex-hc' bindtap="chooseImg" wx:if="{{imgBox.length < 3}}">
<image class="chooseBadge" wx:if="{{chooseBadge}}" src="/images/add.png" bindtap="gobadgelist"></image>
</view>
</view>
</view> </view>
</view> </view>
<view class="button"> <view class="button">
......
...@@ -106,4 +106,33 @@ page { ...@@ -106,4 +106,33 @@ page {
font-size: 30rpx; font-size: 30rpx;
text-align: center; text-align: center;
line-height: 80rpx; line-height: 80rpx;
} }
\ No newline at end of file
/* 徽章 */
.img {
width: 130rpx;
height: 130rpx;
border: 1px solid #EBEBEB;
border-radius: 5rpx;
margin-right: 30rpx;
margin-bottom: 30rpx;
position: relative;
}
.img image {
width: 130rpx;
height: 130rpx;
margin-right: 54rpx;
}
.delete-btn {
position: absolute;
right: -25rpx;
top: -25rpx;
}
.delete-btn .iconguanbi {
font-size: 52rpx;
color: #B3B3B3;
}
.addBox {
width: 130rpx;
height: 130rpx;
}
...@@ -78,6 +78,7 @@ Page({ ...@@ -78,6 +78,7 @@ Page({
this.setData({ this.setData({
datalList: data datalList: data
}) })
this.getList()
} }
} }
base.newRequest(params) base.newRequest(params)
......
...@@ -12,7 +12,6 @@ page{ ...@@ -12,7 +12,6 @@ page{
height: 340rpx; height: 340rpx;
background: #FFFFFF; background: #FFFFFF;
border-radius: 15rpx; border-radius: 15rpx;
box-shadow: 0 10rpx 20rpx 10rpx rgba(239, 240, 241, 0.72);
padding: 35rpx 18rpx; padding: 35rpx 18rpx;
} }
.top .course .course_top{ .top .course .course_top{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment