积分商城功能完善

This commit is contained in:
2025-12-10 19:33:29 +08:00
parent 6b53d30f69
commit 87f2ee8c3d
12 changed files with 1268 additions and 589 deletions

View File

@@ -13,7 +13,6 @@ platformType = 'alipay'
payType='aliPay' payType='aliPay'
// #endif // #endif
//订单列表
export const pointGoodsPage = (data) => { export const pointGoodsPage = (data) => {
return request({ return request({
url: url + '/user/pointGoods/page', url: url + '/user/pointGoods/page',
@@ -22,3 +21,38 @@ export const pointGoodsPage = (data) => {
}) })
} }
export const exchange = (data) => {
return request({
url: url + '/user/pointGoods/exchange',
method: 'post',
data: {...data,payType}
})
}
export const applyRefund = (data) => {
return request({
url: url + '/user/pointGoods/applyRefund',
method: 'post',
data: data
})
}
export const cancelRefund = (data) => {
return request({
url: url + '/user/pointGoods/cancelRefund',
method: 'post',
data: data
})
}
export const recordPage = (data) => {
return request({
url: url + '/user/pointGoods/record/page',
method: 'get',
data: data
})
}

View File

@@ -0,0 +1,142 @@
<!-- 优惠券图标 -->
<template>
<view class="container">
<view class="icon icon1" v-if="props.item[props.typeKey] == 1">
<view class="top">
<text class="i"></text>
<text class="num">{{ props.item.discountAmount }}</text>
</view>
<view class="intro">
<text class="t">{{ props.item.fullAmount }}可用</text>
</view>
</view>
<view class="icon icon2" v-if="props.item[props.typeKey] == 2">
<view class="top">
<text class="i">{{ props.item.discountNum }}</text>
<text class="num">商品兑换</text>
</view>
<view class="intro">
<text class="t">{{ props.item.fullAmount }}可用</text>
</view>
</view>
<view class="icon icon3" v-if="props.item[props.typeKey] == 3">
<view class="top">
<text class="num">{{ props.item.discountRate/10 }}</text>
</view>
<view class="intro">
<text class="t">{{ props.item.fullAmount }}可用</text>
</view>
</view>
<view class="icon icon2" v-if="props.item[props.typeKey] == 4">
<view class="top">
<text class="i">第二件</text>
<text class="num">半价券</text>
</view>
</view>
<view class="icon icon2" v-if="props.item[props.typeKey] == 6">
<view class="top">
<text class="i">买一送</text>
<text class="num">一券</text>
</view>
</view>
</view>
</template>
<script setup>
const props = defineProps({
item: {
type: Object,
default: {}
},
typeKey: {
type: String,
default: 'type'
}
});
</script>
<style scoped lang="scss">
$color: #ff1c1c;
.container {
width: 100%;
height: 100%;
.icon {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
&.icon1 {
.top {
.i {
color: $color;
font-size: 24upx;
font-weight: bold;
}
.num {
color: $color;
font-size: 72upx;
font-weight: bold;
}
}
}
&.icon2 {
.top {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.i {
color: $color;
font-size: 34upx;
font-weight: bold;
}
.num {
color: $color;
font-size: 34upx;
font-weight: bold;
}
}
}
&.icon3 {
.top {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
.i {
color: $color;
font-size: 34upx;
font-weight: bold;
}
.num {
color: $color;
font-size: 52upx;
font-weight: bold;
}
}
}
.intro {
display: flex;
justify-content: center;
.t {
font-size: 22upx;
color: #999;
}
}
}
}
</style>

View File

@@ -204,7 +204,7 @@ import {
getCouponShops, getCouponShops,
} from "@/common/api/member.js"; } from "@/common/api/member.js";
import { findCoupon } from "@/common/api/market/coupon.js"; import { findCoupon } from "@/common/api/market/coupon.js";
import couponIcon from "@/pages/user/components/coupon-icon.vue"; import couponIcon from "@/components/coupon-icon/index";
// import * as UTILS from '@/utils/goods-utils.js'; // import * as UTILS from '@/utils/goods-utils.js';
import yskUtils from "ysk-utils"; import yskUtils from "ysk-utils";
const UTILS = yskUtils.couponUtils; const UTILS = yskUtils.couponUtils;

View File

@@ -1,267 +1,406 @@
<template> <template>
<view class="color-333 u-font-28"> <view class="color-333 u-font-28" v-if="item.id">
<view class="top" :style="{ backgroundImage: 'url(' + imgs.bg + ')' }"> <template v-if="item.goodsCategory=='优惠券'">
<view class="name"> 这里是优惠券名称啊啊啊啊 </view> <view class="top" :style="{ backgroundImage: 'url(' + imgs.bg + ')' }">
<view class="info"> 15元代金券满200可用 </view> <view class="name u-line-1"> {{item.couponInfo.title}} </view>
</view> <view class="info"> {{returnCouponTypeName}} </view>
<view class="sku"> </view>
<view> </template>
<view> <template v-else>
<text class="price">800</text> <image class="top-img" :src="item.goodsImageUrl" mode="aspectFit"></image>
<text class="text">积分</text>
<text class="price">+</text>
<text class="price">9.99</text>
<text class="text"></text>
</view>
<view class="u-m-t-16 text"> 限购2份 </view>
</view>
<text class="text">剩余99999</text>
</view>
<view class="goods-name">这里是商品名称啊啊啊啊啊</view>
<view class="bg-f7" style="height: 24rpx"></view>
<view class="desc">
<view class="u-flex">
<view class="color-666 no-wrap">领取方式</view>
<view class="u-m-l-16">系统发放</view>
</view>
<view class="u-flex u-m-t-16 u-col-baseline">
<view class="color-666 no-wrap">特别说明</view>
<view class="u-m-l-16"
>优惠券为虚拟发放一旦兑换不支持退款请悉知</view
>
</view>
</view>
<view class="bg-f7" style="height: 24rpx"></view>
<view class="goods-detail"> </template>
<view class="u-flex u-row-center"> <view class="sku">
<view class="title">商品详情</view> <view>
</view> <view>
</view> <text class="price">{{item.requiredPoints}}</text>
<text class="text">积分</text>
<template v-if="item.extraPrice">
<text class="price">+</text>
<text class="price">{{item.extraPrice}}</text>
<text class="text"></text>
</template>
<view style="height: 72px"></view> </view>
<view class="fixed-bottom u-flex u-row-center"> <view class="u-m-t-16 text" v-if="item.limitQuota"> 限购{{item.limitQuota}} </view>
<view class="btn" @click="exchangeClick">立即兑换</view> </view>
</view> <text class="text">剩余{{item.quantity}}</text>
</view>
<view class="goods-name">{{item.goodsName}}</view>
<view class="bg-f7" style="height: 24rpx"></view>
<view class="desc">
<view class="u-flex">
<view class="color-666 no-wrap">领取方式</view>
<view class="u-m-l-16" v-if="item.goodsCategory=='优惠券'">系统发放</view>
<view class="u-m-l-16" v-else>店内自取</view>
</view>
<view class="u-flex u-m-t-16 u-col-baseline" v-if="item.goodsCategory=='优惠券'">
<view class="color-666 no-wrap">特别说明</view>
<view class="u-m-l-16">优惠券为虚拟发放一旦兑换不支持退款请悉知</view>
</view>
</view>
<view class="bg-f7" style="height: 24rpx"></view>
<!-- 兑换确认弹窗start --> <view class="goods-detail" v-if="item.goodsCategory!='优惠券'">
<modal <view class="u-flex u-row-center">
v-model="modalData.show" <view class="title">商品详情</view>
title="立即兑换确认" </view>
@confirm="confirmExchange" <view class="u-m-t-32">
> <image class="w-full" v-for="(item,index) in item.goodsDescription" :key="index" mode="widthFix" :src="item">
<view style="padding: 32rpx 50rpx"> </image>
<view class="u-font-32" </view>
>您将消耗{800}积分兑换商品{这里是商品名称}是否确认兑换</view </view>
>
<view class="u-m-t-20 waring u-flex u-font-32 u-col-center">
<up-icon name="info-circle" size="16" color="#FF9900"></up-icon>
<view class="u-m-l-24"
>优惠券为虚拟发放一旦兑换不支持退款请悉知</view
>
</view>
</view>
</modal>
<!-- 需要支付的弹窗 --> <view style="height: 100px"></view>
<up-popup <view class="fixed-bottom u-flex u-row-center">
:show="popupData.show" <view class="btn" @click="exchangeClick" :class="isCanExchange">立即兑换</view>
mode="bottom" </view>
closeOnClickOverlay
@close="popupData.show = false"
>
<view class="popup-content">
<view class="popup-content-top">
<text class="color-666">领取方式</text>
<text class="u-m-l-16">需前往店铺自行兑换领取</text>
</view>
<view class="goods-info">
<view class="u-flex">
<image class="cover"></image>
<view class="u-flex u-flex-1 u-row-between u-p-l-16 u-col-center">
<view>
<view class="u-font-32 font-bold">这里是商品名称</view>
<view class="u-m-t-54 color-666">8000积分+9.99</view>
</view>
<text class="color-666">X1</text>
</view>
</view>
<view class="u-m-t-20 waring u-flex u-col-center">
<up-icon name="info-circle" size="16" color="#FF9900"></up-icon>
<view class="u-m-l-16"
>优惠券为虚拟发放一旦兑换不支持退款请悉知</view
>
</view>
</view>
<view class="bottom font-bold text-right"> <!-- 兑换确认弹窗start -->
<text>合计 8000积分 + ¥9.99</text> <modal v-model="modalData.show" title="立即兑换确认" @confirm="confirmExchange">
</view> <view style="padding: 32rpx 50rpx">
<view class="u-font-32">您将消耗{{item.requiredPoints}}积分兑换商品{{item.goodsName}}是否确认兑换</view>
<view class="u-m-t-20 waring u-flex u-font-32 u-col-center">
<up-icon name="info-circle" size="16" color="#FF9900"></up-icon>
<view class="u-m-l-24">优惠券为虚拟发放一旦兑换不支持退款请悉知</view>
</view>
</view>
</modal>
<view class="u-m-t-42 u-flex u-row-center"> <!-- 需要支付的弹窗 -->
<view class="btn">确认兑换</view> <up-popup :show="popupData.show" mode="bottom" closeOnClickOverlay @close="popupData.show = false">
</view> <view class="popup-content">
</view> <view class="popup-content-top">
</up-popup> <text class="color-666">领取方式</text>
<!-- 兑换确认弹窗end --> <text class="u-m-l-16">需前往店铺自行兑换领取</text>
</view> </view>
<view class="goods-info">
<view class="u-flex">
<image class="cover"></image>
<view class="u-flex u-flex-1 u-row-between u-p-l-16 u-col-center">
<view>
<view class="u-font-32 font-bold">这里是商品名称</view>
<view class="u-m-t-54 color-666">8000积分+9.99</view>
</view>
<text class="color-666">X1</text>
</view>
</view>
<view class="u-m-t-20 waring u-flex u-col-center">
<up-icon name="info-circle" size="16" color="#FF9900"></up-icon>
<view class="u-m-l-16">优惠券为虚拟发放一旦兑换不支持退款请悉知</view>
</view>
</view>
<view class="bottom font-bold text-right">
<text>合计 8000积分 + ¥9.99</text>
</view>
<view class="u-m-t-42 u-flex u-row-center">
<view class="btn">确认兑换</view>
</view>
</view>
</up-popup>
<!-- 兑换确认弹窗end -->
</view>
</template> </template>
<script setup> <script setup>
import modal from "@/scoreShop/components/modal.vue"; import {
const imgs = { computed,
bg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/9fd6a3ad2b384f6cb4e88ed6b77bd334.png", reactive
}; } from "vue";
const modalData = reactive({ import {
show: false, getOpenId
}); } from '@/utils/uniapp.js'
import modal from "@/scoreShop/components/modal.vue";
import * as pointGoodsApi from "@/common/api/order/pointGoods.js";
const imgs = {
bg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/9fd6a3ad2b384f6cb4e88ed6b77bd334.png",
};
const modalData = reactive({
show: false,
});
const popupData = reactive({ const popupData = reactive({
show: false, show: false,
}); });
function exchangeClick() {
modalData.show = true; function exchangeClick() {
} modalData.show = true;
function confirmExchange() { }
modalData.show = false;
} function confirmExchange() {
// modalData.show = false;
exchange()
}
async function exchange() {
uni.showLoading({
title: '兑换中……'
})
const openId = await getOpenId()
uni.hideLoading()
if (openId) {
pointGoodsApi.exchange({
pointsGoodsId: item.id,
shopId: item.shopId,
number: 1,
price: item.extraPrice,
openId
}).then(res => {
modalData.show = false;
if(res){
uni.setStorageSync('exchange_goods_success',res)
uni.redirectTo({
url:'/scoreShop/success/index'
})
}else{
uni.showToast({
title: '兑换失败',
icon: 'none'
})
}
})
} else {
uni.showToast({
title: '鉴权失败,兑换失败',
icon: 'none'
})
}
}
const item = reactive({
goodsDescription: []
})
const couponTypes = {
1: "满减券",
2: "商品券",
3: "折扣券",
4: "第二件半价券",
5: "消费送券",
6: "买一送一券",
7: "固定价格券",
8: "免配送费券",
};
const returnCouponTypeName = computed(() => {
if (!item.id) {
return ' '
}
const type = item.couponInfo.couponType
if (type == 1) {
return item.couponInfo.discountAmount + '元代金券' + ' ' + `(满${item.fullAmount}可用)`
}
if (type == 2) {
return item.couponInfo.discountNum + '件商品兑换' + ' ' + `(满${item.fullAmount}可用)`
}
if (type == 3) {
return item.couponInfo.discountRate / 10 + '折' + ' ' + `(满${item.fullAmount}可用)`
}
if (type == 4) {
return '第二件半价券'
}
if (type == 6) {
return '买一送一券'
}
})
const pointsUser = reactive({
pointBalance: 0,
})
const isCanExchange = computed(() => {
if (pointsUser.pointBalance <= 0) {
return false
}
if (pointsUser.pointBalance < item.requiredPoints) {
return false
}
if (item.quantity <= 0) {
return false
}
if(item.limitQuota&&item.boughtCount>=item.limitQuota){
return false
}
return true
})
onLoad((opt) => {
const exchange_goods = uni.getStorageSync('exchange_goods')
if (exchange_goods.goodsDescription) {
exchange_goods.goodsDescription = JSON.parse(exchange_goods.goodsDescription)
} else {
exchange_goods.goodsDescription = []
}
const pointsUserData = uni.getStorageSync('pointsUser')
Object.assign(item, exchange_goods)
Object.assign(pointsUser, pointsUserData)
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.top { $topHeight: 350rpx;
margin: 14rpx 18rpx;
background-size: cover;
height: 350rpx;
box-sizing: border-box;
padding-left: 70rpx;
padding-top: 95rpx;
.name { .top-img {
color: #000000; width: 750rpx;
font-size: 36rpx; height: $topHeight;
font-weight: 700; }
}
.info {
color: #333333;
font-size: 48rpx;
font-weight: 700;
margin-top: 62rpx;
}
}
.sku {
display: flex;
justify-content: space-between;
padding: 20rpx 36rpx;
align-items: center;
background: linear-gradient(90deg, #ff4a63 0%, #fd1f48 100%);
.price {
color: #fff;
font-weight: 700;
font-size: 36rpx;
}
.text {
color: #fff;
font-size: 28rpx;
}
}
.goods-name {
padding: 20rpx 28rpx;
background: #fff;
font-size: 32rpx;
font-weight: 700;
color: #333;
}
.desc {
padding: 32rpx 28rpx;
background-color: #fff;
}
.goods-detail {
padding: 32rpx;
.title {
position: relative;
padding: 0 22rpx;
&::before {
content: "";
display: block;
position: absolute;
right: 100%;
width: 70rpx;
height: 2rpx;
top: 50%;
transform: translateY(-50%);
background: linear-gradient(90deg, #f7f8f9 0%, #c9cbcc 100%);
}
&::after {
left: 100%;
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
display: block;
width: 70rpx;
height: 2rpx;
background: linear-gradient(90deg, #c9cbcc 0%, #f7f8f9 100%);
}
}
}
.fixed-bottom { .top {
position: fixed; margin: 14rpx 18rpx;
background-color: #fff; background-size: cover;
left: 0; height: $topHeight;
right: 0; box-sizing: border-box;
padding-bottom: calc(env(safe-area-inset-bottom) + 2rpx); padding-left: 70rpx;
background-color: #fff; padding-top: 95rpx;
bottom: 0;
z-index: 10; .name {
.btn { color: #000000;
padding: 16rpx 62rpx; font-size: 36rpx;
border-radius: 16rpx; font-weight: 700;
font-size: 32rpx; }
font-weight: 700;
color: #9c571f; .info {
background: linear-gradient(180deg, #f7cc84 0%, #f9dda9 100%); color: #333333;
&.gray { font-size: 48rpx;
background: #9999992b; font-weight: 700;
color: #999999; margin-top: 62rpx;
} }
} }
}
.waring { .sku {
background-color: rgba(255, 204, 0, 0.09); display: flex;
padding: 32rpx 24rpx; justify-content: space-between;
color: #ff8d28; padding: 20rpx 36rpx;
} align-items: center;
.popup-content { background: linear-gradient(90deg, #ff4a63 0%, #fd1f48 100%);
font-size: 28rpx;
min-height: 300px; .price {
.popup-content-top { color: #fff;
padding: 32rpx 28rpx; font-weight: 700;
border-bottom: 1px solid #ededed; font-size: 36rpx;
} }
.goods-info {
padding: 44rpx 28rpx; .text {
border-bottom: 1px solid #ededed; color: #fff;
.cover { font-size: 28rpx;
width: 184rpx; }
height: 184rpx; }
border-radius: 16rpx;
background: #d9d9d9; .goods-name {
} padding: 20rpx 28rpx;
} background: #fff;
.bottom { font-size: 32rpx;
padding: 20rpx 28rpx 20rpx 20rpx; font-weight: 700;
border-bottom: 1px solid #ededed; color: #333;
} }
.btn {
display: flex; .desc {
padding: 22rpx 214rpx; padding: 32rpx 28rpx;
align-items: flex-start; background-color: #fff;
gap: 20rpx; }
border-radius: 66rpx;
background: #e8ad7b; .goods-detail {
font-size: 32rpx; padding: 32rpx;
color: #fff;
font-size: 700; .title {
} position: relative;
} padding: 0 22rpx;
</style>
&::before {
content: "";
display: block;
position: absolute;
right: 100%;
width: 70rpx;
height: 2rpx;
top: 50%;
transform: translateY(-50%);
background: linear-gradient(90deg, #f7f8f9 0%, #c9cbcc 100%);
}
&::after {
left: 100%;
content: "";
position: absolute;
top: 50%;
transform: translateY(-50%);
display: block;
width: 70rpx;
height: 2rpx;
background: linear-gradient(90deg, #c9cbcc 0%, #f7f8f9 100%);
}
}
}
.fixed-bottom {
position: fixed;
background-color: #fff;
left: 0;
right: 0;
padding-bottom: calc(env(safe-area-inset-bottom) + 2rpx);
padding-top: 32rpx;
background-color: #fff;
bottom: 0;
z-index: 10;
.btn {
padding: 16rpx 62rpx;
border-radius: 16rpx;
font-size: 32rpx;
font-weight: 700;
color: #9c571f;
background: linear-gradient(180deg, #f7cc84 0%, #f9dda9 100%);
&.gray {
background: #9999992b;
color: #999999;
}
}
}
.waring {
background-color: rgba(255, 204, 0, 0.09);
padding: 32rpx 24rpx;
color: #ff8d28;
}
.popup-content {
font-size: 28rpx;
min-height: 300px;
.popup-content-top {
padding: 32rpx 28rpx;
border-bottom: 1px solid #ededed;
}
.goods-info {
padding: 44rpx 28rpx;
border-bottom: 1px solid #ededed;
.cover {
width: 184rpx;
height: 184rpx;
border-radius: 16rpx;
background: #d9d9d9;
}
}
.bottom {
padding: 20rpx 28rpx 20rpx 20rpx;
border-bottom: 1px solid #ededed;
}
.btn {
display: flex;
padding: 22rpx 214rpx;
align-items: flex-start;
gap: 20rpx;
border-radius: 66rpx;
background: #e8ad7b;
font-size: 32rpx;
color: #fff;
font-size: 700;
}
}
</style>

View File

@@ -1,155 +1,242 @@
<template> <template>
<view class="goodslist" :class="[layout]"> <view class="goodslist" :class="[layout]">
<view v-for="(item, index) in 10" :key="index" @click="toDetail(item)"> <view v-for="(item, index) in list" :key="index" @click="toDetail(item)">
<template v-if="layout === 'list'"> <template v-if="layout === 'list'">
<view class="item"> <view class="item">
<image class="img" lazy-load></image> <view class="img coupon" v-if="item.goodsCategory=='优惠劵'&&item.couponInfo">
<view class="info"> <couponIcon :item="item.couponInfo" typeKey="couponType" />
<view> </view>
<view class="name u-line-1">这里是商品名称</view> <image class="img" v-else lazy-load :src="item.goodsImageUrl"></image>
<view class="price">8000积分</view> <view class="info">
</view> <view>
<view class="u-flex u-row-center u-col-center u-flex-col"> <view class="name u-line-1">{{item.goodsName}}</view>
<view class="btn">兑换</view> <view class="price">
<view class="limit">限购2份</view> <text>{{item.requiredPoints}}积分 </text>
</view> <text v-if="item.extraPrice">+{{item.extraPrice}}</text>
</view> </view>
</view> </view>
</template> <view class="u-flex u-row-center u-col-center u-flex-col">
<template v-if="layout === 'block'"> <view class="btn" v-if="canExchange(item)">兑换</view>
<view class="item"> <view class="btn end" v-else>已兑完</view>
<image class="img" lazy-load></image> <view class="limit" v-if="item.limitQuota">限购{{item.limitQuota}}</view>
<view class="info"> </view>
<view class="name u-line-1">这里是商品名称</view> </view>
<view class="price">8000积分</view> </view>
<view class="u-flex u-col-center u-m-t-16 u-row-between"> </template>
<view class="limit">限购2份</view> <template v-if="layout === 'block'">
<view class="btn">兑换</view> <view class="item">
</view> <view class="img coupon" v-if="item.goodsCategory=='优惠劵'&&item.couponInfo">
</view> <couponIcon :item="item.couponInfo" typeKey="couponType" />
</view> </view>
</template> <image class="img" v-else lazy-load :src="item.goodsImageUrl"></image>
</view> <view class="info">
</view> <view class="name u-line-1">{{item.goodsName}}</view>
<view class="price">
<text>{{item.requiredPoints}}积分 </text>
<text v-if="item.extraPrice">+{{item.extraPrice}}</text>
</view>
<view class="u-flex u-col-center u-m-t-16 u-row-between">
<view class="limit" v-if="item.limitQuota">限购{{item.limitQuota}}</view>
<view class="btn" v-if="canExchange(item)">兑换</view>
<view class="btn end" v-else>已兑完</view>
</view>
</view>
</view>
</template>
</view>
</view>
</template> </template>
<script setup> <script setup>
const props = defineProps({ import couponIcon from "@/components/coupon-icon/index";
list: { const props = defineProps({
type: Object, list: {
default: () => [], type: Object,
}, default: () => [],
layout: { },
type: String, layout: {
default: "block", type: String,
}, default: "block",
}); },
pointsUser: {
type: Object,
default: () => {},
}
});
function toDetail(item) { function toDetail(item) {
uni.navigateTo({ if (!canExchange(item)) {
url: '/scoreShop/detail/index?id=' + item.id, return
}) }
} uni.setStorageSync('exchange_goods', item)
uni.navigateTo({
url: '/scoreShop/detail/index?id=' + item.id,
})
}
function canExchange(item) {
if (item.goodsCategory == '优惠券' && !item.couponInfo) {
return false
}
if (props.pointsUser.pointBalance <= 0) {
return false
}
if (props.pointsUser.pointBalance < item.requiredPoints) {
return false
}
if (item.quantity <= 0) {
return false
}
if (item.limitQuota && item.boughtCount >= item.limitQuota) {
return false
}
return true
}
const emits = defineEmits('exchange')
function exchange(item) {
// uni.showModal({
// title: '提示',
// content: `是否确认兑换` + item.goodsName + '',
// cancelText: '取消',
// showCancel: true,
// success(res) {
// if (res.confirm) {
// emits('exchange', item)
// }
// }
// })
}
</script> </script>
<style lang="scss"> <style lang="scss">
.goodslist { .goodslist {
padding: 28rpx; padding: 28rpx;
&.list {
.item { &.list {
background-color: #fff; .item {
padding: 32rpx 24rpx; background-color: #fff;
border-radius: 16rpx; padding: 32rpx 24rpx;
display: flex; border-radius: 16rpx;
margin-bottom: 18rpx; display: flex;
.img { margin-bottom: 18rpx;
width: 112rpx;
height: 112rpx;
border-radius: 16rpx; .img {
background: #d9d9d9; width: 112rpx;
} height: 112rpx;
.info { border-radius: 16rpx;
flex: 1; background: #d9d9d9;
padding-left: 16rpx;
display: flex; &.coupon {
justify-content: space-between; // background-color: transparent;
align-items: center; }
.name { }
font-size: 28rpx;
color: #333; .info {
font-weight: 700; flex: 1;
} padding-left: 16rpx;
.price { display: flex;
font-size: 28rpx; justify-content: space-between;
margin-top: 14rpx; align-items: center;
color: #666;
} .name {
.btn { font-size: 28rpx;
padding: 14rpx 48rpx; color: #333;
border-radius: 16rpx; font-weight: 700;
background: linear-gradient(180deg, #f7cc84 0%, #f9dda9 100%); }
color: #9c571f;
font-size: 28rpx; .price {
font-weight: 700; font-size: 28rpx;
&.end { margin-top: 14rpx;
color: #999999; color: #666;
background-color: rgba(153, 153, 153, 0.3); }
}
} .btn {
.limit { padding: 14rpx 48rpx;
color: #666; border-radius: 16rpx;
font-size: 24rpx; background: linear-gradient(180deg, #f7cc84 0%, #f9dda9 100%);
margin-top: 8rpx; color: #9c571f;
} font-size: 28rpx;
} font-weight: 700;
} white-space: nowrap;
} &.end {
&.block { color: #999999;
display: grid; background: rgba(153, 153, 153, 0.3);
grid-template-columns: repeat(2, 1fr); }
row-gap: 30rpx; }
column-gap: 52rpx;
.item { .limit {
padding: 32rpx 28rpx; color: #666;
border-radius: 16rpx; font-size: 24rpx;
background-color: #fff; margin-top: 8rpx;
.img { white-space: nowrap;
width: 266rpx; }
height: 266rpx; }
border-radius: 16rpx; }
background: #d9d9d9; }
}
.info { &.block {
margin-top: 28rpx; display: grid;
.name { grid-template-columns: repeat(2, 1fr);
font-size: 28rpx; row-gap: 30rpx;
color: #333; column-gap: 52rpx;
font-weight: 700;
} .item {
.price { padding: 32rpx 28rpx;
font-size: 28rpx; border-radius: 16rpx;
margin-top: 16rpx; background-color: #fff;
font-weight: 700;
color: #9C571F;
} .img {
.btn { width: 266rpx;
padding: 14rpx 48rpx; height: 266rpx;
border-radius: 16rpx; border-radius: 16rpx;
background: linear-gradient(180deg, #f7cc84 0%, #f9dda9 100%); background: #d9d9d9;
color: #9c571f;
font-size: 28rpx; &.coupon {
font-weight: 700; // background-color: transparent;
&.end { }
color: #999999; }
background-color: rgba(153, 153, 153, 0.3);
} .info {
} margin-top: 28rpx;
.limit {
color: #666; .name {
font-size: 24rpx; font-size: 28rpx;
} color: #333;
} font-weight: 700;
} }
}
} .price {
</style> font-size: 28rpx;
margin-top: 16rpx;
font-weight: 700;
color: #9C571F;
}
.btn {
padding: 14rpx 48rpx;
border-radius: 16rpx;
background: linear-gradient(180deg, #f7cc84 0%, #f9dda9 100%);
color: #9c571f;
font-size: 28rpx;
font-weight: 700;
white-space: nowrap;
&.end {
color: #999999;
background: rgba(153, 153, 153, 0.3);
}
}
.limit {
color: #666;
font-size: 24rpx;
white-space: nowrap;
}
}
}
}
}
</style>

View File

@@ -7,13 +7,16 @@
<view> <view>
<view class="u-flex"> <view class="u-flex">
<image :src="imgs.wujiaoxing" class="wujiaoxing"></image> <image :src="imgs.wujiaoxing" class="wujiaoxing"></image>
<view class="number u-m-l-20 u-m-r-12">{{pointsUser?pointsUser.pointBalance:''}}</view> <view class="u-flex" @click="toDetail">
<view class="u-flex"> <view class="number u-m-l-20 u-m-r-12">{{pointsUser?pointsUser.pointBalance:0}}</view>
<up-icon name="arrow-right" size="18" bold color="#9C571F"></up-icon> <view class="u-flex">
<up-icon name="arrow-right" size="18" bold color="#9C571F"></up-icon>
</view>
</view> </view>
</view> </view>
<view class="u-m-t-10 u-flex color1" style="margin-left: 66rpx"> <view class="u-m-t-10 u-flex color1" style="margin-left: 66rpx">
<text @click="toPage('/scoreShop/order/index')">积分订单</text> <text @click="toPage('/scoreShop/order/index?shopId='+query.shopId)">积分订单</text>
<text class="u-m-l-44" @click="toDetail">积分明细</text> <text class="u-m-l-44" @click="toDetail">积分明细</text>
</view> </view>
</view> </view>
@@ -26,13 +29,17 @@
<view class="tab-box u-flex"> <view class="tab-box u-flex">
<view class="tabs u-flex-1 u-flex"> <view class="tabs u-flex-1 u-flex">
<view class="tab-item" :class="tabActive === 0 ? 'active' : ''" @click="tabActive = 0">优惠券</view> <view class="tab-item" :class="tabActive === 0 ? 'active' : ''" @click="tabActive = 0">优惠券</view>
<view class="tab-item" :class="tabActive === 1 ? 'active' : ''" @click="tabActive = 1">商品</view> <view class="tab-item" :class="tabActive === 1 ? 'active' : ''" @click="tabActive = 1">商品</view>
</view> </view>
<view class="u-flex" @click="toggleLayout"> <view class="u-flex" @click="toggleLayout">
<image :src="layout === 'block' ? imgs.layout_block : imgs.layout" class="layout" /> <image :src="layout === 'block' ? imgs.layout_block : imgs.layout" class="layout" />
</view> </view>
</view> </view>
<goodsList :layout="layout"></goodsList> <goodsList :pointsUser="pointsUser" :layout="layout" :list="list" @exchange="exchange"></goodsList>
<view class="">
<up-loadmore :status="isEnd?'nomore':'loadmore'"></up-loadmore>
</view>
</view> </view>
</view> </view>
</template> </template>
@@ -42,6 +49,13 @@
import { import {
onLoad onLoad
} from "@dcloudio/uni-app"; } from "@dcloudio/uni-app";
import {
reactive,
watch
} from "vue";
import {
onReachBottom
} from "@dcloudio/uni-app";
const imgs = { const imgs = {
bg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/3716211a58d84fda9ee596a1882c0704.png", //背景图 bg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/3716211a58d84fda9ee596a1882c0704.png", //背景图
huizhang: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/5d07600cc494490aa3adacfe51d8845d.png", //徽章 huizhang: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/5d07600cc494490aa3adacfe51d8845d.png", //徽章
@@ -61,6 +75,17 @@
}); });
} }
// function exchange(item) {
// pointGoodsApi.exchange({
// pointsGoodsId: item.id,
// shopId: item.shopId,
// number: 1,
// price: item.extraPrice
// }).then(res => {
// refresh()
// })
// }
function toDetail() { function toDetail() {
uni.navigateTo({ uni.navigateTo({
url: '/pages/user/member/billDetails?type=2&shopId=' + query.shopId + '&id=' + (pointsUser.value.id || url: '/pages/user/member/billDetails?type=2&shopId=' + query.shopId + '&id=' + (pointsUser.value.id ||
@@ -78,22 +103,52 @@
page: 1, page: 1,
size: 10, size: 10,
shopId: '', shopId: '',
goodsCategory: ''
}); });
const isEnd = ref(false); const isEnd = ref(false);
const pointsUser = ref(null) const pointsUser = ref(null)
const list = ref([])
function getList() { function getList() {
pointGoodsApi.pointGoodsPage(query).then(res => { const goodsCategory = tabActive.value === 1 ? '其它商品' : '优惠券'
pointGoodsApi.pointGoodsPage({
...query,
goodsCategory,
}).then(res => {
pointsUser.value = res.pointsUser pointsUser.value = res.pointsUser
uni.setStorageSync('pointsUser', res.pointsUser)
const newList = res.pointsGoods.records
if (query.page == 1) {
list.value = newList
} else {
list.value.push(...newList)
}
if (query.page >= res.pointsGoods.totalPage * 1) {
isEnd.value = true
}
}) })
} }
onLoad((opt) => { onLoad((opt) => {
query.shopId = opt.id || '' query.shopId = opt.shopId || ''
}) })
onShow(() => { watch(() => tabActive.value, (newval, oldval) => {
refresh()
})
function refresh() {
query.page = 1; query.page = 1;
isEnd.value = false; isEnd.value = false;
getList(); getList();
}
onReachBottom(() => {
if (isEnd.value) {
return
}
query.page++
getList();
})
onShow(() => {
refresh()
}); });
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@@ -1,78 +1,128 @@
<template> <template>
<view class="list"> <view class="list">
<view v-for="(item, index) in 10" :key="index" class="item"> <view v-for="(item, index) in list" :key="index" class="item">
<view class="u-flex u-row-between"> <view class="u-flex u-row-between">
<text class="color-999">2025/08/20 02:37:58</text> <text class="color-999">{{item.createTime}}</text>
<text class="status success">待核销</text> <text class="status " :class="[returnStatusClass(item)]">{{item.status}}</text>
</view> </view>
<view class="u-m-t-22 u-flex u-col-center"> <view class="u-m-t-22 u-flex u-col-center">
<up-image width="132rpx" height="132rpx" :src="item.img"></up-image> <up-image width="132rpx" height="132rpx" :src="item.goodsImageUrl" v-if="item.goodsCategory!='优惠券'"></up-image>
<view class="u-p-l-36"> <view class="img" v-else>
<view>这里是商品名称</view> <couponIcon :item="item.couponInfo" typeKey="couponType" />
<view class="u-m-t-28 color-666">800积分</view> </view>
</view> <view class="u-p-l-36">
</view> <view>{{item.pointsGoodsName}}</view>
<view class="u-m-t-28 u-flex u-row-right btns"> <view class="u-m-t-28 color-666">{{item.spendPoints}}积分</view>
<view class="btn look" @click="lookCode">查看券码</view> </view>
<view class="btn black">申请退款</view> </view>
</view> <view class="u-m-t-28 u-flex u-row-right btns">
</view> <view class="btn look" @click="lookCode(item)" v-if="item.goodsCategory!='优惠券'">查看券码</view>
</view> <view class="btn black" @click="tuikuan(item)" v-if="canRefund(item)">申请退款</view>
<view class="btn black" @click="cancelRefund(item)" v-if="item.status=='退款中'" >取消退款</view>
</view>
</view>
</view>
</template> </template>
<script setup> <script setup>
import { ref } from "vue"; import couponIcon from "@/components/coupon-icon/index";
import {
ref
} from "vue";
const props = defineProps({
list: {
type: Array,
default: () => []
}
})
const emits = defineEmits(["lookCode", "refund","cancelRefund"]);
const lookCode = (item) => {
emits("lookCode", item);
};
const emits = defineEmits(["lookCode"]); function tuikuan(item) {
const lookCode = () => { emits("refund", item);
emits("lookCode"); }
}; function cancelRefund(item) {
emits("cancelRefund", item);
}
function returnStatusClass(item) {
if (item.status == '已完成' || item.status == '已退款') {
return 'gray'
}
if (item.status == '待核销') {
return 'success'
}
if (item.status == '退款中') {
return 'error'
}
}
function canRefund(item) {
if(item.status=='已退款'|| item.status=='退款中'||item.goodsCategory!='其它商品' ){
return false
}
return true
}
</script> </script>
<style lang="scss"> <style lang="scss">
.list { .list {
padding: 28rpx; padding: 28rpx;
.item {
padding: 14rpx 46rpx; .item {
border-radius: 24rpx; padding: 14rpx 46rpx;
background: #fff; border-radius: 24rpx;
margin-bottom: 48rpx; background: #fff;
.status { margin-bottom: 48rpx;
padding: 8rpx 18rpx; .img{
border-radius: 8rpx; width: 132rpx;
border: 2rpx solid transparent; height: 132rpx;
&.success { }
background: rgba(123, 209, 54, 0.12); .status {
border-color: #7bd136; padding: 8rpx 18rpx;
color: #7bd136; border-radius: 8rpx;
} border: 2rpx solid transparent;
&.gray {
background: #9999991f; &.success {
border-color: #999; background: rgba(123, 209, 54, 0.12);
color: #999; border-color: #7bd136;
} color: #7bd136;
&.error { }
background: #ff1c1c2e;
border-color: #ff1c1c; &.gray {
color: #ff1c1c; background: #9999991f;
} border-color: #999;
} color: #999;
.btns { }
display: flex;
gap: 34rpx; &.error {
.btn { background: #ff1c1c2e;
padding: 8rpx 14rpx; border-color: #ff1c1c;
border-radius: 10rpx; color: #ff1c1c;
border: 2rpx solid transparent; }
&.look { }
border-color: #ededed;
color: #333; .btns {
} display: flex;
&.black { gap: 34rpx;
border-color: #343030;
background: #343030; .btn {
color: #fff; padding: 8rpx 14rpx;
} border-radius: 10rpx;
} border: 2rpx solid transparent;
}
} &.look {
} border-color: #ededed;
</style> color: #333;
}
&.black {
border-color: #343030;
background: #343030;
color: #fff;
}
}
}
}
}
</style>

View File

@@ -1,105 +1,220 @@
<template> <template>
<view class="min-page bg-f7 u-font-28"> <view class="min-page bg-f7 u-font-28">
<up-sticky> <up-sticky>
<view class="top"> <view class="top">
<view <view v-for="(item, index) in tabs.list" :key="index" class="tab-item"
v-for="(item, index) in tabs.list" :class="{ active: item.value == tabs.sel }" @click="tabs.sel = item.value">{{ item.name }}</view>
:key="index" </view>
class="tab-item" </up-sticky>
:class="{ active: item.value == tabs.sel }"
@click="tabs.sel = item.value"
>{{ item.name }}</view
>
</view>
</up-sticky>
<orderList :list="list" @lookCode="lookCode" /> <orderList :list="list" @lookCode="lookCode" @refund="refund" @cancelRefund="cancelRefund" />
<modal v-model="modalData.show" title="立即兑换确认" :showBottom="false"> <view class="safe-bottom">
<view class="u-p-28"> <up-loadmore :status="isEnd?'nomore':'loadmore'"></up-loadmore>
<view class="u-flex u-row-center"> </view>
<up-qrcode cid="ex1" :size="104" :val="qrcode"></up-qrcode>
</view> <modal v-model="modalData.show" title="立即兑换确认" :showBottom="false">
<view class="u-m-t-22 u-flex u-row-center"> <view class="u-p-28">
<text>{{ qrcode }}</text> <view class="u-flex u-row-center">
<view @click="copyCode"> <up-qrcode cid="ex1" :size="104" :val="qrcode"></up-qrcode>
<image </view>
src="/scoreShop/static/image/copy.png" <view class="u-m-t-22 u-flex u-row-center">
class="u-m-l-24 copy" <text>{{ qrcode }}</text>
></image> <view @click="copyCode">
</view> <image src="/scoreShop/static/image/copy.png" class="u-m-l-24 copy"></image>
</view> </view>
</view> </view>
</modal> </view>
</view> </modal>
</view>
</template> </template>
<script setup> <script setup>
import modal from "@/scoreShop/components/modal.vue"; import modal from "@/scoreShop/components/modal.vue";
import orderList from "./components/order-list.vue"; import orderList from "./components/order-list.vue";
const modalData = reactive({ import * as pointGoodsApi from "@/common/api/order/pointGoods.js";
show: false, import {
}); onLoad
const qrcode = ref("daddadaddad"); } from "@dcloudio/uni-app";
import {
watch
} from "vue";
function copyCode() { const modalData = reactive({
uni.setClipboardData({ show: false,
data: qrcode.value, });
success: function () { const qrcode = ref("");
uni.showToast({
title: "复制成功", function copyCode() {
icon: "none", uni.setClipboardData({
}); data: qrcode.value,
}, success: function() {
}); uni.showToast({
} title: "复制成功",
icon: "none",
});
},
});
}
function lookCode() { function refresh() {
modalData.show = true; query.page = 1;
} isEnd.value = false;
const tabs = reactive({ getList();
list: [ }
{
name: "全部订单",
value: "", function refund(item) {
}, uni.showModal({
{ title: '提示',
name: "待核销", content: '是否申请退款',
value: "unevaluated", showCancel: true,
}, success(res) {
{ if (res.confirm) {
name: "已核销", pointGoodsApi.applyRefund({
value: "evaluated", orderNo: item.orderNo,
}, recordId: item.id
{ }).then(res => {
name: "售后", if (res) {
value: "after_sale", uni.showToast({
}, title: '申请退款成功',
], icon: 'none'
sel: "", })
});
const list = ref([]); } else {
uni.showToast({
title: '申请退款失败',
icon: 'none'
})
}
setTimeout(() => {
refresh()
}, 1000)
})
}
}
})
}
function cancelRefund(item) {
uni.showModal({
title: '提示',
content: '是否取消退款',
showCancel: true,
success(res) {
if (res.confirm) {
pointGoodsApi.cancelRefund({
orderNo: item.orderNo,
recordId: item.id
}).then(res => {
if (res) {
uni.showToast({
title: '取消退款成功',
icon: 'none'
})
} else {
uni.showToast({
title: '取消退款失败',
icon: 'none'
})
}
setTimeout(() => {
refresh()
}, 1000)
})
}
}
})
}
function lookCode(item) {
qrcode.value = item.couponCode
modalData.show = true;
}
const tabs = reactive({
list: [{
name: "全部订单",
value: "",
},
{
name: "待核销",
value: "unevaluated",
},
{
name: "已核销",
value: "evaluated",
},
{
name: "售后",
value: "after_sale",
},
],
sel: "",
});
const list = ref([]);
const query = reactive({
page: 1,
size: 10,
shopId: '',
});
const isEnd = ref(false);
watch(() => tabs.sel, (newval) => {
refresh()
})
function getList() {
const status = tabs.list.find(v => v.value == tabs.sel)
pointGoodsApi.recordPage({
...query,
}).then(res => {
const newList = res.records
if (query.page == 1) {
list.value = newList
} else {
list.value.push(...newList)
}
if (query.page >= res.totalPage * 1) {
isEnd.value = true
}
})
}
onLoad((opt) => {
query.shopId = opt.shopId || ''
getList()
})
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">
.top { .top {
background-color: #fff; background-color: #fff;
padding: 32rpx 28rpx; padding: 32rpx 28rpx;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
} }
.tab-item {
color: #999; .tab-item {
transition: all 0.3s ease-in-out; color: #999;
&.active { transition: all 0.3s ease-in-out;
color: #000;
font-size: 32rpx; &.active {
font-weight: 700; color: #000;
} font-size: 32rpx;
} font-weight: 700;
.copy { }
width: 28rpx; }
height: 28rpx;
} .copy {
</style> width: 28rpx;
height: 28rpx;
}
.safe-bottom {
padding-bottom: calc(env(safe-area-inset-bottom) + 2rpx);
}
</style>

View File

@@ -10,29 +10,30 @@
<view class="bg" :style="{ backgroundImage: `url(${imgs.bg})` }"> <view class="bg" :style="{ backgroundImage: `url(${imgs.bg})` }">
<image :src="imgs.success" class="success"></image> <image :src="imgs.success" class="success"></image>
<view class="u-font-40 font-700">兑换成功</view> <view class="u-font-40 font-700">兑换成功</view>
<view class="u-font-32 font-700">这里是商品名称</view> <view class="u-font-32 font-700">{{item.pointsGoodsName}}</view>
<view class="u-m-t-14">需前往店铺自行兑换领取</view> <view class="u-m-t-14" v-if="item.goodsCategory!='优惠券'">需前往店铺自行兑换领取</view>
<view class="u-m-t-14" v-else>优惠券直接到账您的账户中</view>
</view> </view>
<view class="info u-flex u-flex-col"> <view class="info u-flex u-flex-col">
<view class="u-p-22"> <view class="u-p-22">
<text class="color-666">兑换商品</text> <text class="color-666">兑换商品</text>
<text>这里是商品名称</text> <text>{{item.pointsGoodsName}}</text>
</view> </view>
<view class="u-p-22"> <view class="u-p-22">
<text class="color-666">兑换数量</text> <text class="color-666">兑换数量</text>
<text>1</text> <text>{{item.number}}</text>
</view> </view>
<view class="u-p-22"> <view class="u-p-22">
<text class="color-666">消耗积分</text> <text class="color-666">消耗积分</text>
<text>800</text> <text>{{item.spendPoints}}</text>
</view> </view>
<view class="u-p-22"> <view class="u-p-22">
<text class="color-666">下单时间</text> <text class="color-666">下单时间</text>
<text>2025-12-3 17:1932</text> <text>{{item.checkoutTime}}</text>
</view> </view>
<view class="u-p-22"> <view class="u-p-22">
<text class="color-666">订单号</text> <text class="color-666">订单号</text>
<text>DH202511300001</text> <text>{{item.orderNo}}</text>
</view> </view>
</view> </view>
<view class="u-flex bottom u-row-center"> <view class="u-flex bottom u-row-center">
@@ -44,6 +45,8 @@
</template> </template>
<script setup> <script setup>
const imgs = { const imgs = {
bg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/b625560a5b75418c9e643841f8674a0c.png", bg: "https://cashier-oss.oss-cn-beijing.aliyuncs.com/upload/2/b625560a5b75418c9e643841f8674a0c.png",
success: success:
@@ -53,8 +56,18 @@ function back() {
uni.navigateBack(); uni.navigateBack();
} }
function lookOrder() { function lookOrder() {
uni.redirectTo({
url:'/scoreShop/order/index?shopId='+item.shopId
})
} }
const item=reactive({
})
onLoad(opt=>{
const exchange_goods_success_data=uni.getStorageSync('exchange_goods_success')
Object.assign(item,exchange_goods_success_data)
})
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@@ -32,6 +32,7 @@ declare global {
const onLoad: typeof import('@dcloudio/uni-app')['onLoad'] const onLoad: typeof import('@dcloudio/uni-app')['onLoad']
const onMounted: typeof import('vue')['onMounted'] const onMounted: typeof import('vue')['onMounted']
const onPageScroll: typeof import('@dcloudio/uni-app')['onPageScroll'] const onPageScroll: typeof import('@dcloudio/uni-app')['onPageScroll']
const onReachBottom: typeof import('@dcloudio/uni-app')['onReachBottom']
const onReady: typeof import('@dcloudio/uni-app')['onReady'] const onReady: typeof import('@dcloudio/uni-app')['onReady']
const onRenderTracked: typeof import('vue')['onRenderTracked'] const onRenderTracked: typeof import('vue')['onRenderTracked']
const onRenderTriggered: typeof import('vue')['onRenderTriggered'] const onRenderTriggered: typeof import('vue')['onRenderTriggered']

View File

@@ -1,16 +1,58 @@
export const back=()=>{ export const back = () => {
console.log('调用返回方法back'); console.log('调用返回方法back');
try { try {
const arr= getCurrentPages() const arr = getCurrentPages()
if(arr.length>=2){ if (arr.length >= 2) {
return uni.navigateBack() return uni.navigateBack()
}else{ } else {
uni.reLaunch({ uni.reLaunch({
url:'/pages/index/index' url: '/pages/index/index'
}) })
} }
} catch (error) { } catch (error) {
console.error('页面返回出错',error) console.error('页面返回出错', error)
//TODO handle the exception //TODO handle the exception
} }
}
import {
APIuserlogin,
APIuser
} from "@/common/api/api.js";
export const getOpenId = () => {
// #ifdef MP-WEIXIN
return new Promise((resolve, reject) => {
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",
});
if (res) {
resolve(res.userInfo
.wechatOpenId);
} else {
reject(false);
}
},
fail: (err) => {
reject(false);
},
});
},
});
})
// #endif
// #ifdef MP-ALIPAY
// #endif
} }

View File

@@ -17,6 +17,7 @@ module.exports = defineConfig({
"onHide", "onHide",
"onUnload", "onUnload",
"onReady", "onReady",
"onReachBottom",
"onPageScroll", "onPageScroll",
"uni.request", "uni.request",
"uni.navigateTo", "uni.navigateTo",