Commit a77f0c1d authored by wangxuelai's avatar wangxuelai

''

parent 02cbcf6a
......@@ -13,13 +13,67 @@ Page({
imageRoot: app.globalData.imageRoot,
imageVersion: app.globalData.imageVersion,
localImageRoot: '../../../images/',
sid: 0,
params: {
'1': { // 打卡
single: 1,
daily_limit: 1,
isUnlimit: 0 // 0 不是无限 1 无限
},
'2': { // 点赞别人
single: 2,
daily_limit: 2,
isUnlimit: 0 // 0 不是无限 1 无限
},
'3': { // 评论别人
single: 3,
daily_limit: 3,
isUnlimit: 0 // 0 不是无限 1 无限
},
'4': { // 转发打卡
single: 4,
daily_limit: 4,
isUnlimit: 0 // 0 不是无限 1 无限
},
'5': { // 被点赞
single: 5,
daily_limit: 5,
isUnlimit: 0 // 0 不是无限 1 无限
},
'6': { // 被围观
single: 6,
daily_limit: 6,
isUnlimit: 0 // 0 不是无限 1 无限
},
'7': { // 打卡被转发
single: 7,
daily_limit: 7,
isUnlimit: 0 // 0 不是无限 1 无限
},
'8': { // 被评论
single: 8,
daily_limit: 8,
isUnlimit: 0 // 0 不是无限 1 无限
},
'9': { // 被点评
single: 9,
daily_limit: 9,
isUnlimit: 0 // 0 不是无限 1 无限
}
},
addOrUpdate: 'add',
submitting: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
const {sid} = options;
this.setData({
sid
})
this.integralRulesShow();
},
/**
......@@ -63,11 +117,96 @@ Page({
onReachBottom: function () {
},
submit () {
this.data.submitting = true;
if (this.data.submitting) {
return
}
wx.showLoading({
title: '积分保存中...'
})
const params = JSON.parse(JSON.stringify(this.data.params));
for (let i in params) {
if (params[i].isUnlimit == 1) {
params[i].daily_limit = -1;
}
if (params[i].daily_limit == '') {
params[i].daily_limit = 0;
}
if (params[i].single == '') {
params[i].single = 0;
}
params[i].school_id = this.data.sid;
delete params[i].isUnlimit;
}
let ajax = null;
if (this.data.addOrUpdate == 'add') {
ajax = integralRulesAdd;
} else if (this.data.addOrUpdate == 'update') {
ajax = integralRulesUpdate;
}
ajax({
data: JSON.stringify(params)
}).then((res) => {
const {data, code} = res;
wx.hideLoading();
if (code == 200) {
wx.showToast({
title: '积分规则保存成功'
})
}
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
integralRulesShow () {
integralRulesShow({
school_id: this.data.sid
}).then((res) => {
const {code, data} = res;
if(code == 200) {
if (data.list.length > 0) {
this.data.addOrUpdate = 'update';
data.list.forEach((ele) => {
if (ele.daily_limit == -1) {
this.setData({
[`params.${ele.type}`]: {
daily_limit: 0,
single: ele.single,
isUnlimit: 1
}
})
} else {
this.setData({
[`params.${ele.type}`]: {
daily_limit: ele.daily_limit,
single: ele.single,
isUnlimit: 0
}
})
}
})
} else {
this.data.addOrUpdate = 'add';
}
}
})
},
selectUnLimit (e) {
const {dataset} = e.currentTarget;
let isUnlimit = `params.${dataset.type}.isUnlimit`
if (this.data.params[dataset.type].isUnlimit == 0) {
this.setData({
[isUnlimit]: 1
})
} else {
this.setData({
[isUnlimit]: 0
})
}
}
})
\ No newline at end of file
......@@ -4,7 +4,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日打卡</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[1].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -12,10 +12,10 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput active" type="number"/>
<text class="counttext active" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[1].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[1].daily_limit}}"/>
<text class="counttext {{params[1].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[1].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="1" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
......@@ -25,7 +25,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">点赞鼓励</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[2].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -33,10 +33,10 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput" type="number"/>
<text class="counttext" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[2].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[2].daily_limit}}"/>
<text class="counttext {{params[2].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit active" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[2].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="2" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
......@@ -46,7 +46,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">评论互动</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[3].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -54,10 +54,10 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput active" type="number"/>
<text class="counttext active" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[3].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[3].daily_limit}}"/>
<text class="counttext {{params[3].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[3].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="3" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
......@@ -67,7 +67,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">分享打卡</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[4].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -75,10 +75,10 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput active" type="number"/>
<text class="counttext active" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[4].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[4].daily_limit}}"/>
<text class="counttext {{params[4].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[4].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="4" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
......@@ -88,7 +88,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">打卡内容被点赞</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[5].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -96,10 +96,10 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput active" type="number"/>
<text class="counttext active" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[5].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[5].daily_limit}}"/>
<text class="counttext {{params[5].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[5].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="5" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
......@@ -109,7 +109,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">打卡内容被围观</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[6].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -117,10 +117,10 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput active" type="number"/>
<text class="counttext active" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[6].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[6].daily_limit}}"/>
<text class="counttext {{params[6].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[6].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="6" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
......@@ -130,7 +130,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">打卡内容被转发</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[7].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -138,10 +138,10 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput active" type="number"/>
<text class="counttext active" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[7].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[7].daily_limit}}"/>
<text class="counttext {{params[7].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[7].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="7" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
......@@ -151,7 +151,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">打卡内容被评论</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[8].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -159,10 +159,10 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput active" type="number"/>
<text class="counttext active" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[8].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[8].daily_limit}}"/>
<text class="counttext {{params[8].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[8].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="8" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
......@@ -172,7 +172,7 @@
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">打卡内容被老师点评</view>
<view class="scoreinputbox" hover-class="none" hover-stop-propagation="false">
<text class="" selectable="false" space="false" decode="false">获得</text>
<input class="scoreinput" type="number"/>
<input class="scoreinput" type="number" value="{{params[9].single}}"/>
<text class="" selectable="false" space="false" decode="false">积分</text>
</view>
</view>
......@@ -180,13 +180,13 @@
<view class="itembottom" hover-class="none" hover-stop-propagation="false">
<view class="itemtitle" hover-class="none" hover-stop-propagation="false">每日最高次数</view>
<view class="countinputbox" hover-class="none" hover-stop-propagation="false">
<input class="countinput active" type="number"/>
<text class="counttext active" selectable="false" space="false" decode="false">次</text>
<input class="countinput {{params[9].isUnlimit == 0 ? 'active' : ''}}" type="number" value="{{params[9].daily_limit}}"/>
<text class="counttext {{params[9].isUnlimit == 0 ? 'active' : ''}}" selectable="false" space="false" decode="false">次</text>
<text class="divide" selectable="false" space="false" decode="false">/</text>
<view class="unlimit" hover-class="none" hover-stop-propagation="false">不限</view>
<view class="unlimit {{params[9].isUnlimit == 0 ? '' : 'active'}}" hover-class="none" hover-stop-propagation="false" data-type="9" bindtap="selectUnLimit">不限</view>
</view>
</view>
</view>
<view class="divideline" hover-class="none" hover-stop-propagation="false"></view>
<view class="submitbtn" hover-class="none" hover-stop-propagation="false">保存</view>
<view class="submitbtn" hover-class="none" hover-stop-propagation="false" bindtap="submit">保存</view>
</view>
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