| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- import animation from '../../utils/animation';
- const app = getApp();
- Page({
- data: {
- IsShowSelect:false,
- IsShowRemind:false,
- AlertClass:"",
- Sort1:"panel112",
- Sort2:"",
- RemindArr:[
- {
- "Title":"取消收藏",
- "Content":"确定删除这条收藏记录吗?删除后无法恢复。",
- "BtnName":"删除",
- },{
- "Title":"取消收藏",
- "Content":"确定删除这些收藏记录吗?删除后无法恢复。",
- "BtnName":"删除",
- },{
- "Title":"生成文章",
- "Content":"要用这些单词生成新文章吗?",
- "BtnName":"继续",
- },{
- "Title":"导出到秒过",
- "Content":"要把这些单词做成秒过题卡吗?\n\n该功能需要切换到「秒过 - 错题记忆卡」小程序中实现。",
- "BtnName":"继续",
- },
- ],
- RemindIndex:0,
- },
- onLoad: function (options) {
- let that = this;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- List:app.globalData.UserCollect,
- Count:0,
- });
- },
- sortWord:function(e){
- let isSort=e.currentTarget.dataset.issort;
- let list=[];
- let sort1="",sort2="";
- if (isSort=="1"){
- list=common.sort(this.data.List,"ASC","Word","String");
- sort1="";
- sort2="panel112";
- }
- else{
- list=common.sort(this.data.List,"DESC","ID","Number");
- sort1="panel112";
- sort2="";
- }
- //debugger;
- this.setData({
- List:list,
- Sort1:sort1,
- Sort2:sort2,
- });
- },
- selecItem:function(e){
- let index=e.currentTarget.dataset.index;
- let list=this.data.List;
-
- for(let i=0;i<list.length;i++){
- if (index=="all")
- list[i].Selected=1;
- else if (index==i)
- list[i].Selected=list[i].Selected==1?0:1;
- }
- let count=0;
- for(let i=0;i<list.length;i++){
- if (list[i].Selected==1)
- count++;
- }
- this.setData({
- List:list,
- Count:count,
- });
- },
- setDataBoolean:function(e){
- if (e.currentTarget.dataset.name=="IsShowSelect"){
- this.cancelSelected();
- }
- this.setData({
- IsShowSelect:!this.data.IsShowSelect,
- });
- },
-
- showRemindStart:function(e){
- let that=this;
- let remindIndex=e.currentTarget.dataset.type;
- this.setData({
- RemindIndex:remindIndex,
- });
- let arr=that.getSelectedWord();
- if (arr){
- if (arr.length==0){
- // 使用组件显示提示
- this.selectComponent('#alertTip').showAlert("请至少选择1个单词");
- return null;
- }
- else if (remindIndex==2 && arr.length>10){
- // 使用组件显示提示
- this.selectComponent('#alertTip').showAlert("一篇文章最多可选10个单词");
- return null;
- }
- }
- if (e.currentTarget.dataset.word)
- that.Word=e.currentTarget.dataset.word;
- animation.toggleRemindWithAnimation(this, {
- hideColor: 'rgba(0,0,0,0)',
- showColor: 'rgba(277,277,277,0.5)',
- panelAnimationKey: 'panelAnimation', // 控制内容面板的动画
- animationKey: 'parentAnimation' // 控制父容器的动画(如果需要)
- });
- },
- showRemindEnd:function(e){
- let that=this;
- const confirm=e.currentTarget.dataset.confirm;
- animation.toggleRemindWithAnimation(this, {
- hideColor: 'rgba(0,0,0,0)',
- showColor: 'rgba(277,277,277,0.5)'
- });
- if (confirm=="1") {
- switch(Number(that.data.RemindIndex)){
- case 0:
- that.deleteItem(that.Word);
- break;
- case 1:
- that.deleteMany();
- break;
- case 2:
- that.setClipboard();
- break;
- case 3:
- that.gotoMiaoguo();
- break;
- }
- }
- },
- deleteItem:function(word){
- let that=this;
- main.getData('AddOrDeleteYJBDCUserCollect?UserID='+app.globalData.userInfo.UserID+'&Word='+word, function (data) {
- if (data){
- app.globalData.UserCollect=data;
- that.setData({
- List:app.globalData.UserCollect,
- });
- wx.showToast({
- title: '删除完成',
- });
- }
- });
- },
- deleteMany:function(){
- let that=this;
- let arr=that.getSelectedWord();
- main.getData('DeleteYJBDCUserCollect?UserID='+app.globalData.userInfo.UserID+'&WordArr='+arr.join(","), function (data) {
- if (data){
- app.globalData.UserCollect=data;
- that.setData({
- List:app.globalData.UserCollect,
- });
- wx.showToast({
- title: '批量删除完成',
- });
- }
- });
- },
- setClipboard:function(e){
- let that=this;
- let arr=that.getSelectedWord(true);
- app.globalData.SelectedWords=arr;
- wx.redirectTo({
- url: 'wordsinput',
- });
- },
- gotoMiaoguo:function(e){
- let that=this;
- let arr=that.getSelectedWord();
- var appid="wx84b3feac6069eec3";
- var path="pages/index/index?SourceID="+app.globalData.ProgramID+"&goto=buildcard&Words="+arr.join(",");
- wx.navigateToMiniProgram({
- appId: appid,
- path: path,
- });
- },
- getSelectedWord:function(selectTen){
- let that=this;
- let list=that.data.List;
- let arr=[];
- for(let i=0;i<list.length;i++){
- if (list[i].Selected==1)
- arr.push(list[i].Word);
- }
- return arr;
- },
- cancelSelected:function(){
- let list=this.data.List;
- for(let i=0;i<list.length;i++)
- list[i].Selected=0;
- this.setData({
- List:list,
- Count:0,
- });
- },
- goto: function (e) {
- let that=this;
- var url=e.currentTarget.dataset.url;
- wx.navigateTo({
- url: url,
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|