Browse Source

增加H5账号密码登录

seimin 3 years ago
parent
commit
f9110bc181
1 changed files with 49 additions and 31 deletions
  1. 49 31
      pages/homePage/homePage.vue

+ 49 - 31
pages/homePage/homePage.vue

@@ -40,15 +40,15 @@
40 40
         </view>
41 41
       </view>
42 42
     </view>
43
-    <view class="login" v-if="!workSchemeType && isApp">
44
-      <!-- #ifndef H5 -->
43
+    <!-- APP或H5账号密码登录页面 start -->
44
+    <view class="login" v-if="!workSchemeType && (isApp||isH5AndPwd)">
45 45
       <view class="title"> 转运系统登录 </view>
46 46
       <input class="login_input" v-model="username" placeholder="请输入用户名" />
47 47
       <input class="login_input" password v-model="password" placeholder="请输入密码" />
48
-      <input class="login_input" v-model="ip" placeholder="请输入域名或IP地址,如:http(s)://192.168.3.108" />
48
+      <input class="login_input" v-show="!isH5AndPwd" v-model="ip" placeholder="请输入域名或IP地址,如:http(s)://192.168.3.108" />
49 49
       <view class="page_item_btn" @click="login()"> 登录 </view>
50
-      <!-- #endif -->
51 50
     </view>
51
+    <!-- APP或H5账号密码登录页面 end -->
52 52
     <view class="botImg" v-if="online || (!online && online !== undefined && workSchemeType == 1)">
53 53
       <view class="img"></view>
54 54
     </view>
@@ -80,6 +80,8 @@
80 80
         online: undefined,
81 81
         // 是否是app
82 82
         isApp: false,
83
+        // 是否是H5,账号密码登录
84
+        isH5AndPwd: false,
83 85
         // 用户名
84 86
         username: "",
85 87
         // 密码
@@ -771,6 +773,15 @@
771 773
       stop(e) {
772 774
         e.preventDefault();
773 775
       },
776
+      //获取查询参数
777
+      GetQueryString(name) {
778
+        var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
779
+        var r = location.search.substr(1).match(reg);
780
+        if (r != null) {
781
+          return unescape(r[2]);
782
+        }
783
+        return null;
784
+      }
774 785
     },
775 786
     onHide() {
776 787
       this.zxzData = [];
@@ -818,37 +829,44 @@
818 829
       this.isApp = false;
819 830
       this.type = options.type || "";
820 831
       console.log(this.type);
821
-      this.subm();
832
+      if (this.GetQueryString('login') === '1') {
833
+        //H5页面账号密码登录
834
+        this.isH5AndPwd = true;
835
+        this.ip = location.origin;
836
+      } else {
837
+        this.isH5AndPwd = false;
838
+        this.subm();
839
+      }
822 840
       //#endif
823 841
       // #ifdef APP-PLUS
824 842
       this.isApp = true;
825 843
       // 通知权限 start
826
-      var main = plus.android.runtimeMainActivity();
827
-      var pkName = main.getPackageName();
828
-      var NotificationManagerCompat = plus.android.importClass(
829
-        "android.support.v4.app.NotificationManagerCompat"
830
-      );
831
-      var packageNames = NotificationManagerCompat.from(main);
832
-      console.log(JSON.stringify(packageNames));
833
-      if (packageNames.areNotificationsEnabled()) {
834
-        console.log("已开启通知权限");
835
-      } else {
836
-        uni.showModal({
837
-          title: "提示",
838
-          content: "请先打开APP通知权限",
839
-          showCancel: true,
840
-          success: function(res) {
841
-            if (res.confirm) {
842
-              var Intent = plus.android.importClass("android.content.Intent");
843
-              var intent = new Intent(
844
-                "android.settings.APP_NOTIFICATION_SETTINGS"
845
-              ); //可设置表中所有Action字段
846
-              intent.putExtra("android.provider.extra.APP_PACKAGE", pkName);
847
-              main.startActivity(intent);
848
-            }
849
-          },
850
-        });
851
-      }
844
+      // var main = plus.android.runtimeMainActivity();
845
+      // var pkName = main.getPackageName();
846
+      // var NotificationManagerCompat = plus.android.importClass(
847
+      //   "android.support.v4.app.NotificationManagerCompat"
848
+      // );
849
+      // var packageNames = NotificationManagerCompat.from(main);
850
+      // console.log(JSON.stringify(packageNames));
851
+      // if (packageNames.areNotificationsEnabled()) {
852
+      //   console.log("已开启通知权限");
853
+      // } else {
854
+      //   uni.showModal({
855
+      //     title: "提示",
856
+      //     content: "请先打开APP通知权限",
857
+      //     showCancel: true,
858
+      //     success: function(res) {
859
+      //       if (res.confirm) {
860
+      //         var Intent = plus.android.importClass("android.content.Intent");
861
+      //         var intent = new Intent(
862
+      //           "android.settings.APP_NOTIFICATION_SETTINGS"
863
+      //         ); //可设置表中所有Action字段
864
+      //         intent.putExtra("android.provider.extra.APP_PACKAGE", pkName);
865
+      //         main.startActivity(intent);
866
+      //       }
867
+      //     },
868
+      //   });
869
+      // }
852 870
       // 通知权限 end
853 871
       // #endif
854 872
     },