修改公众号关注逻辑,增加电子围栏
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
// const debug = process.env.NODE_ENV == 'development' ? true : false;
|
// const debug = process.env.NODE_ENV == 'development' ? true : false;
|
||||||
const debug = false;
|
const debug = true;
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
const proxyApi = "/api";
|
const proxyApi = "/api";
|
||||||
// #endif
|
// #endif
|
||||||
|
|||||||
@@ -24,11 +24,18 @@ onMounted(() => {
|
|||||||
// 页面加载完成后生成二维码
|
// 页面加载完成后生成二维码
|
||||||
const userInfo = uni.cache.get("userInfo") || {};
|
const userInfo = uni.cache.get("userInfo") || {};
|
||||||
const wechatAcQrcode = userInfo.wechatAcQrcode || "";
|
const wechatAcQrcode = userInfo.wechatAcQrcode || "";
|
||||||
|
if(!userInfo.isAc){
|
||||||
codeOptions.value.code = wechatAcQrcode;
|
codeOptions.value.code = wechatAcQrcode;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
const emit = defineEmits(["generate"]);
|
const emit = defineEmits(["generate"]);
|
||||||
function qrcodeResult(e) {
|
function qrcodeResult(e) {
|
||||||
|
const userInfo = uni.cache.get("userInfo") || {};
|
||||||
|
if(!userInfo.isAc){
|
||||||
emit("generate", e.img.tempFilePath);
|
emit("generate", e.img.tempFilePath);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,6 @@
|
|||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"pinia": "^2.3.1",
|
"pinia": "^2.3.1",
|
||||||
"pinia-plugin-unistorage": "^0.1.2",
|
"pinia-plugin-unistorage": "^0.1.2",
|
||||||
"ysk-utils": "^1.0.45"
|
"ysk-utils": "^1.0.78"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -326,33 +326,8 @@ const indexsRef = ref(null);
|
|||||||
|
|
||||||
onShow(async () => {
|
onShow(async () => {
|
||||||
try {
|
try {
|
||||||
uni.getLocation({
|
await storeuser.getLocation()
|
||||||
type: 'wgs84',
|
|
||||||
success: async (res) => {
|
|
||||||
console.log('getLocation',res);
|
|
||||||
let successres = await APIgeocodelocation({
|
|
||||||
lng: res.longitude,
|
|
||||||
lat: res.latitude
|
|
||||||
});
|
|
||||||
if (successres) {
|
|
||||||
let datastorage = {
|
|
||||||
country: successres.addressComponent.country, // "中国"
|
|
||||||
province: successres.addressComponent.province, //province: "陕西省"
|
|
||||||
address: successres.addressComponent.city, //district: "西安市"
|
|
||||||
district: successres.addressComponent.district, //district: "未央区"
|
|
||||||
lng: res.longitude,
|
|
||||||
lat: res.latitude
|
|
||||||
};
|
|
||||||
uni.cache.set('getLocationstorage', datastorage);
|
|
||||||
// 登录
|
|
||||||
proxy.$isResolve();
|
proxy.$isResolve();
|
||||||
}
|
|
||||||
},
|
|
||||||
fail(error) {
|
|
||||||
console.error('获取经纬度失败',error);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
const shopId=uni.cache.get('shopId')
|
const shopId=uni.cache.get('shopId')
|
||||||
if(shopId){
|
if(shopId){
|
||||||
indexsRef.value.getVipConfig();
|
indexsRef.value.getVipConfig();
|
||||||
|
|||||||
@@ -1227,6 +1227,10 @@ const disablePayType = computed(() => {
|
|||||||
arr.add("余额支付");
|
arr.add("余额支付");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (cartStore.orderCostSummary.orderOriginFinalPayAmount <= 0) {
|
||||||
|
arr.add("微信支付");
|
||||||
|
}
|
||||||
|
|
||||||
//充值并付款时只能微信支付
|
//充值并付款时只能微信支付
|
||||||
if (rechargeItem.value.id) {
|
if (rechargeItem.value.id) {
|
||||||
arr.add("余额支付");
|
arr.add("余额支付");
|
||||||
|
|||||||
@@ -16,14 +16,28 @@
|
|||||||
</view>
|
</view>
|
||||||
</view> -->
|
</view> -->
|
||||||
<view class="status-wrap">
|
<view class="status-wrap">
|
||||||
<view class="item" :class="{ active: querForm.statusActiveIndex == 0 }" @click="tabChange(0)">
|
<view
|
||||||
|
class="item"
|
||||||
|
:class="{ active: querForm.statusActiveIndex == 0 }"
|
||||||
|
@click="tabChange(0)"
|
||||||
|
>
|
||||||
<text class="t">商品兑换券 {{ returnSelNumber(0) }}</text>
|
<text class="t">商品兑换券 {{ returnSelNumber(0) }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" :class="{ active: querForm.statusActiveIndex == 1 }" @click="tabChange(1)">
|
<view
|
||||||
|
class="item"
|
||||||
|
:class="{ active: querForm.statusActiveIndex == 1 }"
|
||||||
|
@click="tabChange(1)"
|
||||||
|
>
|
||||||
<text class="t">折扣优惠券{{ returnSelNumber(1) }}</text>
|
<text class="t">折扣优惠券{{ returnSelNumber(1) }}</text>
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<view class="icon-wrap" :style="{ width: `${100 / statusList.length}%`, left: `${(100 / statusList.length) * querForm.statusActiveIndex}%` }">
|
<view
|
||||||
|
class="icon-wrap"
|
||||||
|
:style="{
|
||||||
|
width: `${100 / statusList.length}%`,
|
||||||
|
left: `${(100 / statusList.length) * querForm.statusActiveIndex}%`,
|
||||||
|
}"
|
||||||
|
>
|
||||||
<image
|
<image
|
||||||
class="active-icon"
|
class="active-icon"
|
||||||
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAMCAYAAAB4MH11AAACKUlEQVR4AaRTS2sTURT+MpkxUzNtRpuYpBsrqbgQH6BYRHGllloQN+5cuNeV6MKfoj9BwYUgIsXHRqE+SluliFLbBqmENJNMMpMm87qecw1NglJse+HMPeee833nce8oIgpFq7wsGt/fCb9eFrtdfmNd1L+9Jc4Vog6E4jcqqM0/R+3zNOwv09jtshdfSx7mDJwKqAMfIvAAEaFVWkLgWjvOEbVdtNa+Epf4wxmFUNTkfqiDGUkqogDu8icKiKS9nQ9jnR8fqM5AwuJJE/G9JhRF05E8dAqIKeDlrsyiWVxg9f+Fum+uzsFZmtnEGIVxKHsGIFn1bAF6ZlQ6I28D9uIrmYSrkodbfETgw6GubZo9Yzk0kR4Fc7IuE8QUFebJKSTSB/kM4UYd1scnKL18QInm4Vk/6W6qiNoOwpZDuoX2elFWXHrzELW5Z+RzJVbPHca+09doIKq0ZQLW+C44iWbm2ZQSNMqozj5F5f1jWCSVGd4fwerstYUXCOplGcsfxponJqHS7Nlm2UyAWAza0AFkzt1A6uhFqEYaoHsR9BLCpg2vukZVr5IU4dV+yU7oRikkTrHDMI9PIHPhJrhQ9Kxugs6hkkhi8Mh5DI9flyCep6ImOt7uxnF6dgypYxMy1hg7S0/yH3FdSL+mpbIw6CVwVSNX7yM/eQfZS7eQu3wb+St3MTJ1D2nq1iicgZbK9YN7rL866PH1qfGBIWj0v/Do4rrR59vK+A0AAP//GfTndQAAAAZJREFUAwCu+SjIaSGpLwAAAABJRU5ErkJggg=="
|
src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAMCAYAAAB4MH11AAACKUlEQVR4AaRTS2sTURT+MpkxUzNtRpuYpBsrqbgQH6BYRHGllloQN+5cuNeV6MKfoj9BwYUgIsXHRqE+SluliFLbBqmENJNMMpMm87qecw1NglJse+HMPeee833nce8oIgpFq7wsGt/fCb9eFrtdfmNd1L+9Jc4Vog6E4jcqqM0/R+3zNOwv09jtshdfSx7mDJwKqAMfIvAAEaFVWkLgWjvOEbVdtNa+Epf4wxmFUNTkfqiDGUkqogDu8icKiKS9nQ9jnR8fqM5AwuJJE/G9JhRF05E8dAqIKeDlrsyiWVxg9f+Fum+uzsFZmtnEGIVxKHsGIFn1bAF6ZlQ6I28D9uIrmYSrkodbfETgw6GubZo9Yzk0kR4Fc7IuE8QUFebJKSTSB/kM4UYd1scnKL18QInm4Vk/6W6qiNoOwpZDuoX2elFWXHrzELW5Z+RzJVbPHca+09doIKq0ZQLW+C44iWbm2ZQSNMqozj5F5f1jWCSVGd4fwerstYUXCOplGcsfxponJqHS7Nlm2UyAWAza0AFkzt1A6uhFqEYaoHsR9BLCpg2vukZVr5IU4dV+yU7oRikkTrHDMI9PIHPhJrhQ9Kxugs6hkkhi8Mh5DI9flyCep6ImOt7uxnF6dgypYxMy1hg7S0/yH3FdSL+mpbIw6CVwVSNX7yM/eQfZS7eQu3wb+St3MTJ1D2nq1iicgZbK9YN7rL866PH1qfGBIWj0v/Do4rrR59vK+A0AAP//GfTndQAAAAZJREFUAwCu+SjIaSGpLwAAAABJRU5ErkJggg=="
|
||||||
@@ -33,13 +47,20 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="list-wrap">
|
<view class="list-wrap">
|
||||||
<view class="tips">
|
<view class="tips">
|
||||||
<text class="t">使用商品兑换券的商品,不再计入同享优惠券门槛和折扣计算。</text>
|
<text class="t"
|
||||||
|
>使用商品兑换券的商品,不再计入同享优惠券门槛和折扣计算。</text
|
||||||
|
>
|
||||||
</view>
|
</view>
|
||||||
<view class="title-wrap">
|
<view class="title-wrap">
|
||||||
<text class="t">可用红包</text>
|
<text class="t">可用红包</text>
|
||||||
<text class="n">{{ list.canUseCoupons.length }}张</text>
|
<text class="n">{{ list.canUseCoupons.length }}张</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item" v-for="item in list.canUseCoupons" :key="item.id" @click="changeSelCoupon(item)">
|
<view
|
||||||
|
class="item"
|
||||||
|
v-for="item in list.canUseCoupons"
|
||||||
|
:key="item.id"
|
||||||
|
@click="changeSelCoupon(item)"
|
||||||
|
>
|
||||||
<view class="top">
|
<view class="top">
|
||||||
<view class="icon">
|
<view class="icon">
|
||||||
<couponIcon :item="item" />
|
<couponIcon :item="item" />
|
||||||
@@ -49,18 +70,29 @@
|
|||||||
<text class="t">{{ item.name }}</text>
|
<text class="t">{{ item.name }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="view time">
|
<view class="view time">
|
||||||
<text class="t">{{ dayjs(item.effectStartTime).format('YYYY.M.D') }} - {{ dayjs(item.effectEndTime).format('YYYY.M.D') }}</text>
|
<text class="t"
|
||||||
|
>{{ dayjs(item.effectStartTime).format("YYYY.M.D") }} -
|
||||||
|
{{ dayjs(item.effectEndTime).format("YYYY.M.D") }}</text
|
||||||
|
>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btn">
|
<view class="btn">
|
||||||
<view class="active" v-if="isActive(item)">
|
<view class="active" v-if="isActive(item)">
|
||||||
<up-icon name="checkmark-circle-fill" size="24" color="#FF3232"></up-icon>
|
<up-icon
|
||||||
|
name="checkmark-circle-fill"
|
||||||
|
size="24"
|
||||||
|
color="#FF3232"
|
||||||
|
></up-icon>
|
||||||
</view>
|
</view>
|
||||||
<view class="round" v-else></view>
|
<view class="round" v-else></view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btm">
|
<view class="btm">
|
||||||
<view class="left">1、可适用门店:{{ item.useShops }} 2、可适用商品:{{ item.foods }}3、可使用类型:{{ convertValuesToLabels(item.useType) }}</view>
|
<view class="left"
|
||||||
|
>1、可适用门店:{{ item.useShops }} 2、可适用商品:{{
|
||||||
|
item.foods
|
||||||
|
}}3、可使用类型:{{ convertValuesToLabels(item.useType) }}</view
|
||||||
|
>
|
||||||
<view class="right" @click.stop="showDetailHandle(item)">
|
<view class="right" @click.stop="showDetailHandle(item)">
|
||||||
<text class="t">查看详情</text>
|
<text class="t">查看详情</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -70,7 +102,11 @@
|
|||||||
<text class="t">不可用红包</text>
|
<text class="t">不可用红包</text>
|
||||||
<text class="n">{{ list.noCanUseCoupons.length }}张</text>
|
<text class="n">{{ list.noCanUseCoupons.length }}张</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="item disabled" v-for="item in list.noCanUseCoupons" :key="item.id">
|
<view
|
||||||
|
class="item disabled"
|
||||||
|
v-for="item in list.noCanUseCoupons"
|
||||||
|
:key="item.id"
|
||||||
|
>
|
||||||
<view class="top">
|
<view class="top">
|
||||||
<view class="icon">
|
<view class="icon">
|
||||||
<couponIcon :item="item" />
|
<couponIcon :item="item" />
|
||||||
@@ -80,7 +116,10 @@
|
|||||||
<text class="t">{{ item.name }}</text>
|
<text class="t">{{ item.name }}</text>
|
||||||
</view>
|
</view>
|
||||||
<view class="view time">
|
<view class="view time">
|
||||||
<text class="t">{{ dayjs(item.effectStartTime).format('YYYY.M.D') }} - {{ dayjs(item.effectEndTime).format('YYYY.M.D') }}</text>
|
<text class="t"
|
||||||
|
>{{ dayjs(item.effectStartTime).format("YYYY.M.D") }} -
|
||||||
|
{{ dayjs(item.effectEndTime).format("YYYY.M.D") }}</text
|
||||||
|
>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
<view class="btn">
|
<view class="btn">
|
||||||
@@ -105,8 +144,17 @@
|
|||||||
<view class="title">
|
<view class="title">
|
||||||
<text class="t">店铺列表</text>
|
<text class="t">店铺列表</text>
|
||||||
</view>
|
</view>
|
||||||
<scroll-view class="popup-list" direction="vertical" @scrollend="scrollBottom">
|
<scroll-view
|
||||||
<view class="item" v-for="item in shopList" :key="item.shopId" @click="selectShopHandle(item)">
|
class="popup-list"
|
||||||
|
direction="vertical"
|
||||||
|
@scrollend="scrollBottom"
|
||||||
|
>
|
||||||
|
<view
|
||||||
|
class="item"
|
||||||
|
v-for="item in shopList"
|
||||||
|
:key="item.shopId"
|
||||||
|
@click="selectShopHandle(item)"
|
||||||
|
>
|
||||||
<text class="t">{{ item.shopName }}</text>
|
<text class="t">{{ item.shopName }}</text>
|
||||||
<text class="intro">地址:{{ item.shopAddress }}</text>
|
<text class="intro">地址:{{ item.shopAddress }}</text>
|
||||||
</view>
|
</view>
|
||||||
@@ -114,14 +162,24 @@
|
|||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</u-popup>
|
</u-popup>
|
||||||
<u-popup :show="showDetail" round="20" closeable @close="showDetail = false">
|
<u-popup
|
||||||
|
:show="showDetail"
|
||||||
|
round="20"
|
||||||
|
closeable
|
||||||
|
@close="showDetail = false"
|
||||||
|
>
|
||||||
<view class="shoplist-popup">
|
<view class="shoplist-popup">
|
||||||
<view class="title">
|
<view class="title">
|
||||||
<text class="t">详情说明</text>
|
<text class="t">详情说明</text>
|
||||||
</view>
|
</view>
|
||||||
<scroll-view class="popup-list" direction="vertical">
|
<scroll-view class="popup-list" direction="vertical">
|
||||||
<view class="ul">
|
<view class="ul">
|
||||||
<view class="li" v-for="(item, index) in selectListItemDetails" :key="index">{{ index + 1 }}、{{ item }}</view>
|
<view
|
||||||
|
class="li"
|
||||||
|
v-for="(item, index) in selectListItemDetails"
|
||||||
|
:key="index"
|
||||||
|
>{{ index + 1 }}、{{ item }}</view
|
||||||
|
>
|
||||||
</view>
|
</view>
|
||||||
</scroll-view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
@@ -130,14 +188,27 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import dayjs from 'dayjs';
|
import dayjs from "dayjs";
|
||||||
import { ref, reactive, onMounted, computed, watch } from 'vue';
|
import { ref, reactive, onMounted, computed, watch } from "vue";
|
||||||
import { onLoad, onReady, onShow, onPageScroll, onReachBottom, onBackPress } from '@dcloudio/uni-app';
|
import {
|
||||||
import { APIcouponfindByUserId, APIfindCoupon, getCouponShops } from '@/common/api/member.js';
|
onLoad,
|
||||||
import { findCoupon } from '@/common/api/market/coupon.js';
|
onReady,
|
||||||
import couponIcon from '@/pages/user/components/coupon-icon.vue';
|
onShow,
|
||||||
import * as UTILS from '@/utils/goods-utils.js';
|
onPageScroll,
|
||||||
import { useCartsStore } from '@/stores/carts.js';
|
onReachBottom,
|
||||||
|
onBackPress,
|
||||||
|
} from "@dcloudio/uni-app";
|
||||||
|
import {
|
||||||
|
APIcouponfindByUserId,
|
||||||
|
APIfindCoupon,
|
||||||
|
getCouponShops,
|
||||||
|
} from "@/common/api/member.js";
|
||||||
|
import { findCoupon } from "@/common/api/market/coupon.js";
|
||||||
|
import couponIcon from "@/pages/user/components/coupon-icon.vue";
|
||||||
|
// import * as UTILS from '@/utils/goods-utils.js';
|
||||||
|
import yskUtils from "ysk-utils";
|
||||||
|
const UTILS = yskUtils.couponUtils;
|
||||||
|
import { useCartsStore } from "@/stores/carts.js";
|
||||||
const cartStore = useCartsStore();
|
const cartStore = useCartsStore();
|
||||||
|
|
||||||
//返回不可用原因
|
//返回不可用原因
|
||||||
@@ -148,43 +219,43 @@ function returnNoUseRestrictions(item) {
|
|||||||
if (item.canuseResult) {
|
if (item.canuseResult) {
|
||||||
return item.canuseResult.reason;
|
return item.canuseResult.reason;
|
||||||
}
|
}
|
||||||
return '';
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
|
|
||||||
const querForm = ref({
|
const querForm = ref({
|
||||||
searchValue: '',
|
searchValue: "",
|
||||||
shopId: '',
|
shopId: "",
|
||||||
shopName: '',
|
shopName: "",
|
||||||
statusActiveIndex: 0
|
statusActiveIndex: 0,
|
||||||
});
|
});
|
||||||
|
|
||||||
const statusList = ref([
|
const statusList = ref([
|
||||||
{
|
{
|
||||||
value: 0,
|
value: 0,
|
||||||
label: '商品兑换券',
|
label: "商品兑换券",
|
||||||
bg: '#333333',
|
bg: "#333333",
|
||||||
color: '#ffffff'
|
color: "#ffffff",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 1,
|
value: 1,
|
||||||
label: '折扣优惠券',
|
label: "折扣优惠券",
|
||||||
bg: '#F8F8F8',
|
bg: "#F8F8F8",
|
||||||
color: '#999999'
|
color: "#999999",
|
||||||
}
|
},
|
||||||
]);
|
]);
|
||||||
const list = reactive({
|
const list = reactive({
|
||||||
page: 1,
|
page: 1,
|
||||||
size: 10,
|
size: 10,
|
||||||
status: 'nomore',
|
status: "nomore",
|
||||||
data: [],
|
data: [],
|
||||||
noCanUseCoupons: [],
|
noCanUseCoupons: [],
|
||||||
canUseCoupons: []
|
canUseCoupons: [],
|
||||||
});
|
});
|
||||||
|
|
||||||
const showDetail = ref(false);
|
const showDetail = ref(false);
|
||||||
const selectListItem = ref('');
|
const selectListItem = ref("");
|
||||||
const selectListItemDetails = ref([]);
|
const selectListItemDetails = ref([]);
|
||||||
|
|
||||||
function showDetailHandle(item) {
|
function showDetailHandle(item) {
|
||||||
@@ -194,32 +265,52 @@ function showDetailHandle(item) {
|
|||||||
const ruleList = [];
|
const ruleList = [];
|
||||||
|
|
||||||
// 规则1:限时折扣同享(始终显示)
|
// 规则1:限时折扣同享(始终显示)
|
||||||
const discountRule = item.discountShare ? '与限时折扣同享' : '不与限时折扣同享';
|
const discountRule = item.discountShare
|
||||||
|
? "与限时折扣同享"
|
||||||
|
: "不与限时折扣同享";
|
||||||
ruleList.push(discountRule);
|
ruleList.push(discountRule);
|
||||||
|
|
||||||
// 规则2:会员价/会员折扣同享(始终显示)
|
// 规则2:会员价/会员折扣同享(始终显示)
|
||||||
const vipRule = item.vipPriceShare ? '与会员价/会员折扣同享' : '不与会员价/会员折扣同享';
|
const vipRule = item.vipPriceShare
|
||||||
|
? "与会员价/会员折扣同享"
|
||||||
|
: "不与会员价/会员折扣同享";
|
||||||
ruleList.push(vipRule);
|
ruleList.push(vipRule);
|
||||||
|
|
||||||
// 规则3:其他优惠券同享(仅item.type=2时显示)
|
// 规则3:其他优惠券同享(仅item.type=2时显示)
|
||||||
if (item.type === 2) {
|
if (item.type === 2) {
|
||||||
const otherCouponRule = item.otherCouponShare ? '与其他优惠券同享' : '不与其他优惠券同享';
|
const otherCouponRule = item.otherCouponShare
|
||||||
|
? "与其他优惠券同享"
|
||||||
|
: "不与其他优惠券同享";
|
||||||
ruleList.push(otherCouponRule);
|
ruleList.push(otherCouponRule);
|
||||||
}
|
}
|
||||||
const shareRuleText = `${ruleList.join('、')}`;
|
const shareRuleText = `${ruleList.join("、")}`;
|
||||||
let foods=item.foods;
|
let foods = item.foods;
|
||||||
selectListItemDetails.value = [
|
selectListItemDetails.value = [
|
||||||
`可适用门店:${item.useShops}`,
|
`可适用门店:${item.useShops}`,
|
||||||
`可适用商品:${foods}`,
|
`可适用商品:${foods}`,
|
||||||
`可使用类型:${convertValuesToLabels(item.useType)}`,
|
`可使用类型:${convertValuesToLabels(item.useType)}`,
|
||||||
`可用时间段:${item.useTimeType == 'all' ? '全段时间可用' : `${item.useStartTime} - ${item.useEndTime}`}`,
|
`可用时间段:${
|
||||||
`限量规则:每人限领${item.getLimit == -10086 ? `无限张` : `${item.getLimit}张`},每日最多可使用${item.useLimit == -10086 ? `无限张` : `${item.useLimit}张`}`,
|
item.useTimeType == "all"
|
||||||
|
? "全段时间可用"
|
||||||
|
: `${item.useStartTime} - ${item.useEndTime}`
|
||||||
|
}`,
|
||||||
|
`限量规则:每人限领${
|
||||||
|
item.getLimit == -10086 ? `无限张` : `${item.getLimit}张`
|
||||||
|
},每日最多可使用${
|
||||||
|
item.useLimit == -10086 ? `无限张` : `${item.useLimit}张`
|
||||||
|
}`,
|
||||||
`同享规则:${shareRuleText}`,
|
`同享规则:${shareRuleText}`,
|
||||||
`其它说明:${item.ruleDetails || '无'}`
|
`其它说明:${item.ruleDetails || "无"}`,
|
||||||
];
|
];
|
||||||
|
|
||||||
if (item.type == 2 || item.type == 4 || item.type == 6) {
|
if (item.type == 2 || item.type == 4 || item.type == 6) {
|
||||||
selectListItemDetails.value.splice(2, 0, `使用规则:${item.useRule == 'price_asc' ? '从最低价开始抵扣' : '从最高价开始抵扣'}`);
|
selectListItemDetails.value.splice(
|
||||||
|
2,
|
||||||
|
0,
|
||||||
|
`使用规则:${
|
||||||
|
item.useRule == "price_asc" ? "从最低价开始抵扣" : "从最高价开始抵扣"
|
||||||
|
}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.type == 3) {
|
if (item.type == 3) {
|
||||||
@@ -230,22 +321,22 @@ function showDetailHandle(item) {
|
|||||||
function returnSelNumber(index) {
|
function returnSelNumber(index) {
|
||||||
if (index) {
|
if (index) {
|
||||||
if (couponSel.value.id) {
|
if (couponSel.value.id) {
|
||||||
return '(1)';
|
return "(1)";
|
||||||
} else {
|
} else {
|
||||||
return '(0)';
|
return "(0)";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (goodsCouponSel.value.id) {
|
if (goodsCouponSel.value.id) {
|
||||||
return '(1)';
|
return "(1)";
|
||||||
} else {
|
} else {
|
||||||
return '(0)';
|
return "(0)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 搜索
|
// 搜索
|
||||||
function searchHandle() {
|
function searchHandle() {
|
||||||
list.page = 1;
|
list.page = 1;
|
||||||
list.status = 'nomore';
|
list.status = "nomore";
|
||||||
getCouponList();
|
getCouponList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -253,7 +344,7 @@ function searchHandle() {
|
|||||||
function tabChange(index) {
|
function tabChange(index) {
|
||||||
querForm.value.statusActiveIndex = index;
|
querForm.value.statusActiveIndex = index;
|
||||||
list.page = 1;
|
list.page = 1;
|
||||||
list.status = 'nomore';
|
list.status = "nomore";
|
||||||
formatCoupon();
|
formatCoupon();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -261,7 +352,7 @@ function changeSelCoupon(item) {
|
|||||||
if (querForm.value.statusActiveIndex) {
|
if (querForm.value.statusActiveIndex) {
|
||||||
if (couponSel.value.id == item.id) {
|
if (couponSel.value.id == item.id) {
|
||||||
couponSel.value = {
|
couponSel.value = {
|
||||||
id: ''
|
id: "",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
couponSel.value = item;
|
couponSel.value = item;
|
||||||
@@ -269,7 +360,7 @@ function changeSelCoupon(item) {
|
|||||||
} else {
|
} else {
|
||||||
if (goodsCouponSel.value.id == item.id) {
|
if (goodsCouponSel.value.id == item.id) {
|
||||||
goodsCouponSel.value = {
|
goodsCouponSel.value = {
|
||||||
id: ''
|
id: "",
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
goodsCouponSel.value = item;
|
goodsCouponSel.value = item;
|
||||||
@@ -277,22 +368,27 @@ function changeSelCoupon(item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const couponSel = ref({
|
const couponSel = ref({
|
||||||
id: ''
|
id: "",
|
||||||
});
|
});
|
||||||
const goodsCouponSel = ref({
|
const goodsCouponSel = ref({
|
||||||
id: ''
|
id: "",
|
||||||
});
|
});
|
||||||
const quansSelArr = computed(() => {
|
const quansSelArr = computed(() => {
|
||||||
return [couponSel.value, goodsCouponSel.value].filter((v) => v.id);
|
return [couponSel.value, goodsCouponSel.value].filter((v) => v.id);
|
||||||
});
|
});
|
||||||
watch(()=>couponSel.value.id,(newval)=>{
|
watch(
|
||||||
formatCoupon()
|
() => couponSel.value.id,
|
||||||
})
|
(newval) => {
|
||||||
watch(()=>goodsCouponSel.value.id,(newval)=>{
|
formatCoupon();
|
||||||
formatCoupon()
|
}
|
||||||
})
|
);
|
||||||
|
watch(
|
||||||
|
() => goodsCouponSel.value.id,
|
||||||
|
(newval) => {
|
||||||
|
formatCoupon();
|
||||||
|
}
|
||||||
|
);
|
||||||
function isActive(item) {
|
function isActive(item) {
|
||||||
if (querForm.value.statusActiveIndex) {
|
if (querForm.value.statusActiveIndex) {
|
||||||
return couponSel.value.id == item.id;
|
return couponSel.value.id == item.id;
|
||||||
@@ -301,35 +397,40 @@ function isActive(item) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const couponList = ref([]);
|
||||||
const couponList=ref([])
|
function formatCoupon() {
|
||||||
function formatCoupon(){
|
|
||||||
|
|
||||||
let canUseGoodsCoupon = [];
|
let canUseGoodsCoupon = [];
|
||||||
let canUseDiscountCoupon = [];
|
let canUseDiscountCoupon = [];
|
||||||
|
|
||||||
let noUseGoodsCoupon = [];
|
let noUseGoodsCoupon = [];
|
||||||
let noUseDiscountCoupon = [];
|
let noUseDiscountCoupon = [];
|
||||||
const user = uni.cache.get('shopUserInfo');
|
const user = uni.cache.get("shopUserInfo");
|
||||||
let shopInfo = uni.cache.get('shopInfo') || {};
|
let shopInfo = uni.cache.get("shopInfo") || {};
|
||||||
if (!shopInfo.isMemberPrice) {
|
if (!shopInfo.isMemberPrice) {
|
||||||
shopInfo = {};
|
shopInfo = {};
|
||||||
}
|
}
|
||||||
const goodsOrderPrice = uni.getStorageSync('goodsOrderPrice') || 0;
|
const goodsOrderPrice = uni.getStorageSync("goodsOrderPrice") || 0;
|
||||||
const dinnerType = cartStore.dinnerType;
|
const dinnerType = cartStore.dinnerType;
|
||||||
const canDikouGoodsArr = UTILS.returnCanDikouGoods(cartStore.allGoods, [], user);
|
const canDikouGoodsArr = UTILS.returnCanDikouGoods(
|
||||||
const shopId = uni.cache.get('shopId');
|
cartStore.allGoods,
|
||||||
|
[],
|
||||||
|
user
|
||||||
|
);
|
||||||
|
const shopId = uni.cache.get("shopId");
|
||||||
for (let i = 0; i < couponList.value.length; i++) {
|
for (let i = 0; i < couponList.value.length; i++) {
|
||||||
const coupon = couponList.value[i];
|
const coupon = couponList.value[i];
|
||||||
const selCoupon=querForm.value.statusActiveIndex!=1?quansSelArr.value.filter(v=>v.type!=2):quansSelArr.value.filter(v=>v.type==2)
|
const selCoupon =
|
||||||
|
querForm.value.statusActiveIndex != 1
|
||||||
|
? quansSelArr.value.filter((v) => v.type != 2)
|
||||||
|
: quansSelArr.value.filter((v) => v.type == 2);
|
||||||
const canuseResult = UTILS.returnCouponCanUse({
|
const canuseResult = UTILS.returnCouponCanUse({
|
||||||
canDikouGoodsArr,
|
canDikouGoodsArr,
|
||||||
coupon,
|
coupon,
|
||||||
goodsOrderPrice,
|
goodsOrderPrice,
|
||||||
user,
|
user,
|
||||||
selCoupon:selCoupon,
|
selCoupon: selCoupon,
|
||||||
shopInfo,
|
shopInfo,
|
||||||
limitTimeDiscount:cartStore.limitTimeDiscount
|
limitTimeDiscount: cartStore.limitTimeDiscount,
|
||||||
});
|
});
|
||||||
const { canUse, reason } = canuseResult;
|
const { canUse, reason } = canuseResult;
|
||||||
if (coupon.type == 2) {
|
if (coupon.type == 2) {
|
||||||
@@ -338,7 +439,7 @@ function formatCoupon(){
|
|||||||
} else {
|
} else {
|
||||||
noUseGoodsCoupon.push({
|
noUseGoodsCoupon.push({
|
||||||
...coupon,
|
...coupon,
|
||||||
canuseResult
|
canuseResult,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -347,27 +448,43 @@ function formatCoupon(){
|
|||||||
} else {
|
} else {
|
||||||
noUseDiscountCoupon.push({
|
noUseDiscountCoupon.push({
|
||||||
...coupon,
|
...coupon,
|
||||||
canuseResult
|
canuseResult,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//商品券
|
//商品券
|
||||||
canUseGoodsCoupon = canUseGoodsCoupon.map((v) => {
|
canUseGoodsCoupon = canUseGoodsCoupon.map((v) => {
|
||||||
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo,cartStore.limitTimeDiscount);
|
const discount = UTILS.returnCouponDiscount(
|
||||||
|
canDikouGoodsArr,
|
||||||
|
v,
|
||||||
|
user,
|
||||||
|
goodsOrderPrice,
|
||||||
|
quansSelArr.value,
|
||||||
|
shopInfo,
|
||||||
|
cartStore.limitTimeDiscount
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
discount,
|
discount,
|
||||||
discountAmount: discount ? discount.discountPrice : v.discountAmount
|
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
//非商品券
|
//非商品券
|
||||||
canUseDiscountCoupon = canUseDiscountCoupon.map((v) => {
|
canUseDiscountCoupon = canUseDiscountCoupon.map((v) => {
|
||||||
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, quansSelArr.value, shopInfo,cartStore.limitTimeDiscount);
|
const discount = UTILS.returnCouponDiscount(
|
||||||
|
canDikouGoodsArr,
|
||||||
|
v,
|
||||||
|
user,
|
||||||
|
goodsOrderPrice,
|
||||||
|
quansSelArr.value,
|
||||||
|
shopInfo,
|
||||||
|
cartStore.limitTimeDiscount
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
discount,
|
discount,
|
||||||
discountAmount: discount ? discount.discountPrice : v.discountAmount
|
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -379,25 +496,24 @@ function formatCoupon(){
|
|||||||
list.canUseCoupons = canUseDiscountCoupon;
|
list.canUseCoupons = canUseDiscountCoupon;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('canUseGoodsCoupon', canUseGoodsCoupon);
|
console.log("canUseGoodsCoupon", canUseGoodsCoupon);
|
||||||
console.log('noUseGoodsCoupon', noUseGoodsCoupon);
|
console.log("noUseGoodsCoupon", noUseGoodsCoupon);
|
||||||
console.log('canUseDiscountCoupon', canUseDiscountCoupon);
|
console.log("canUseDiscountCoupon", canUseDiscountCoupon);
|
||||||
console.log('noUseDiscountCoupon', noUseDiscountCoupon);
|
console.log("noUseDiscountCoupon", noUseDiscountCoupon);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取优惠券列表
|
// 获取优惠券列表
|
||||||
async function getCouponList() {
|
async function getCouponList() {
|
||||||
try {
|
try {
|
||||||
uni.showLoading({
|
uni.showLoading({
|
||||||
title: '加载中...',
|
title: "加载中...",
|
||||||
mask: true
|
mask: true,
|
||||||
});
|
});
|
||||||
const res = await findCoupon({
|
const res = await findCoupon({
|
||||||
shopUserId: uni.cache.get('shopUserInfo').id
|
shopUserId: uni.cache.get("shopUserInfo").id,
|
||||||
});
|
});
|
||||||
couponList.value=res
|
couponList.value = res;
|
||||||
formatCoupon()
|
formatCoupon();
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
}
|
}
|
||||||
@@ -406,7 +522,7 @@ async function getCouponList() {
|
|||||||
|
|
||||||
// 店铺列表滚动到底部了
|
// 店铺列表滚动到底部了
|
||||||
function scrollBottom() {
|
function scrollBottom() {
|
||||||
console.log('店铺列表滚动到底部了');
|
console.log("店铺列表滚动到底部了");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -416,56 +532,62 @@ function scrollBottom() {
|
|||||||
* @param {string} separator - 标签拼接分隔符,默认值为'、'
|
* @param {string} separator - 标签拼接分隔符,默认值为'、'
|
||||||
* @returns {string} 拼接后的label字符串,如"堂食、自取"
|
* @returns {string} 拼接后的label字符串,如"堂食、自取"
|
||||||
*/
|
*/
|
||||||
function convertValuesToLabels(valueStr, options, separator = '、') {
|
function convertValuesToLabels(valueStr, options, separator = "、") {
|
||||||
try {
|
try {
|
||||||
options = [
|
options = [
|
||||||
{
|
{
|
||||||
value: 'dine',
|
value: "dine",
|
||||||
label: '堂食'
|
label: "堂食",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'pickup',
|
value: "pickup",
|
||||||
label: '自取'
|
label: "自取",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'deliv',
|
value: "deliv",
|
||||||
label: '配送'
|
label: "配送",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'express',
|
value: "express",
|
||||||
label: '快递'
|
label: "快递",
|
||||||
}
|
},
|
||||||
];
|
];
|
||||||
// 验证输入参数
|
// 验证输入参数
|
||||||
if (!Array.isArray(options)) {
|
if (!Array.isArray(options)) {
|
||||||
throw new Error('options必须是数组');
|
throw new Error("options必须是数组");
|
||||||
}
|
}
|
||||||
if (typeof valueStr !== 'string') {
|
if (typeof valueStr !== "string") {
|
||||||
throw new Error('valueStr必须是字符串');
|
throw new Error("valueStr必须是字符串");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 解析value数组字符串
|
// 解析value数组字符串
|
||||||
const values = JSON.parse(valueStr);
|
const values = JSON.parse(valueStr);
|
||||||
if (!Array.isArray(values)) {
|
if (!Array.isArray(values)) {
|
||||||
throw new Error('解析后的valueStr必须是数组');
|
throw new Error("解析后的valueStr必须是数组");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 构建value到label的映射表
|
// 构建value到label的映射表
|
||||||
const valueLabelMap = new Map();
|
const valueLabelMap = new Map();
|
||||||
options.forEach((item) => {
|
options.forEach((item) => {
|
||||||
if (item && typeof item.value !== 'undefined' && typeof item.label !== 'undefined') {
|
if (
|
||||||
|
item &&
|
||||||
|
typeof item.value !== "undefined" &&
|
||||||
|
typeof item.label !== "undefined"
|
||||||
|
) {
|
||||||
valueLabelMap.set(item.value, item.label);
|
valueLabelMap.set(item.value, item.label);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// 匹配并收集label
|
// 匹配并收集label
|
||||||
const labels = values.map((value) => valueLabelMap.get(value)).filter(Boolean); // 过滤未匹配到的项
|
const labels = values
|
||||||
|
.map((value) => valueLabelMap.get(value))
|
||||||
|
.filter(Boolean); // 过滤未匹配到的项
|
||||||
|
|
||||||
// 拼接结果
|
// 拼接结果
|
||||||
return labels.join(separator);
|
return labels.join(separator);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('转换失败:', error.message);
|
console.error("转换失败:", error.message);
|
||||||
return ''; // 出错时返回空字符串
|
return ""; // 出错时返回空字符串
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -507,37 +629,57 @@ watch(
|
|||||||
() => quansSelArr.value,
|
() => quansSelArr.value,
|
||||||
(newval) => {
|
(newval) => {
|
||||||
// getCouponList()
|
// getCouponList()
|
||||||
const user = uni.cache.get('shopUserInfo');
|
const user = uni.cache.get("shopUserInfo");
|
||||||
let shopInfo = uni.cache.get('shopInfo') || {};
|
let shopInfo = uni.cache.get("shopInfo") || {};
|
||||||
if (!shopInfo.isMemberPrice) {
|
if (!shopInfo.isMemberPrice) {
|
||||||
shopInfo = {};
|
shopInfo = {};
|
||||||
}
|
}
|
||||||
const goodsOrderPrice = uni.getStorageSync('goodsOrderPrice') || 0;
|
const goodsOrderPrice = uni.getStorageSync("goodsOrderPrice") || 0;
|
||||||
const dinnerType = cartStore.dinnerType;
|
const dinnerType = cartStore.dinnerType;
|
||||||
const canDikouGoodsArr = UTILS.returnCanDikouGoods(cartStore.allGoods, [], user);
|
const canDikouGoodsArr = UTILS.returnCanDikouGoods(
|
||||||
const shopId = uni.cache.get('shopId');
|
cartStore.allGoods,
|
||||||
|
[],
|
||||||
|
user
|
||||||
|
);
|
||||||
|
const shopId = uni.cache.get("shopId");
|
||||||
let goodsCoupon = newval.filter((v) => v.type == 2);
|
let goodsCoupon = newval.filter((v) => v.type == 2);
|
||||||
let otherCoupon = newval.filter((v) => v.type != 2);
|
let otherCoupon = newval.filter((v) => v.type != 2);
|
||||||
goodsCoupon = goodsCoupon.map((v) => {
|
goodsCoupon = goodsCoupon.map((v) => {
|
||||||
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, [], shopInfo,cartStore.limitTimeDiscount);
|
const discount = UTILS.returnCouponDiscount(
|
||||||
|
canDikouGoodsArr,
|
||||||
|
v,
|
||||||
|
user,
|
||||||
|
goodsOrderPrice,
|
||||||
|
[],
|
||||||
|
shopInfo,
|
||||||
|
cartStore.limitTimeDiscount
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
discount,
|
discount,
|
||||||
discountAmount: discount ? discount.discountPrice : v.discountAmount
|
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
otherCoupon = otherCoupon.map((v) => {
|
otherCoupon = otherCoupon.map((v) => {
|
||||||
const discount = UTILS.returnCouponDiscount(canDikouGoodsArr, v, user, goodsOrderPrice, goodsCoupon, shopInfo,cartStore.limitTimeDiscount);
|
const discount = UTILS.returnCouponDiscount(
|
||||||
|
canDikouGoodsArr,
|
||||||
|
v,
|
||||||
|
user,
|
||||||
|
goodsOrderPrice,
|
||||||
|
goodsCoupon,
|
||||||
|
shopInfo,
|
||||||
|
cartStore.limitTimeDiscount
|
||||||
|
);
|
||||||
return {
|
return {
|
||||||
...v,
|
...v,
|
||||||
discount,
|
discount,
|
||||||
discountAmount: discount ? discount.discountPrice : v.discountAmount
|
discountAmount: discount ? discount.discountPrice : v.discountAmount,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
uni.$emit('selCoupon', [...goodsCoupon, ...otherCoupon]);
|
uni.$emit("selCoupon", [...goodsCoupon, ...otherCoupon]);
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
deep: true
|
deep: true,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
</script>
|
</script>
|
||||||
@@ -691,7 +833,7 @@ page {
|
|||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
content: '';
|
content: "";
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@@ -732,7 +874,7 @@ page {
|
|||||||
|
|
||||||
&::after {
|
&::after {
|
||||||
$height: 100upx;
|
$height: 100upx;
|
||||||
content: '';
|
content: "";
|
||||||
height: $height;
|
height: $height;
|
||||||
border-left: 1upx solid #f7f7f7;
|
border-left: 1upx solid #f7f7f7;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|||||||
@@ -250,7 +250,7 @@
|
|||||||
></view>
|
></view>
|
||||||
</view>
|
</view>
|
||||||
<text class="num">{{ ifcartNumber(item) }}</text>
|
<text class="num">{{ ifcartNumber(item) }}</text>
|
||||||
<view class="btn">
|
<view class="btn" >
|
||||||
<up-icon
|
<up-icon
|
||||||
name="plus-circle-fill"
|
name="plus-circle-fill"
|
||||||
color="#E9AB7A"
|
color="#E9AB7A"
|
||||||
@@ -495,7 +495,7 @@
|
|||||||
</view>
|
</view>
|
||||||
|
|
||||||
<text class="num">{{ ifcartNumber(item1) }}</text>
|
<text class="num">{{ ifcartNumber(item1) }}</text>
|
||||||
<view class="btn">
|
<view class="btn" >
|
||||||
<up-icon
|
<up-icon
|
||||||
name="plus-circle-fill"
|
name="plus-circle-fill"
|
||||||
color="#E9AB7A"
|
color="#E9AB7A"
|
||||||
@@ -1674,15 +1674,33 @@ const isProductAvailable = async (sellDaysStr, startTimeStr, endTimeStr) => {
|
|||||||
return isInRange;
|
return isInRange;
|
||||||
};
|
};
|
||||||
|
|
||||||
// 单规格
|
/**
|
||||||
const singleclick = async (item, i) => {
|
* 判断商品是否可售
|
||||||
console.log("单规格商品点击事件:", item, i);
|
* @param {Object} item
|
||||||
|
*/
|
||||||
|
function juageProductAvailable(item) {
|
||||||
if (!isProductAvailable(item.days, item.startTime, item.endTime)) {
|
if (!isProductAvailable(item.days, item.startTime, item.endTime)) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: "不在可售时间内",
|
title: "不在可售时间内",
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(item.isStock&&item.stockNumber<item.suitNum){
|
||||||
|
uni.showToast({
|
||||||
|
title: "库存不足",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
// 单规格
|
||||||
|
const singleclick = async (item, i) => {
|
||||||
|
console.log("单规格商品点击事件:", item, i);
|
||||||
|
if(!juageProductAvailable(item)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
// 判断购物车是否有该选中商品
|
// 判断购物车是否有该选中商品
|
||||||
let res = null;
|
let res = null;
|
||||||
try {
|
try {
|
||||||
@@ -3055,7 +3073,7 @@ function toHistory() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.shop_sku_box:last-child {
|
.shop_sku_box:last-child {
|
||||||
padding-bottom: 60rpx;
|
padding-bottom: 140rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
.shop_sku_box {
|
.shop_sku_box {
|
||||||
|
|||||||
59
pnpm-lock.yaml
generated
59
pnpm-lock.yaml
generated
@@ -30,8 +30,8 @@ importers:
|
|||||||
specifier: ^0.1.2
|
specifier: ^0.1.2
|
||||||
version: 0.1.2
|
version: 0.1.2
|
||||||
ysk-utils:
|
ysk-utils:
|
||||||
specifier: ^1.0.40
|
specifier: ^1.0.78
|
||||||
version: 1.0.40
|
version: 1.0.78
|
||||||
|
|
||||||
packages:
|
packages:
|
||||||
|
|
||||||
@@ -39,17 +39,17 @@ packages:
|
|||||||
resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==}
|
resolution: {integrity: sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
'@babel/helper-validator-identifier@7.27.1':
|
'@babel/helper-validator-identifier@7.28.5':
|
||||||
resolution: {integrity: sha512-D2hP9eA+Sqx1kBZgzxZh0y1trbuU+JoDkiEwqhQ36nodYqJwyEIhPSdMNd7lOm/4io72luTPWH20Yda0xOuUow==}
|
resolution: {integrity: sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
'@babel/parser@7.28.4':
|
'@babel/parser@7.28.5':
|
||||||
resolution: {integrity: sha512-yZbBqeM6TkpP9du/I2pUZnJsRMGGvOuIrhjzC1AwHwW+6he4mni6Bp/m8ijn0iOuZuPI2BfkCoSRunpyjnrQKg==}
|
resolution: {integrity: sha512-KKBU1VGYR7ORr3At5HAtUQ+TV3SzRCXmA/8OdDZiLDBIZxVyzXuztPjfLd3BV1PRAQGCMWWSHYhL0F8d5uHBDQ==}
|
||||||
engines: {node: '>=6.0.0'}
|
engines: {node: '>=6.0.0'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
|
|
||||||
'@babel/types@7.28.4':
|
'@babel/types@7.28.5':
|
||||||
resolution: {integrity: sha512-bkFqkLhh3pMBUQQkpVgWDWq/lqzc2678eUyDlTBhRqhCHFguYYGM0Efga7tYk4TogG/3x0EEl66/OQ+WGbWB/Q==}
|
resolution: {integrity: sha512-qQ5m48eI/MFLQ5PxQj4PFaprjyCTLI37ElWMmNs0K8Lk3dVeOdNpB3ks8jc7yM5CDmVC73eMVk/trk3fgmrUpA==}
|
||||||
engines: {node: '>=6.9.0'}
|
engines: {node: '>=6.9.0'}
|
||||||
|
|
||||||
'@dcloudio/types@3.4.21':
|
'@dcloudio/types@3.4.21':
|
||||||
@@ -104,8 +104,8 @@ packages:
|
|||||||
bignumber.js@9.3.1:
|
bignumber.js@9.3.1:
|
||||||
resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==}
|
resolution: {integrity: sha512-Ko0uX15oIUS7wJ3Rb30Fs6SkVbLmPBAKdlm7q9+ak9bbIeFf0MwuBsQV6z7+X768/cHsfg+WlysDWJcmthjsjQ==}
|
||||||
|
|
||||||
csstype@3.1.3:
|
csstype@3.2.3:
|
||||||
resolution: {integrity: sha512-M1uQkMl8rQK/szD0LNhtqxIPLpimGm8sOBwU7lLnCpSbTyY3yeU1Vc7l4KT5zT4s/yOxHH5O7tIuuLOCnLADRw==}
|
resolution: {integrity: sha512-z1HGKcYy2xA8AGQfwrn0PAy+PB7X/GSj3UVJW9qKyn43xWa+gl5nXmU4qqLMRzWVLFC8KusUX8T/0kCiOYpAIQ==}
|
||||||
|
|
||||||
dayjs@1.11.18:
|
dayjs@1.11.18:
|
||||||
resolution: {integrity: sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==}
|
resolution: {integrity: sha512-zFBQ7WFRvVRhKcWoUh+ZA1g2HVgUbsZm9sbddh8EC5iv93sui8DVVz1Npvz+r6meo9VKfa8NyLWBsQK1VvIKPA==}
|
||||||
@@ -120,11 +120,15 @@ packages:
|
|||||||
jsbarcode@3.12.1:
|
jsbarcode@3.12.1:
|
||||||
resolution: {integrity: sha512-QZQSqIknC2Rr/YOUyOkCBqsoiBAOTYK+7yNN3JsqfoUtJtkazxNw1dmPpxuv7VVvqW13kA3/mKiLq+s/e3o9hQ==}
|
resolution: {integrity: sha512-QZQSqIknC2Rr/YOUyOkCBqsoiBAOTYK+7yNN3JsqfoUtJtkazxNw1dmPpxuv7VVvqW13kA3/mKiLq+s/e3o9hQ==}
|
||||||
|
|
||||||
|
loadsh@0.0.4:
|
||||||
|
resolution: {integrity: sha512-U+wLL8InpfRalWrr+0SuhWgGt10M4OyAk6G8xCYo2rwpiHtxZkWiFpjei0vO463ghW8LPCdhqQxXlMy2qicAEw==}
|
||||||
|
deprecated: This is a typosquat on the popular Lodash package. This is not maintained nor is the original Lodash package.
|
||||||
|
|
||||||
lodash@4.17.21:
|
lodash@4.17.21:
|
||||||
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==}
|
||||||
|
|
||||||
magic-string@0.30.19:
|
magic-string@0.30.21:
|
||||||
resolution: {integrity: sha512-2N21sPY9Ws53PZvsEpVtNuSW+ScYbQdp4b9qUaL+9QkHUrGFKo56Lg9Emg5s9V/qrtNBmiR01sYhUOwu3H+VOw==}
|
resolution: {integrity: sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==}
|
||||||
|
|
||||||
nanoid@3.3.11:
|
nanoid@3.3.11:
|
||||||
resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==}
|
resolution: {integrity: sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==}
|
||||||
@@ -173,23 +177,23 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
ysk-utils@1.0.40:
|
ysk-utils@1.0.78:
|
||||||
resolution: {integrity: sha512-Hi+XI7sykGJizExMY5kVWIBhPvO3wudp2q92Vqv6zI6eDtquLz4CwxIfOLEXFfn5crYXVu/yfJQVjK3WAyNYDQ==}
|
resolution: {integrity: sha512-Bgr5B3WWiy0nbgL91QVKoVPYm4wt13Rlav757zEjMVRHbmTjwFEhi3wJlYus0JGd52mbknSxXHMazAPHXwA7uQ==}
|
||||||
|
|
||||||
snapshots:
|
snapshots:
|
||||||
|
|
||||||
'@babel/helper-string-parser@7.27.1': {}
|
'@babel/helper-string-parser@7.27.1': {}
|
||||||
|
|
||||||
'@babel/helper-validator-identifier@7.27.1': {}
|
'@babel/helper-validator-identifier@7.28.5': {}
|
||||||
|
|
||||||
'@babel/parser@7.28.4':
|
'@babel/parser@7.28.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/types': 7.28.4
|
'@babel/types': 7.28.5
|
||||||
|
|
||||||
'@babel/types@7.28.4':
|
'@babel/types@7.28.5':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/helper-string-parser': 7.27.1
|
'@babel/helper-string-parser': 7.27.1
|
||||||
'@babel/helper-validator-identifier': 7.27.1
|
'@babel/helper-validator-identifier': 7.28.5
|
||||||
|
|
||||||
'@dcloudio/types@3.4.21': {}
|
'@dcloudio/types@3.4.21': {}
|
||||||
|
|
||||||
@@ -202,7 +206,7 @@ snapshots:
|
|||||||
|
|
||||||
'@vue/compiler-core@3.5.22':
|
'@vue/compiler-core@3.5.22':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/parser': 7.28.4
|
'@babel/parser': 7.28.5
|
||||||
'@vue/shared': 3.5.22
|
'@vue/shared': 3.5.22
|
||||||
entities: 4.5.0
|
entities: 4.5.0
|
||||||
estree-walker: 2.0.2
|
estree-walker: 2.0.2
|
||||||
@@ -215,13 +219,13 @@ snapshots:
|
|||||||
|
|
||||||
'@vue/compiler-sfc@3.5.22':
|
'@vue/compiler-sfc@3.5.22':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@babel/parser': 7.28.4
|
'@babel/parser': 7.28.5
|
||||||
'@vue/compiler-core': 3.5.22
|
'@vue/compiler-core': 3.5.22
|
||||||
'@vue/compiler-dom': 3.5.22
|
'@vue/compiler-dom': 3.5.22
|
||||||
'@vue/compiler-ssr': 3.5.22
|
'@vue/compiler-ssr': 3.5.22
|
||||||
'@vue/shared': 3.5.22
|
'@vue/shared': 3.5.22
|
||||||
estree-walker: 2.0.2
|
estree-walker: 2.0.2
|
||||||
magic-string: 0.30.19
|
magic-string: 0.30.21
|
||||||
postcss: 8.5.6
|
postcss: 8.5.6
|
||||||
source-map-js: 1.2.1
|
source-map-js: 1.2.1
|
||||||
|
|
||||||
@@ -250,7 +254,7 @@ snapshots:
|
|||||||
'@vue/reactivity': 3.5.22
|
'@vue/reactivity': 3.5.22
|
||||||
'@vue/runtime-core': 3.5.22
|
'@vue/runtime-core': 3.5.22
|
||||||
'@vue/shared': 3.5.22
|
'@vue/shared': 3.5.22
|
||||||
csstype: 3.1.3
|
csstype: 3.2.3
|
||||||
|
|
||||||
'@vue/server-renderer@3.5.22(vue@3.5.22)':
|
'@vue/server-renderer@3.5.22(vue@3.5.22)':
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -262,7 +266,7 @@ snapshots:
|
|||||||
|
|
||||||
bignumber.js@9.3.1: {}
|
bignumber.js@9.3.1: {}
|
||||||
|
|
||||||
csstype@3.1.3: {}
|
csstype@3.2.3: {}
|
||||||
|
|
||||||
dayjs@1.11.18: {}
|
dayjs@1.11.18: {}
|
||||||
|
|
||||||
@@ -272,9 +276,11 @@ snapshots:
|
|||||||
|
|
||||||
jsbarcode@3.12.1: {}
|
jsbarcode@3.12.1: {}
|
||||||
|
|
||||||
|
loadsh@0.0.4: {}
|
||||||
|
|
||||||
lodash@4.17.21: {}
|
lodash@4.17.21: {}
|
||||||
|
|
||||||
magic-string@0.30.19:
|
magic-string@0.30.21:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@jridgewell/sourcemap-codec': 1.5.5
|
'@jridgewell/sourcemap-codec': 1.5.5
|
||||||
|
|
||||||
@@ -314,7 +320,8 @@ snapshots:
|
|||||||
'@vue/server-renderer': 3.5.22(vue@3.5.22)
|
'@vue/server-renderer': 3.5.22(vue@3.5.22)
|
||||||
'@vue/shared': 3.5.22
|
'@vue/shared': 3.5.22
|
||||||
|
|
||||||
ysk-utils@1.0.40:
|
ysk-utils@1.0.78:
|
||||||
dependencies:
|
dependencies:
|
||||||
bignumber.js: 9.3.1
|
bignumber.js: 9.3.1
|
||||||
|
loadsh: 0.0.4
|
||||||
lodash: 4.17.21
|
lodash: 4.17.21
|
||||||
|
|||||||
368
stores/user.js
368
stores/user.js
@@ -1,68 +1,63 @@
|
|||||||
import {
|
import { defineStore } from "pinia";
|
||||||
defineStore
|
import { ref } from "vue";
|
||||||
} from 'pinia';
|
import { APIuserlogin, APIuser } from "@/common/api/api.js";
|
||||||
import {
|
|
||||||
ref
|
|
||||||
} from 'vue';
|
|
||||||
import {
|
|
||||||
APIuserlogin,
|
|
||||||
APIuser
|
|
||||||
} from '@/common/api/api.js'
|
|
||||||
import {
|
import {
|
||||||
APIproductqueryShop,
|
APIproductqueryShop,
|
||||||
APIusershopInfodetail,
|
APIusershopInfodetail,
|
||||||
APIshopUserInfo
|
APIshopUserInfo,
|
||||||
} from '@/common/api/member.js'
|
} from "@/common/api/member.js";
|
||||||
export const Storelogin = defineStore('login', {
|
import { getDistance } from "@/utils/address.js";
|
||||||
|
import { APIgeocodelocation } from "@/common/api/api.js";
|
||||||
|
|
||||||
|
export const Storelogin = defineStore("login", {
|
||||||
state: () => ({
|
state: () => ({
|
||||||
token: '',
|
token: "",
|
||||||
miniAppOpenId: '',
|
miniAppOpenId: "",
|
||||||
userInfo: '',
|
userInfo: "",
|
||||||
shopInfo: {}
|
shopInfo: {},
|
||||||
}),
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
async getShopInfo(shopId) {
|
async getShopInfo(shopId) {
|
||||||
const shopRes = await APIusershopInfodetail({
|
const shopRes = await APIusershopInfodetail({
|
||||||
shopId
|
shopId,
|
||||||
})
|
});
|
||||||
console.log(shopRes);
|
console.log(shopRes);
|
||||||
},
|
},
|
||||||
actionslogin() {
|
actionslogin() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
uni.login({
|
uni.login({
|
||||||
provider: 'weixin',
|
provider: "weixin",
|
||||||
success: (data) => {
|
success: (data) => {
|
||||||
// 微信小程序环境
|
// 微信小程序环境
|
||||||
uni.getUserInfo({
|
uni.getUserInfo({
|
||||||
provider: 'weixin',
|
provider: "weixin",
|
||||||
success: async (infoRes) => {
|
success: async (infoRes) => {
|
||||||
let res = await APIuserlogin({
|
let res = await APIuserlogin({
|
||||||
code: data.code, //临时登录凭证
|
code: data.code, //临时登录凭证
|
||||||
rawData: infoRes.rawData,
|
rawData: infoRes.rawData,
|
||||||
source: 'wechat'
|
source: "wechat",
|
||||||
})
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
this.token = res.token
|
this.token = res.token;
|
||||||
this.miniAppOpenId = res.userInfo
|
this.miniAppOpenId = res.userInfo.miniAppOpenId;
|
||||||
.miniAppOpenId
|
this.userInfo = res.userInfo;
|
||||||
this.userInfo = res.userInfo
|
uni.cache.set("token", res.token);
|
||||||
uni.cache.set('token', res.token);
|
uni.cache.set("userInfo", res.userInfo);
|
||||||
uni.cache.set('userInfo', res.userInfo);
|
uni.cache.set("followIndex", res.followIndex || "");
|
||||||
uni.cache.set('followIndex', res.followIndex||'');
|
|
||||||
}
|
}
|
||||||
resolve(true);
|
resolve(true);
|
||||||
},
|
},
|
||||||
fail: (err) => {
|
fail: (err) => {
|
||||||
reject(false);
|
reject(false);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef MP-ALIPAY
|
// #ifdef MP-ALIPAY
|
||||||
my.getAuthCode({
|
my.getAuthCode({
|
||||||
scopes: 'auth_base',
|
scopes: "auth_base",
|
||||||
success: async (data) => {
|
success: async (data) => {
|
||||||
// 支付宝小程序环境
|
// 支付宝小程序环境
|
||||||
// my.getAuthUserInfo({
|
// my.getAuthUserInfo({
|
||||||
@@ -70,204 +65,301 @@ export const Storelogin = defineStore('login', {
|
|||||||
let res = await APIuserlogin({
|
let res = await APIuserlogin({
|
||||||
code: data.authCode, //临时登录凭证
|
code: data.authCode, //临时登录凭证
|
||||||
// rawData: JSON.stringify(infoRes),
|
// rawData: JSON.stringify(infoRes),
|
||||||
source: 'alipay'
|
source: "alipay",
|
||||||
})
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
this.token = res.token
|
this.token = res.token;
|
||||||
this.miniAppOpenId = res.userInfo.miniAppOpenId
|
this.miniAppOpenId = res.userInfo.miniAppOpenId;
|
||||||
this.userInfo = res.userInfo
|
this.userInfo = res.userInfo;
|
||||||
uni.cache.set('token', res.token);
|
uni.cache.set("token", res.token);
|
||||||
uni.cache.set('openId', res.userInfo
|
uni.cache.set("openId", res.userInfo.alipayOpenId);
|
||||||
.alipayOpenId)
|
uni.cache.set("userInfo", res.userInfo);
|
||||||
uni.cache.set('userInfo', res.userInfo);
|
|
||||||
resolve(true);
|
resolve(true);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: () => {
|
fail: () => {
|
||||||
reject(false);
|
reject(false);
|
||||||
}
|
},
|
||||||
})
|
});
|
||||||
// #endif
|
// #endif
|
||||||
})
|
});
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export const productStore = defineStore('product', {
|
export const productStore = defineStore("product", {
|
||||||
|
state: () => ({
|
||||||
|
location: {
|
||||||
|
latitude: "",
|
||||||
|
longitude: "",
|
||||||
|
},
|
||||||
|
shopInfo: {
|
||||||
|
shopId: "",
|
||||||
|
isOrderFence: 0,
|
||||||
|
},
|
||||||
|
}),
|
||||||
actions: {
|
actions: {
|
||||||
getQueryString(url, name) { //解码
|
getLocation() {
|
||||||
var reg = new RegExp('(^|&|/?)' + name + '=([^&|/?]*)(&|/?|$)', 'i')
|
return new Promise((resolve, reject) => {
|
||||||
var r = url.substr(1).match(reg)
|
console.log("获取经纬度");
|
||||||
|
uni.getLocation({
|
||||||
|
type: "wgs84",
|
||||||
|
altitude: true,
|
||||||
|
isHighAccuracy: true,
|
||||||
|
success: (res) => {
|
||||||
|
console.log("获取经纬度成功", res);
|
||||||
|
|
||||||
|
this.location = res;
|
||||||
|
this.APIgeocodelocation();
|
||||||
|
resolve(res);
|
||||||
|
},
|
||||||
|
fail: (err) => {
|
||||||
|
console.error("获取经纬度失败", err);
|
||||||
|
reject(err);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
async APIgeocodelocation() {
|
||||||
|
let successres = await APIgeocodelocation({
|
||||||
|
lng: this.location.longitude,
|
||||||
|
lat: this.location.latitude,
|
||||||
|
});
|
||||||
|
if (successres) {
|
||||||
|
let datastorage = {
|
||||||
|
country: successres.addressComponent.country, // "中国"
|
||||||
|
province: successres.addressComponent.province, //province: "陕西省"
|
||||||
|
address: successres.addressComponent.city, //district: "西安市"
|
||||||
|
district: successres.addressComponent.district, //district: "未央区"
|
||||||
|
lng: this.location.longitude,
|
||||||
|
lat: this.location.latitude,
|
||||||
|
};
|
||||||
|
uni.cache.set("getLocationstorage", datastorage);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
getQueryString(url, name) {
|
||||||
|
//解码
|
||||||
|
var reg = new RegExp("(^|&|/?)" + name + "=([^&|/?]*)(&|/?|$)", "i");
|
||||||
|
var r = url.substr(1).match(reg);
|
||||||
if (r != null) {
|
if (r != null) {
|
||||||
return r[2]
|
return r[2];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
// 扫码请求
|
|
||||||
scanCodeactions(q) {
|
/**
|
||||||
console.log('扫码内容', q)
|
* 扫码请求
|
||||||
|
* @param {*} q
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
async scanCodeactions(q) {
|
||||||
|
console.log("扫码内容", q);
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
if (q) {
|
if (q) {
|
||||||
console.log(q)
|
console.log(q);
|
||||||
let tableCode = ""
|
let tableCode = "";
|
||||||
// #ifdef MP-WEIXIN
|
// #ifdef MP-WEIXIN
|
||||||
tableCode = this.getQueryString(decodeURIComponent(q), 'code')
|
tableCode = this.getQueryString(decodeURIComponent(q), "code");
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef MP-ALIPAY
|
// #ifdef MP-ALIPAY
|
||||||
tableCode = q
|
tableCode = q;
|
||||||
// #endif
|
// #endif
|
||||||
// #ifdef H5
|
// #ifdef H5
|
||||||
tableCode = q.tableCode
|
tableCode = q.tableCode;
|
||||||
// #endif
|
// #endif
|
||||||
console.log(tableCode);
|
console.log(tableCode);
|
||||||
// 储存卓玛
|
// 储存卓玛
|
||||||
uni.cache.set('tableCode', tableCode)
|
uni.cache.set("tableCode", tableCode);
|
||||||
if (tableCode) {
|
if (tableCode) {
|
||||||
console.log('台桌码', uni.cache.get('tableCode'));
|
console.log("台桌码", uni.cache.get("tableCode"));
|
||||||
let data = await this.actionsproductqueryShop(tableCode)
|
let data = await this.actionsproductqueryShop(tableCode);
|
||||||
|
|
||||||
console.log('data', data)
|
console.log("data", data);
|
||||||
// -4请求登录
|
// -4请求登录
|
||||||
if (data.code == '500') {
|
if (data.code == "500") {
|
||||||
if (await this.actionslogin()) {
|
if (await this.actionslogin()) {
|
||||||
// 成功 接着在调用
|
// 成功 接着在调用
|
||||||
await this.actionsproductqueryShop()
|
await this.actionsproductqueryShop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 是否免除桌位费 0否1是
|
const canOrder = await this.computedDistance();
|
||||||
if (uni.cache.get('shopInfo').isTableFee == 0) {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: '/pages/product/choosetable'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: '/pages/product/index'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
|
// #ifdef APP || MP-WEIXIN || MP-ALIPAY
|
||||||
uni.scanCode({
|
uni.scanCode({
|
||||||
success: async (res) => {
|
success: async (res) => {
|
||||||
let tableCode = this.getQueryString(
|
let tableCode = this.getQueryString(
|
||||||
decodeURIComponent(res.result), 'code')
|
decodeURIComponent(res.result),
|
||||||
|
"code"
|
||||||
|
);
|
||||||
// 储存卓玛
|
// 储存卓玛
|
||||||
uni.cache.set('tableCode', tableCode)
|
uni.cache.set("tableCode", tableCode);
|
||||||
if (tableCode) {
|
if (tableCode) {
|
||||||
let data = await this.actionsproductqueryShop()
|
let data = await this.actionsproductqueryShop();
|
||||||
if (!data) {
|
if (!data) {
|
||||||
uni.showToast({
|
uni.showToast({
|
||||||
title: '店铺已过期或其他问题,请联系商家',
|
title: "店铺已过期或其他问题,请联系商家",
|
||||||
icon:'none'
|
icon: "none",
|
||||||
})
|
});
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
// -4请求登录
|
// -4请求登录
|
||||||
const store = Storelogin()
|
const store = Storelogin();
|
||||||
if (data.code == '-4') {
|
if (data.code == "-4") {
|
||||||
if (await store.actionslogin()) {
|
if (await store.actionslogin()) {
|
||||||
// 成功 接着在调用
|
// 成功 接着在调用
|
||||||
await this.actionsproductqueryShop()
|
await this.actionsproductqueryShop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 是否免除桌位费 0否1是
|
const canOrder = await this.computedDistance();
|
||||||
if (uni.cache.get('shopInfo').isTableFee == 0) {
|
|
||||||
uni.navigateTo({
|
|
||||||
url: '/pages/product/choosetable'
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
uni.reLaunch({
|
|
||||||
url: '/pages/product/index'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
fail: (res) => {
|
fail: (res) => {
|
||||||
console.log(res)
|
console.log(res);
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
// #endif
|
// #endif
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
})
|
//计算距离判断是否可以点餐
|
||||||
|
async computedDistance() {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
console.log("店铺经纬度", this.shopInfo.lat, this.shopInfo.lng);
|
||||||
|
console.log(
|
||||||
|
"用户经纬度",
|
||||||
|
this.location.latitude,
|
||||||
|
this.location.longitude
|
||||||
|
);
|
||||||
|
|
||||||
|
if (this.shopInfo.isOrderFence == 0) {
|
||||||
|
this.jumpToOrderPage();
|
||||||
|
resolve(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const juli = getDistance(
|
||||||
|
this.location.latitude,
|
||||||
|
this.location.longitude,
|
||||||
|
this.shopInfo.lat,
|
||||||
|
this.shopInfo.lng
|
||||||
|
);
|
||||||
|
const orderFenceDistance = (
|
||||||
|
(this.shopInfo.orderFenceDistance || 2000) / 2000
|
||||||
|
).toFixed(2);
|
||||||
|
|
||||||
|
console.log("距离", juli);
|
||||||
|
|
||||||
|
if (this.shopInfo.isOrderFence && juli > orderFenceDistance) {
|
||||||
|
uni.showModal({
|
||||||
|
title: "提示",
|
||||||
|
confirmText: "重新定位",
|
||||||
|
content:
|
||||||
|
"抱歉,您当前距离店铺过远,为保障您的用餐体验,请您到店后或在门店附近再下单。若您已在店铺附近,可尝试重新定位",
|
||||||
|
success: async(res) => {
|
||||||
|
if (res.confirm) {
|
||||||
|
console.log("用户点击了确认");
|
||||||
|
await this.getLocation();
|
||||||
|
this.computedDistance();
|
||||||
|
} else if (res.cancel) {
|
||||||
|
console.log("用户点击了取消");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
reject();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.jumpToOrderPage();
|
||||||
|
resolve(juli);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
// 跳转点餐页面
|
||||||
|
jumpToOrderPage() {
|
||||||
|
// 是否免除桌位费 0否1是
|
||||||
|
if (this.shopInfo.isTableFee == 0) {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: "/pages/product/choosetable",
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
uni.reLaunch({
|
||||||
|
url: "/pages/product/index",
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// /通过桌码获取当前店铺信息
|
// /通过桌码获取当前店铺信息
|
||||||
actionsproductqueryShop(tableCode) {
|
actionsproductqueryShop(tableCode) {
|
||||||
console.log('台桌码',tableCode);
|
console.log("台桌码", tableCode);
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
// try {
|
// try {
|
||||||
try {
|
try {
|
||||||
let res = await APIproductqueryShop({
|
let res = await APIproductqueryShop({
|
||||||
tableCode: tableCode ? tableCode : uni.cache.get('tableCode'),
|
tableCode: tableCode ? tableCode : uni.cache.get("tableCode"),
|
||||||
})
|
});
|
||||||
if (res) {
|
if (res) {
|
||||||
res.shopInfo.isVip = res.vip ? '1' : '0'
|
res.shopInfo.isVip = res.vip ? "1" : "0";
|
||||||
res.shopTable.shopExtendMap = res.shopExtendMap
|
res.shopTable.shopExtendMap = res.shopExtendMap;
|
||||||
|
this.shopInfo = res.shopInfo;
|
||||||
// 店铺信息
|
// 店铺信息
|
||||||
uni.cache.set('shopTable', res.shopTable)
|
uni.cache.set("shopTable", res.shopTable);
|
||||||
// 台桌信息
|
// 台桌信息
|
||||||
uni.cache.set('shopInfo', res.shopInfo)
|
uni.cache.set("shopInfo", res.shopInfo);
|
||||||
uni.cache.set('shopId', res.shopTable.shopId, 30)
|
uni.cache.set("shopId", res.shopTable.shopId, 30);
|
||||||
// 当前用户距离店铺的米数
|
|
||||||
uni.cache.set('distance', res.distance)
|
|
||||||
|
|
||||||
resolve(res)
|
resolve(res);
|
||||||
} else {
|
} else {
|
||||||
console.error('通过桌码获取当前店铺信息失败' ,res)
|
uni.showToast({
|
||||||
reject()
|
title: "通过桌码获取当前店铺信息失败",
|
||||||
|
icon: "none",
|
||||||
|
});
|
||||||
|
console.error("通过桌码获取当前店铺信息失败", res);
|
||||||
|
reject();
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
reject()
|
reject();
|
||||||
//TODO handle the exception
|
//TODO handle the exception
|
||||||
}
|
}
|
||||||
|
|
||||||
// } catch (e) {
|
// } catch (e) {
|
||||||
// reject(false)
|
// reject(false)
|
||||||
// }
|
// }
|
||||||
|
});
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 通过shopId 获取店铺会员信息
|
// 通过shopId 获取店铺会员信息
|
||||||
actionsproductqueryProduct() {
|
actionsproductqueryProduct() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
let res = await APIshopUserInfo()
|
let res = await APIshopUserInfo();
|
||||||
uni.cache.set('shopUserInfo', res);
|
uni.cache.set("shopUserInfo", res);
|
||||||
uni.cache.set('orderVIP', res)
|
uni.cache.set("orderVIP", res);
|
||||||
uni.cache.set('ordershopUserInfo', res.shopInfo)
|
uni.cache.set("ordershopUserInfo", res.shopInfo);
|
||||||
resolve(res)
|
resolve(res);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(false)
|
reject(false);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
})
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 用户信息获取
|
// 用户信息获取
|
||||||
actionsAPIuser() {
|
actionsAPIuser() {
|
||||||
return new Promise(async (resolve, reject) => {
|
return new Promise(async (resolve, reject) => {
|
||||||
try {
|
try {
|
||||||
let res = null
|
let res = null;
|
||||||
// 获取店铺用户会员信息
|
// 获取店铺用户会员信息
|
||||||
if (uni.cache.get('shopId')) {
|
if (uni.cache.get("shopId")) {
|
||||||
res = await this.actionsproductqueryProduct()
|
res = await this.actionsproductqueryProduct();
|
||||||
} else {
|
} else {
|
||||||
res = await APIuser()
|
res = await APIuser();
|
||||||
uni.cache.set('userInfo', res);
|
uni.cache.set("userInfo", res);
|
||||||
}
|
}
|
||||||
console.log('actionsAPIuser res', res);
|
console.log("actionsAPIuser res", res);
|
||||||
resolve(res)
|
resolve(res);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
reject(false)
|
reject(false);
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
13
utils/address.js
Normal file
13
utils/address.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
// 计算距离
|
||||||
|
export const getDistance = (la1, lo1, la2, lo2) => { // 当前的纬度,当前的经度,接口拿到的纬度,接口拿到的经度
|
||||||
|
let La1 = la1 * Math.PI / 180.0;
|
||||||
|
let La2 = la2 * Math.PI / 180.0;
|
||||||
|
let La3 = La1 - La2;
|
||||||
|
let Lb3 = lo1 * Math.PI / 180.0 - lo2 * Math.PI / 180.0;
|
||||||
|
let distance = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin(La3 / 2), 2) + Math.cos(La1) * Math.cos(La2) *
|
||||||
|
Math.pow(Math.sin(Lb3 / 2), 2)));
|
||||||
|
distance = distance * 6378.137;
|
||||||
|
distance = Math.round(distance * 10000) / 10000;
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user