| @@ -51,9 +51,9 @@ | |||||
| /* 小程序特有相关 */ | /* 小程序特有相关 */ | ||||
| "mp-weixin": { | "mp-weixin": { | ||||
| "appid": "wx75cf14e3a0d45821", | "appid": "wx75cf14e3a0d45821", | ||||
| "useExtendedLib": { | |||||
| "share": true // 确保分享功能已经开启 | |||||
| }, | |||||
| // "useExtendedLib": { | |||||
| // "share": true // 确保分享功能已经开启 | |||||
| // }, | |||||
| "permission": { | "permission": { | ||||
| "scope.userLocation": { | "scope.userLocation": { | ||||
| "desc": "获取您的地理位置信息" | "desc": "获取您的地理位置信息" | ||||
| @@ -1,6 +1,10 @@ | |||||
| <template> | <template> | ||||
| <div class="page"> | <div class="page"> | ||||
| <u-list class="styleListBox" @scrolltolower="scrolltolower"> | |||||
| <u-list | |||||
| class="styleListBox" | |||||
| @scrolltolower="scrolltolower" | |||||
| lowerThreshold="100" | |||||
| > | |||||
| <u-list-item class="glodYBox"> | <u-list-item class="glodYBox"> | ||||
| <u-list-item | <u-list-item | ||||
| v-for="item in styleList" | v-for="item in styleList" | ||||
| @@ -42,7 +46,7 @@ import { getListApi } from "../../api/closeStyle"; | |||||
| //#region 列表加载 | //#region 列表加载 | ||||
| const pageNum = ref(1); | const pageNum = ref(1); | ||||
| const pageSize = ref(8); | |||||
| const pageSize = ref(20); | |||||
| const styleList = ref([]); | const styleList = ref([]); | ||||
| // 得到列表 | // 得到列表 | ||||
| async function getList() { | async function getList() { | ||||
| @@ -63,11 +67,15 @@ const scrolltolower = async () => { | |||||
| uni.showLoading({ | uni.showLoading({ | ||||
| title: "加载中...", | title: "加载中...", | ||||
| mask: true, | mask: true, | ||||
| duration: 2000, | |||||
| }); | }); | ||||
| pageNum.value += 1; | pageNum.value += 1; | ||||
| const res = await getListApi(pageNum.value, pageSize.value); | const res = await getListApi(pageNum.value, pageSize.value); | ||||
| styleList.value.push(...res.data.list); | styleList.value.push(...res.data.list); | ||||
| uni.hideLoading(); | |||||
| setTimeout(function () { | |||||
| uni.hideLoading(); | |||||
| }, 500); | |||||
| if (res.data.list.length == 0) { | if (res.data.list.length == 0) { | ||||
| pageNum.value -= 1; | pageNum.value -= 1; | ||||
| uni.showToast({ | uni.showToast({ | ||||
| @@ -76,7 +84,9 @@ const scrolltolower = async () => { | |||||
| }); | }); | ||||
| } | } | ||||
| } catch (error) { | } catch (error) { | ||||
| uni.hideLoading(); | |||||
| setTimeout(function () { | |||||
| uni.hideLoading(); | |||||
| }, 500); | |||||
| uni.showToast({ | uni.showToast({ | ||||
| title: "获取数据失败,请重试", | title: "获取数据失败,请重试", | ||||
| icon: "none", | icon: "none", | ||||
| @@ -408,26 +408,23 @@ onLoad((options) => { | |||||
| // uni.setStorageSync("token", userInfoModulesPinia.token); | // uni.setStorageSync("token", userInfoModulesPinia.token); | ||||
| console.log(userInfoModulesPinia.openId, "获取openid"); | console.log(userInfoModulesPinia.openId, "获取openid"); | ||||
| // 获取头像和金币 | // 获取头像和金币 | ||||
| const res3 = await findImageApi(); | |||||
| userInfoModulesPinia.myAvatar = | |||||
| res3.data && res3.data.image ? res3.data.image : ""; | |||||
| const res4 = await findGlodApi(); | |||||
| if (!res4.data) { | |||||
| userInfoModulesPinia.myGlod = 0; | |||||
| } else { | |||||
| userInfoModulesPinia.myGlod = res4.data.digitalAvatarResidueGlod | |||||
| ? res4.data.digitalAvatarResidueGlod | |||||
| : 0; | |||||
| } | |||||
| // const res3 = await findImageApi(); | |||||
| // userInfoModulesPinia.myAvatar = | |||||
| // res3.data && res3.data.image ? res3.data.image : ""; | |||||
| // const res4 = await findGlodApi(); | |||||
| // if (!res4.data) { | |||||
| // userInfoModulesPinia.myGlod = 0; | |||||
| // } else { | |||||
| // userInfoModulesPinia.myGlod = res4.data.digitalAvatarResidueGlod | |||||
| // ? res4.data.digitalAvatarResidueGlod | |||||
| // : 0; | |||||
| // } | |||||
| uni.hideLoading(); | uni.hideLoading(); | ||||
| if (res2.data.token) { | if (res2.data.token) { | ||||
| // uni.redirectTo({ | |||||
| // url: "/pages/index/index", | |||||
| // }); | |||||
| } else { | |||||
| uni.redirectTo({ | |||||
| url: "/pages/login/index", | |||||
| uni.switchTab({ | |||||
| url: "/pages/uploadPhoto/uploadPhoto", | |||||
| }); | }); | ||||
| } else { | |||||
| console.log("error1"); | console.log("error1"); | ||||
| uni.showToast({ | uni.showToast({ | ||||
| title: "登录失败,请重试", | title: "登录失败,请重试", | ||||
| @@ -33,7 +33,7 @@ | |||||
| <view class="tips"> | <view class="tips"> | ||||
| <text>邀请好友可获得2枚金币</text> | <text>邀请好友可获得2枚金币</text> | ||||
| </view> | </view> | ||||
| <button open-type="share" class="shareBtn" @click="share">分享</button> | |||||
| <button open-type="share" class="shareBtn">分享</button> | |||||
| <view class="shareBtn" @click="inviteFriend">邀请好友</view> | <view class="shareBtn" @click="inviteFriend">邀请好友</view> | ||||
| <view class="shareBtn" @click="buyCoin">金币充值</view> | <view class="shareBtn" @click="buyCoin">金币充值</view> | ||||
| </view> | </view> | ||||
| @@ -43,7 +43,7 @@ | |||||
| <script setup> | <script setup> | ||||
| // import myloading from '../../components/myLoading.vue' | // import myloading from '../../components/myLoading.vue' | ||||
| //#region 导入 | //#region 导入 | ||||
| import { onLoad } from "@dcloudio/uni-app"; | |||||
| import { onLoad, onShareAppMessage, onShareTimeline } from "@dcloudio/uni-app"; | |||||
| import { ref, reactive, watch } from "vue"; | import { ref, reactive, watch } from "vue"; | ||||
| import { userInfoModules } from "@/store/modules/userInfo"; | import { userInfoModules } from "@/store/modules/userInfo"; | ||||
| import { | import { | ||||
| @@ -159,6 +159,34 @@ function previewImage(index) { | |||||
| //#endregion --------------------- | //#endregion --------------------- | ||||
| //#region 分享 | //#region 分享 | ||||
| onShareAppMessage((res) => { | |||||
| // 分享事件来源:button(页面内分享按钮)、menu(右上角分享按钮) | |||||
| if (res.from === "button") { | |||||
| // 来自页面内分享按钮 | |||||
| return { | |||||
| //分享标题 | |||||
| title: "智像", | |||||
| //页面 path | |||||
| path: `/pages/login/index`, | |||||
| // 分享图标 | |||||
| // imageUr: shopDetailsData.value?.GoodsCoverImg, | |||||
| success: function () { | |||||
| // 转发成功 | |||||
| console.log("res", res); | |||||
| }, | |||||
| fail: function () { | |||||
| // 转发失败 | |||||
| console.log("res", res); | |||||
| }, | |||||
| }; | |||||
| } else { | |||||
| return { | |||||
| title: "智像", | |||||
| path: "/pages/login/index", | |||||
| // imageUr: shopDetailsData.value?.GoodsCoverImg, | |||||
| }; | |||||
| } | |||||
| }); | |||||
| // onShareAppMessage((res) => { | // onShareAppMessage((res) => { | ||||
| // return { | // return { | ||||
| // title: "页面分享的标题", | // title: "页面分享的标题", | ||||