|
@@ -33,7 +33,7 @@
|
|
|
|
|
|
<script setup lang="ts">
|
|
<script setup lang="ts">
|
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
import { onLoad, onShow } from "@dcloudio/uni-app";
|
|
-import { getCarousel } from "@/services/ams";
|
|
|
|
|
|
+import { getCarousel, getOpenId } from "@/services/ams";
|
|
import { ref } from "vue";
|
|
import { ref } from "vue";
|
|
// import { useInfoStore } from "@/store/info";
|
|
// import { useInfoStore } from "@/store/info";
|
|
import { getActivityData, isGetPhone } from "@/utils/system";
|
|
import { getActivityData, isGetPhone } from "@/utils/system";
|
|
@@ -41,38 +41,13 @@ import UserLoginPopup from "@/components/userLoginPopup.vue";
|
|
|
|
|
|
const current = ref<number>(0);
|
|
const current = ref<number>(0);
|
|
const appid = uni.getStorageSync("appid");
|
|
const appid = uni.getStorageSync("appid");
|
|
-onLoad(() => {
|
|
|
|
- getBanner();
|
|
|
|
-});
|
|
|
|
|
|
|
|
-const payment = () => {
|
|
|
|
|
|
+const onLogin = () => {
|
|
uni.login({
|
|
uni.login({
|
|
//获取code,
|
|
//获取code,
|
|
success: (res) => {
|
|
success: (res) => {
|
|
- var code = res.code,
|
|
|
|
- appId = "wx4f6dc4ac1674547c",
|
|
|
|
- secret = "9e0e7fe5161541d9862b8ee2db6da840";
|
|
|
|
- console.log("正在登录中...");
|
|
|
|
- //根据获取的code去腾讯服务器,请求用户数据,返回的结果中,包含openid
|
|
|
|
- wx.request({
|
|
|
|
- url:
|
|
|
|
- "https://api.weixin.qq.com/sns/jscode2session?appid=" +
|
|
|
|
- appId +
|
|
|
|
- "&secret=" +
|
|
|
|
- secret +
|
|
|
|
- "&js_code=" +
|
|
|
|
- code +
|
|
|
|
- "&grant_type=authorization_code",
|
|
|
|
- data: {},
|
|
|
|
- header: {
|
|
|
|
- "content-type": "json",
|
|
|
|
- },
|
|
|
|
- success: (user_res) => {
|
|
|
|
- //请求成功获取openid;
|
|
|
|
- const user_openid = user_res.data.openid;
|
|
|
|
- uni.setStorageSync("openid", user_openid);
|
|
|
|
- console.log("登录成功", user_openid);
|
|
|
|
- },
|
|
|
|
|
|
+ getOpenId(res.code).then((res: any) => {
|
|
|
|
+ uni.setStorageSync("openid", res.data.openid);
|
|
});
|
|
});
|
|
},
|
|
},
|
|
});
|
|
});
|
|
@@ -95,6 +70,12 @@ const toActivity = () => {
|
|
});
|
|
});
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
+
|
|
|
|
+onLoad(() => {
|
|
|
|
+ onLogin();
|
|
|
|
+ getBanner();
|
|
|
|
+});
|
|
|
|
+
|
|
onShow(() => {
|
|
onShow(() => {
|
|
getActivityData();
|
|
getActivityData();
|
|
});
|
|
});
|