帖子
帖子
用户
博客
课程
12下一页
返回列表 发新帖
显示全部楼层
2
帖子
0
勋章
30
Y币

[其他] 网络错误

[复制链接]
发表于 2022-5-16 16:46:24
上个月是编译自定义loader成功打开了app,然后一直没动过,现在打开要测试了,不管怎么一直显示网络错误,登录啥的功能,单个页面可以实时预览,但是登录都登不了,各个功能点开也是显示网络错误,apicloud也没有报错,去数据库比对设置的账号密码也没错,把代码里面的网络错误弹窗也注释了,还是显示网络错误,用流量,两个wifi连接也是网络错误,我都服了。眼看明天就要答辩了,每个月都得出点问题
自定义loader 每个月要重新编译一次吧。 你再编译一下
2
帖子
0
勋章
30
Y币
重新编译下载了,还是一样显示网络错误
2
帖子
0
勋章
30
Y币

重新编译下载了,还是一样显示网络错误
勇可可 · 2022-5-16 16:49自定义loader 每个月要重新编译一次吧。 你再编译一下
发下代码看看   或者是你新建一个应用  只添加你的ajax试一下
2
帖子
0
勋章
30
Y币
  1. <template>
  2.     <view class="main">
  3.         <navigationBar title="登录" rightButtonText="注册" onRightButton={this.onRightButton}></navigationBar>
  4.         <scroll-view class="scrollView" scroll-y='true'>
  5.             <view class="container">
  6.                 <text class="text bold" style="text-align:center;color:#016D3C;font-size:25px;">北京农学院校园代取外卖app</text>
  7.                 <image src="../../image/logo.jpg" style="margin-left:20%;border-radius:50%;width:200px;height:200px;">
  8.                
  9.                 <view>
  10.                     <text>用户名:</text>
  11.                     <input id="username" class="input" placeholder="请输入用户名" />
  12.                 </view>
  13.                 <view>
  14.                     <text>密码:</text>
  15.                      <input id="password" class="input" type="password" placeholder="请输入密码" />
  16.                 </view>
  17.                 <view>
  18.                     <text>角色:</text>
  19.                     <picker class="picker" id="selector" mode="selector" value={selectorValue} onChange={this.selectorChange}>
  20.                         <text  class="input"  placeholder="请点我选择角色">{roleDesc}</text>
  21.                     </picker>
  22.                 </view>
  23.                
  24.                 <text class="btn" onclick={this.fnLogin}>登录</text>
  25.                
  26.             </view>
  27.         </scroll-view>
  28.     </view>

  29. </template>

  30. <script >


  31. import navigationBar from "../../components/navigationBar.stml"
  32. import $kn from "../../script/kn.js"

  33. export default {
  34.     name: 'login',
  35.     data() {
  36.         return {
  37.             roleDesc: '学生',
  38.             roleList: ['学生','管理员','客服'],
  39.             selectorValue: '学生',
  40.         }
  41.     },
  42.    
  43.     methods: {
  44.         apiready() {
  45.             var selector = document.getElementById('selector');
  46.             selector.setData({
  47.                 data: this.data.roleList
  48.             });
  49.                 // document.getElementById('role').innerHTML='学生';
  50.              //   document.getElementById('username').focus();
  51.             
  52.         },
  53.           selectorChange(e) {
  54.                 this.data.selectorValue = e.detail.value;
  55.                 this.data.roleDesc = this.data.roleList[this.data.selectorValue];
  56.             },
  57.         // 登录
  58.         fnLogin() {
  59.             var that = this;
  60.             var usernameValue = document.getElementById('username').value;
  61.             var passwordValue = document.getElementById('password').value;
  62.             var role= this.data.roleDesc;
  63.             if (!usernameValue) {
  64.                 this.toast('请输入用户名');
  65.                 return;
  66.             }
  67.             if (!passwordValue) {
  68.                 this.toast('请输入密码');
  69.                 return;
  70.             }
  71.             if (!role) {
  72.                 this.toast('请选择注册角色');
  73.                 return;
  74.             }
  75.             $kn.ajax({
  76.                 url: '/t_users/UserLogin',
  77.                 method: 'post',
  78.                 data: {
  79.                     body: {
  80.                         username: usernameValue,
  81.                         password: passwordValue,
  82.                         type: role
  83.                     }
  84.                 }
  85.             }, function (ret, err) {
  86.                 if (ret) {
  87.                     if (ret.data) {
  88.                         $kn.setUserInfo(ret.data);
  89.                          that.toast('登录成功');
  90.                         if(role=="客服"){
  91.                             api.openWin({
  92.                                 name: 'userlist',
  93.                                 url: '../userlist/userlist.stml'
  94.                             });  
  95.                         }else if(role=="管理员"){
  96.                             api.openWin({
  97.                                 name: 'admin',
  98.                                 url: '../admin/admin.stml'
  99.                             });
  100.                         }else{
  101.                           $kn.openNavTabWin();
  102.                         }
  103.                     } else if (ret.status == 4004) {
  104.                         that.toast('用户名不存在');
  105.                     } else if (ret.status == 4005) {
  106.                         that.toast('密码错误');
  107.                     } else {
  108.                         that.toast('登录失败');
  109.                     }
  110.                 } else {
  111.                     that.toast('网络错误');
  112.                 }
  113.             });
  114.         },

  115.         toast(msg) {
  116.             api.toast({
  117.                 msg: msg,
  118.                 location: 'middle',
  119.                 global: true
  120.             });
  121.         },

  122.         onRightButton() {
  123.             //  $kn.openNavTabWin();
  124.             api.openWin({
  125.                 name: 'register',
  126.                 url: '../register/register.stml'
  127.             });
  128.         },

  129.         fnThirdLogin(e) {
  130.             this.toast(e.currentTarget.dataset.type + '登录');
  131.         }
  132.     }
  133. }
  134. </script>
  135. <style>
  136.   

  137.     .main {
  138.         width: 100%;
  139.         height: 100%;
  140.         background-color: #fff;
  141.     }
  142.     .scrollView {
  143.         flex: 1;
  144.     }
  145.     .container {
  146.         padding: 20px;
  147.     }

  148.     .input {
  149.         width: 100%;
  150.         height: 40px;
  151.         margin-bottom: 30px;
  152.         border: none;
  153.         border-bottom: 1px solid #ddd;
  154.     }

  155.     .btn {
  156.         height: 50px;
  157.         background-color:#016D3C;
  158.         line-height: 50px;
  159.         color: #fff;
  160.         font-size: 24px;
  161.         text-align: center;
  162.         border-radius: 8px;
  163.     }

  164.     .btn:active {
  165.         opacity: 0.8;
  166.     }

  167.     .third-login {
  168.         align-items: center;
  169.         margin-top: 30px;
  170.     }

  171.     .third-login-desc {
  172.         text-align: center;
  173.     }

  174.     .icon-container {
  175.         flex-direction: row;
  176.         justify-content: center;
  177.     }

  178.     .icon {
  179.         width:50px;
  180.         height: 50px;
  181.         margin: 8px;
  182.         border-radius: 25px;
  183.         background-color: gray;
  184.     }
  185.     .radio-group {
  186.         flex-direction:row;
  187.         margin: 5px;
  188.     }
  189.     .item {
  190.         flex-direction:row;
  191.           align-items:center;
  192.         margin: 5px;
  193.     }
  194. </style>
复制代码
勇可可 · 2022-5-16 16:55发下代码看看   或者是你新建一个应用  只添加你的ajax试一下
$kn.ajax  里面是用什么ajax  然后url 前面域名是什么
2
帖子
0
勋章
30
Y币
  1. /*
  2. * APICloud JavaScript Library
  3. * Copyright (c) 2014 apicloud.com
  4. */
  5. const $kn = {
  6.     openNavTabWin(){
  7.         var param = {
  8.             name: 'nav-tab',
  9.             title:'nav-tab',
  10.             bgColor:'#fff',
  11.             slidBackEnabled: false,
  12.             navigationBar: {
  13.                 hideBackButton: false,
  14.                 background:"#016D3C",
  15.                 color:'#fff',
  16.                 fontSize:18
  17.             },
  18.             tabBar: {
  19.                 animated: true,
  20.                 list: [
  21.                     {
  22.                         text: "接单",
  23.                         iconPath: "widget://image/nav_tab_1.png",
  24.                         selectedIconPath: "widget://image/nav_tab_1_on.png"
  25.                     }, {
  26.                         text: "发布",
  27.                         iconPath: "widget://image/tab30.png",
  28.                         selectedIconPath: "widget://image/tab31.png"
  29.                     }, {
  30.                         text: "任务",
  31.                         iconPath: "widget://image/nav_tab_3.png",
  32.                         selectedIconPath: "widget://image/nav_tab_3_on.png"
  33.                     }, {
  34.                         text: "订单",
  35.                         iconPath: "widget://image/tab40.png",
  36.                         selectedIconPath: "widget://image/tab41.png"
  37.                     },{
  38.                         text: "我",
  39.                         iconPath: "widget://image/nav_tab_4.png",
  40.                         selectedIconPath: "widget://image/nav_tab_4_on.png"
  41.                     }
  42.                 ],
  43.                 frames: [
  44.                     {
  45.                         title: "接单",//tab切换时对应的标题
  46.                         name: "ordertaking",
  47.                         url: "widget://pages/ordertaking/ordertaking.stml",
  48.                         //其他继承自openFrame的参数
  49.                     }, {
  50.                         title: "发布",
  51.                         name: "public",
  52.                         url: "widget://pages/public/public.stml"
  53.                         //其他继承自openFrame的参数
  54.                     }, {
  55.                         title: "任务",
  56.                         name: "ordertaking",
  57.                         url: "widget://pages/task/task.stml"
  58.                         //其他继承自openFrame的参数
  59.                     }, {
  60.                         title: "订单",
  61.                         name: "order",
  62.                         url: "widget://pages/order/order.stml"
  63.                         //其他继承自openFrame的参数
  64.                     }, {
  65.                         title: "我",
  66.                         name: "me",
  67.                         url: "widget://pages/me/me.stml"
  68.                         //其他继承自openFrame的参数
  69.                     }
  70.                 ]
  71.             }
  72.         }
  73.         api.openTabLayout(param);
  74.     },
  75.     isApp(){
  76.         if (api.platform && api.platform == 'app') {
  77.             return true;
  78.         }
  79.         
  80.         return false;
  81.     },
  82.     byId(id) {
  83.         return document.getElementById(id);
  84.     },
  85.     ajax(p, callback) {
  86.         var param = p;
  87.         if (!param.headers) {
  88.             param.headers = {};
  89.         }
  90.         param.headers['x-apicloud-mcm-key'] = 'cZKzX7DabDmYyfez';
  91.         if (param.data && param.data.body) {
  92.             param.headers['Content-Type'] = 'application/json; charset=utf-8';
  93.         }
  94.         if (param.url) {
  95.             var baseUrl = 'https://a6181898128080-dev.apicloud**.**/api/';
  96.             param.url = baseUrl + param.url;
  97.         }
  98.         api.ajax(param, (ret, err)=> {
  99.             
  100.             if (callback) callback(ret, err);
  101.             if (ret) {
  102.                 var status =  ret.status;
  103.                 if (status &&  status == 4001) {
  104.                   
  105.                 }
  106.             }
  107.         });
  108.     },
  109.     getUserInfo() {
  110.         var value = api.getPrefs({
  111.             key: 'userInfo',
  112.             sync: true
  113.         });
  114.         return value?JSON.parse(value):'';
  115.     },
  116.     setUserInfo(userInfo) {
  117.         api.setPrefs({
  118.             key: 'userInfo',
  119.             value: userInfo
  120.         });
  121.     },
  122.     getCurrentCityInfo() {
  123.         var value = api.getPrefs({
  124.             key: 'currentCity',
  125.             sync: true
  126.         });
  127.         return value?JSON.parse(value):'';
  128.     },
  129.     setCurrentCityInfo(cityInfo) {
  130.         api.setPrefs({
  131.             key: 'currentCity',
  132.             value: cityInfo
  133.         });
  134.     },
  135.     getWareTypeList() {
  136.         var value = api.readFile({
  137.             sync: true,
  138.             path: 'fs://WareTypeList'
  139.         });
  140.         return value?JSON.parse(value):'';
  141.     },
  142.     setWareTypeList(list) {
  143.         api.writeFile({
  144.             path: 'fs://WareTypeList',
  145.             data: JSON.stringify(list)
  146.         });
  147.     },
  148.     fitRichText(richtext, width){
  149.         var str = `<img style="max-width:${width}px;"`;
  150.         var result = richtext.replace(/\<img/gi, str);
  151.         return result;
  152.     },
  153.     getNowTime(){
  154.         var datetime=new Date();
  155.         var y=datetime.getFullYear();
  156.         var m=(datetime.getMonth()+1);
  157.         var d=datetime.getDate();
  158.         var hour=datetime.getHours();
  159.         var min=datetime.getMinutes();
  160.         console.log(y+"-"+m+"-"+d+" "+hour+":"+min)
  161.         return y+"-"+m+"-"+d+" "+hour+":"+min;
  162.     },
  163.     getNowDate(){
  164.         var datetime=new Date();
  165.         var y=datetime.getFullYear();
  166.         var m=(datetime.getMonth()+1);
  167.         var d=datetime.getDate();
  168.         return y+"-"+m+"-"+d+" " ;
  169.     },
  170.     num_two(s)
  171.     {
  172.         return (parseInt(s)>9)?s:'0'+s;
  173.     },
  174.     /**
  175. * 判断是否是空
  176. * @param value
  177. */
  178.     is_define(value)
  179.     {
  180.         if (value == null || value == "" || value == "undefined" || value == undefined || value == "null" || value == "(null)" || value == 'NULL' || typeof (value) == 'undefined')
  181.         {
  182.             return false;
  183.         }
  184.         else
  185.         {
  186.             value = value + "";
  187.             value = value.replace(/\s/g, "");
  188.             if (value == "")
  189.             {
  190.                 return false;
  191.             }
  192.             return true;
  193.         }
  194.     },
  195.     text(el, txt){
  196.         el.textContent = txt;
  197.         return el;
  198.     }
  199. };
  200. export default $kn;
复制代码
勇可可 · 2022-5-16 17:00$kn.ajax  里面是用什么ajax  然后url 前面域名是什么
2
帖子
0
勋章
30
Y币
[WARN] Could not set arguments on picker (Reason: java.lang.String cannot be cast to java.lang.Integer) at login.js:0
是不是这个原因
2
帖子
0
勋章
30
Y币
本帖最后由 云小七 于 2022-5-16 20:58 编辑

救命啊啊啊啊啊
12下一页
您需要登录后才可以回帖 登录

本版积分规则