| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- "use strict";
- var common_vendor = require("../../common/vendor.js");
- var api_user = require("../../api/user.js");
- require("../../common/request.js");
- const wxAuth = () => "../components/wxAuth.js";
- const _sfc_main = {
- components: {
- wxAuth
- },
- data() {
- return {
- wxShow: false,
- isAgreement: false,
- code: null
- };
- },
- computed: {},
- onLoad(option) {
- common_vendor.index.$on("refreshLogin", () => {
- common_vendor.index.navigateBack({
- delta: 1
- });
- });
- this.getCode();
- },
- onUnload() {
- },
- mounted() {
- },
- methods: {
- updateUser() {
- this.wxShow = false;
- common_vendor.index.$emit("refreshLogin");
- common_vendor.index.$emit("refreshIM");
- },
- wxAuthOpen() {
- this.wxShow = true;
- var that = this;
- setTimeout(function() {
- that.$refs.wxauth.getUserInfo();
- });
- },
- wxAuthClose() {
- this.wxShow = false;
- },
- wxLogin(e) {
- var that = this;
- if (!this.isAgreement) {
- common_vendor.index.showToast({
- icon: "none",
- title: "\u8BF7\u5148\u540C\u610F\u534F\u8BAE\u540E\u518D\u767B\u5F55"
- });
- return false;
- }
- common_vendor.index.showLoading({
- title: "\u5904\u7406\u4E2D..."
- });
- that.$getProvider().then((provider) => {
- console.log("\u5F53\u524D\u7684\u73AF\u5883\u5546", provider);
- if (!provider) {
- reject();
- }
- common_vendor.index.login({
- provider,
- success: async (loginRes) => {
- console.log(111);
- console.log(e);
- console.log(loginRes);
- }
- });
- }).catch((err) => {
- common_vendor.index.showToast({
- icon: "none",
- title: err
- });
- });
- },
- handleAgree() {
- if (!this.isAgreement) {
- common_vendor.index.showToast({
- icon: "none",
- title: "\u8BF7\u5148\u540C\u610F\u534F\u8BAE\u540E\u518D\u767B\u5F55"
- });
- }
- },
- openContent(type) {
- console.log(type);
- common_vendor.index.navigateTo({
- url: "/pages_user/agreement?type=" + type
- });
- },
- handleAgreement() {
- this.isAgreement = !this.isAgreement;
- },
- getCode() {
- var that = this;
- that.$getProvider().then((provider) => {
- if (!provider) {
- reject();
- }
- common_vendor.index.login({
- provider,
- success: async (loginRes) => {
- that.code = loginRes.code;
- }
- });
- }).catch((err) => {
- });
- },
- phoneLogin(e) {
- var that = this;
- common_vendor.index.showLoading({
- title: "\u5904\u7406\u4E2D"
- });
- console.log(e);
- if (e.detail.errMsg == "getPhoneNumber:ok") {
- this.$getProvider().then((provider) => {
- console.log("\u5F53\u524D\u7684\u73AF\u5883\u5546", provider);
- if (!provider) {
- reject();
- }
- common_vendor.index.login({
- provider,
- success: async (loginRes) => {
- console.log(loginRes);
- let code = loginRes.code;
- var tuiUserId = common_vendor.index.getStorageSync("tuiUserId");
- api_user.wxLogin({
- encryptedData: e.detail.encryptedData,
- iv: e.detail.iv,
- code,
- tuiUserId
- }).then((res) => {
- common_vendor.index.hideLoading();
- if (res.code == 200) {
- common_vendor.index.showToast({
- icon: "none",
- title: "\u767B\u5F55\u6210\u529F"
- });
- common_vendor.index.setStorageSync("AppToken", res.token);
- common_vendor.index.setStorageSync("userId", res.user.userId);
- common_vendor.index.setStorageSync("avatar", res.user.avatar);
- common_vendor.index.setStorageSync("nickName", res.user.nickName);
- if (res.user.isWeixinAuth == 0) {
- that.wxAuthOpen();
- } else {
- common_vendor.index.$emit("refreshLogin");
- common_vendor.index.$emit("refreshIM");
- }
- } else {
- common_vendor.index.showToast({
- icon: "none",
- title: "\u6388\u6743\u767B\u5F55\u5931\u8D25,\u8BF7\u91CD\u65B0\u767B\u5F55"
- });
- }
- }).catch((error) => {
- console.log(error);
- common_vendor.index.hideLoading();
- common_vendor.index.showToast({
- icon: "none",
- title: "\u6388\u6743\u767B\u5F55\u5931\u8D25,\u8BF7\u91CD\u65B0\u767B\u5F55"
- });
- });
- }
- });
- }).catch((err) => {
- });
- } else {
- common_vendor.index.showToast({
- title: "\u5DF2\u62D2\u7EDD\u6388\u6743",
- icon: "none",
- duration: 2e3
- });
- }
- },
- back() {
- common_vendor.index.reLaunch({
- url: "/pages/index/index",
- animationType: "pop-in",
- animationDuration: 100
- });
- }
- }
- };
- if (!Array) {
- const _component_wx_auth = common_vendor.resolveComponent("wx-auth");
- const _easycom_u_popup2 = common_vendor.resolveComponent("u-popup");
- (_component_wx_auth + _easycom_u_popup2)();
- }
- const _easycom_u_popup = () => "../../uni_modules/uview-plus/components/u-popup/u-popup.js";
- if (!Math) {
- _easycom_u_popup();
- }
- function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
- return common_vendor.e({
- a: common_vendor.o((...args) => $options.phoneLogin && $options.phoneLogin(...args)),
- b: $data.isAgreement == false
- }, $data.isAgreement == false ? {
- c: common_vendor.o(($event) => $options.handleAgree())
- } : {}, {
- d: common_vendor.o((...args) => $options.back && $options.back(...args)),
- e: $data.isAgreement,
- f: common_vendor.o(($event) => $options.handleAgreement()),
- g: common_vendor.o(($event) => $options.handleAgreement()),
- h: common_vendor.o(($event) => $options.openContent("userRegister")),
- i: common_vendor.o(($event) => $options.openContent("userPrivacy")),
- j: common_vendor.sr("wxauth", "1e427071-1,1e427071-0"),
- k: common_vendor.o(($event) => $options.updateUser()),
- l: common_vendor.o($options.wxAuthClose),
- m: common_vendor.o($options.wxAuthOpen),
- n: common_vendor.p({
- bgColor: "#f6f6f6",
- safeAreaInsetBottom: false,
- round: 15,
- mode: "bottom",
- show: $data.wxShow
- })
- });
- }
- var MiniProgramPage = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "E:/Project/2023/\u95EE\u8BCA\u5E73\u53F0/his_user_miniapp/pages/auth/login.vue"]]);
- wx.createPage(MiniProgramPage);
|