封装分享功能
This commit is contained in:
@@ -136,6 +136,15 @@ export const getInviteCode = (data) => {
|
||||
data: data,
|
||||
});
|
||||
};
|
||||
export const autoGetInviteCode = (data) => {
|
||||
return request({
|
||||
url: prveUrl + "/user/distribution/autoGetInviteCode",
|
||||
method: "get",
|
||||
data: data,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
// 获取配置
|
||||
export const getConfig = (data) => {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// const debug = process.env.NODE_ENV == 'development' ? true : false;
|
||||
// const debug = false; // false线上 true本地
|
||||
const debug = false; // false线上 true本地
|
||||
const debug = true; // false线上 true本地
|
||||
let baseUrl = ''
|
||||
let baseUrlwws = ''
|
||||
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
<!-- 轮播图 -->
|
||||
<swipers :carousel="hometoplist.bannerList"></swipers>
|
||||
<!-- 广告 -->
|
||||
<advertisement :bannervo="hometoplist.freeBannerList" :itemStyle="advertisementStyle" ref="refbannervo"></advertisement>
|
||||
<advertisement :bannervo="hometoplist.freeBannerList" :itemStyle="advertisementStyle" ref="refbannervo">
|
||||
</advertisement>
|
||||
<!-- 金刚区 -->
|
||||
<diamond :district="hometoplist.district"></diamond>
|
||||
<!-- 今日上线 -->
|
||||
@@ -133,39 +134,67 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import CouponModal from '@/components/coupon-modal.vue';
|
||||
import { ref, computed, onMounted, reactive, onBeforeUnmount, watch, getCurrentInstance, nextTick } from 'vue';
|
||||
import { onLoad, onReady, onShow, onReachBottom, onPageScroll } from '@dcloudio/uni-app';
|
||||
// 获取全局属性
|
||||
const { proxy } = getCurrentInstance();
|
||||
import pageLoading from './components/pageLoading.vue';
|
||||
import swipers from './components/swiper.vue'; //引入轮播
|
||||
import advertisement from './components/advertisement.vue'; //广告
|
||||
import diamond from './components/diamond.vue'; //金刚区
|
||||
import todaylist from './components/todaylist.vue'; //今日上线
|
||||
import indexs from './indexs.vue';
|
||||
import AreaSelect from './components/AreaSelect.vue'; //城市联动
|
||||
import grouping from './components/grouping.vue'; //其他
|
||||
import Nav from '@/components/indexnav.vue'; //导航栏
|
||||
import { APIhomehomePageUp, APIhome } from '@/common/api/index/index.js';
|
||||
import { APIgeocodelocation } from '@/common/api/api.js';
|
||||
import { useNavbarStore } from '@/stores/navbarStore';
|
||||
import { productStore } from '@/stores/user.js';
|
||||
import { getUnReadCountReq } from '../../common/api/account/message';
|
||||
const store = useNavbarStore();
|
||||
const storeuser = productStore();
|
||||
store.updateNavbarConfig({
|
||||
import CouponModal from '@/components/coupon-modal.vue';
|
||||
import {
|
||||
ref,
|
||||
computed,
|
||||
onMounted,
|
||||
reactive,
|
||||
onBeforeUnmount,
|
||||
watch,
|
||||
getCurrentInstance,
|
||||
nextTick
|
||||
} from 'vue';
|
||||
import {
|
||||
onLoad,
|
||||
onReady,
|
||||
onShow,
|
||||
onReachBottom,
|
||||
onPageScroll
|
||||
} from '@dcloudio/uni-app';
|
||||
// 获取全局属性
|
||||
const {
|
||||
proxy
|
||||
} = getCurrentInstance();
|
||||
import pageLoading from './components/pageLoading.vue';
|
||||
import swipers from './components/swiper.vue'; //引入轮播
|
||||
import advertisement from './components/advertisement.vue'; //广告
|
||||
import diamond from './components/diamond.vue'; //金刚区
|
||||
import todaylist from './components/todaylist.vue'; //今日上线
|
||||
import indexs from './indexs.vue';
|
||||
import AreaSelect from './components/AreaSelect.vue'; //城市联动
|
||||
import grouping from './components/grouping.vue'; //其他
|
||||
import Nav from '@/components/indexnav.vue'; //导航栏
|
||||
import {
|
||||
APIhomehomePageUp,
|
||||
APIhome
|
||||
} from '@/common/api/index/index.js';
|
||||
import {
|
||||
APIgeocodelocation
|
||||
} from '@/common/api/api.js';
|
||||
import {
|
||||
useNavbarStore
|
||||
} from '@/stores/navbarStore';
|
||||
import {
|
||||
productStore
|
||||
} from '@/stores/user.js';
|
||||
import {
|
||||
getUnReadCountReq
|
||||
} from '../../common/api/account/message';
|
||||
const store = useNavbarStore();
|
||||
const storeuser = productStore();
|
||||
store.updateNavbarConfig({
|
||||
showBack: true, //左边返回键
|
||||
rightText: '', //右边文字
|
||||
showSearch: true, //true是标题其他事文字
|
||||
title: '我的页面',
|
||||
isTransparent: false,
|
||||
hasPlaceholder: false //是否要占位符
|
||||
});
|
||||
// 显示
|
||||
const showindex = ref('index');
|
||||
//计算广告图片的重合尺寸是位移
|
||||
const getStyle = (e) => {
|
||||
});
|
||||
// 显示
|
||||
const showindex = ref('index');
|
||||
//计算广告图片的重合尺寸是位移
|
||||
const getStyle = (e) => {
|
||||
if (e > hometoplist.freeBannerList.length / 2) {
|
||||
var right = hometoplist.freeBannerList.length - e;
|
||||
return {
|
||||
@@ -180,13 +209,13 @@ const getStyle = (e) => {
|
||||
opacity: 1
|
||||
};
|
||||
}
|
||||
};
|
||||
const advertisementStyle = ref([]);
|
||||
const refbannervo = ref(null);
|
||||
//数据
|
||||
const hometoplist = reactive({});
|
||||
// 首页上面数据
|
||||
const hometop = async () => {
|
||||
};
|
||||
const advertisementStyle = ref([]);
|
||||
const refbannervo = ref(null);
|
||||
//数据
|
||||
const hometoplist = reactive({});
|
||||
// 首页上面数据
|
||||
const hometop = async () => {
|
||||
try {
|
||||
let res = await APIhomehomePageUp();
|
||||
Object.assign(hometoplist, res);
|
||||
@@ -205,9 +234,9 @@ const hometop = async () => {
|
||||
.exec();
|
||||
}, 500);
|
||||
} catch (e) {}
|
||||
};
|
||||
// 下面初始数据
|
||||
const formhomelist = reactive({
|
||||
};
|
||||
// 下面初始数据
|
||||
const formhomelist = reactive({
|
||||
//筛选
|
||||
address: '', //地址
|
||||
categoryId: '1', //品类
|
||||
@@ -218,15 +247,15 @@ const formhomelist = reactive({
|
||||
status: 'loadmore',
|
||||
name: '1',
|
||||
list: []
|
||||
});
|
||||
// 使用 reactive 创建响应式对象
|
||||
const timeData = ref({});
|
||||
});
|
||||
// 使用 reactive 创建响应式对象
|
||||
const timeData = ref({});
|
||||
|
||||
// 定义 onChange 方法
|
||||
const onChange = (e) => {
|
||||
// 定义 onChange 方法
|
||||
const onChange = (e) => {
|
||||
timeData.value = e;
|
||||
};
|
||||
const onLoadhome = async () => {
|
||||
};
|
||||
const onLoadhome = async () => {
|
||||
try {
|
||||
let res = await APIhome(formhomelist);
|
||||
var dates = new Date().getTime();
|
||||
@@ -270,9 +299,9 @@ const onLoadhome = async () => {
|
||||
}
|
||||
}
|
||||
} catch (e) {}
|
||||
};
|
||||
// /筛选数据处理
|
||||
const init_fn = async () => {
|
||||
};
|
||||
// /筛选数据处理
|
||||
const init_fn = async () => {
|
||||
formhomelist.list = [];
|
||||
Object.assign(formhomelist, {
|
||||
address: uni.cache.get('getLocationstorage').address, //地址
|
||||
@@ -286,28 +315,28 @@ const init_fn = async () => {
|
||||
status: 'loadmore'
|
||||
});
|
||||
onLoadhome();
|
||||
};
|
||||
};
|
||||
|
||||
const orderVIP = ref({
|
||||
const orderVIP = ref({
|
||||
shopExtendList: ''
|
||||
});
|
||||
});
|
||||
|
||||
// 弹出层处理
|
||||
const showproductlist = ref(false);
|
||||
// 定义方法
|
||||
const openproductlist = (e) => {
|
||||
// 弹出层处理
|
||||
const showproductlist = ref(false);
|
||||
// 定义方法
|
||||
const openproductlist = (e) => {
|
||||
hometoplist.menuList[viewHistoryindex.value].name = e; //下标更改name
|
||||
showproductlist.value = !showproductlist.value;
|
||||
};
|
||||
};
|
||||
|
||||
// 存储每个元素距离顶部的距离
|
||||
const elementTop = ref(0);
|
||||
// 存储是否吸顶的状态
|
||||
const isSticky = ref(true);
|
||||
//下标
|
||||
const viewHistoryindex = ref(null);
|
||||
// 点击滑动元素
|
||||
const viewHistory = async (item, index) => {
|
||||
// 存储每个元素距离顶部的距离
|
||||
const elementTop = ref(0);
|
||||
// 存储是否吸顶的状态
|
||||
const isSticky = ref(true);
|
||||
//下标
|
||||
const viewHistoryindex = ref(null);
|
||||
// 点击滑动元素
|
||||
const viewHistory = async (item, index) => {
|
||||
if (isSticky) {
|
||||
uni.pageScrollTo({
|
||||
scrollTop: elementTop.value,
|
||||
@@ -316,29 +345,47 @@ const viewHistory = async (item, index) => {
|
||||
}
|
||||
// 是否有弹出层
|
||||
if (item.isChild) {
|
||||
showproductlist.value = showproductlist.value ? (viewHistoryindex.value == index ? false : true) : !showproductlist.value;
|
||||
showproductlist.value = showproductlist.value ? (viewHistoryindex.value == index ? false : true) : !
|
||||
showproductlist.value;
|
||||
}
|
||||
viewHistoryindex.value = index;
|
||||
};
|
||||
// 滑动
|
||||
onPageScroll((res) => {
|
||||
};
|
||||
// 滑动
|
||||
onPageScroll((res) => {
|
||||
isSticky.value = res.scrollTop > elementTop.value ? true : false;
|
||||
uni.$u.debounce((store.scrollTop = res.scrollTop), 500);
|
||||
});
|
||||
});
|
||||
|
||||
const indexsRef = ref(null);
|
||||
const indexsRef = ref(null);
|
||||
const shopId = ref(null)
|
||||
const shopInfo = ref(null)
|
||||
onShow(async () => {
|
||||
if (!storeuser.isHasLogin) {
|
||||
await handleMixinOnLoad(options)
|
||||
console.log('shopInfo', uni.cache.get('shopInfo'));
|
||||
console.log('【页面】开始处理自身业务逻辑');
|
||||
setTimeout(() => {
|
||||
showPageLoading.value = false;
|
||||
getUnReadMsgCount();
|
||||
}, 800);
|
||||
onPageShow()
|
||||
} else {
|
||||
onPageShow()
|
||||
}
|
||||
|
||||
onShow(async () => {
|
||||
});
|
||||
|
||||
async function onPageShow() {
|
||||
try {
|
||||
await storeuser.getLocation();
|
||||
proxy.$isResolve();
|
||||
const shopId = uni.cache.get('shopId');
|
||||
if (shopId) {
|
||||
shopId.value = uni.cache.get('shopId');
|
||||
if (shopId.value) {
|
||||
indexsRef.value.updateData();
|
||||
}
|
||||
} catch (error) {}
|
||||
await proxy.$onLaunched;
|
||||
if (uni.cache.get('shopId')) {
|
||||
if (shopId.value) {
|
||||
showindex.value = 'shopIndex';
|
||||
await storeuser.actionsproductqueryProduct();
|
||||
await nextTick();
|
||||
@@ -349,11 +396,13 @@ onShow(async () => {
|
||||
init_fn();
|
||||
// 获取初始定位高度
|
||||
}
|
||||
});
|
||||
|
||||
const showPageLoading = ref(true);
|
||||
shopInfo.value = uni.cache.get('shopInfo');
|
||||
}
|
||||
|
||||
const getUnReadMsgCount = async () => {
|
||||
const showPageLoading = ref(true);
|
||||
|
||||
const getUnReadMsgCount = async () => {
|
||||
let res = await getUnReadCountReq()
|
||||
|
||||
let badge = Number(res)
|
||||
@@ -367,30 +416,64 @@ const getUnReadMsgCount = async () => {
|
||||
index: 2
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
setTimeout(() => {
|
||||
showPageLoading.value = false;
|
||||
|
||||
getUnReadMsgCount();
|
||||
}, 800);
|
||||
});
|
||||
|
||||
onReachBottom(() => {
|
||||
onReachBottom(() => {
|
||||
onLoadhome();
|
||||
});
|
||||
});
|
||||
|
||||
// 页面离开时清除定时器
|
||||
// onBeforeUnmount(() => {
|
||||
// if (refbannervo.value) {
|
||||
// refbannervo.value.clearTimer();
|
||||
// }
|
||||
// });
|
||||
import {
|
||||
shareMixin,
|
||||
handleMixinOnLoad
|
||||
} from '@/utils/share.js'
|
||||
|
||||
|
||||
watch(() => shopId.value, (newval) => {
|
||||
if (newval) {
|
||||
uni.showShareMenu({
|
||||
withShareTicket: true, // 可选:是否返回分享票据
|
||||
menus: ['shareAppMessage', 'shareTimeline'] // 显示「分享好友」和「分享朋友圈」
|
||||
});
|
||||
} else {
|
||||
uni.hideShareMenu();
|
||||
}
|
||||
}, {
|
||||
immediate: true
|
||||
})
|
||||
|
||||
|
||||
defineOptions({
|
||||
mixins: [shareMixin],
|
||||
});
|
||||
|
||||
|
||||
const options = reactive({})
|
||||
|
||||
onLoad(async (opt) => {
|
||||
Object.assign(options, opt)
|
||||
// await handleMixinOnLoad(options)
|
||||
// console.log('shopInfo', uni.cache.get('shopInfo'));
|
||||
// console.log('【页面】开始处理自身业务逻辑');
|
||||
// setTimeout(() => {
|
||||
// showPageLoading.value = false;
|
||||
// getUnReadMsgCount();
|
||||
// }, 800);
|
||||
})
|
||||
|
||||
|
||||
|
||||
// 页面离开时清除定时器
|
||||
// onBeforeUnmount(() => {
|
||||
// if (refbannervo.value) {
|
||||
// refbannervo.value.clearTimer();
|
||||
// }
|
||||
// });
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.content {
|
||||
.content {
|
||||
background: #f9f9f9;
|
||||
|
||||
.fourcontent {
|
||||
@@ -702,5 +785,5 @@ onReachBottom(() => {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -2,9 +2,11 @@
|
||||
<view class="content min-page bg-f7">
|
||||
<view class="contentbox">
|
||||
<template v-if="shopExtend.length">
|
||||
<image class="bg" :src="shopExtend[0].value" mode="aspectFill" v-if="!isJsonArrayString(shopExtend[0].value)"></image>
|
||||
<image class="bg" :src="shopExtend[0].value" mode="aspectFill"
|
||||
v-if="!isJsonArrayString(shopExtend[0].value)"></image>
|
||||
<swiper class="swiper" autoplay circular v-else>
|
||||
<swiper-item class="swiper-item" v-for="(item, index) in JSON.parse(shopExtend[0].value)" :key="index">
|
||||
<swiper-item class="swiper-item" v-for="(item, index) in JSON.parse(shopExtend[0].value)"
|
||||
:key="index">
|
||||
<image class="swiper-bg" :src="item"></image>
|
||||
</swiper-item>
|
||||
</swiper>
|
||||
@@ -118,15 +120,28 @@
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import attractPopup from '@/components/attract-popup.vue';
|
||||
import { homeData } from '@/common/api/market/index.js';
|
||||
import { getMemberConfig, getRechargeConfig } from '@/common/api/index/index.js';
|
||||
import { ref, reactive, defineProps, defineEmits, onMounted } from 'vue';
|
||||
import { isJsonArrayString } from '@/utils/util.js';
|
||||
import attractPopup from '@/components/attract-popup.vue';
|
||||
import {
|
||||
homeData
|
||||
} from '@/common/api/market/index.js';
|
||||
import {
|
||||
getMemberConfig,
|
||||
getRechargeConfig
|
||||
} from '@/common/api/index/index.js';
|
||||
import {
|
||||
ref,
|
||||
reactive,
|
||||
defineProps,
|
||||
defineEmits,
|
||||
onMounted
|
||||
} from 'vue';
|
||||
import {
|
||||
isJsonArrayString
|
||||
} from '@/utils/util.js';
|
||||
|
||||
const attractPopupRef = ref(null);
|
||||
const attractPopupRef = ref(null);
|
||||
|
||||
const imgs = {
|
||||
const imgs = {
|
||||
recharge: 'https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/4/2f22c0ced494497e8d6f981832b191c9.png',
|
||||
share: 'https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/4/bcb8d461e96d445ba40256079da775b3.png',
|
||||
vip: 'https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/4/cfc3bf5ba12747c6ada4d5a388aceca3.png',
|
||||
@@ -138,75 +153,79 @@ const imgs = {
|
||||
code: 'https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/4/044dcaf913054f03a9db7983f048b1e6.png',
|
||||
defaultAvatar: 'https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/4/b98d2c7110e847f996e8d7ba4342f0a5.png',
|
||||
taocan: 'https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/4/1eb9aa9b865b47b39ab9d7ac404601a9.png'
|
||||
};
|
||||
// 定义接收的属性
|
||||
const props = defineProps({
|
||||
};
|
||||
// 定义接收的属性
|
||||
const props = defineProps({
|
||||
shopExtend: {
|
||||
type: Array,
|
||||
default: []
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function toGroupBuying() {
|
||||
function toGroupBuying() {
|
||||
uni.navigateTo({
|
||||
url: '/groupBuying/index/index'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function toFenxiao() {
|
||||
function toFenxiao() {
|
||||
uni.navigateTo({
|
||||
url: '/distribution/shop-detail/index?shopId=' + uni.cache.get('shopId')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function toIntegralMall() {
|
||||
function toIntegralMall() {
|
||||
uni.navigateTo({
|
||||
url: '/scoreShop/index/index?shopId=' + uni.cache.get('shopId')
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
import { productStore } from '@/stores/user.js';
|
||||
import { onShow } from '@dcloudio/uni-app';
|
||||
import {
|
||||
productStore
|
||||
} from '@/stores/user.js';
|
||||
import {
|
||||
onShow
|
||||
} from '@dcloudio/uni-app';
|
||||
|
||||
// 显示弹窗
|
||||
const popupShow = ref(false);
|
||||
const scanCodehandle = (i) => {
|
||||
// 显示弹窗
|
||||
const popupShow = ref(false);
|
||||
const scanCodehandle = (i) => {
|
||||
popupShow.value = true;
|
||||
};
|
||||
};
|
||||
|
||||
// 预点单
|
||||
function beforehandOrderHandle() {
|
||||
// 预点单
|
||||
function beforehandOrderHandle() {
|
||||
popupShow.value = false;
|
||||
uni.cache.set('dinersNum', 1);
|
||||
uni.cache.set('tableCode', shopUserInfo.id);
|
||||
uni.navigateTo({
|
||||
url: '/pages/product/index?type=beforehand'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 扫码点餐
|
||||
async function scanOrderHandle() {
|
||||
// 扫码点餐
|
||||
async function scanOrderHandle() {
|
||||
popupShow.value = false;
|
||||
const store = productStore();
|
||||
await store.scanCodeactions();
|
||||
}
|
||||
}
|
||||
|
||||
function toTaocan() {
|
||||
function toTaocan() {
|
||||
uni.navigateTo({
|
||||
url: '/userPackage/index/index'
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
const memberindex = (url) => {
|
||||
const memberindex = (url) => {
|
||||
uni.pro.navigateTo(url, {
|
||||
shopId: uni.cache.get('shopId'),
|
||||
type: 'index'
|
||||
});
|
||||
};
|
||||
const shopUserInfo = reactive({});
|
||||
Object.assign(shopUserInfo, uni.cache.get('shopUserInfo') || {});
|
||||
};
|
||||
const shopUserInfo = reactive({});
|
||||
Object.assign(shopUserInfo, uni.cache.get('shopUserInfo') || {});
|
||||
|
||||
function tomember() {
|
||||
function tomember() {
|
||||
if (isMember.value) {
|
||||
const shopId = uni.cache.get('shopId');
|
||||
if (!shopUserInfo.isVip) {
|
||||
@@ -224,9 +243,9 @@ function tomember() {
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function toCharge() {
|
||||
function toCharge() {
|
||||
if (isCharge.value) {
|
||||
const shopId = uni.cache.get('shopId');
|
||||
uni.navigateTo({
|
||||
@@ -238,8 +257,8 @@ function toCharge() {
|
||||
icon: 'none'
|
||||
});
|
||||
}
|
||||
}
|
||||
const getQueryString = (url, name) => {
|
||||
}
|
||||
const getQueryString = (url, name) => {
|
||||
//解码
|
||||
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i');
|
||||
var r = url.substr(1).match(reg);
|
||||
@@ -247,12 +266,12 @@ const getQueryString = (url, name) => {
|
||||
return r[2];
|
||||
}
|
||||
return null;
|
||||
};
|
||||
};
|
||||
|
||||
// 获取会员配置
|
||||
const isMember = ref(0);
|
||||
const isCharge = ref(0);
|
||||
async function getVipConfig() {
|
||||
// 获取会员配置
|
||||
const isMember = ref(0);
|
||||
const isCharge = ref(0);
|
||||
async function getVipConfig() {
|
||||
try {
|
||||
const res1 = await getMemberConfig({
|
||||
shopId: uni.cache.get('shopId')
|
||||
@@ -266,43 +285,46 @@ async function getVipConfig() {
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const allConfig = reactive({
|
||||
const allConfig = reactive({
|
||||
takeout: 0,
|
||||
group: 0,
|
||||
pointsMall: 0,
|
||||
distribution: 0,
|
||||
couponNum: 0,
|
||||
pointNum: 0
|
||||
});
|
||||
});
|
||||
|
||||
function getHomeData() {
|
||||
function getHomeData() {
|
||||
homeData().then((res) => {
|
||||
Object.assign(allConfig, res);
|
||||
imgs.defaultAvatar = res.userAvatar ? res.userAvatar : imgs.defaultAvatar;
|
||||
});
|
||||
}
|
||||
onMounted(() => {
|
||||
}
|
||||
onMounted(() => {
|
||||
updateData();
|
||||
});
|
||||
});
|
||||
|
||||
function updateData() {
|
||||
function updateData() {
|
||||
Object.assign(shopUserInfo, uni.cache.get('shopUserInfo') || {});
|
||||
getVipConfig();
|
||||
getHomeData();
|
||||
}
|
||||
defineExpose({
|
||||
}
|
||||
defineExpose({
|
||||
updateData
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
page {
|
||||
page {
|
||||
background: #f6f8fa;
|
||||
}
|
||||
}
|
||||
|
||||
.swiper {
|
||||
.swiper {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
@@ -315,9 +337,9 @@ page {
|
||||
height: 100%;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.content {
|
||||
.content {
|
||||
.contentbox {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
@@ -405,9 +427,9 @@ page {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.popup-content {
|
||||
.popup-content {
|
||||
width: 90vw;
|
||||
background-color: #fff;
|
||||
border-radius: 8px;
|
||||
@@ -446,9 +468,9 @@ page {
|
||||
width: 248upx;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.menus {
|
||||
.menus {
|
||||
display: flex;
|
||||
padding: 32rpx 40rpx;
|
||||
margin-top: 150rpx;
|
||||
@@ -462,9 +484,9 @@ page {
|
||||
box-shadow: 0rpx 6rpx 12rpx 2rpx rgba(0, 0, 0, 0.16);
|
||||
flex: 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.userInfo {
|
||||
.userInfo {
|
||||
display: flex;
|
||||
padding: 22rpx 24rpx;
|
||||
margin: 0 4rpx;
|
||||
@@ -489,9 +511,9 @@ page {
|
||||
width: 33px;
|
||||
height: 33px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.new-menus-box {
|
||||
.new-menus-box {
|
||||
margin: 0 16rpx 0 16rpx;
|
||||
|
||||
.new-menus {
|
||||
@@ -523,8 +545,7 @@ page {
|
||||
background: #ededed;
|
||||
}
|
||||
|
||||
.takeout {
|
||||
}
|
||||
.takeout {}
|
||||
}
|
||||
|
||||
&.layout1 {
|
||||
@@ -549,9 +570,9 @@ page {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.groupBuying {
|
||||
.groupBuying {
|
||||
padding: 16rpx 38rpx;
|
||||
border-top: 2rpx solid #ededed;
|
||||
background-color: #fff;
|
||||
@@ -563,21 +584,21 @@ page {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.title {
|
||||
.title {
|
||||
color: #333333;
|
||||
font-size: 36rpx;
|
||||
font-weight: 700;
|
||||
}
|
||||
}
|
||||
|
||||
.desc {
|
||||
.desc {
|
||||
margin-top: 16rpx;
|
||||
font-size: 28rpx;
|
||||
color: #999;
|
||||
}
|
||||
}
|
||||
|
||||
.points {
|
||||
.points {
|
||||
margin-top: 10px;
|
||||
background-color: #fff;
|
||||
padding: 16rpx 68rpx;
|
||||
@@ -590,16 +611,16 @@ page {
|
||||
width: 98px;
|
||||
height: 98px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.taocan {
|
||||
.taocan {
|
||||
.img {
|
||||
width: 117px;
|
||||
height: 117px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.bottom_menus {
|
||||
.bottom_menus {
|
||||
display: flex;
|
||||
gap: 14rpx;
|
||||
margin-top: 10px;
|
||||
@@ -629,5 +650,5 @@ page {
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -749,7 +749,7 @@
|
||||
useCartStore
|
||||
} from '@/stores/order.js';
|
||||
import {
|
||||
computed, provide
|
||||
computed, provide, reactive
|
||||
} from 'vue';
|
||||
const cartStore = useCartStore();
|
||||
/**
|
||||
@@ -2437,27 +2437,50 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
import {
|
||||
shareMixin,
|
||||
handleMixinOnLoad,returnQuery
|
||||
} from '@/utils/share.js'
|
||||
defineOptions({
|
||||
mixins: [shareMixin],
|
||||
});
|
||||
|
||||
onShareAppMessage((res)=>{
|
||||
let query=returnQuery()
|
||||
query+='&type=beforehand'
|
||||
return {
|
||||
...res,
|
||||
...query,
|
||||
path: '/pages/product/index' + '?' + query,
|
||||
query,
|
||||
}
|
||||
})
|
||||
|
||||
const pageOptions=reactive({})
|
||||
onLoad(async (e) => {
|
||||
Object.assign(pageOptions,e)
|
||||
if (e.type) {
|
||||
orderType.value = e.type;
|
||||
}
|
||||
//获取用户信息
|
||||
const userInfo = await APIshopUserInfo({
|
||||
shopId: uni.cache.get('shopId')
|
||||
})
|
||||
//获取店铺信息
|
||||
const shopInfoRes = await APIusershopInfodetail({
|
||||
shopId: uni.cache.get('shopId')
|
||||
});
|
||||
await handleMixinOnLoad(e)
|
||||
const userInfo= userStore.userInfo
|
||||
const shopInfoRes=userStore.shopInfo
|
||||
// //获取用户信息
|
||||
// const userInfo = await APIshopUserInfo({
|
||||
// shopId: uni.cache.get('shopId')
|
||||
// })
|
||||
// //获取店铺信息
|
||||
// const shopInfoRes = await APIusershopInfodetail({
|
||||
// shopId: uni.cache.get('shopId')
|
||||
// });
|
||||
if (shopInfoRes && shopInfoRes.shopInfo) {
|
||||
Object.assign(shopInfo, shopInfoRes.shopInfo);
|
||||
uni.cache.set('shopInfo', shopInfoRes.shopInfo)
|
||||
}
|
||||
|
||||
|
||||
if (userInfo && typeof userInfo === 'object') {
|
||||
shopUserInfo.value = userInfo
|
||||
uni.cache.set('shopUserInfo', userInfo)
|
||||
}
|
||||
await productqueryProduct();
|
||||
|
||||
|
||||
104
stores/user.js
104
stores/user.js
@@ -49,7 +49,7 @@ export const Storelogin = defineStore("login", {
|
||||
rawData: infoRes.rawData,
|
||||
source: "wechat",
|
||||
});
|
||||
console.log('APIuserlogin',res);
|
||||
console.log('APIuserlogin', res);
|
||||
if (res) {
|
||||
this.token = res.token;
|
||||
this.miniAppOpenId = res.userInfo
|
||||
@@ -110,12 +110,90 @@ export const productStore = defineStore("product", {
|
||||
latitude: "",
|
||||
longitude: "",
|
||||
},
|
||||
token: "",
|
||||
miniAppOpenId: "",
|
||||
userInfo: "",
|
||||
shopId: uni.cache.get('shopId') || '',
|
||||
shopInfo: {
|
||||
shopId: "",
|
||||
isOrderFence: 0,
|
||||
id: '',
|
||||
},
|
||||
shopUserInfo:{
|
||||
|
||||
},
|
||||
isHasLogin:false
|
||||
}),
|
||||
actions: {
|
||||
actionslogin() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// #ifdef MP-WEIXIN
|
||||
uni.login({
|
||||
provider: "weixin",
|
||||
success: (data) => {
|
||||
// 微信小程序环境
|
||||
uni.getUserInfo({
|
||||
provider: "weixin",
|
||||
success: async (infoRes) => {
|
||||
let res = await APIuserlogin({
|
||||
code: data.code, //临时登录凭证
|
||||
rawData: infoRes.rawData,
|
||||
source: "wechat",
|
||||
});
|
||||
console.log('APIuserlogin', res);
|
||||
if (res) {
|
||||
this.token = res.token;
|
||||
this.isHasLogin=true
|
||||
this.miniAppOpenId = res.userInfo
|
||||
.miniAppOpenId;
|
||||
this.userInfo = res.userInfo;
|
||||
uni.cache.set("token", res.token);
|
||||
uni.cache.set("userInfo", res.userInfo);
|
||||
uni.cache.set("followIndex", res
|
||||
.followIndex || "");
|
||||
}
|
||||
resolve(true);
|
||||
},
|
||||
fail: (err) => {
|
||||
reject(false);
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
// #endif
|
||||
// #ifdef MP-ALIPAY
|
||||
my.getAuthCode({
|
||||
scopes: "auth_base",
|
||||
success: async (data) => {
|
||||
// 支付宝小程序环境
|
||||
// my.getAuthUserInfo({
|
||||
// success: async (infoRes) => {
|
||||
let res = await APIuserlogin({
|
||||
code: data.authCode, //临时登录凭证
|
||||
// rawData: JSON.stringify(infoRes),
|
||||
source: "alipay",
|
||||
});
|
||||
if (res) {
|
||||
this.isHasLogin=true
|
||||
this.token = res.token;
|
||||
this.miniAppOpenId = res.userInfo.miniAppOpenId;
|
||||
this.userInfo = res.userInfo;
|
||||
uni.cache.set("token", res.token);
|
||||
uni.cache.set("openId", res.userInfo.alipayOpenId);
|
||||
uni.cache.set("userInfo", res.userInfo);
|
||||
resolve(true);
|
||||
}
|
||||
},
|
||||
fail: () => {
|
||||
reject(false);
|
||||
},
|
||||
});
|
||||
// #endif
|
||||
// #ifdef H5
|
||||
resolve(true)
|
||||
// #endif
|
||||
});
|
||||
},
|
||||
getLocation() {
|
||||
return new Promise((resolve, reject) => {
|
||||
console.log("获取经纬度");
|
||||
@@ -185,7 +263,7 @@ export const productStore = defineStore("product", {
|
||||
console.log("扫码内容", q);
|
||||
// #ifdef H5
|
||||
uni.navigateTo({
|
||||
url:'/pages/product/index'
|
||||
url: '/pages/product/index'
|
||||
})
|
||||
return
|
||||
// #endif
|
||||
@@ -448,19 +526,41 @@ export const productStore = defineStore("product", {
|
||||
|
||||
// 通过shopId 获取店铺会员信息
|
||||
actionsproductqueryProduct() {
|
||||
console.log('actionsproductqueryProduct:token',uni.cache.get('token'));
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
let res = await APIshopUserInfo();
|
||||
if(res&& typeof res === 'object'){
|
||||
this.shopUserInfo=res;
|
||||
uni.cache.set("shopUserInfo", res);
|
||||
uni.cache.set("orderVIP", res);
|
||||
uni.cache.set("ordershopUserInfo", res.shopInfo);
|
||||
resolve(res);
|
||||
}else{
|
||||
reject(false);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
reject(false);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
async pageOnload() {
|
||||
//登录
|
||||
await this.actionslogin()
|
||||
//获取会员信息
|
||||
await this.actionsproductqueryProduct()
|
||||
//获取店铺信息
|
||||
await this.getShopInfo()
|
||||
},
|
||||
async getShopInfo(shopId) {
|
||||
const shopRes = await APIusershopInfodetail({
|
||||
shopId: this.shopId || shopId,
|
||||
});
|
||||
this.shopInfo = shopRes.shopInfo;
|
||||
uni.cache.set("shopInfo", shopRes.shopInfo);
|
||||
},
|
||||
// 用户信息获取
|
||||
actionsAPIuser() {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
|
||||
246
utils/share.js
246
utils/share.js
@@ -1,7 +1,15 @@
|
||||
import {
|
||||
autoBindInviteUser
|
||||
autoBindInviteUser,
|
||||
autoGetInviteCode
|
||||
} from '@/common/api/market/distribution.js'
|
||||
|
||||
import {
|
||||
APIshopUserInfo,
|
||||
APIusershopInfodetail
|
||||
} from '@/common/api/member.js'
|
||||
import {
|
||||
productStore
|
||||
} from '@/stores/user.js';
|
||||
const accountStore = productStore();
|
||||
const accountInfo = wx.getAccountInfoSync();
|
||||
export const envVersion = accountInfo.miniProgram.envVersion;
|
||||
let type = 3;
|
||||
@@ -53,3 +61,237 @@ export function wxShare(par) {
|
||||
type
|
||||
}
|
||||
}
|
||||
|
||||
export async function returnQuery(query) {
|
||||
|
||||
|
||||
const shopId = uni.cache.get('shopId')
|
||||
const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
const shopInfo = uni.cache.get('shopInfo')
|
||||
const inviteCode = await autoGetInviteCode({
|
||||
shopId: shopId,
|
||||
shopUserId: shopUserInfo.id
|
||||
})
|
||||
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const currentPath = currentPage.route;
|
||||
const currentOptions = currentPage.options;
|
||||
|
||||
|
||||
let sharePath = `/${currentPath}`;
|
||||
const queryJson = {
|
||||
inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
|
||||
shopId,
|
||||
shopUserId: shopUserInfo.id,
|
||||
...query
|
||||
}
|
||||
for (const key in currentOptions) {
|
||||
if (currentOptions.hasOwnProperty(key)) {
|
||||
queryJson[key] = encodeURIComponent(currentOptions[key])
|
||||
}
|
||||
}
|
||||
queryJson.shopId = shopId
|
||||
queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
||||
queryJson.shopUserId = shopUserInfo.id
|
||||
|
||||
let result = ''
|
||||
for (let key in queryJson) {
|
||||
if (queryJson[key]) {
|
||||
if (result === '') {
|
||||
result += `${key}=${queryJson[key]}`
|
||||
} else {
|
||||
result += `&${key}=${queryJson[key]}`
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function parseQueryString(queryString) {
|
||||
const queryParams = queryString.split("&").map((param) => param.split("="));
|
||||
const params = {};
|
||||
for (const [key, value] of queryParams) {
|
||||
params[key] = value;
|
||||
}
|
||||
return params;
|
||||
}
|
||||
/**
|
||||
* 混入的 onLoad 核心逻辑(抽成独立函数)
|
||||
* @param {Object} opt - 页面 onLoad 接收的参数
|
||||
* @param {Object} vm - 组件实例(this)
|
||||
*/
|
||||
export async function handleMixinOnLoad(opt, vm) {
|
||||
console.log('onLoad');
|
||||
const options = {}
|
||||
if (opt.q) {
|
||||
const q = decodeURIComponent(opt.q);
|
||||
const params = parseQueryString(q.split("?")[1]);
|
||||
Object.assign(options, params);
|
||||
} else {
|
||||
Object.assign(options, opt);
|
||||
}
|
||||
console.log('options', options);
|
||||
if (options.shopId) {
|
||||
uni.cache.set('shopId', options.shopId)
|
||||
accountStore.shopId = options.shopId
|
||||
await accountStore.pageOnload()
|
||||
}
|
||||
uni.setStorageSync('loadFinsh', true)
|
||||
// const shopId = uni.cache.get('shopId')
|
||||
// const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
// const shopInfo = uni.cache.get('shopInfo')
|
||||
// const inviteCode = await autoGetInviteCode({
|
||||
// shopId: shopId,
|
||||
// shopUserId: shopUserInfo.id
|
||||
// })
|
||||
|
||||
if (options.inviteCode) {
|
||||
bindInvite(options)
|
||||
}
|
||||
}
|
||||
// utils/share.js
|
||||
export const shareMixin = {
|
||||
|
||||
// async onLoad(opt) {
|
||||
// console.log('onLoad');
|
||||
// const options = {}
|
||||
// if (opt.q) {
|
||||
// const q = decodeURIComponent(opt.q);
|
||||
// const params = parseQueryString(q.split("?")[1]);
|
||||
// Object.assign(options, params);
|
||||
// } else {
|
||||
// Object.assign(options, opt);
|
||||
// }
|
||||
// console.log('options', options);
|
||||
// if (options.shopId) {
|
||||
// uni.cache.set('shopId', options.shopId)
|
||||
// }
|
||||
|
||||
// const shopId = uni.cache.get('shopId')
|
||||
// const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
// const shopInfo = uni.cache.get('shopInfo')
|
||||
// const inviteCode = await autoGetInviteCode({
|
||||
// shopId: shopId,
|
||||
// shopUserId: shopUserInfo.id
|
||||
// })
|
||||
|
||||
// uni.setStorageSync('loadFinsh',true)
|
||||
|
||||
|
||||
// if (options.inviteCode) {
|
||||
// bindInvite(options)
|
||||
// }
|
||||
// },
|
||||
async onShareAppMessage(res) {
|
||||
// const shopId = uni.cache.get('shopId')
|
||||
// const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
const shopInfo = uni.cache.get('shopInfo')
|
||||
// const inviteCode = await autoGetInviteCode({
|
||||
// shopId: shopId,
|
||||
// shopUserId: shopUserInfo.id
|
||||
// })
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const currentPath = currentPage.route;
|
||||
const currentOptions = currentPage.options;
|
||||
|
||||
let sharePath = `/${currentPath}`;
|
||||
// const queryJson = {
|
||||
// inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
|
||||
// shopId,
|
||||
// shopUserId: shopUserInfo.id,
|
||||
// }
|
||||
// for (const key in currentOptions) {
|
||||
// if (currentOptions.hasOwnProperty(key)) {
|
||||
// queryJson[key] = encodeURIComponent(currentOptions[key])
|
||||
// }
|
||||
// }
|
||||
// queryJson.shopId = shopId
|
||||
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
||||
// queryJson.shopUserId = shopUserInfo.id
|
||||
|
||||
const query = returnQuery()
|
||||
|
||||
|
||||
// 全局默认配置(可被页面覆盖)
|
||||
const defaultShareConfig = {
|
||||
title: shopInfo.shopName,
|
||||
path: sharePath + '?' + query,
|
||||
imageUrl: shopInfo.logo,
|
||||
query,
|
||||
// desc: '描述',
|
||||
success: (res) => {
|
||||
console.log('分享好友成功', res);
|
||||
// 可加埋点等统一逻辑
|
||||
},
|
||||
fail: (err) => {
|
||||
console.error('分享好友失败', err);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 页面自定义配置覆盖全局
|
||||
const pageShareConfig = this.$options.shareConfig || {};
|
||||
console.log('mixIn onShareAppMessage', {
|
||||
...defaultShareConfig,
|
||||
...pageShareConfig
|
||||
})
|
||||
return {
|
||||
...defaultShareConfig,
|
||||
...pageShareConfig
|
||||
};
|
||||
},
|
||||
|
||||
|
||||
async onShareTimeline() {
|
||||
|
||||
|
||||
// const shopId = uni.cache.get('shopId')
|
||||
// const shopUserInfo = uni.cache.get('shopUserInfo')
|
||||
const shopInfo = uni.cache.get('shopInfo')
|
||||
// const inviteCode = await autoGetInviteCode({
|
||||
// shopId: shopId,
|
||||
// shopUserId: shopUserInfo.id
|
||||
// })
|
||||
|
||||
const pages = getCurrentPages();
|
||||
const currentPage = pages[pages.length - 1];
|
||||
const currentPath = currentPage.route;
|
||||
const currentOptions = currentPage.options;
|
||||
|
||||
|
||||
let sharePath = `/${currentPath}`;
|
||||
// const queryJson = {
|
||||
// inviteCode: (inviteCode && inviteCode !== true) ? inviteCode : null,
|
||||
// shopId,
|
||||
// shopUserId: shopUserInfo.id,
|
||||
// }
|
||||
// for (const key in currentOptions) {
|
||||
// if (currentOptions.hasOwnProperty(key)) {
|
||||
// queryJson[key] = encodeURIComponent(currentOptions[key])
|
||||
// }
|
||||
// }
|
||||
// queryJson.shopId = shopId
|
||||
// queryJson.inviteCode = (inviteCode && inviteCode !== true) ? inviteCode : null
|
||||
// queryJson.shopUserId = shopUserInfo.id
|
||||
|
||||
const query = returnQuery()
|
||||
|
||||
const defaultTimelineConfig = {
|
||||
title: shopInfo.shopName,
|
||||
path: sharePath + '?' + query,
|
||||
imageUrl: shopInfo.logo,
|
||||
query,
|
||||
};
|
||||
|
||||
const pageTimelineConfig = this.$options.shareTimelineConfig || {};
|
||||
return {
|
||||
...defaultTimelineConfig,
|
||||
...pageTimelineConfig
|
||||
};
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user