Parcourir la source

【Mod】取消登录,返回上一页

liuxiangxin il y a 2 mois
Parent
commit
4c2ae437a1
1 fichiers modifiés avec 32 ajouts et 65 suppressions
  1. 32 65
      pages/login/index.vue

+ 32 - 65
pages/login/index.vue

@@ -11,20 +11,19 @@
       <button @click="toPhoneLogin" class="get_phone">授权登录</button>
       <!-- #endif -->
       <!-- #ifdef MP-TOUTIAO -->
-      <view>
-        <button open-type="getPhoneNumber" @getphonenumber="getPhonenumber" class="get_phone">抖音用户手机号授权登录</button>
-        <!-- <button class="get_phone" style="margin-top: 40rpx; background-color: #fff; color: #333">手机号验证登录</button> -->
-        <view class="policy_content">
-          <image
-            class="checkbox"
-            @click="changeAgreePolicy"
-            :src="agreePolicy ? 'https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/checked.png' : 'https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/checkbox.png'"
-          ></image>
-          我已阅读并同意
-          <navigator url="/pages/policy/index" style="color: #e03519">《服务协议》</navigator>
-        </view>
-      </view>
+		<button open-type="getPhoneNumber" @getphonenumber="getPhonenumber" class="get_phone">抖音用户手机号授权登录</button>
+		<!-- <button class="get_phone" style="margin-top: 40rpx; background-color: #fff; color: #333">手机号验证登录</button> -->
+		<view class="policy_content">
+		  <image
+			class="checkbox"
+			@click="changeAgreePolicy"
+			:src="agreePolicy ? 'https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/checked.png' : 'https://kailin-mp.oss-cn-shenzhen.aliyuncs.com/static/icon/checkbox.png'"
+		  ></image>
+		  我已阅读并同意
+		  <navigator url="/pages/policy/index" style="color: #e03519">《服务协议》</navigator>
+		</view>
       <!-- #endif -->
+		<button  class="cancel_login" @click="cancelLogin()">取消登录</button>
     </view>
   </view>
 </template>
@@ -48,58 +47,10 @@ export default {
     changeAgreePolicy() {
       this.agreePolicy = !this.agreePolicy;
     },
-    methods: {
-      getPhonenumber(re) {
-        // // 如果授权失败的话
-        if (re.detail.errMsg != "getPhoneNumber:ok") {
-          uni.showToast({
-            icon: "error",
-            title: "授权失败",
-          });
-          return;
-        }
-        let share_uid = "";
-        share_uid = uni.getStorageSync("share_uid");
-        // 授权成功以后,调用登录
-        this.$http.request("api/wechat/phone_number", { code: re.detail.code, share_uid: share_uid }, "post").then((re) => {
-          // 成功的话
-          if (re.code == "success") {
-            // 存储登录标识
-            uni.setStorageSync("userLogin", re.data);
-            // 跳转到页面
-            if (this.redirect) {
-              let url = this.redirect;
-              if (this.activity_id) url = url + "?id=" + this.activity_id;
-              if (this.id) url = url + "?id=" + this.id;
-              uni.redirectTo({ url: url });
-            } else uni.switchTab({ url: "/pages/user/index" });
-          } else {
-            uni.showToast({
-              title: re.msg,
-              icon: "none",
-            });
-          }
-        });
-      },
-      toPhoneLogin(re) {
-        // 登录效果
-        this.$http.request("api/wechat/phone_number", this.requestParam).then((re) => {
-          // 成功的话
-          if (re.code == "success") {
-            // 存储登录标识
-            uni.setStorageSync("userLogin", re.data);
-            // 跳转到页面
-            uni.switchTab({ url: "/pages/user/index" });
-          } else {
-            uni.showToast({
-              title: re.msg,
-              icon: "none",
-            });
-          }
-        });
-        return;
-      },
-    },
+	cancelLogin(){
+		// 返回上一页
+		uni.navigateBack();
+	},
     getPhonenumber(re) {
       // // 如果授权失败的话
       if (re.detail.errMsg != "getPhoneNumber:ok") {
@@ -192,4 +143,20 @@ export default {
 .get_phone::after {
   border: 0rpx solid #dddddd;
 }
+.cancel_login{
+	display: block;
+	width: 100%;
+	height: 80rpx;
+	color: #666666;
+	font-size: 28rpx;
+	background: #dddddd;
+	margin: 0rpx auto;
+	line-height: 80rpx;
+	margin-top: 40rpx;
+	border-radius: 30rpx;
+	border: 0rpx solid #dddddd;
+}
+.cancel_login::after {
+  border: 0rpx solid #dddddd;
+}
 </style>