| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104 |
- import common from '../../utils/util';
- import main from '../../utils/main';
- const COUNT_MAX=10;
- const app = getApp();
- Page({
- data: {
- IsShowAlert:false,
- Count:0,
- CountMax:COUNT_MAX,
- Words:[],
- IsShowExample:false,
- },
- onLoad: function (options) {
- var that = this;
- let words=app.globalData.OCRWords;
- that.data.Words=[];
- for(let i=0;i<words.length;i++){
- let obj={};
- obj.Name=words[i];
- obj.CSS="";
- that.data.Words.push(obj);
- }
- let list=app.globalData.SelectedWords;
- that.setData({
- Containnerheight: main.getWindowHeight(),
- Words:that.data.Words,
- CountMax:COUNT_MAX-list.length,
- });
- },
- selectWord:function(e){
- let word=e.currentTarget.dataset.word;
- let list=this.data.Words;
- let count=0;
- for(let i=0;i<list.length;i++){
- if(word==list[i].Name){
- if (list[i].CSS)
- list[i].CSS="";
- else if(count<this.data.CountMax && this.data.Count<this.data.CountMax)
- list[i].CSS="Selected";
- }
- if(list[i].CSS=="Selected"){
- count++;
- }
- }
- if (count>0){
- this.setData({
- IsShowAlert:false,
- });
- }
- else{
- this.setData({
- IsShowAlert:true,
- });
- }
- this.setData({
- Words:list,
- Count:count,
- });
- },
- goto: function (e) {
- let that=this;
- var url=e.currentTarget.dataset.url;
- wx.navigateTo({
- url: url,
- });
- },
- close:function(n){
- if (!n)
- n=1;
- wx.navigateBack({
- delta: n
- })
- },
- submit:function(){
- if (this.data.Count==0){
- this.setData({
- IsShowAlert:true,
- });
- }
- else{
- let list=this.data.Words;
- for(let i=0;i<list.length;i++){
- if(list[i].CSS=="Selected"){
- app.globalData.SelectedWords.push(list[i].Name);
- }
- }
- this.close(2);
- }
- },
- showExample:function(){
- this.setData({
- IsShowExample:!this.data.IsShowExample,
- });
- },
- onShareAppMessage: function () {
- return {
- title: app.globalData.ShareTitle,
- path: app.globalData.SharePath + '?UserID=' + app.globalData.userInfo.UserID,
- imageUrl: app.globalData.ShareImage,
- }
- },
- })
|