diff --git a/star_lock/assets/countries.json b/star_lock/assets/countries.json deleted file mode 100644 index e084bd73..00000000 --- a/star_lock/assets/countries.json +++ /dev/null @@ -1,1540 +0,0 @@ -[{ - "short": "AD", - "name": "安道尔共和国", - "en": "Andorra", - "tel": "376", - "pinyin": "adeghg" -}, -{ - "short": "AE", - "name": "阿拉伯联合酋长国", - "en": "UnitedArabEmirates", - "tel": "971", - "pinyin": "alblhqzg" -}, -{ - "short": "AF", - "name": "阿富汗", - "en": "Afghanistan", - "tel": "93", - "pinyin": "afh" -}, -{ - "short": "AG", - "name": "安提瓜和巴布达", - "en": "AntiguaandBarbuda", - "tel": "1268", - "pinyin": "atghbbd" -}, -{ - "short": "AI", - "name": "安圭拉岛", - "en": "Anguilla", - "tel": "1264", - "pinyin": "agld" -}, -{ - "short": "AL", - "name": "阿尔巴尼亚", - "en": "Albania", - "tel": "355", - "pinyin": "aebny" -}, -{ - "short": "AM", - "name": "阿美尼亚", - "en": "Armenia", - "tel": "374", - "pinyin": "amny" -}, -{ - "short": "", - "name": "阿森松", - "en": "Ascension", - "tel": "247", - "pinyin": "als" - -}, -{ - "short": "AO", - "name": "安哥拉", - "en": "Angola", - "tel": "244", - "pinyin": "agl" - -}, -{ - "short": "AR", - "name": "阿根廷", - "en": "Argentina", - "tel": "54", - "pinyin": "agt" - -}, -{ - "short": "AT", - "name": "奥地利", - "en": "Austria", - "tel": "43", - "pinyin": "adl" - -}, -{ - "short": "AU", - "name": "澳大利亚", - "en": "Australia", - "tel": "61", - "pinyin": "adly" - -}, -{ - "short": "AZ", - "name": "阿塞拜疆", - "en": "Azerbaijan", - "tel": "994", - "pinyin": "asbj" - -}, -{ - "short": "BB", - "name": "巴巴多斯", - "en": "Barbados", - "tel": "1246", - "pinyin": "bbds" - -}, -{ - "short": "BD", - "name": "孟加拉国", - "en": "Bangladesh", - "tel": "880", - "pinyin": "mjlg" - -}, -{ - "short": "BE", - "name": "比利时", - "en": "Belgium", - "tel": "32", - "pinyin": "bls" - -}, -{ - "short": "BF", - "name": "布基纳法索", - "en": "Burkina-faso", - "tel": "226", - "pinyin": "bjnfs" - -}, -{ - "short": "BG", - "name": "保加利亚", - "en": "Bulgaria", - "tel": "359", - "pinyin": "bjly" - -}, -{ - "short": "BH", - "name": "巴林", - "en": "Bahrain", - "tel": "973", - "pinyin": "bl" - -}, -{ - "short": "BI", - "name": "布隆迪", - "en": "Burundi", - "tel": "257", - "pinyin": "bld" - -}, -{ - "short": "BJ", - "name": "贝宁", - "en": "Benin", - "tel": "229", - "pinyin": "bl" - -}, -{ - "short": "BL", - "name": "巴勒斯坦", - "en": "Palestine", - "tel": "970", - "pinyin": "blst" - -}, -{ - "short": "BM", - "name": "百慕大群岛", - "en": "BermudaIs.", - "tel": "1441", - "pinyin": "bmdqd" - -}, -{ - "short": "BN", - "name": "文莱", - "en": "Brunei", - "tel": "673", - "pinyin": "wl" - -}, -{ - "short": "BO", - "name": "玻利维亚", - "en": "Bolivia", - "tel": "591", - "pinyin": "blwy" - -}, -{ - "short": "BR", - "name": "巴西", - "en": "Brazil", - "tel": "55", - "pinyin": "bx" - -}, -{ - "short": "BS", - "name": "巴哈马", - "en": "Bahamas", - "tel": "1242", - "pinyin": "bhm" - -}, -{ - "short": "BW", - "name": "博茨瓦纳", - "en": "Botswana", - "tel": "267", - "pinyin": "bcwn" - -}, -{ - "short": "BY", - "name": "白俄罗斯", - "en": "Belarus", - "tel": "375", - "pinyin": "bels" - -}, -{ - "short": "BZ", - "name": "伯利兹", - "en": "Belize", - "tel": "501", - "pinyin": "blz" - -}, -{ - "short": "CA", - "name": "加拿大", - "en": "Canada", - "tel": "1", - "pinyin": "jnd" - -}, -{ - "short": "", - "name": "开曼群岛", - "en": "CaymanIs.", - "tel": "1345", - "pinyin": "kmqd" - -}, -{ - "short": "CF", - "name": "中非共和国", - "en": "CentralAfricanRepublic", - "tel": "236", - "pinyin": "zfghg" - -}, -{ - "short": "CG", - "name": "刚果", - "en": "Congo", - "tel": "242", - "pinyin": "gg" - -}, -{ - "short": "CH", - "name": "瑞士", - "en": "Switzerland", - "tel": "41", - "pinyin": "rs" - -}, -{ - "short": "CK", - "name": "库克群岛", - "en": "CookIs.", - "tel": "682", - "pinyin": "kkqd" - -}, -{ - "short": "CL", - "name": "智利", - "en": "Chile", - "tel": "56", - "pinyin": "zl" - -}, -{ - "short": "CM", - "name": "喀麦隆", - "en": "Cameroon", - "tel": "237", - "pinyin": "kml" - -}, -{ - "short": "CN", - "name": "中国", - "en": "China", - "tel": "86", - "pinyin": "zg" - -}, -{ - "short": "CO", - "name": "哥伦比亚", - "en": "Colombia", - "tel": "57", - "pinyin": "glby" - -}, -{ - "short": "CR", - "name": "哥斯达黎加", - "en": "CostaRica", - "tel": "506", - "pinyin": "gsdlj" - -}, -{ - "short": "CS", - "name": "捷克", - "en": "Czech", - "tel": "420", - "pinyin": "jk" - -}, -{ - "short": "CU", - "name": "古巴", - "en": "Cuba", - "tel": "53", - "pinyin": "gb" - -}, -{ - "short": "CY", - "name": "塞浦路斯", - "en": "Cyprus", - "tel": "357", - "pinyin": "spls" - -}, -{ - "short": "CZ", - "name": "捷克", - "en": "CzechRepublic", - "tel": "420", - "pinyin": "jk" - -}, -{ - "short": "DE", - "name": "德国", - "en": "Germany", - "tel": "49", - "pinyin": "dg" - -}, -{ - "short": "DJ", - "name": "吉布提", - "en": "Djibouti", - "tel": "253", - "pinyin": "jbt" - -}, -{ - "short": "DK", - "name": "丹麦", - "en": "Denmark", - "tel": "45", - "pinyin": "dm" - -}, -{ - "short": "DO", - "name": "多米尼加共和国", - "en": "DominicaRep.", - "tel": "1890", - "pinyin": "dmnjghg" - -}, -{ - "short": "DZ", - "name": "阿尔及利亚", - "en": "Algeria", - "tel": "213", - "pinyin": "aejly" - -}, -{ - "short": "EC", - "name": "厄瓜多尔", - "en": "Ecuador", - "tel": "593", - "pinyin": "egde" - -}, -{ - "short": "EE", - "name": "爱沙尼亚", - "en": "Estonia", - "tel": "372", - "pinyin": "asny" - -}, -{ - "short": "EG", - "name": "埃及", - "en": "Egypt", - "tel": "20", - "pinyin": "ej" - -}, -{ - "short": "ES", - "name": "西班牙", - "en": "Spain", - "tel": "34", - "pinyin": "xby" - -}, -{ - "short": "ET", - "name": "埃塞俄比亚", - "en": "Ethiopia", - "tel": "251", - "pinyin": "aseby" - -}, -{ - "short": "FI", - "name": "芬兰", - "en": "Finland", - "tel": "358", - "pinyin": "fl" - -}, -{ - "short": "FJ", - "name": "斐济", - "en": "Fiji", - "tel": "679", - "pinyin": "fj" - -}, -{ - "short": "FR", - "name": "法国", - "en": "France", - "tel": "33", - "pinyin": "fg" - -}, -{ - "short": "GA", - "name": "加蓬", - "en": "Gabon", - "tel": "241", - "pinyin": "jp" - -}, -{ - "short": "GB", - "name": "英国", - "en": "UnitedKiongdom", - "tel": "44", - "pinyin": "yg" - -}, -{ - "short": "GD", - "name": "格林纳达", - "en": "Grenada", - "tel": "1809", - "pinyin": "glnd" - -}, -{ - "short": "GE", - "name": "格鲁吉亚", - "en": "Georgia", - "tel": "995", - "pinyin": "gljy" - -}, -{ - "short": "GF", - "name": "法属圭亚那", - "en": "FrenchGuiana", - "tel": "594", - "pinyin": "fsgyn" - -}, -{ - "short": "GH", - "name": "加纳", - "en": "Ghana", - "tel": "233", - "pinyin": "jn" - -}, -{ - "short": "GI", - "name": "直布罗陀", - "en": "Gibraltar", - "tel": "350", - "pinyin": "zblt" - -}, -{ - "short": "GM", - "name": "冈比亚", - "en": "Gambia", - "tel": "220", - "pinyin": "gby" - -}, -{ - "short": "GN", - "name": "几内亚", - "en": "Guinea", - "tel": "224", - "pinyin": "jny" - -}, -{ - "short": "GR", - "name": "希腊", - "en": "Greece", - "tel": "30", - "pinyin": "xl" - -}, -{ - "short": "GT", - "name": "危地马拉", - "en": "Guatemala", - "tel": "502", - "pinyin": "wdml" - -}, -{ - "short": "GU", - "name": "关岛", - "en": "Guam", - "tel": "1671", - "pinyin": "gd" - -}, -{ - "short": "GY", - "name": "圭亚那", - "en": "Guyana", - "tel": "592", - "pinyin": "gyn" - -}, -{ - "short": "HK", - "name": "香港(中国)", - "en": "Hongkong", - "tel": "852", - "pinyin": "xgzg" - -}, -{ - "short": "HN", - "name": "洪都拉斯", - "en": "Honduras", - "tel": "504", - "pinyin": "hdls" - -}, -{ - "short": "HT", - "name": "海地", - "en": "Haiti", - "tel": "509", - "pinyin": "hd" - -}, -{ - "short": "HU", - "name": "匈牙利", - "en": "Hungary", - "tel": "36", - "pinyin": "xyl" - -}, -{ - "short": "ID", - "name": "印度尼西亚", - "en": "Indonesia", - "tel": "62", - "pinyin": "ydnxy" - -}, -{ - "short": "IE", - "name": "爱尔兰", - "en": "Ireland", - "tel": "353", - "pinyin": "ael" - -}, -{ - "short": "IL", - "name": "以色列", - "en": "Israel", - "tel": "972", - "pinyin": "ysl" - -}, -{ - "short": "IN", - "name": "印度", - "en": "India", - "tel": "91", - "pinyin": "yd" - -}, -{ - "short": "IQ", - "name": "伊拉克", - "en": "Iraq", - "tel": "964", - "pinyin": "ylk" - -}, -{ - "short": "IR", - "name": "伊朗", - "en": "Iran", - "tel": "98", - "pinyin": "yl" - -}, -{ - "short": "IS", - "name": "冰岛", - "en": "Iceland", - "tel": "354", - "pinyin": "bd" - -}, -{ - "short": "IT", - "name": "意大利", - "en": "Italy", - "tel": "39", - "pinyin": "ydl" - -}, -{ - "short": "", - "name": "科特迪瓦", - "en": "IvoryCoast", - "tel": "225", - "pinyin": "ktdw" - -}, -{ - "short": "JM", - "name": "牙买加", - "en": "Jamaica", - "tel": "1876", - "pinyin": "ymj" - -}, -{ - "short": "JO", - "name": "约旦", - "en": "Jordan", - "tel": "962", - "pinyin": "yd" - -}, -{ - "short": "JP", - "name": "日本", - "en": "Japan", - "tel": "81", - "pinyin": "rb" - -}, -{ - "short": "KE", - "name": "肯尼亚", - "en": "Kenya", - "tel": "254", - "pinyin": "kny" - -}, -{ - "short": "KG", - "name": "吉尔吉斯坦", - "en": "Kyrgyzstan", - "tel": "331", - "pinyin": "jejst" - -}, -{ - "short": "KH", - "name": "柬埔寨", - "en": "Kampuchea(Cambodia)", - "tel": "855", - "pinyin": "jpz" - -}, -{ - "short": "KP", - "name": "朝鲜", - "en": "NorthKorea", - "tel": "850", - "pinyin": "cx" - -}, -{ - "short": "KR", - "name": "韩国", - "en": "Korea", - "tel": "82", - "pinyin": "hg" - - -}, -{ - "short": "KT", - "name": "科特迪瓦共和国", - "en": "RepublicofIvoryCoast", - "tel": "225", - "pinyin": "ktdwghg" - -}, -{ - "short": "KW", - "name": "科威特", - "en": "Kuwait", - "tel": "965", - "pinyin": "kwt" - -}, -{ - "short": "KZ", - "name": "哈萨克斯坦", - "en": "Kazakstan", - "tel": "327", - "pinyin": "hskst" - -}, -{ - "short": "LA", - "name": "老挝", - "en": "Laos", - "tel": "856", - "pinyin": "lw" - -}, -{ - "short": "LB", - "name": "黎巴嫩", - "en": "Lebanon", - "tel": "961", - "pinyin": "lbn" - -}, -{ - "short": "LC", - "name": "圣卢西亚", - "en": "St.Lucia", - "tel": "1758", - "pinyin": "slxy" - -}, -{ - "short": "LI", - "name": "列支敦士登", - "en": "Liechtenstein", - "tel": "423", - "pinyin": "lzdsd" - -}, -{ - "short": "LK", - "name": "斯里兰卡", - "en": "SriLanka", - "tel": "94", - "pinyin": "sllk" - -}, -{ - "short": "LR", - "name": "利比里亚", - "en": "Liberia", - "tel": "231", - "pinyin": "lbly" - -}, -{ - "short": "LS", - "name": "莱索托", - "en": "Lesotho", - "tel": "266", - "pinyin": "lst" - -}, -{ - "short": "LT", - "name": "立陶宛", - "en": "Lithuania", - "tel": "370", - "pinyin": "ltw" - -}, -{ - "short": "LU", - "name": "卢森堡", - "en": "Luxembourg", - "tel": "352", - "pinyin": "lsb" - -}, -{ - "short": "LV", - "name": "拉脱维亚", - "en": "Latvia", - "tel": "371", - "pinyin": "ltwy" - -}, -{ - "short": "LY", - "name": "利比亚", - "en": "Libya", - "tel": "218", - "pinyin": "lby" - -}, -{ - "short": "MA", - "name": "摩洛哥", - "en": "Morocco", - "tel": "212", - "pinyin": "mlg" - -}, -{ - "short": "MC", - "name": "摩纳哥", - "en": "Monaco", - "tel": "377", - "pinyin": "mng" - -}, -{ - "short": "MD", - "name": "摩尔多瓦", - "en": "Moldova,Republicof", - "tel": "373", - "pinyin": "medw" - -}, -{ - "short": "MG", - "name": "马达加斯加", - "en": "Madagascar", - "tel": "261", - "pinyin": "mdjsj" - -}, -{ - "short": "ML", - "name": "马里", - "en": "Mali", - "tel": "223", - "pinyin": "ml" - -}, -{ - "short": "MM", - "name": "缅甸", - "en": "Burma", - "tel": "95", - "pinyin": "md" - -}, -{ - "short": "MN", - "name": "蒙古", - "en": "Mongolia", - "tel": "976", - "pinyin": "mg" - -}, -{ - "short": "MO", - "name": "澳门(中国)", - "en": "Macao", - "tel": "853", - "pinyin": "am zg" - -}, -{ - "short": "MS", - "name": "蒙特塞拉特岛", - "en": "MontserratIs", - "tel": "1664", - "pinyin": "mtsstd" - -}, -{ - "short": "MT", - "name": "马耳他", - "en": "Malta", - "tel": "356", - "pinyin": "met" - -}, -{ - "short": "", - "name": "马里亚那群岛", - "en": "MarianaIs", - "tel": "1670", - "pinyin": "mlynqd" - -}, -{ - "short": "", - "name": "马提尼克", - "en": "Martinique", - "tel": "596", - "pinyin": "mtnk" - -}, -{ - "short": "MU", - "name": "毛里求斯", - "en": "Mauritius", - "tel": "230", - "pinyin": "mlqs" - -}, -{ - "short": "MV", - "name": "马尔代夫", - "en": "Maldives", - "tel": "960", - "pinyin": "medf" - - -}, -{ - "short": "MW", - "name": "马拉维", - "en": "Malawi", - "tel": "265", - "pinyin": "mlw" - -}, -{ - "short": "MX", - "name": "墨西哥", - "en": "Mexico", - "tel": "52", - "pinyin": "mxg" - -}, -{ - "short": "MY", - "name": "马来西亚", - "en": "Malaysia", - "tel": "60", - "pinyin": "mlxy" - -}, -{ - "short": "MZ", - "name": "莫桑比克", - "en": "Mozambique", - "tel": "258", - "pinyin": "msbk" - -}, -{ - "short": "NA", - "name": "纳米比亚", - "en": "Namibia", - "tel": "264", - "pinyin": "nmby" - -}, -{ - "short": "NE", - "name": "尼日尔", - "en": "Niger", - "tel": "977", - "pinyin": "nre" - -}, -{ - "short": "NG", - "name": "尼日利亚", - "en": "Nigeria", - "tel": "234", - "pinyin": "nrly" - -}, -{ - "short": "NI", - "name": "尼加拉瓜", - "en": "Nicaragua", - "tel": "505", - "pinyin": "njlg" - -}, -{ - "short": "NL", - "name": "荷兰", - "en": "Netherlands", - "tel": "31", - "pinyin": "hl" - -}, -{ - "short": "NO", - "name": "挪威", - "en": "Norway", - "tel": "47", - "pinyin": "nw" - -}, -{ - "short": "NP", - "name": "尼泊尔", - "en": "Nepal", - "tel": "977", - "pinyin": "nbe" - -}, -{ - "short": "", - "name": "荷属安的列斯", - "en": "NetheriandsAntilles", - "tel": "599", - "pinyin": "hsadls" - -}, -{ - "short": "NR", - "name": "瑙鲁", - "en": "Nauru", - "tel": "674", - "pinyin": "nl" - -}, -{ - "short": "NZ", - "name": "新西兰", - "en": "NewZealand", - "tel": "64", - "pinyin": "xxl" - -}, -{ - "short": "OM", - "name": "阿曼", - "en": "Oman", - "tel": "968", - "pinyin": "am" - -}, -{ - "short": "PA", - "name": "巴拿马", - "en": "Panama", - "tel": "507", - "pinyin": "bnm" - -}, -{ - "short": "PE", - "name": "秘鲁", - "en": "Peru", - "tel": "51", - "pinyin": "bl" - -}, -{ - "short": "PF", - "name": "法属玻利尼西亚", - "en": "FrenchPolynesia", - "tel": "689", - "pinyin": "fsblnxy" - -}, -{ - "short": "PG", - "name": "巴布亚新几内亚", - "en": "PapuaNewCuinea", - "tel": "675", - "pinyin": "bbyxjny" - -}, -{ - "short": "PH", - "name": "菲律宾", - "en": "Philippines", - "tel": "63", - "pinyin": "flb" - -}, -{ - "short": "PK", - "name": "巴基斯坦", - "en": "Pakistan", - "tel": "92", - "pinyin": "bjst" - -}, -{ - "short": "PL", - "name": "波兰", - "en": "Poland", - "tel": "48", - "pinyin": "bl" - -}, -{ - "short": "PR", - "name": "波多黎各", - "en": "PuertoRico", - "tel": "1787", - "pinyin": "bdlg" - -}, -{ - "short": "PT", - "name": "葡萄牙", - "en": "Portugal", - "tel": "351", - "pinyin": "pty" - -}, -{ - "short": "PY", - "name": "巴拉圭", - "en": "Paraguay", - "tel": "595", - "pinyin": "blg" - -}, -{ - "short": "QA", - "name": "卡塔尔", - "en": "Qatar", - "tel": "974", - "pinyin": "kte" - -}, -{ - "short": "", - "name": "留尼旺", - "en": "Reunion", - "tel": "262", - "pinyin": "lnw" - -}, -{ - "short": "RO", - "name": "罗马尼亚", - "en": "Romania", - "tel": "40", - "pinyin": "lmny" - -}, -{ - "short": "RU", - "name": "俄罗斯", - "en": "Russia", - "tel": "7", - "pinyin": "els" - -}, -{ - "short": "SA", - "name": "沙特阿拉伯", - "en": "SaudiArabia", - "tel": "966", - "pinyin": "stalb" - -}, -{ - "short": "SB", - "name": "所罗门群岛", - "en": "SolomonIs", - "tel": "677", - "pinyin": "slmqd" - -}, -{ - "short": "SC", - "name": "塞舌尔", - "en": "Seychelles", - "tel": "248", - "pinyin": "sse" - -}, -{ - "short": "SD", - "name": "苏丹", - "en": "Sudan", - "tel": "249", - "pinyin": "sd" - -}, -{ - "short": "SE", - "name": "瑞典", - "en": "Sweden", - "tel": "46", - "pinyin": "rd" - -}, -{ - "short": "SG", - "name": "新加坡", - "en": "Singapore", - "tel": "65", - "pinyin": "xjp" - -}, -{ - "short": "SI", - "name": "斯洛文尼亚", - "en": "Slovenia", - "tel": "386", - "pinyin": "slwny" - -}, -{ - "short": "SK", - "name": "斯洛伐克", - "en": "Slovakia", - "tel": "421", - "pinyin": "slfk" - -}, -{ - "short": "SL", - "name": "塞拉利昂", - "en": "SierraLeone", - "tel": "232", - "pinyin": "slla" - -}, -{ - "short": "SM", - "name": "圣马力诺", - "en": "SanMarino", - "tel": "378", - "pinyin": "smln" - -}, -{ - "short": "", - "name": "东萨摩亚(美)", - "en": "SamoaEastern", - "tel": "684", - "pinyin": "dsmym" - -}, -{ - "short": "", - "name": "西萨摩亚", - "en": "SanMarino", - "tel": "685", - "pinyin": "xsmy" - -}, -{ - "short": "SN", - "name": "塞内加尔", - "en": "Senegal", - "tel": "221", - "pinyin": "snje" - -}, -{ - "short": "SO", - "name": "索马里", - "en": "Somali", - "tel": "252", - "pinyin": "sml" - -}, -{ - "short": "SR", - "name": "苏里南", - "en": "Suriname", - "tel": "597", - "pinyin": "sln" - -}, -{ - "short": "ST", - "name": "圣多美和普林西比", - "en": "SaoTomeandPrincipe", - "tel": "239", - "pinyin": "sdmhplxb" - -}, -{ - "short": "SV", - "name": "萨尔瓦多", - "en": "EISalvador", - "tel": "503", - "pinyin": "sewd" - -}, -{ - "short": "SY", - "name": "叙利亚", - "en": "Syria", - "tel": "963", - "pinyin": "xly" - -}, -{ - "short": "SZ", - "name": "斯威士兰", - "en": "Swaziland", - "tel": "268", - "pinyin": "swsl" - -}, -{ - "short": "TD", - "name": "乍得", - "en": "Chad", - "tel": "235", - "pinyin": "zd" - -}, -{ - "short": "TG", - "name": "多哥", - "en": "Togo", - "tel": "228", - "pinyin": "dg" - -}, -{ - "short": "TH", - "name": "泰国", - "en": "Thailand", - "tel": "66", - "pinyin": "tg" - -}, -{ - "short": "TJ", - "name": "塔吉克斯坦", - "en": "Tajikstan", - "tel": "992", - "pinyin": "tjkst" - -}, -{ - "short": "TM", - "name": "土库曼斯坦", - "en": "Turkmenistan", - "tel": "993", - "pinyin": "tkmst" - -}, -{ - "short": "TN", - "name": "突尼斯", - "en": "Tunisia", - "tel": "216", - "pinyin": "tns" - -}, -{ - "short": "TO", - "name": "汤加", - "en": "Tonga", - "tel": "676", - "pinyin": "tj" - -}, -{ - "short": "TR", - "name": "土耳其", - "en": "Turkey", - "tel": "90", - "pinyin": "teq" - -}, -{ - "short": "TT", - "name": "特立尼达和多巴哥", - "en": "TrinidadandTobago", - "tel": "1809", - "pinyin": "tlndhdbg" - -}, -{ - "short": "TW", - "name": "台湾(中国)", - "en": "Taiwan", - "tel": "886", - "pinyin": "twzg" - -}, -{ - "short": "TZ", - "name": "坦桑尼亚", - "en": "Tanzania", - "tel": "255", - "pinyin": "tsny" - -}, -{ - "short": "UA", - "name": "乌克兰", - "en": "Ukraine", - "tel": "380", - "pinyin": "wkl" - -}, -{ - "short": "UG", - "name": "乌干达", - "en": "Uganda", - "tel": "256", - "pinyin": "wgd" - -}, -{ - "short": "US", - "name": "美国", - "en": "UnitedStatesofAmerica", - "tel": "1", - "pinyin": "mg" - -}, -{ - "short": "UY", - "name": "乌拉圭", - "en": "Uruguay", - "tel": "598", - "pinyin": "wlg" - -}, -{ - "short": "UZ", - "name": "乌兹别克斯坦", - "en": "Uzbekistan", - "tel": "233", - "pinyin": "wzbkst" - -}, -{ - "short": "VC", - "name": "圣文森特岛", - "en": "SaintVincent", - "tel": "1784", - "pinyin": "swstd" - -}, -{ - "short": "VE", - "name": "委内瑞拉", - "en": "Venezuela", - "tel": "58", - "pinyin": "wnrl" - -}, -{ - "short": "VN", - "name": "越南", - "en": "Vietnam", - "tel": "84", - "pinyin": "yn" - -}, -{ - "short": "YE", - "name": "也门", - "en": "Yemen", - "tel": "967", - "pinyin": "ym" - -}, -{ - "short": "YU", - "name": "南斯拉夫", - "en": "Yugoslavia", - "tel": "381", - "pinyin": "nslf" - -}, -{ - "short": "ZA", - "name": "南非", - "en": "SouthAfrica", - "tel": "27", - "pinyin": "nf" - -}, -{ - "short": "ZM", - "name": "赞比亚", - "en": "Zambia", - "tel": "260", - "pinyin": "zby" - -}, -{ - "short": "ZR", - "name": "扎伊尔", - "en": "Zaire", - "tel": "243", - "pinyin": "zye" - -}, -{ - "short": "ZW", - "name": "津巴布韦", - "en": "Zimbabwe", - "tel": "263", - "pinyin": "jbbw" - -} -] diff --git a/star_lock/lib/login/register/starLock_register_page.dart b/star_lock/lib/login/register/starLock_register_page.dart index c65a31e9..2f6de795 100644 --- a/star_lock/lib/login/register/starLock_register_page.dart +++ b/star_lock/lib/login/register/starLock_register_page.dart @@ -77,7 +77,8 @@ class _StarLockRegisterPageState extends State { // color: Colors.red, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(30.h)), - border: Border.all(width: 1.0, color: AppColors.greyLineColor)), + border: + Border.all(width: 1.0, color: AppColors.greyLineColor)), child: Row( children: [ GestureDetector( @@ -87,16 +88,22 @@ class _StarLockRegisterPageState extends State { child: Obx(() => Container( width: 170.w, height: 60.h, - decoration: state.isIphoneType.value ? BoxDecoration( - color: AppColors.mainColor, - borderRadius: - BorderRadius.all(Radius.circular(30.h)), - border: Border.all(width: 1.0, color: AppColors.greyLineColor)):null, + decoration: state.isIphoneType.value + ? BoxDecoration( + color: AppColors.mainColor, + borderRadius: + BorderRadius.all(Radius.circular(30.h)), + border: Border.all( + width: 1.0, color: AppColors.greyLineColor)) + : null, child: Center( child: Text( - TranslationLoader.lanKeys!.iphone!.tr, - style: TextStyle(color: state.isIphoneType.value ? Colors.white : Colors.black), - )))), + TranslationLoader.lanKeys!.iphone!.tr, + style: TextStyle( + color: state.isIphoneType.value + ? Colors.white + : Colors.black), + )))), ), Expanded( child: GestureDetector( @@ -106,13 +113,23 @@ class _StarLockRegisterPageState extends State { child: Obx(() => Container( height: 60.h, // color: Colors.red, - decoration: state.isIphoneType.value ? null : BoxDecoration( - color: AppColors.mainColor, - borderRadius: - BorderRadius.all(Radius.circular(30.h)), - border: Border.all(width: 1.0, color: AppColors.greyLineColor)), + decoration: state.isIphoneType.value + ? null + : BoxDecoration( + color: AppColors.mainColor, + borderRadius: + BorderRadius.all(Radius.circular(30.h)), + border: Border.all( + width: 1.0, + color: AppColors.greyLineColor)), child: Center( - child: Text(TranslationLoader.lanKeys!.email!.tr, style: TextStyle(color: state.isIphoneType.value ? Colors.black : Colors.white),)))), + child: Text( + TranslationLoader.lanKeys!.email!.tr, + style: TextStyle( + color: state.isIphoneType.value + ? Colors.black + : Colors.white), + )))), ), ), ], @@ -124,30 +141,43 @@ class _StarLockRegisterPageState extends State { GestureDetector( onTap: () async { // Navigator.pushNamed(context, Routers.seletCountryRegionPage); - var result = await Navigator.pushNamed(context, Routers.seletCountryRegionPage); - // logic.state.countryCode.value = (result as Map)['code']; - // logic.state.countryId.value = result["countryId"]; - logic.state.countryCode.value = "+86"; - logic.state.countryId.value = "9"; - - // print("路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}"); + var result = await Navigator.pushNamed( + context, Routers.seletCountryRegionPage); + result as Map; + logic.state.countryCode.value = result['code']; + logic.state.countryId.value = result["countryId"]; + logic.state.countryName.value = result['countryName']; + print( + "路由返回值: ${result}, countryCode:${logic.state.countryCode} ,countryId:${logic.state.countryId}"); }, - child: Container( + child: SizedBox( height: 70.h, child: Row( children: [ SizedBox(width: 5.w), Expanded( - child: Text(TranslationLoader.lanKeys!.countryAndRegion!.tr, style: TextStyle(fontSize: 26.sp, color: AppColors.blackColor))), + child: Text(TranslationLoader.lanKeys!.countryAndRegion!.tr, + style: TextStyle( + fontSize: 26.sp, color: AppColors.blackColor))), SizedBox(width: 20.w), Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - Obx(() => Text(state.isIphoneType.value ? "中国+86" : "中国", textAlign: TextAlign.end, style: TextStyle(fontSize: 26.sp, color: AppColors.blackColor),)) + Obx(() => Text( + state.isIphoneType.value + ? '${logic.state.countryName} +${logic.state.countryCode}' + : "${logic.state.countryName}", + textAlign: TextAlign.end, + style: TextStyle( + fontSize: 26.sp, color: AppColors.blackColor), + )) ], ), SizedBox(width: 5.w), - Image.asset('images/icon_right.png', width: 50.w, height: 50.w, + Image.asset( + 'images/icon_right.png', + width: 50.w, + height: 50.w, ), ], ), @@ -171,10 +201,14 @@ class _StarLockRegisterPageState extends State { logic.checkNext(state.phoneOrEmailController); }, leftWidget: - // Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,), - Padding( + // Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,), + Padding( padding: EdgeInsets.only(right: 10.w, left: 5.w), - child: Image.asset('images/icon_login_account.png', width: 30.w, height: 30.w,), + child: Image.asset( + 'images/icon_login_account.png', + width: 30.w, + height: 30.w, + ), ), hintText: TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, keyboardType: TextInputType.number, @@ -191,7 +225,11 @@ class _StarLockRegisterPageState extends State { isPwd: true, leftWidget: Padding( padding: EdgeInsets.only(right: 10.w, left: 5.w), - child: Image.asset('images/icon_login_password.png', width: 30.w, height: 30.w,), + child: Image.asset( + 'images/icon_login_password.png', + width: 30.w, + height: 30.w, + ), ), hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.password!.tr}", @@ -213,7 +251,11 @@ class _StarLockRegisterPageState extends State { isPwd: true, leftWidget: Padding( padding: EdgeInsets.only(right: 10.w, left: 5.w), - child: Image.asset('images/icon_login_password.png', width: 30.w, height: 30.w,), + child: Image.asset( + 'images/icon_login_password.png', + width: 30.w, + height: 30.w, + ), ), hintText: "${TranslationLoader.lanKeys!.sure!.tr}${TranslationLoader.lanKeys!.password!.tr}", @@ -236,7 +278,8 @@ class _StarLockRegisterPageState extends State { height: 30.w, ), ), - hintText: "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}", + hintText: + "${TranslationLoader.lanKeys!.pleaseEnter!.tr}${TranslationLoader.lanKeys!.verificationCode!.tr}", inputFormatters: [ LengthLimitingTextInputFormatter(20), ]), @@ -245,27 +288,39 @@ class _StarLockRegisterPageState extends State { width: 20.w, ), Obx(() => GestureDetector( - onTap: state.phoneOrEmailStrIsOK.value ? () async { - // Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); - var result = await Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); - logic.state.xWidth.value = (result as Map)['xWidth']; - logic.sendValidationCode(); - }:null, - child: Container( - width: 180.w, - height: 60.h, - padding: EdgeInsets.all(5.h), - decoration: BoxDecoration( - color: state.phoneOrEmailStrIsOK.value ? AppColors.mainColor : Colors.grey, - borderRadius: BorderRadius.circular(5)), - child: Center( - child: Text( - state.btnText.value, - textAlign: TextAlign.center, - style: TextStyle(color: Colors.white, fontSize: 26.sp,)), - ), - ), - )) + onTap: state.phoneOrEmailStrIsOK.value + ? () async { + // Navigator.pushNamed(context, Routers.safetyVerificationPage, arguments: {"countryCode":"+86", "account":state.phoneOrEmailStr.value}); + var result = await Navigator.pushNamed( + context, Routers.safetyVerificationPage, + arguments: { + "countryCode": state.countryCode, + "account": state.phoneOrEmailStr.value + }); + logic.state.xWidth.value = + (result as Map)['xWidth']; + logic.sendValidationCode(); + } + : null, + child: Container( + width: 180.w, + height: 60.h, + padding: EdgeInsets.all(5.h), + decoration: BoxDecoration( + color: state.phoneOrEmailStrIsOK.value + ? AppColors.mainColor + : Colors.grey, + borderRadius: BorderRadius.circular(5)), + child: Center( + child: Text(state.btnText.value, + textAlign: TextAlign.center, + style: TextStyle( + color: Colors.white, + fontSize: 26.sp, + )), + ), + ), + )) ], ), SizedBox(height: 50.w), diff --git a/star_lock/lib/login/register/starLock_register_state.dart b/star_lock/lib/login/register/starLock_register_state.dart index 50e61ca1..1f23e1e0 100644 --- a/star_lock/lib/login/register/starLock_register_state.dart +++ b/star_lock/lib/login/register/starLock_register_state.dart @@ -11,7 +11,8 @@ class StarLockRegisterState { final TextEditingController codeController = TextEditingController(); var countryCode = '+86'.obs; - var countryId = '9'.obs; + var countryId = '1'.obs; + var countryName = '中国'.obs; var phoneOrEmailStr = ''.obs; var phoneOrEmailStrIsOK = false.obs; var pwd = ''.obs; diff --git a/star_lock/lib/login/seletCountryRegion/common/countries_model.dart b/star_lock/lib/login/seletCountryRegion/common/countries_model.dart deleted file mode 100644 index f1e49d4c..00000000 --- a/star_lock/lib/login/seletCountryRegion/common/countries_model.dart +++ /dev/null @@ -1,54 +0,0 @@ -import 'package:azlistview/azlistview.dart'; - -import 'index.dart'; - -class CountriesModel extends ISuspensionBean { - String? short; - late String name; - String? en; - late String tel; - String? pinyin; - String? tagIndex; - - CountriesModel( - {this.short, - required this.name, - this.en, - required this.tel, - this.pinyin, - this.tagIndex}); - - CountriesModel.fromJson(Map json) { - if (json["short"] is String) { - short = json["short"]; - } - if (json["name"] is String) { - name = json["name"]; - } - if (json["en"] is String) { - en = json["en"]; - } - if (json["tel"] is String) { - tel = json["tel"]; - } - if (json["pinyin"] is String) { - pinyin = json["pinyin"]; - } - } - - Map toJson() { - final Map data = {}; - data["short"] = short; - data["name"] = name; - data["en"] = en; - data["tel"] = tel; - data["pinyin"] = pinyin; - return data; - } - - @override - String getSuspensionTag() => tagIndex!; - - @override - String toString() => json.encode(this); -} diff --git a/star_lock/lib/login/seletCountryRegion/common/countryRegionEntity.dart b/star_lock/lib/login/seletCountryRegion/common/countryRegionEntity.dart new file mode 100644 index 00000000..48e448ee --- /dev/null +++ b/star_lock/lib/login/seletCountryRegion/common/countryRegionEntity.dart @@ -0,0 +1,81 @@ +import 'dart:convert'; + +import 'package:azlistview/azlistview.dart'; + +class CountryRegionEntity { + int? errorCode; + String? description; + String? errorMsg; + List? dataList; + + CountryRegionEntity( + {this.errorCode, this.description, this.errorMsg, this.dataList}); + + CountryRegionEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + if (json['data'] != null) { + dataList = []; + json['data'].forEach((v) { + dataList!.add(CountryRegionModel.fromJson(v)); + }); + } + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (dataList != null) { + data['data'] = dataList!.map((v) => v.toJson()).toList(); + } + return data; + } +} + +class CountryRegionModel extends ISuspensionBean { + int? countryId; + String? name; + String? code; + String? flag; + String? abbreviation; + String? group; + String? tagIndex; + + CountryRegionModel( + {this.countryId, + this.name, + this.code, + this.flag, + this.abbreviation, + this.group, + this.tagIndex}); + + CountryRegionModel.fromJson(Map json) { + countryId = json['countryId']; + name = json['name']; + code = json['code']; + flag = json['flag']; + abbreviation = json['abbreviation']; + group = json['group']; + } + + Map toJson() { + final Map data = {}; + data['countryId'] = countryId; + data['name'] = name; + data['code'] = code; + data['flag'] = flag; + data['abbreviation'] = abbreviation; + data['group'] = group; + return data; + } + + @override + String getSuspensionTag() => tagIndex!; + + @override + String toString() => json.encode(this); +} diff --git a/star_lock/lib/login/seletCountryRegion/common/models.dart b/star_lock/lib/login/seletCountryRegion/common/models.dart deleted file mode 100644 index e0324ca4..00000000 --- a/star_lock/lib/login/seletCountryRegion/common/models.dart +++ /dev/null @@ -1,108 +0,0 @@ -import 'dart:convert'; - -import 'package:azlistview/azlistview.dart'; -import 'package:flutter/material.dart'; - -class CityModel extends ISuspensionBean { - String name; - String? tagIndex; - String? namePinyin; - - CityModel({ - required this.name, - this.tagIndex, - this.namePinyin, - }); - - CityModel.fromJson(Map json) : name = json['name']; - - Map toJson() => { - 'name': name, -// 'tagIndex': tagIndex, -// 'namePinyin': namePinyin, -// 'isShowSuspension': isShowSuspension - }; - - @override - String getSuspensionTag() => tagIndex!; - - @override - String toString() => json.encode(this); -} - -class ContactInfo extends ISuspensionBean { - String name; - String? tagIndex; - String? namePinyin; - - Color? bgColor; - IconData? iconData; - - String? img; - String? id; - String? firstletter; - - ContactInfo({ - required this.name, - this.tagIndex, - this.namePinyin, - this.bgColor, - this.iconData, - this.img, - this.id, - this.firstletter, - }); - - ContactInfo.fromJson(Map json) - : name = json['name'], - img = json['img'], - id = json['id']?.toString(), - firstletter = json['firstletter']; - - Map toJson() => { -// 'id': id, - 'name': name, - 'img': img, -// 'firstletter': firstletter, -// 'tagIndex': tagIndex, -// 'namePinyin': namePinyin, -// 'isShowSuspension': isShowSuspension - }; - - @override - String getSuspensionTag() => tagIndex!; - - @override - String toString() => json.encode(this); -} - -// class Languages extends GithubLanguage with ISuspensionBean { -// String? tagIndex; -// String? pinyin; -// String? shortPinyin; - -// Languages.fromJson(Map json) : super.fromJson(json); - -// @override -// Map toJson() { -// final Map map = super.toJson(); -// void addIfNonNull(String fieldName, dynamic value) { -// if (value != null) { -// map[fieldName] = value; -// } -// } - -// // addIfNonNull('tagIndex', tagIndex); -// return map; -// } - -// @override -// String getSuspensionTag() { -// return tagIndex!; -// } - -// @override -// String toString() { -// return json.encode(this); -// } -// } diff --git a/star_lock/lib/login/seletCountryRegion/common/utils.dart b/star_lock/lib/login/seletCountryRegion/common/utils.dart index 4c12483d..f3eea6f5 100644 --- a/star_lock/lib/login/seletCountryRegion/common/utils.dart +++ b/star_lock/lib/login/seletCountryRegion/common/utils.dart @@ -1,13 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:star_lock/app_settings/app_colors.dart'; -import 'package:star_lock/login/seletCountryRegion/common/countries_model.dart'; -import 'package:star_lock/login/seletCountryRegion/common/models.dart'; - -import 'index.dart'; +import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart'; class Utils { - static String getImgPath(String name, {String format: 'png'}) { + static String getImgPath(String name, {String format = 'png'}) { return 'assets/images/$name.$format'; } @@ -15,7 +12,7 @@ class Utils { ScaffoldMessenger.of(context).showSnackBar( SnackBar( content: Text(msg), - duration: Duration(seconds: 2), + duration: const Duration(seconds: 2), ), ); } @@ -42,7 +39,8 @@ class Utils { ); } - static Widget getListItem(BuildContext context, CountriesModel model, + static Widget getListItem( + BuildContext context, CountryRegionModel model, Function() onClick, {double susHeight = 40}) { return GestureDetector( child: SizedBox( @@ -54,7 +52,7 @@ class Utils { width: 20.w, ), Text( - model.name, + model.name!, style: TextStyle( color: AppColors.darkGrayTextColor, fontSize: 24.sp), ), @@ -63,7 +61,7 @@ class Utils { width: 30.w, )), Text( - '+${model.tel}', + '+${model.code}', style: TextStyle(color: AppColors.blackColor, fontSize: 22.sp), ), SizedBox( @@ -71,99 +69,11 @@ class Utils { ) ], ), - // Divider( - // height: 1, - // color: AppColors.greyLineColor, - // endIndent: 0, - // indent: 20.w, - // ) ), onTap: () { - LogUtil.e("onItemClick : $model"); - Utils.showSnackBar(context, 'onItemClick : ${model.name}'); - }, - ); - - // return ListTile( - // title: Text('${model.name} +${model.tel}'), - // onTap: () { - // LogUtil.e("onItemClick : $model"); - // Utils.showSnackBar(context, 'onItemClick : ${model.name}'); - // }, - // ); -// return Column( -// mainAxisSize: MainAxisSize.min, -// children: [ -// Offstage( -// offstage: !(model.isShowSuspension == true), -// child: getSusItem(context, model.getSuspensionTag(), -// susHeight: susHeight), -// ), -// ListTile( -// title: Text(model.name), -// onTap: () { -// LogUtil.e("onItemClick : $model"); -// Utils.showSnackBar(context, 'onItemClick : ${model.name}'); -// }, -// ) -// ], -// ); - } - - static Widget getWeChatListItem( - BuildContext context, - ContactInfo model, { - double susHeight = 40, - Color? defHeaderBgColor, - }) { - return getWeChatItem(context, model, defHeaderBgColor: defHeaderBgColor); -// return Column( -// mainAxisSize: MainAxisSize.min, -// children: [ -// Offstage( -// offstage: !(model.isShowSuspension == true), -// child: getSusItem(context, model.getSuspensionTag(), -// susHeight: susHeight), -// ), -// getWeChatItem(context, model, defHeaderBgColor: defHeaderBgColor), -// ], -// ); - } - - static Widget getWeChatItem( - BuildContext context, - ContactInfo model, { - Color? defHeaderBgColor, - }) { - DecorationImage? image; -// if (model.img != null && model.img.isNotEmpty) { -// image = DecorationImage( -// image: CachedNetworkImageProvider(model.img), -// fit: BoxFit.contain, -// ); -// } - return ListTile( - leading: Container( - width: 36, - height: 36, - decoration: BoxDecoration( - shape: BoxShape.rectangle, - borderRadius: BorderRadius.circular(4.0), - color: model.bgColor ?? defHeaderBgColor, - image: image, - ), - child: model.iconData == null - ? null - : Icon( - model.iconData, - color: Colors.white, - size: 20, - ), - ), - title: Text(model.name), - onTap: () { - LogUtil.e("onItemClick : $model"); - Utils.showSnackBar(context, 'onItemClick : ${model.name}'); + onClick(); + // LogUtil.e("onItemClick : $model"); + // Utils.showSnackBar(context, 'onItemClick : ${model.name}'); }, ); } diff --git a/star_lock/lib/login/seletCountryRegion/seletCountryRegion_page.dart b/star_lock/lib/login/seletCountryRegion/seletCountryRegion_page.dart index a4874b25..52847ec2 100644 --- a/star_lock/lib/login/seletCountryRegion/seletCountryRegion_page.dart +++ b/star_lock/lib/login/seletCountryRegion/seletCountryRegion_page.dart @@ -2,11 +2,13 @@ import 'package:azlistview/azlistview.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:get/get.dart'; +import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; import '../../app_settings/app_colors.dart'; import '../../tools/titleAppBar.dart'; import '../../translations/trans_lib.dart'; -import 'common/countries_model.dart'; import 'common/index.dart'; class SeletCountryRegionPage extends StatefulWidget { @@ -17,7 +19,7 @@ class SeletCountryRegionPage extends StatefulWidget { } class _SeletCountryRegionPageState extends State { - List countriesList = []; + List countriesList = []; @override void initState() { @@ -26,33 +28,31 @@ class _SeletCountryRegionPageState extends State { SuspensionUtil.setShowSuspensionStatus( countriesList.cast()); Future.delayed(const Duration(milliseconds: 500), () { - loadData(); + getCountriesListRequest(); + // loadData(); }); } + //请求国家/地区json文件 + Future getCountriesListRequest() async { + CountryRegionEntity entity = await ApiRepository.to.getCountryRegion('1'); + countriesList.clear(); + if (entity.errorCode!.codeIsSuccessful) { + print("国家/地区json文件成功啦啦啦啦啦"); + countriesList.addAll(entity.dataList!); + _handleList(countriesList); + } + } + Future loadJsonFromAssets(String assetsPath) async { return await rootBundle.loadString(assetsPath); } - void loadData() async { - //加载国家列表 - String jsonData = await loadJsonFromAssets('assets/countries.json'); - countriesList.clear(); - List list = json.decode(jsonData); - for (var v in list) { - countriesList.add(CountriesModel.fromJson(v)); - } - - _handleList(countriesList); - } - - void _handleList(List list) { + void _handleList(List list) { if (list.isEmpty) return; for (int i = 0, length = list.length; i < length; i++) { - CountriesModel countryModel = list[i]; - // String pinyin = PinyinHelper.getPinyinE(list[i].name); - String tag = countryModel.pinyin!.substring(0, 1).toUpperCase(); - // list[i].pinyin = pinyin; + CountryRegionModel countryModel = list[i]; + String tag = countryModel.group!; if (RegExp('[A-Z]').hasMatch(tag)) { list[i].tagIndex = tag; } else { @@ -82,16 +82,22 @@ class _SeletCountryRegionPageState extends State { data: countriesList, itemCount: countriesList.length, itemBuilder: (BuildContext context, int index) { - CountriesModel model = countriesList[index]; - return Utils.getListItem(context, model); + CountryRegionModel model = countriesList[index]; + return Utils.getListItem(context, model, () { + Map resultMap = {}; + resultMap['code'] = model.code; + resultMap['countryId'] = model.countryId.toString(); + resultMap['countryName'] = model.name; + Navigator.pop(context, resultMap); + }); }, padding: EdgeInsets.zero, susItemBuilder: (BuildContext context, int index) { - CountriesModel model = countriesList[index]; + CountryRegionModel model = countriesList[index]; String tag = model.getSuspensionTag(); return Utils.getSusItem(context, tag); }, - indexBarData: ['★', ...kIndexBarData], + indexBarData: const ['★', ...kIndexBarData], ), ); } diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart index fa670e53..162ef5fb 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdmin/authorizedAdmin_page.dart @@ -1,8 +1,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; +import 'package:flutter_pickers/pickers.dart'; +import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -22,15 +26,31 @@ class _AuthorizedAdminPageState extends State { final FlutterContactPicker _contactPicker = FlutterContactPicker(); late Contact _contact; - @override - Widget build(BuildContext context) { - return indexChangeWidget(); - } + // bool _isRemoteUnlock = false; //是否允许远程开锁 + bool _isAuthentication = false; //是否可以实名认证 + var _selectEffectiveDate = ''; //生效时间 + var _selectFailureDate = ''; //失效时间 + final TextEditingController _emailOrPhoneController = + TextEditingController(); //邮箱/手机号输入框 + final TextEditingController _keyNameController = + TextEditingController(); //钥匙名输入框 + late bool _isSendSuccess; @override void initState() { - // TODO: implement initState super.initState(); + + DateTime dateTime = DateTime.now(); + _selectEffectiveDate = + '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 + _selectFailureDate = + '${dateTime.year}-${dateTime.month}-${dateTime.day} ${dateTime.hour}:${dateTime.minute}'; //默认为当前时间 + _isSendSuccess = false; + } + + @override + Widget build(BuildContext context) { + return indexChangeWidget(); } Widget indexChangeWidget() { @@ -70,14 +90,14 @@ class _AuthorizedAdminPageState extends State { rightTitle: "", isHaveLine: true, isHaveRightWidget: true, - rightWidget: getTFWidget( - true, TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr)), + rightWidget: getTFWidget(true, + TranslationLoader.lanKeys!.pleaseEnterNumberOrEmail!.tr, 1)), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, rightTitle: "", isHaveRightWidget: true, - rightWidget: - getTFWidget(false, TranslationLoader.lanKeys!.pleaseEnter!.tr)), + rightWidget: getTFWidget( + false, TranslationLoader.lanKeys!.pleaseEnter!.tr, 2)), Container(height: 10.h), ], ); @@ -89,18 +109,30 @@ class _AuthorizedAdminPageState extends State { children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.effectiveTime!.tr, - rightTitle: "2020.06.20 11:49", + rightTitle: _selectEffectiveDate, isHaveLine: true, isHaveDirection: true, action: () { - // _showDatePicker(); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + _selectEffectiveDate = + '${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}'; + }); + }); }), CommonItem( leftTitel: TranslationLoader.lanKeys!.failureTime!.tr, - rightTitle: "2020.06.20 11:49", + rightTitle: _selectFailureDate, isHaveDirection: true, action: () { - // _showDatePicker(); + Pickers.showDatePicker(context, mode: DateMode.YMDHM, + onConfirm: (p) { + setState(() { + _selectFailureDate = + '${p.year}-${p.month}-${p.day} ${p.hour}:${p.minute}'; + }); + }); }), Container(height: 10.h), ], @@ -143,7 +175,15 @@ class _AuthorizedAdminPageState extends State { SizedBox( height: 20.h, ), - SubmitBtn(btnName: TranslationLoader.lanKeys!.send!.tr, onClick: () {}), + SubmitBtn( + btnName: TranslationLoader.lanKeys!.send!.tr, + onClick: () { + //发送钥匙请求 + if (_emailOrPhoneController.text.isNotEmpty && + _keyNameController.text.isNotEmpty) { + sendElectronicKeyRequest(); + } + }), Container( padding: EdgeInsets.only(right: 30.w), // color: Colors.red, @@ -241,8 +281,8 @@ class _AuthorizedAdminPageState extends State { } // 接受者信息输入框 - Widget getTFWidget(bool isHaveBtn, String tfStr) { - return Container( + Widget getTFWidget(bool isHaveBtn, String tfStr, int lineIndex) { + return SizedBox( height: 50.h, width: 300.w, child: Row( @@ -251,7 +291,8 @@ class _AuthorizedAdminPageState extends State { child: TextField( //输入框一行 maxLines: 1, - // controller: _controller, + controller: + lineIndex == 1 ? _emailOrPhoneController : _keyNameController, autofocus: false, textAlign: TextAlign.end, decoration: InputDecoration( @@ -295,27 +336,52 @@ class _AuthorizedAdminPageState extends State { ); } - CupertinoSwitch _switch() { - /* - return Switch( - value: false, - onChanged: (value){ - // switchValue = !switchValue; - setState(() { + //发送钥匙请求 + Future sendElectronicKeyRequest() async { + String getFailureDateTime = '0'; + String getEffectiveDateTime = '0'; + String deviceID = '28'; + String getKeyType = (int.parse(widget.type) + 1).toString(); + if (widget.type == '0') { + getFailureDateTime = + DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString(); + getEffectiveDateTime = DateTime.parse(_selectEffectiveDate) + .millisecondsSinceEpoch + .toString(); + } + var entity = await ApiRepository.to.sendElectronicKey( + '0', + '0', + '1', + getFailureDateTime, + _isAuthentication == true ? '1' : '2', + '2', + '2', + _keyNameController.text, + '1', + getKeyType, + deviceID, + '小吴副号', + _emailOrPhoneController.text, + '0', + getEffectiveDateTime, []); + if (entity.errorCode!.codeIsSuccessful) { + print('发送电子钥匙成功'); + _isSendSuccess = true; + setState(() {}); + } + } - }); - } - ); - */ - bool _isOn = false; +//实名认证 + CupertinoSwitch _switch() { return CupertinoSwitch( activeColor: CupertinoColors.activeBlue, trackColor: CupertinoColors.systemGrey5, thumbColor: CupertinoColors.white, - value: _isOn, + value: _isAuthentication, onChanged: (value) { setState(() { - _isOn = value; + _isAuthentication = value; }); }, ); diff --git a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart index 5f4ea104..f76eb6cf 100644 --- a/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart +++ b/star_lock/lib/main/lockDetail/authorizedAdmin/authorizedAdminList/authorizedAdminList_page.dart @@ -28,40 +28,52 @@ class _AuthorizedAdminListPageState extends State { barTitle: TranslationLoader.lanKeys!.authorizedAdmin!.tr, haveBack: true, backgroundColor: AppColors.mainColor, - // actionsList: [ - // TextButton( - // child: Text( - // TranslationLoader.lanKeys!.reset!.tr, - // style: TextStyle(color: Colors.white, fontSize: 24.sp), - // ), - // onPressed: () {}, - // ), - // ], - ), - body: Column( - children: [ - Expanded(child: _buildMainUI()), - SizedBox( - height: 20.h, - ), - AddBottomWhiteBtn( - btnName: TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, - onClick: () { - Navigator.pushNamed(context, Routers.authorizedAdminManagePage); - }, - ), - SizedBox( - height: 64.h, - ) - ], ), + body: FutureBuilder>( + future: mockNetworkDataRequest(), + builder: (BuildContext context, + AsyncSnapshot> snapshot) { + //请求结束 + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + //请求失败 + return const Text('请求失败'); + } else { + //请求成功 + final List itemData = snapshot.data!; + + return Column( + children: [ + Expanded(child: _buildMainUI(itemData)), + SizedBox( + height: 20.h, + ), + AddBottomWhiteBtn( + btnName: + TranslationLoader.lanKeys!.addAuthorizedAdmin!.tr, + onClick: () { + Navigator.pushNamed( + context, Routers.authorizedAdminManagePage); + }, + ), + SizedBox( + height: 64.h, + ) + ], + ); + } + } else { + //请求未结束 显示loading + return Container(); + } + }), ); } - //请求电子钥匙列表 + //请求授权管理员列表 跟电子钥匙列表的接口一样,但必须在参数中加keyRight=1为授权管理员 Future> mockNetworkDataRequest() async { ElectronicKeyListEntity entity = await ApiRepository.to - .electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0'); + .electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0', '1'); if (entity.errorCode!.codeIsSuccessful) { print("电子钥匙列表成功:${entity.data?.itemList}"); } @@ -73,20 +85,89 @@ class _AuthorizedAdminListPageState extends State { } } - Widget _buildMainUI() { + Widget _buildMainUI(itemData) { + List getItemData = itemData; return ListView.builder( - itemCount: 5, + itemCount: getItemData.length, itemBuilder: (c, index) { - return _electronicKeyItem('images/controls_user.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { + ElectronicKeyListItem indexEntity = getItemData[index]; + String useDateStr = ''; //使用期限 + String keyStatus = ''; //钥匙状态 + + //使用期限 + useDateStr = getUseDateStr(indexEntity); + + //钥匙状态 + keyStatus = getKeyStatus(indexEntity.keyStatus); + + //是否为管理钥匙 + bool isAdminKey = false; + if (indexEntity.keyRight == 1) { + isAdminKey = true; + } else { + isAdminKey = false; + } + return _electronicKeyItem('images/controls_user.png', + indexEntity.keyName!, useDateStr, keyStatus, isAdminKey, () { // Navigator.pushNamed(context, Routers.authorizedAdminDetailPage); Navigator.pushNamed(context, Routers.electronicKeyDetailPage); }); }); } - Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function() action) { + //使用期限 + String getUseDateStr(ElectronicKeyListItem indexEntity) { + String useDateStr = ''; + if (indexEntity.keyType == 1) { + //限期 + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; + } else if (indexEntity.keyType == 2) { + //永久 + DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久'; + } else if (indexEntity.keyType == 3) { + //单次 + DateTime dateStr = DateTime.fromMillisecondsSinceEpoch(indexEntity.date!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次'; + } else if (indexEntity.keyType == 4) { + //循环 + useDateStr = '循环'; + } + + return useDateStr; + } + +//钥匙状态 + String getKeyStatus(int? keyStatusFlag) { + String keyStatus = ''; + + if (keyStatusFlag == 110401) { + //正常使用 + keyStatus = ''; + } else if (keyStatusFlag == 110402) { + //待接收 + keyStatus = '待接收'; + } else if (keyStatusFlag == 110405) { + //已冻结 + keyStatus = '已冻结'; + } else if (keyStatusFlag == 110408) { + //已删除 + keyStatus = '已删除'; + } else if (keyStatusFlag == 110410) { + //已重置 + keyStatus = '已重置'; + } + + return keyStatus; + } + + Widget _electronicKeyItem(String avatarURL, String receiveUser, + String useDate, String keyStatus, bool isAdminKey, Function() action) { return GestureDetector( onTap: action, child: Container( @@ -102,7 +183,7 @@ class _AuthorizedAdminListPageState extends State { width: 30.w, ), Image.asset( - lockTypeIcon, + avatarURL, width: 60.w, height: 60.w, ), @@ -117,7 +198,7 @@ class _AuthorizedAdminListPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - lockTypeTitle, + receiveUser, style: TextStyle( fontSize: 24.sp, color: AppColors.blackColor), ), @@ -132,7 +213,7 @@ class _AuthorizedAdminListPageState extends State { borderRadius: BorderRadius.circular(5.0), ), child: Text( - '待接收', + keyStatus, style: TextStyle(color: Colors.red, fontSize: 16.sp), ), ) @@ -143,7 +224,7 @@ class _AuthorizedAdminListPageState extends State { mainAxisAlignment: MainAxisAlignment.start, children: [ Text( - "2023.6.21 11.15 永久", + useDate, style: TextStyle( fontSize: 18.sp, color: AppColors.placeholderTextColor), diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart index 9ad70cc0..c2d82182 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyDetail/electronicKeyDetail/electronicKeyDetail_page.dart @@ -2,8 +2,12 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; import 'package:star_lock/tools/jh_pop_menus.dart'; +import 'package:star_lock/tools/toast.dart'; import '../../../../../appRouters.dart'; import '../../../../../app_settings/app_colors.dart'; @@ -23,11 +27,10 @@ class ElectronicKeyDetailPage extends StatefulWidget { class _ElectronicKeyDetailPageState extends State { final TextEditingController _changeNameController = TextEditingController(); + ElectronicKeyListItem itemData = ElectronicKeyListItem(); @override Widget build(BuildContext context) { - ElectronicKeyListItem itemData = ElectronicKeyListItem(); - dynamic obj = ModalRoute.of(context)?.settings.arguments; if (obj != null && (obj["itemData"] != null)) { itemData = obj["itemData"]; @@ -63,7 +66,9 @@ class _ElectronicKeyDetailPageState extends State { children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: itemData.keyName, + rightTitle: _changeNameController.text.isNotEmpty + ? _changeNameController.text + : itemData.keyName, isHaveDirection: true, isHaveLine: true, action: () { @@ -230,15 +235,42 @@ class _ElectronicKeyDetailPageState extends State { ); } - void showCupertinoAlertDialog(BuildContext context) { + //修改钥匙名称请求 + Future modifyKeyNameRequest() async { + KeyOperationRecordEntity entity = await ApiRepository.to + .modifyKeyNameForAdmin( + itemData.keyId.toString(), _changeNameController.text, '0'); + if (entity.errorCode!.codeIsSuccessful) { + print("修改要是名称成功啦啦啦啦啦"); + Toast.show(msg: "修改成功"); + setState(() { + Navigator.pop(context); + }); + } + } + + void showCupertinoAlertDialog( + BuildContext context, + ) { showDialog( - context: context, - builder: (BuildContext context) { - return ShowTFView( - title: - "${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}", - tipTitle: "请输入", - controller: _changeNameController); - }); + context: context, + builder: (BuildContext context) { + return ShowTFView( + title: + "${TranslationLoader.lanKeys!.amend!.tr} ${TranslationLoader.lanKeys!.name!.tr}", + tipTitle: "请输入", + controller: _changeNameController, + sureClick: () { + //发送编辑钥匙名称请求 + if (_changeNameController.text.isNotEmpty) { + modifyKeyNameRequest(); + } + }, + cancelClick: () { + Navigator.pop(context); + }, + ); + }, + ); } } diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart index 2576ea4f..59a94de1 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_logic.dart @@ -7,7 +7,7 @@ class ElectronicKeyListLogic { late ElectronicKeyListEntity dataEntity = ElectronicKeyListEntity(); void electronicKeyList() async { var entity = await ApiRepository.to - .electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0'); + .electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0', '0'); if (entity.errorCode!.codeIsSuccessful) { print("电子钥匙列表成功:${entity.data?.itemList}"); dataEntity = entity; diff --git a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart index 965d8d51..990db641 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/electronicKeyList/electronicKeyList_page.dart @@ -27,7 +27,7 @@ class _ElectronicKeyListPageState extends State { //请求电子钥匙列表 Future> mockNetworkDataRequest() async { ElectronicKeyListEntity entity = await ApiRepository.to - .electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0'); + .electronicKeyList('0', '63', '0', '28', '1', '1', '20', '0', '0'); if (entity.errorCode!.codeIsSuccessful) { print("电子钥匙列表成功:${entity.data?.itemList}"); } diff --git a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart index 5a47b2d4..54059186 100644 --- a/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart +++ b/star_lock/lib/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_page.dart @@ -3,13 +3,12 @@ import 'package:flutter/material.dart'; import 'package:flutter_pickers/pickers.dart'; import 'package:flutter_pickers/time_picker/model/date_mode.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; -import 'package:fluttertoast/fluttertoast.dart'; import 'package:get/get.dart'; import 'package:star_lock/app_settings/app_colors.dart'; import 'package:flutter_native_contact_picker/flutter_native_contact_picker.dart'; -import 'package:star_lock/main/lockDetail/electronicKey/sendElectronicKey/sendElectronicKey/sendElectronicKey_logic.dart'; import 'package:star_lock/network/api_repository.dart'; import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; import '../../../../../appRouters.dart'; import '../../../../../tools/commonItem.dart'; @@ -34,8 +33,8 @@ class _SendElectronicKeyPageState extends State { bool _isRemoteUnlock = false; //是否允许远程开锁 bool _isAuthentication = false; //是否可以实名认证 - var _selectEffectiveDate = ''; //生效时间 - var _selectFailureDate = ''; //失效时间 + String _selectEffectiveDate = ''; //生效时间 + String _selectFailureDate = ''; //失效时间 TextEditingController emailOrPhoneController = TextEditingController(); //邮箱/手机号输入框 TextEditingController keyNameController = TextEditingController(); //钥匙名输入框 @@ -277,13 +276,10 @@ class _SendElectronicKeyPageState extends State { String getKeyType = (int.parse(widget.type) + 1).toString(); if (widget.type == '0') { getFailureDateTime = - DateTime.fromMillisecondsSinceEpoch(int.parse(_selectFailureDate)) - .toString() - .substring(0, 19); - getEffectiveDateTime = - DateTime.fromMillisecondsSinceEpoch(int.parse(_selectEffectiveDate)) - .toString() - .substring(0, 19); + DateTime.parse(_selectFailureDate).millisecondsSinceEpoch.toString(); + getEffectiveDateTime = DateTime.parse(_selectEffectiveDate) + .millisecondsSinceEpoch + .toString(); } var entity = await ApiRepository.to.sendElectronicKey( '0', @@ -305,9 +301,21 @@ class _SendElectronicKeyPageState extends State { print('发送电子钥匙成功'); _isSendSuccess = true; setState(() {}); + } else { + Toast.show(msg: '${entity.errorMsg}'); } } + ///日期转时间戳 + static int dateToTimestamp(String date, {isMicroseconds = false}) { + DateTime dateTime = DateTime.parse(date); + int timestamp = dateTime.millisecondsSinceEpoch; + if (isMicroseconds) { + timestamp = dateTime.microsecondsSinceEpoch; + } + return timestamp; + } + // 发送电子钥匙成功 Widget sendElectronicKeySucceed() { return Column( @@ -471,4 +479,8 @@ class _SendElectronicKeyPageState extends State { }, ); } + + String intToStr(int v) { + return (v < 10) ? "0$v" : "$v"; + } } diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart index 9c9009e9..60857039 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyDetail/passwordKeyDetail_page.dart @@ -2,6 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import 'package:star_lock/tools/shareModule/sharePopup.dart'; import '../../../../appRouters.dart'; @@ -19,8 +20,15 @@ class PasswordKeyDetailPage extends StatefulWidget { } class _PasswordKeyDetailPageState extends State { + PasswordKeyListItem itemData = PasswordKeyListItem(); + @override Widget build(BuildContext context) { + dynamic obj = ModalRoute.of(context)?.settings.arguments; + if (obj != null && (obj["itemData"] != null)) { + itemData = obj["itemData"]; + } + return Scaffold( backgroundColor: AppColors.mainBackgroundColor, appBar: TitleAppBar( @@ -51,7 +59,7 @@ class _PasswordKeyDetailPageState extends State { children: [ CommonItem( leftTitel: TranslationLoader.lanKeys!.password!.tr, - rightTitle: "98765432", + rightTitle: itemData.keyboardPwd, isHaveDirection: true, isHaveLine: true, action: () { @@ -59,7 +67,7 @@ class _PasswordKeyDetailPageState extends State { }), CommonItem( leftTitel: TranslationLoader.lanKeys!.name!.tr, - rightTitle: "你好", + rightTitle: itemData.keyboardPwdName, isHaveDirection: true, isHaveLine: true, action: () { @@ -76,11 +84,11 @@ class _PasswordKeyDetailPageState extends State { Container(height: 10.h), CommonItem( leftTitel: TranslationLoader.lanKeys!.sender!.tr, - rightTitle: "15080825640", + rightTitle: itemData.senderUsername, action: () {}), CommonItem( leftTitel: TranslationLoader.lanKeys!.senderTime!.tr, - rightTitle: "2020.06.21 11:49", + rightTitle: itemData.sendDate.toString(), action: () {}), Container(height: 10.h), CommonItem( diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart new file mode 100644 index 00000000..fd8506d9 --- /dev/null +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart @@ -0,0 +1,134 @@ +class PasswordKeyListEntity { + int? errorCode; + String? description; + String? errorMsg; + PasswordKeyListData? data; + + PasswordKeyListEntity( + {this.errorCode, this.description, this.errorMsg, this.data}); + + PasswordKeyListEntity.fromJson(Map json) { + errorCode = json['errorCode']; + description = json['description']; + errorMsg = json['errorMsg']; + data = json['data'] != null + ? PasswordKeyListData.fromJson(json['data']) + : null; + } + + Map toJson() { + final Map data = {}; + data['errorCode'] = errorCode; + data['description'] = description; + data['errorMsg'] = errorMsg; + if (this.data != null) { + data['data'] = this.data!.toJson(); + } + return data; + } +} + +class PasswordKeyListData { + List? itemList; + int? pageNo; + int? pageSize; + int? pages; + int? total; + + PasswordKeyListData( + {this.itemList, this.pageNo, this.pageSize, this.pages, this.total}); + + PasswordKeyListData.fromJson(Map json) { + if (json['list'] != null) { + itemList = []; + json['list'].forEach((v) { + itemList!.add(PasswordKeyListItem.fromJson(v)); + }); + } + pageNo = json['pageNo']; + pageSize = json['pageSize']; + pages = json['pages']; + total = json['total']; + } + + Map toJson() { + final Map data = {}; + if (itemList != null) { + data['list'] = itemList!.map((v) => v.toJson()).toList(); + } + data['pageNo'] = pageNo; + data['pageSize'] = pageSize; + data['pages'] = pages; + data['total'] = total; + return data; + } +} + +class PasswordKeyListItem { + int? apiUserId; + int? lockId; + String? keyboardPwd; + String? keyboardPwdName; + int? keyboardPwdStatus; + int? keyboardPwdType; + int? startDate; + int? endDate; + int? isCustom; + String? createdAt; + String? senderUsername; + int? keyboardPwdId; + int? sendDate; + String? validTimeStr; + + PasswordKeyListItem( + {this.apiUserId, + this.lockId, + this.keyboardPwd, + this.keyboardPwdName, + this.keyboardPwdStatus, + this.keyboardPwdType, + this.startDate, + this.endDate, + this.isCustom, + this.createdAt, + this.senderUsername, + this.keyboardPwdId, + this.sendDate, + this.validTimeStr}); + + PasswordKeyListItem.fromJson(Map json) { + apiUserId = json['apiUserId']; + lockId = json['lockId']; + keyboardPwd = json['keyboardPwd']; + keyboardPwdName = json['keyboardPwdName']; + keyboardPwdStatus = json['keyboardPwdStatus']; + keyboardPwdType = json['keyboardPwdType']; + startDate = json['startDate']; + endDate = json['endDate']; + isCustom = json['isCustom']; + createdAt = json['created_at']; + senderUsername = json['senderUsername']; + keyboardPwdId = json['keyboardPwdId']; + sendDate = json['sendDate']; + validTimeStr = json['validTimeStr']; + } + + Map toJson() { + final Map data = {}; + data['apiUserId'] = apiUserId; + data['lockId'] = lockId; + data['keyboardPwd'] = keyboardPwd; + data['keyboardPwdName'] = keyboardPwdName; + data['keyboardPwdStatus'] = keyboardPwdStatus; + data['keyboardPwdType'] = keyboardPwdType; + data['startDate'] = startDate; + data['endDate'] = endDate; + data['isCustom'] = isCustom; + data['created_at'] = createdAt; + data['senderUsername'] = senderUsername; + data['keyboardPwdId'] = keyboardPwdId; + data['sendDate'] = sendDate; + data['validTimeStr'] = validTimeStr; + return data; + } +} diff --git a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart index 5ad07fa5..cb132494 100644 --- a/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart +++ b/star_lock/lib/main/lockDetail/passwordKey/passwordKeyList/passwordKeyList_page.dart @@ -1,6 +1,10 @@ import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; +import 'package:star_lock/network/api_repository.dart'; +import 'package:star_lock/tools/baseGetXController.dart'; +import 'package:star_lock/tools/toast.dart'; import '../../../../appRouters.dart'; import '../../../../app_settings/app_colors.dart'; @@ -30,34 +34,83 @@ class _PasswordKeyListPageState extends State { TranslationLoader.lanKeys!.reset!.tr, style: TextStyle(color: Colors.white, fontSize: 24.sp), ), - onPressed: () {}, - ), - ], - ), - body: Column( - children: [ - _searchWidget(), - SizedBox( - height: 20.h, - ), - Expanded(child: _buildMainUI()), - SizedBox( - height: 20.h, - ), - AddBottomWhiteBtn( - btnName: TranslationLoader.lanKeys!.getPassword!.tr, - onClick: () { - Navigator.pushNamed(context, Routers.passwordKeyManagePage); + onPressed: () { + resetPasswordKeyListRequest(); }, ), - SizedBox( - height: 42.h, - ) ], ), + body: FutureBuilder>( + future: mockNetworkDataRequest(), + builder: (BuildContext context, + AsyncSnapshot> snapshot) { + //请求结束 + if (snapshot.connectionState == ConnectionState.done) { + if (snapshot.hasError) { + //请求失败 + return const Text('请求失败'); + } else { + //请求成功 + final List itemData = snapshot.data!; + + return Column( + children: [ + _searchWidget(), + SizedBox( + height: 20.h, + ), + Expanded(child: _buildMainUI(itemData)), + SizedBox( + height: 20.h, + ), + AddBottomWhiteBtn( + btnName: TranslationLoader.lanKeys!.getPassword!.tr, + onClick: () { + Navigator.pushNamed( + context, Routers.passwordKeyManagePage); + }, + ), + SizedBox( + height: 42.h, + ) + ], + ); + } + } else { + //请求未结束 显示loading + return Container(); + } + }), ); } + //请求密码钥匙列表 + Future> mockNetworkDataRequest() async { + PasswordKeyListEntity entity = + await ApiRepository.to.passwordKeyList('0', '28', '0', '1', '20'); + if (entity.errorCode!.codeIsSuccessful) { + print("密码钥匙列表成功:${entity.data?.itemList}"); + } + if (entity.data != null) { + return entity.data!.itemList!; + } else { + List dataList = []; + return dataList; + } + } + + //密码钥匙重置请求 + Future resetPasswordKeyListRequest() async { + PasswordKeyListEntity entity = + await ApiRepository.to.resetPasswordKey('28', '0'); + if (entity.errorCode!.codeIsSuccessful) { + print("重置电子钥匙成功啦啦啦啦啦"); + Toast.show(msg: "重置成功"); + mockNetworkDataRequest(); + setState(() {}); + } + } + Widget _searchWidget() { return Container( height: 60.h, @@ -93,13 +146,21 @@ class _PasswordKeyListPageState extends State { ); } - Widget _buildMainUI() { + Widget _buildMainUI(itemData) { + List getItemData = itemData; return ListView.separated( - itemCount: 5, + itemCount: getItemData.length, itemBuilder: (c, index) { - return _electronicKeyItem('images/icon_password.png', "张三", - "2023.6.21 11.15", "2023.6.21 11.15", () { - Navigator.pushNamed(context, Routers.passwordKeyDetailPage); + PasswordKeyListItem indexEntity = getItemData[index]; + String useDateStr = ''; //使用期限 + + //使用期限 + useDateStr = getUseDateStr(indexEntity); + + return _electronicKeyItem('images/controls_user.png', + indexEntity.keyboardPwdName!, useDateStr, () { + Navigator.pushNamed(context, Routers.passwordKeyDetailPage, + arguments: {"itemData": indexEntity}); }); }, separatorBuilder: (BuildContext context, int index) { @@ -111,8 +172,53 @@ class _PasswordKeyListPageState extends State { ); } + //使用期限 + /** +单次 1 只能在开始时间后6小时内使用一次 +永久 2 从开始时间开始永久有效,必需在开始时间24小时内使用一次,否则将失效 +限期 3 在开始和结束时间内有效,必需在开始时间24小时内使用一次,否则将失效 +删除 4 在锁上使用后会删除之前在锁上使用过的密码 +周未循环 5 在周未开始和结束时间指定时间段内有效 +每日循环 6 每天开始和结束时间指定时间段内有效 +工作日循环 7 工作日开始和结束时间指定的时间段内有效 +周一循环 8 每周一开始和结束时间指定时间段内有效 +周二循环 9 每周二开始和结束时间指定时间段内有效 +周三循环 10 每周三开始和结束时间指定时间段内有效 +周四循环 11 每周四开始和结束时间指定时间段内有效 +周五循环 12 每周五开始和结束时间指定时间段内有效 +周六循环 13 每周六开始和结束时间指定时间段内有效 +周天循环 14 每周日开始和结束时间指定时间段内有效 + */ + String getUseDateStr(PasswordKeyListItem indexEntity) { + String useDateStr = ''; + if (indexEntity.keyboardPwdType == 3) { + //限期 + DateTime startDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.startDate!); + DateTime endDateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.endDate!); + useDateStr = + '${startDateStr.toLocal().toString().substring(0, 16)}-${endDateStr.toLocal().toString().substring(0, 16)}'; + } else if (indexEntity.keyboardPwdType == 2) { + //永久 + DateTime dateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 永久'; + } else if (indexEntity.keyboardPwdType == 1) { + //单次 + DateTime dateStr = + DateTime.fromMillisecondsSinceEpoch(indexEntity.sendDate!); + useDateStr = '${dateStr.toLocal().toString().substring(0, 16)} 单次'; + } else if (indexEntity.keyboardPwdType == 4) { + //循环 + useDateStr = '循环'; + } + + return useDateStr; + } + Widget _electronicKeyItem(String lockTypeIcon, String lockTypeTitle, - String beginTime, String endTime, Function()? action) { + String useDateStr, Function()? action) { return GestureDetector( onTap: action, child: Container( @@ -147,18 +253,16 @@ class _PasswordKeyListPageState extends State { ], ), SizedBox(height: 5.h), - Container( - child: Row( - mainAxisAlignment: MainAxisAlignment.start, - children: [ - Text( - "2023.6.21 18:00 清空码", - style: TextStyle( - fontSize: 18.sp, - color: AppColors.placeholderTextColor), - ), - ], - ), + Row( + mainAxisAlignment: MainAxisAlignment.start, + children: [ + Text( + useDateStr, + style: TextStyle( + fontSize: 18.sp, + color: AppColors.placeholderTextColor), + ), + ], ), SizedBox(width: 20.h), ], diff --git a/star_lock/lib/network/api.dart b/star_lock/lib/network/api.dart index 32f71758..790c5151 100644 --- a/star_lock/lib/network/api.dart +++ b/star_lock/lib/network/api.dart @@ -18,4 +18,8 @@ abstract class Api { final String uploadElectricQuantityURL = '/room/uploadElectricQuantity'; //锁电量更新 final String modifyKeyNameURL = '/key/modifyKeyName'; //修改锁名称 + final String modifyKeyNameForAdminURL = + '/key/modifyKeyNameForAdmin'; //编辑电子钥匙名字 + final String passwordKeyListURL = '/keyboardPwd/listSendRecords'; //密码钥匙列表 + final String passwordKeyResetURL = '/keyboardPwd/reset'; //密码钥匙重置 } diff --git a/star_lock/lib/network/api_provider.dart b/star_lock/lib/network/api_provider.dart index d247f3fd..45a787eb 100644 --- a/star_lock/lib/network/api_provider.dart +++ b/star_lock/lib/network/api_provider.dart @@ -101,7 +101,8 @@ class ApiProvider extends BaseProvider { String operatorUid, String pageNo, String pageSize, - String startDate) => + String startDate, + String keyRight) => post( electronicKeyListURL.toUrl, jsonEncode({ @@ -113,6 +114,7 @@ class ApiProvider extends BaseProvider { 'pageNo': pageNo, 'pageSize': pageSize, 'startDate': startDate, + 'keyRight': keyRight })); Future sendElectronicKey( @@ -179,6 +181,19 @@ class ApiProvider extends BaseProvider { 'operatorUid': operatorUid, })); + Future modifyKeyNameForAdmin( + String keyId, + String keyNameForAdmin, + String operatorUid, + ) => + post( + modifyKeyNameForAdminURL.toUrl, + jsonEncode({ + 'keyId': keyId, + 'keyNameForAdmin': keyNameForAdmin, + 'operatorUid': operatorUid, + })); + Future resetElectronicKey(String lockId, String operatorUid) => post(resetElectronicKeyURL.toUrl, jsonEncode({'lockId': lockId, 'operatorUid': operatorUid})); @@ -210,8 +225,29 @@ class ApiProvider extends BaseProvider { 'searchStr': searchStr, 'timezoneRawOffSet': timezoneRawOffSet })); + + Future passwordKeyList( + String keyStatus, + String lockId, + String operatorUid, + String pageNo, + String pageSize, + ) => + post( + passwordKeyListURL.toUrl, + jsonEncode({ + 'keyStatus': keyStatus, + 'lockId': lockId, + 'operatorUid': operatorUid, + 'pageNo': pageNo, + 'pageSize': pageSize + })); + + Future resetPasswordKey(String lockId, String operatorUid) => post( + resetElectronicKeyURL.toUrl, + jsonEncode({'lockId': lockId, 'operatorUid': operatorUid})); } extension ExtensionString on String { - String get toUrl => '$this'; + String get toUrl => this; } diff --git a/star_lock/lib/network/api_repository.dart b/star_lock/lib/network/api_repository.dart index 1aa47825..6c485391 100644 --- a/star_lock/lib/network/api_repository.dart +++ b/star_lock/lib/network/api_repository.dart @@ -1,6 +1,8 @@ import 'package:get/get.dart'; +import 'package:star_lock/login/seletCountryRegion/common/countryRegionEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyDetail/keyOperationRecordEntity.dart'; import 'package:star_lock/main/lockDetail/electronicKey/electronicKeyList/entity/ElectronicKeyListEntity.dart'; +import 'package:star_lock/main/lockDetail/passwordKey/passwordKeyList/passwordKeyListEntity.dart'; import '../common/safetyVerification/entity/CheckSafetyVerificationEntity.dart'; import '../common/safetyVerification/entity/SafetyVerificationEntity.dart'; import '../login/login/entity/LoginEntity.dart'; @@ -76,9 +78,9 @@ class ApiRepository { } //获取国家或地区 json文件 - Future getCountryRegion(String type) async { + Future getCountryRegion(String type) async { final res = await apiProvider.getCountryRegion(type); - return LoginEntity.fromJson(res.body); + return CountryRegionEntity.fromJson(res.body); } //电子钥匙列表 @@ -90,9 +92,10 @@ class ApiRepository { String operatorUid, String pageNo, String pageSize, - String startDate) async { + String startDate, + String keyRight) async { final res = await apiProvider.electronicKeyList(endDate, keyId, keyStatus, - lockId, operatorUid, pageNo, pageSize, startDate); + lockId, operatorUid, pageNo, pageSize, startDate, keyRight); return ElectronicKeyListEntity.fromJson(res.body); } @@ -188,4 +191,35 @@ class ApiRepository { await apiProvider.modifyKeyName(keyId, lockId, keyName, operatorUid); return KeyOperationRecordEntity.fromJson(res.body); } + + //编辑电子钥匙名字 + Future modifyKeyNameForAdmin( + String keyId, + String keyNameForAdmin, + String operatorUid, + ) async { + final res = await apiProvider.modifyKeyNameForAdmin( + keyId, keyNameForAdmin, operatorUid); + return KeyOperationRecordEntity.fromJson(res.body); + } + + //编辑电子钥匙名字 + Future passwordKeyList( + String keyStatus, + String lockId, + String operatorUid, + String pageNo, + String pageSize, + ) async { + final res = await apiProvider.passwordKeyList( + keyStatus, lockId, operatorUid, pageNo, pageSize); + return PasswordKeyListEntity.fromJson(res.body); + } + + //重置密码钥匙 + Future resetPasswordKey( + String lockId, String operatorUid) async { + final res = await apiProvider.resetPasswordKey(lockId, operatorUid); + return PasswordKeyListEntity.fromJson(res.body); + } } diff --git a/star_lock/lib/tools/showTFView.dart b/star_lock/lib/tools/showTFView.dart index dc3b0c3d..c6b8ce79 100644 --- a/star_lock/lib/tools/showTFView.dart +++ b/star_lock/lib/tools/showTFView.dart @@ -9,8 +9,17 @@ class ShowTFView extends StatelessWidget { String? title; String? tipTitle; TextEditingController? controller; + Function()? sureClick; + Function()? cancelClick; - ShowTFView({Key? key, this.title, this.tipTitle, this.controller}) : super(key: key); + ShowTFView( + {Key? key, + this.title, + this.tipTitle, + this.controller, + this.sureClick, + this.cancelClick}) + : super(key: key); @override Widget build(BuildContext context) { @@ -20,15 +29,16 @@ class ShowTFView extends StatelessWidget { title: Text(title!), content: Column( children: [ - const SizedBox(height: 10,), + const SizedBox( + height: 10, + ), Container( height: 50.h, // color: Colors.white, // padding: EdgeInsets.only(left:20.w, right: 110.w), decoration: BoxDecoration( color: Colors.white, - borderRadius: BorderRadius.circular(15.w) - ), + borderRadius: BorderRadius.circular(15.w)), child: TextField( //输入框一行 maxLines: 1, @@ -36,9 +46,10 @@ class ShowTFView extends StatelessWidget { autofocus: false, decoration: InputDecoration( //输入里面输入文字内边距设置 - contentPadding: EdgeInsets.only(top: 20.h, left: 15.0, bottom: 13.h), + contentPadding: + EdgeInsets.only(top: 20.h, left: 15.0, bottom: 13.h), hintText: tipTitle, - hintStyle:TextStyle(fontSize: 28.sp), + hintStyle: TextStyle(fontSize: 28.sp), //不需要输入框下划线 border: InputBorder.none, //左边图标设置 @@ -66,16 +77,26 @@ class ShowTFView extends StatelessWidget { ), actions: [ CupertinoDialogAction( - child: Text(TranslationLoader.lanKeys!.cancel!.tr, style: const TextStyle(color: Colors.black),), + child: Text( + TranslationLoader.lanKeys!.cancel!.tr, + style: const TextStyle(color: Colors.black), + ), onPressed: () { - Navigator.pop(context); + // Navigator.pop(context); // print("取消"); + if (cancelClick != null) { + cancelClick!(); + } }, ), CupertinoDialogAction( - child: Text(TranslationLoader.lanKeys!.sure!.tr, style: const TextStyle(color: Colors.black)), + child: Text(TranslationLoader.lanKeys!.sure!.tr, + style: const TextStyle(color: Colors.black)), onPressed: () { - Navigator.pop(context); + if (sureClick != null) { + sureClick!(); + } + // Navigator.pop(context); // print("确定"); }, ), diff --git a/star_lock/pubspec.yaml b/star_lock/pubspec.yaml index 8da6a97d..aeb63e8c 100644 --- a/star_lock/pubspec.yaml +++ b/star_lock/pubspec.yaml @@ -118,7 +118,6 @@ flutter: - images/lan/ - images/mine/ - images/lockType/ - - assets/ # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware