|
|
@@ -1,41 +1,22 @@
|
|
|
<template>
|
|
|
- <view class="home-index2">
|
|
|
- <view
|
|
|
- v-if="modules.latest_recommend && modules.latest_recommend.length"
|
|
|
- class="base-list"
|
|
|
- >
|
|
|
+ <view class="shop">
|
|
|
+ <view class="fixtitle">当前积分:{{ userInfo.source || 0 }}</view>
|
|
|
+ <view v-if="modules && modules.length" class="base-list">
|
|
|
<list-item
|
|
|
- v-for="item in modules.latest_recommend"
|
|
|
- :key="item.module_id"
|
|
|
+ v-for="item in modules"
|
|
|
+ :key="item.id"
|
|
|
:item="item"
|
|
|
+ :btn="true"
|
|
|
class="base-list-item"
|
|
|
@click="handleDetail(item)"
|
|
|
- >
|
|
|
- </list-item>
|
|
|
- </view>
|
|
|
- <view class="fixed-btns">
|
|
|
- <!-- <image
|
|
|
- class="fixed-btn"
|
|
|
- :src="require('@/assets/icon/icon-btn-service.png')"
|
|
|
- @click="jumpModuleAll('/pages/help/help_contact')"
|
|
|
- ></image>
|
|
|
- <image
|
|
|
- class="fixed-btn"
|
|
|
- :src="require('@/assets/icon/icon-btn-message.png')"
|
|
|
- @click="jumpModuleAll('/pages/my/messages')"
|
|
|
- ></image>
|
|
|
- -->
|
|
|
- <image
|
|
|
- v-if="showTask"
|
|
|
- class="fixed-btn"
|
|
|
- :src="require('@/assets/icon/icon-btn-sign.png')"
|
|
|
- @click="jumpModuleAll('/pages/task/index')"
|
|
|
- ></image>
|
|
|
+ />
|
|
|
</view>
|
|
|
</view>
|
|
|
</template>
|
|
|
<script>
|
|
|
-import { getScoreList } from "@/lib/api/shop";
|
|
|
+import login from "@/lib/utils/login";
|
|
|
+import { getUserInfo } from "@/lib/api/user";
|
|
|
+import { getScoreList, exchangeScore } from "@/lib/api/shop";
|
|
|
import listItem from "@/components/list-item/list-item.vue";
|
|
|
|
|
|
export default {
|
|
|
@@ -45,11 +26,8 @@ export default {
|
|
|
},
|
|
|
data() {
|
|
|
return {
|
|
|
- statusBarHeight: 0, // 自定义导航
|
|
|
- titleBarHeight: 44, // 自定义导航
|
|
|
- BarHeight: 0, // 自定义导航
|
|
|
userInfo: {},
|
|
|
- modules: {},
|
|
|
+ modules: [],
|
|
|
tabStyle: "",
|
|
|
showTask: false,
|
|
|
};
|
|
|
@@ -70,24 +48,24 @@ export default {
|
|
|
const uinfoStr = uni.getStorageSync("userinfo");
|
|
|
if (uinfoStr) {
|
|
|
this.userInfo = JSON.parse(uinfoStr);
|
|
|
+ this.getUserInfo();
|
|
|
} else {
|
|
|
this.userInfo = {};
|
|
|
}
|
|
|
- // this.getTaskInfo();
|
|
|
},
|
|
|
onShareAppMessage() {
|
|
|
return {
|
|
|
- title: "各种爆款手办/盲盒,还能0元抽热款~快来试试你的欧气!",
|
|
|
+ title: "云果国潮会员中心",
|
|
|
imageUrl:
|
|
|
- "https://chujianchaowan.oss-cn-beijing.aliyuncs.com/images/45bfb688e6e9dba557f64fd052e850cc.png",
|
|
|
+ "https://yggc.oss-cn-beijing.aliyuncs.com/images/81d939394aea637ac0f6a3026d1a38e6.jpg",
|
|
|
path: "/pages/index/index",
|
|
|
};
|
|
|
},
|
|
|
onShareTimeline() {
|
|
|
return {
|
|
|
- title: "各种爆款手办/盲盒,还能0元抽热款~快来试试你的欧气!",
|
|
|
+ title: "云果国潮会员中心",
|
|
|
imageUrl:
|
|
|
- "https://chujianchaowan.oss-cn-beijing.aliyuncs.com/images/45bfb688e6e9dba557f64fd052e850cc.png",
|
|
|
+ "https://yggc.oss-cn-beijing.aliyuncs.com/images/81d939394aea637ac0f6a3026d1a38e6.jpg",
|
|
|
path: "/pages/index/index",
|
|
|
};
|
|
|
},
|
|
|
@@ -95,41 +73,13 @@ export default {
|
|
|
await this.loadModules().catch((e) => console.log(e));
|
|
|
uni.stopPullDownRefresh();
|
|
|
},
|
|
|
- mounted() {
|
|
|
- const systemInfo = uni.getSystemInfoSync();
|
|
|
- this.statusBarHeight = systemInfo.statusBarHeight;
|
|
|
-
|
|
|
- // #ifdef MP
|
|
|
- this.statusBarHeight = systemInfo.statusBarHeight;
|
|
|
- // this.titleBarHeight = systemInfo.statusBarHeight;
|
|
|
- // #endif
|
|
|
-
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- this.statusBarHeight = systemInfo.statusBarHeight;
|
|
|
- const menuButtonInfo = wx.getMenuButtonBoundingClientRect();
|
|
|
- this.titleBarHeight =
|
|
|
- (menuButtonInfo.top - systemInfo.statusBarHeight) * 2 +
|
|
|
- menuButtonInfo.height;
|
|
|
- // #endif
|
|
|
-
|
|
|
- // #ifdef MP-ALIPAY
|
|
|
- this.statusBarHeight = systemInfo.statusBarHeight;
|
|
|
- this.titleBarHeight =
|
|
|
- systemInfo.statusBarHeight + systemInfo.titleBarHeight;
|
|
|
- // #endif
|
|
|
-
|
|
|
- // #ifdef APP-PLUS
|
|
|
- this.statusBarHeight = systemInfo.statusBarHeight;
|
|
|
- // this.titleBarHeight = 44;
|
|
|
- // #endif
|
|
|
-
|
|
|
- // #ifdef H5
|
|
|
- this.statusBarHeight = 0;
|
|
|
- // this.titleBarHeight = systemInfo.statusBarHeight;
|
|
|
- // #endif
|
|
|
- this.BarHeight = this.statusBarHeight + this.titleBarHeight;
|
|
|
- },
|
|
|
+ // mounted() {},
|
|
|
methods: {
|
|
|
+ async getUserInfo() {
|
|
|
+ const res = await getUserInfo();
|
|
|
+ this.userInfo = { ...this.userInfo, ...res.data };
|
|
|
+ uni.setStorageSync("userinfo", JSON.stringify(this.userInfo));
|
|
|
+ },
|
|
|
async loadModules() {
|
|
|
try {
|
|
|
const data = await getScoreList();
|
|
|
@@ -153,25 +103,51 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- jumpModuleAll(url) {
|
|
|
- if (!url) return;
|
|
|
+ login() {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ login.wxLogin((userInfo) => {
|
|
|
+ if (userInfo.session) {
|
|
|
+ this.userInfo = userInfo;
|
|
|
+ this.getUserInfo().then(resolve);
|
|
|
+ } else reject();
|
|
|
+ });
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ async handleDetail(item) {
|
|
|
+ if (!this.userInfo || !this.userInfo.session) await this.login();
|
|
|
|
|
|
- if (/^https?:\/\//i.test(url)) {
|
|
|
- uni.navigateTo({
|
|
|
- url: `../webview/webview?url=${encodeURIComponent(url)}`,
|
|
|
+ if (item.score > Number(this.userInfo.score)) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: "none",
|
|
|
+ text: "积分不足",
|
|
|
});
|
|
|
return;
|
|
|
}
|
|
|
- uni.navigateTo({
|
|
|
- url: url,
|
|
|
+
|
|
|
+ await new Promise((resolve, reject) => {
|
|
|
+ uni.showModal({
|
|
|
+ title: "提示",
|
|
|
+ content: "是否兑换当前商品?",
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ resolve();
|
|
|
+ } else if (res.cancel) {
|
|
|
+ reject();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ });
|
|
|
});
|
|
|
- },
|
|
|
|
|
|
- handleDetail(item) {
|
|
|
- if (item.play_type === 1) {
|
|
|
- this.jumpModuleAll(`../detail/detail?id=${item.id}`);
|
|
|
- } else {
|
|
|
- this.jumpModuleAll(`../reward/detail?id=${item.id}`);
|
|
|
+ const res = await exchangeScore({
|
|
|
+ sku_id: item.id,
|
|
|
+ });
|
|
|
+
|
|
|
+ if (res.errno === 10000) {
|
|
|
+ uni.showToast({
|
|
|
+ icon: "none",
|
|
|
+ text: "兑换成功",
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
},
|