Kaynağa Gözat

小程序提交

plg 4 ay önce
ebeveyn
işleme
30b6ec206b

+ 0 - 1
src/hooks/useIsLogin.ts

@@ -3,7 +3,6 @@
 import { userLoginApi } from '@/services/home'
 import type { LoginParams } from '@/types/home'
 import { useMemberStore } from '@/stores/'
-import { rejects } from 'assert'
 
 const useMember = useMemberStore()
 

+ 23 - 4
src/pages/index/pay.vue

@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import { onLoad, onUnload } from "@dcloudio/uni-app";
+import { onLoad, onShow, onUnload } from "@dcloudio/uni-app";
 import { ref, reactive } from "vue";
 import {
   createOrderApi,
@@ -10,7 +10,8 @@ import {
 import type { QueryPa } from "@/types/home";
 import HomeList from "./components/HomeList.vue";
 import { loginUser } from "@/hooks/useIsLogin";
-
+import { useMemberStore } from "@/stores";
+const userInfo = useMemberStore();
 //1 未支付   --可查看全部信息
 //2 openId相等  但是状态是支付中  --可查看全部状态
 //3 openId不相等  状态是别人在支付中 --不可查看任何信息
@@ -37,10 +38,28 @@ const params = reactive<any>({
 //调用查询参数需要的入参
 const scene = ref<QueryPa>({ scene: "", userId: "" });
 const orderId = ref<string>("");
+
+//onLoad方法  --在页面初次加载时触发,仅会在页面初次加载时触发一次
+//应该将二维码获取唯一标识放到缓存中--这样即使从其他页面过来就回调用就能记住这个标识--然后根据标识去查询
 onLoad((options) => {
   //获取的二维码中得到的参数信息
-  console.log(decodeURIComponent(options?.scene));
-  scene.value.scene = decodeURIComponent(options?.scene);
+  // console.log(decodeURIComponent(options?.scene));
+  // scene.value.scene = decodeURIComponent(options?.scene);
+  userInfo.saveScene(decodeURIComponent(options?.scene));
+  //将scene存入缓存中
+
+  // loginUser().then((res) => {
+  //   //这时已经有返回信息了且用户数据已经
+  //   scene.value.userId = res as string;
+  //   //获取到userId了
+  //   queryParams(scene.value);
+  // });
+});
+onShow(() => {
+  //从缓存中取出信息
+  //  scene.value.scene = decodeURIComponent(options?.scene);
+  //将scene存入缓存中
+  scene.value.scene = userInfo.scene;
   loginUser().then((res) => {
     //这时已经有返回信息了且用户数据已经
     scene.value.userId = res as string;

+ 149 - 0
src/services/a.js

@@ -0,0 +1,149 @@
+/*!
+ * console-ban v5.0.0
+ * (c) 2020-2023 fz6m
+ * Released under the MIT License.
+ */
+!(function (e, t) {
+  'object' == typeof exports && 'undefined' != typeof module
+    ? t(exports)
+    : 'function' == typeof define && define.amd
+    ? define(['exports'], t)
+    : t(((e = 'undefined' != typeof globalThis ? globalThis : e || self).ConsoleBan = {}))
+})(this, function (e) {
+  'use strict'
+  var t = function () {
+      return (
+        (t =
+          Object.assign ||
+          function (e) {
+            for (var t, n = 1, i = arguments.length; n < i; n++)
+              for (var o in (t = arguments[n]))
+                Object.prototype.hasOwnProperty.call(t, o) && (e[o] = t[o])
+            return e
+          }),
+        t.apply(this, arguments)
+      )
+    },
+    n = { clear: !0, debug: !0, debugTime: 3e3, bfcache: !0 },
+    i = 2,
+    o = function (e) {
+      return ~navigator.userAgent.toLowerCase().indexOf(e)
+    },
+    r = function (e, t) {
+      t !== i ? (location.href = e) : location.replace(e)
+    },
+    c = 0,
+    a = 0,
+    f = function (e) {
+      var t = 0,
+        n = 1 << c++
+      return function () {
+        ;(!a || a & n) && 2 === ++t && ((a |= n), e(), (t = 1))
+      }
+    },
+    s = function (e) {
+      var t = /./
+      t.toString = f(e)
+      var n = function () {
+        return t
+      }
+      n.toString = f(e)
+      var i = new Date()
+      ;(i.toString = f(e)), console.log('%c', n, n(), i)
+      var o,
+        r,
+        c = f(e)
+      ;(o = c),
+        (r = new Error()),
+        Object.defineProperty(r, 'message', {
+          get: function () {
+            o()
+          },
+        }),
+        console.log(r)
+    },
+    u = (function () {
+      function e(e) {
+        var i = t(t({}, n), e),
+          o = i.clear,
+          r = i.debug,
+          c = i.debugTime,
+          a = i.callback,
+          f = i.redirect,
+          s = i.write,
+          u = i.bfcache
+        ;(this._debug = r),
+          (this._debugTime = c),
+          (this._clear = o),
+          (this._bfcache = u),
+          (this._callback = a),
+          (this._redirect = f),
+          (this._write = s)
+      }
+      return (
+        (e.prototype.clear = function () {
+          this._clear && (console.clear = function () {})
+        }),
+        (e.prototype.bfcache = function () {
+          this._bfcache &&
+            (window.addEventListener('unload', function () {}),
+            window.addEventListener('beforeunload', function () {}))
+        }),
+        (e.prototype.debug = function () {
+          if (this._debug) {
+            var e = new Function('debugger')
+            setInterval(e, this._debugTime)
+          }
+        }),
+        (e.prototype.redirect = function (e) {
+          var t = this._redirect
+          if (t)
+            if (0 !== t.indexOf('http')) {
+              var n,
+                i = location.pathname + location.search
+              if (((n = t) ? ('/' !== n[0] ? '/'.concat(n) : n) : '/') !== i) r(t, e)
+            } else location.href !== t && r(t, e)
+        }),
+        (e.prototype.callback = function () {
+          if ((this._callback || this._redirect || this._write) && window) {
+            var e,
+              t = this.fire.bind(this),
+              n = window.chrome || o('chrome'),
+              r = o('firefox')
+            if (!n)
+              return r
+                ? (((e = /./).toString = t), void console.log(e))
+                : void (function (e) {
+                    var t = new Image()
+                    Object.defineProperty(t, 'id', {
+                      get: function () {
+                        e(i)
+                      },
+                    }),
+                      console.log(t)
+                  })(t)
+            s(t)
+          }
+        }),
+        (e.prototype.write = function () {
+          var e = this._write
+          e && (document.body.innerHTML = 'string' == typeof e ? e : e.innerHTML)
+        }),
+        (e.prototype.fire = function (e) {
+          this._callback
+            ? this._callback.call(null)
+            : (this.redirect(e), this._redirect || this.write())
+        }),
+        (e.prototype.prepare = function () {
+          this.clear(), this.bfcache(), this.debug()
+        }),
+        (e.prototype.ban = function () {
+          this.prepare(), this.callback()
+        }),
+        e
+      )
+    })()
+  e.init = function (e) {
+    new u(e).ban()
+  }
+})

+ 9 - 0
src/stores/modules/member.ts

@@ -45,6 +45,13 @@ export const useMemberStore = defineStore(
       //海报
       posterBackground: '',
     })
+
+    //用户scene唯一标识保存
+    const scene = ref<string>('')
+    //保存scene唯一标识信息
+    const saveScene = (val: string) => {
+      scene.value = val
+    }
     //保存用户信息
     const saveUserInfo = (val: any) => {
       userInfo.value = val
@@ -76,6 +83,8 @@ export const useMemberStore = defineStore(
       profile,
       token,
       userInfo,
+      scene,
+      saveScene,
       saveToken,
       clearToken,
       setProfile,