Compare commits

...

13 Commits

Author SHA1 Message Date
赵毅
4169e76f53 修改配送地址删除不了的问题 2025-10-08 17:30:45 +08:00
赵毅
b191357f4c 修复好店 是否开启线下快捷买单配置 的逻辑问题 2025-10-08 17:30:01 +08:00
赵毅
924c3bb2fb 修复修改配送地址报错的bug 2025-10-08 17:18:56 +08:00
赵毅
60cf499f38 易购商品改为配送 2025-10-08 17:04:12 +08:00
赵毅
13a271d806 修改活动商品的点击触发逻辑 2025-10-08 16:53:58 +08:00
赵毅
a5d5e3557a 11 2025-10-08 16:32:09 +08:00
赵毅
1d7fbd9f5b 编写首页的搜索商品页面 2025-10-08 16:30:39 +08:00
赵毅
6738f0e5c9 11 2025-10-08 15:15:02 +08:00
赵毅
afd6b44644 修改快捷买单按钮显示异常问题 2025-10-08 14:59:19 +08:00
赵毅
b8a0a13ad3 修改活动商品价格显示不对的问题 2025-10-08 14:56:12 +08:00
赵毅
12f43b2dff 实现店铺管理的选择店铺的功能 2025-10-08 10:28:32 +08:00
赵毅
6f655bed0b 对接个人中心物业费和积分的接口 2025-10-08 10:14:37 +08:00
赵毅
631ef8154e 优化根据登录环境判断请求接口的逻辑 2025-10-08 08:28:08 +08:00
20 changed files with 1410 additions and 240 deletions

View File

@ -54,4 +54,7 @@ export const apiArr = {
checkComm: "/api/v2/wechat/community/check-comm", //检查小区是否属于当前用户
delPay: "/api/v2/wechat/community-order-pay/del", //检查小区是否属于当前用户
getShopList: "/api/v2/wechat/merchant-crud-list/by-user", //根据用户获取商家列表
};

View File

@ -12,6 +12,7 @@ export const apiArr = {
payOrder: "/api/v2/wechat/commodity/order/pay",//支付订单
settingDefaultAddress: '/api/v2/wechat/commodity/receiving_address/default', // 收货地址设置默认
updateAddress: '/api/v2/wechat/commodity/receiving_address/update', // 收货地址修改
deleteAddress: '/api/v2/wechat/commodity/receiving_address/delete', // 收货地址删除
addAddress: '/api/v2/wechat/commodity/receiving_address/add', // 收货地址添加
addAddressList: '/api/v2/wechat/commodity/receiving_address', // 收货地址列表
queryOrder: '/api/v2/wechat/commodity/order/trade_query', // 查询订单

View File

@ -1,4 +1,6 @@
export const apiArr = {
getUserInfo: '/api/v2/wechat/mpuser-crud/info', // 获取城市列表
userInfoUpdate: '/api/v2/wechat/mpuser-crud/update', // 会员信息更新
getAccumulationFund: '/api/v2/wechat/government-housing-fund-flow-crud/page', // 物业费公积金
getPoints: '/api/v2/wechat/member-points-flow-crud/page', // 积分
}

View File

@ -1,5 +1,5 @@
<template>
<view class="container" @click="headerEnterClick" :data-id="item.community_id":data-name="item.name" >
<view class="container" @click="headerEnterClick" :data-id="item.community_id" :data-name="item.name" >
<image class="left_logo" :src="item.pic" mode="aspectFill" />
<view :class="['right', isLast && 'no_bottom']">
<view class="header">

View File

@ -298,6 +298,7 @@ export default {
boxshadow2: false,
id: "",
groupById: "",
promotional_price: "", //
info: "",
currentIndex: "1", //
@ -579,6 +580,8 @@ export default {
// 使itemObj
this.currentGG = this.info.commodity_goods_info_list[this.currentGGIndex];
// promotional_pricesales_price
this.currentGG.sales_price = this.promotional_price;
//
this.changeImg = this.currentGG.commodity_pic[0];
@ -611,6 +614,8 @@ export default {
//
changeGG(item, index) {
this.currentGG = item;
// promotional_pricesales_price
this.currentGG.sales_price = this.promotional_price;
this.currentGGIndex = index;
if (this.currentGG.cart_count) {
this.currentNum = this.currentGG.cart_count.count;
@ -619,7 +624,7 @@ export default {
}
this.changeImg = item.commodity_pic[0]
this.changeName = item.goods_alias
this.changePrice = item.sales_price
this.changePrice = this.currentGG.sales_price
},
car() {
const item = {
@ -662,6 +667,7 @@ export default {
goods_id:
this.info.commodity_goods_info_list[this.currentGGIndex].id,
count: countVal,
price: this.changePrice
},
],
group_buy_id: this.info.commodity_goods_info_list[this.currentGGIndex].group_buy_activity_id,
@ -774,6 +780,7 @@ export default {
this.localHeight = meun.height;
this.id = this.itemObj.commodity_id ? this.itemObj.commodity_id : this.itemObj.id;
this.groupById = this.itemObj.groupById
this.promotional_price = this.itemObj.promotional_price
this.getBuyRecord()
this.getEndTheCountdown(this.endTime)

View File

@ -163,7 +163,7 @@
</view>
</view>
<view v-else>
{{ '¥' + item.commodity_goods_info.sales_price }}
{{ '¥' + item.price }}
/{{ item.commodity_goods_info.goods_unit }}
</view>
</view>
@ -553,16 +553,17 @@ export default {
} else {
let total = 0;
this.orderList2.forEach(goods => {
//
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
if (currentTime >= startTime && currentTime <= endTime) {
// total += goods.commodity_goods_info.group_buy_price * goods.count + goods.commodity_goods_info.freight;
total += goods.commodity_goods_info.group_buy_price * goods.count;
} else {
// total += goods.commodity_goods_info.sales_price * goods.count + goods.commodity_goods_info.freight;
total += goods.commodity_goods_info.sales_price * goods.count;
}
// //
// const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
// const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
// if (currentTime >= startTime && currentTime <= endTime) {
// // total += goods.commodity_goods_info.group_buy_price * goods.count + goods.commodity_goods_info.freight;
// total += goods.commodity_goods_info.group_buy_price * goods.count;
// } else {
// // total += goods.commodity_goods_info.sales_price * goods.count + goods.commodity_goods_info.freight;
// total += goods.commodity_goods_info.sales_price * goods.count;
// }
total += goods.price * goods.count;
});
//
return total.toFixed(2);

View File

@ -172,6 +172,7 @@ export default {
{
goods_id: item.goods_id,
count: item.quantity,
price: item.promotional_price,
},
],
adver_id: item.adver_id
@ -195,6 +196,7 @@ export default {
{
goods_id: item.goods_id,
count: item.quantity,
price: item.promotional_price,
},
],
adver_id: item.adver_id

View File

@ -70,7 +70,7 @@
</view>
<view class="goodsItem_msg_right_msg">
<view class="goodsItem_msg_right_msg_left">
<span></span>{{ getPrice(item) }}
<span></span>{{ item.price }}
<!-- {{ item.commodity_goods_info.group_buy_price ?
item.commodity_goods_info.group_buy_price :
item.commodity_goods_info.sales_price }} -->
@ -154,7 +154,7 @@
</view>
<view class="goodsItem_msg_right_msg">
<view class="goodsItem_msg_right_msg_left">
<span></span>{{ getPrice(item) }}
<span></span>{{ item.price }}
<!-- {{ item.commodity_goods_info.group_buy_price ?
item.commodity_goods_info.group_buy_price :
item.commodity_goods_info.sales_price }} -->
@ -491,14 +491,15 @@ export default {
this.isDayCarList.forEach(carItem => {
carItem.commodity_cart_and_goods_model.forEach(goods => {
if (goods.checked) {
//
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
if (currentTime >= startTime && currentTime <= endTime) {
total += goods.commodity_goods_info.group_buy_price * goods.count;
} else {
total += goods.commodity_goods_info.sales_price * goods.count;
}
// //
// const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
// const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
// if (currentTime >= startTime && currentTime <= endTime) {
// total += goods.commodity_goods_info.group_buy_price * goods.count;
// } else {
// total += goods.commodity_goods_info.sales_price * goods.count;
// }
total += goods.price * goods.count
}
});
});
@ -507,14 +508,15 @@ export default {
this.shopCarList.forEach(carItem => {
carItem.commodity_cart_and_goods_model.forEach(goods => {
if (goods.checked) {
//
const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
if (currentTime >= startTime && currentTime <= endTime) {
total += goods.commodity_goods_info.group_buy_price * goods.count;
} else {
total += goods.commodity_goods_info.sales_price * goods.count;
}
// //
// const startTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.start_time).getTime();
// const endTime = new Date(goods.commodity_goods_info.group_buy_activity_info?.end_time).getTime();
// if (currentTime >= startTime && currentTime <= endTime) {
// total += goods.commodity_goods_info.group_buy_price * goods.count;
// } else {
// total += goods.commodity_goods_info.sales_price * goods.count;
// }
total += goods.price * goods.count
}
});
});
@ -718,6 +720,7 @@ export default {
goods_id_and_count: [{
goods_id: item.goods_id,
count: val,
price: item.price,
},],
};
request(apiArr.updateCar, "POST", params).then((res) => {

View File

@ -29,7 +29,8 @@
</view>
<view class="table">
<view class="label">营业地址</view>
<view class="desc" v-if="info.ad">{{ info.ad.ad_name ? info.ad.ad_name.replace(/,/g, "") : "" }}{{ info.address }}</view>
<view class="desc" v-if="info.ad">{{ info.ad.ad_name ? info.ad.ad_name.replace(/,/g, "") : "" }}{{
info.address }}</view>
</view>
<view class="table mb32">
<view class="label">特色服务</view>
@ -109,10 +110,8 @@
mode="" />
<view>点评</view>
</view>
<view class="left_label" @click="handleKfClick">
<image
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/kefu0.png"
mode="" />
<view class="left_label" @click="handleKfClick">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/kefu0.png" mode="" />
<view>客服</view>
</view>
</view>
@ -149,19 +148,19 @@ export default {
request(apiArr.getMerchantInfo, "POST", params).then(res => {
this.info = res
uni.setStorageSync('merchantInfo', res)
// onLoad
this.page_num = 1
this.flag = false
this.commentList = []
this.getCommentList()
this.getMerchantInfo()
})
},
onShow() {
if(this.info.id){
if (this.info.id) {
this.getCommentList()
}
this.getMerchantInfo()
},
onReachBottom() {
if (this.flag) {
@ -187,13 +186,12 @@ export default {
} else {
this.flag = false;
}
this.isShow = res.rows[0]?.merchant_info.quick_purchase_enabled == 1
const list = res.rows.filter((item) => {
return item.status == 2;
});
list.forEach(item => {
if(item.merchant_evaluation_reply_list){
if (item.merchant_evaluation_reply_list) {
item.merchant_evaluation_reply_list = item.merchant_evaluation_reply_list.filter((item) => {
return item.status == 2;
})

View File

@ -222,10 +222,9 @@ export default {
})
return
}
console.log("🚀 ~ headerSubmitClick ~ type:", this.type)
if(this.type === 'edit') {
const res = await request(apiArr2.updateAddress, "POST", {
user_id: this.id,
id: this.id,
name: this.name,
phone: this.phone,
address: this.tab === 0 ? this.orientation.region + this.orientation.district : `${confirmProv1.short_name}${xsq.short_name ? xsq.short_name : confirmCity.short_name}${confirmDist.short_name}`,

View File

@ -89,7 +89,7 @@ export default {
success: async function (res) {
if (res.confirm) {
console.log('用户点击确定');
const res = await request(apiArr.addressDel, 'POST', { id });
const res = await request(apiArr.deleteAddress, 'POST', { id });
uni.showToast({
title: '删除成功',
icon: 'success',

View File

@ -0,0 +1,608 @@
page {
background-color: #f5f7fb;
}
.container {
padding: 0;
margin: 0;
font-size: 28rpx;
color: #333;
}
/* 顶部切换栏 */
.tab-bar {
display: flex;
background-color: #fff;
padding: 20rpx 0;
}
.tab-item {
width: 180rpx;
height: 70rpx;
line-height: 70rpx;
text-align: center;
border-radius: 15rpx;
margin: 0 20rpx;
font-size: 28rpx;
border: 1rpx solid #ddd;
}
.tab-item.active {
background-color: #ff370b;
color: #fff;
}
/* 分隔线 */
.divider {
height: 20rpx;
background-color: #f5f5f5;
}
/* 公共标题样式 */
.section-title {
font-size: 32rpx;
color: #333;
font-weight: bold;
padding: 20rpx 30rpx;
}
/* 收货地址区域 */
.info-section {
background: repeating-linear-gradient(to right,
#fe5355,
#fe5355 20px,
#549aff 20px,
#549aff 40px);
padding: 10rpx 0;
}
.address-section {
background-color: #fff;
}
.address-info {
padding: 30rpx;
display: flex;
justify-content: space-between;
align-items: flex-start;
border-bottom: 1rpx solid #eee;
}
.address-main {
flex: 1;
}
.address-name-phone {
display: flex;
align-items: center;
margin-bottom: 10rpx;
}
.name {
font-size: 32rpx;
margin-right: 20rpx;
}
.phone {
font-size: 30rpx;
color: #666;
}
.address-detail {
font-size: 28rpx;
color: #666;
line-height: 40rpx;
display: flex;
align-items: center;
}
.address-arrow {
color: #333;
}
.addNewAddress {
font-size: 32rpx;
color: #999999;
float: right;
}
/* 商品信息区域 */
.goods-section {
background-color: #fff;
margin-bottom: 20rpx;
}
.goods-item {
border-radius: 10rpx;
padding: 15rpx;
display: flex;
background-color: #fff;
}
.goods-image {
width: 140rpx;
height: 140rpx;
border-radius: 15rpx;
overflow: hidden;
margin-right: 15rpx;
}
.goods-image image {
width: 100%;
height: 100%;
object-fit: cover;
}
.goods-info {
flex: 1;
display: flex;
flex-direction: column;
justify-content: space-between;
position: relative;
}
.goods-name {
font-size: 28rpx;
font-weight: bold;
margin-bottom: 8rpx;
display: -webkit-box;
-webkit-line-clamp: 2;
-webkit-box-orient: vertical;
overflow: hidden;
}
.goods-desc {
font-size: 22rpx;
color: #666;
margin-bottom: 10rpx;
}
.price-container {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 10rpx;
}
.group-price {
font-size: 28rpx;
color: #e63946;
margin-right: 10rpx;
border-radius: 4rpx;
/* display: flex; */
}
.group-price-box {
display: flex;
}
.group-price1 {
width: 100rpx;
padding: 10rpx 15rpx;
color: #ffffff;
background-color: #fc5d15;
border-radius: 15rpx 0 0 15rpx;
}
.group-price2 {
width: auto;
padding: 10rpx 15rpx;
background: linear-gradient(to bottom, #fef6d6, #fee8a9);
border-radius: 0 15rpx 15rpx 0;
}
.original-price {
font-size: 26rpx;
color: #999;
}
.countdown {
width: 250rpx;
font-size: 22rpx;
padding: 10rpx 15rpx;
color: #ffffff;
margin-bottom: 15rpx;
border-radius: 50rpx;
background-color: #fe2f01;
position: absolute;
top: 150rpx;
right: 0;
}
.quantity-control {
display: flex;
align-items: center;
justify-content: flex-end;
}
.decrease-btn {
width: 40rpx;
height: 40rpx;
background-color: #f5f5f5;
border: 1rpx solid #ccc;
border-radius: 50%;
line-height: 33rpx;
text-align: center;
font-size: 28rpx;
color: #333;
}
.increase-btn {
width: 40rpx;
height: 40rpx;
background-color: #ff502a;
border-radius: 50%;
line-height: 33rpx;
text-align: center;
font-size: 28rpx;
color: #ffffff;
}
.quantity {
margin: 0 15rpx;
font-size: 24rpx;
width: 40rpx;
text-align: center;
}
/* 运费和总金额区域 */
.fee-section,
.total-section {
background-color: #fff;
padding: 30rpx;
display: flex;
justify-content: space-between;
border-bottom: 1rpx solid #eee;
}
.fee-name,
.total-name {
font-size: 30rpx;
}
.fee-value,
.total-value {
font-size: 30rpx;
color: #333;
}
.total-value {
font-weight: bold;
color: #FF7658;
}
/* 复制 */
.copy-icon {
width: 30rpx;
height: 30rpx;
background-image: url('https://wechat-img-file.oss-cn-beijing.aliyuncs.com/myOrder/copy.png');
background-size: cover;
margin-left: 10rpx;
}
/* 支付方式区域 */
.payment-section {
background-color: #fff;
margin-bottom: 20rpx;
margin-top: 15rpx;
}
.payment-item {
padding: 30rpx;
display: flex;
justify-content: space-between;
align-items: center;
border-bottom: 1rpx solid #eee;
}
.payment-icon {
width: 60rpx;
height: 60rpx;
margin-right: 20rpx;
}
.payment-icon image {
width: 100%;
height: 100%;
}
.payment-content {
flex: 1;
}
.payment-name {
font-size: 32rpx;
margin-bottom: 5rpx;
}
.payment-desc {
font-size: 26rpx;
color: #333;
}
.payment-select {
color: #FF7658;
}
/* 立即支付按钮 */
.pay-button {
height: 100rpx;
line-height: 100rpx;
text-align: center;
background: linear-gradient(91deg, #FF7658 0%, #FF370B 100%);
color: #fff;
font-size: 36rpx;
font-weight: bold;
border-radius: 50rpx;
position: fixed;
bottom: 50rpx;
left: 15%;
width: 70%;
/* z-index: 99; */
}
/* 自提样式 */
.pickup-info {
padding: 30rpx;
background-color: #fff;
}
.pickup-address {
font-size: 30rpx;
margin-bottom: 10rpx;
}
.pickup-time {
font-size: 28rpx;
color: #999;
}
/* 弹窗 */
.shadow {
background: rgba(0, 0, 0, 0.4);
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: 9;
}
.shadowBox2 {
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
width: auto;
height: auto;
}
.shadowBox_img {
width: 600rpx;
height: 800rpx;
background-color: #fff;
border-radius: 20rpx;
position: relative;
}
.boxshadow_tit {
font-size: 32rpx;
color: #222222;
padding-top: 40rpx;
display: flex;
justify-content: center;
align-items: center;
}
.boxshadow_tit_img {
width: 70rpx;
height: 70rpx;
margin-right: 10rpx;
}
.boxshadow_img {
/* width: 300rpx;
height: 300rpx; */
margin: 0 auto;
margin-top: 40rpx;
text-align: center;
}
.wealBoxTit {
display: flex;
align-items: flex-end;
margin-top: 30rpx;
margin-left: 20rpx;
}
.wealBoxTit1 {
color: #fe1535;
font-size: 32rpx;
font-weight: bold;
}
.wealBoxTit2 {
color: #fe1535;
font-size: 26rpx;
margin-left: 15rpx;
}
.wealBox {
width: 93%;
height: 170rpx;
margin: 15rpx auto;
display: flex;
}
.wealBoxItem {
width: 150rpx;
height: 150rpx;
margin: 0 10rpx;
border-radius: 15rpx;
padding: 20rpx 10rpx;
text-align: center;
display: flex;
/* 添加 flex 布局 */
flex-direction: column;
/* 设置主轴为垂直方向 */
justify-content: space-between;
/* 垂直方向上平均分布 */
align-items: center;
/* 水平方向居中 */
}
.wealBoxItem1 {
background-color: #fff4f1;
}
.wealBoxItem2 {
background-color: #fff7f1;
}
.wealBoxItem3 {
background-color: #fffaf0;
}
.wealBoxItemTop {
display: flex;
align-items: center;
justify-content: center;
}
.wealBoxItemTop image {
width: 40rpx;
height: 40rpx;
margin-right: 10rpx;
}
.wealBoxItemBottom {
font-size: 26rpx;
color: #999999;
}
.bottom {
width: 100%;
position: absolute;
bottom: 30rpx;
}
.boxbottom1 {
margin: 0 auto;
}
.boxbottom {
width: 100%;
margin-bottom: 50rpx;
display: flex;
justify-content: center;
align-items: center;
}
.line1 {
width: 80rpx;
height: 1rpx;
margin: 0 10rpx;
background: linear-gradient(to left, #333, #fff);
}
.line2 {
width: 80rpx;
height: 1rpx;
margin: 0 10rpx;
background: linear-gradient(to right, #333, #fff);
}
.shadowBox1 {
width: 100%;
display: flex;
margin-bottom: 30rpx;
}
.shadowBox1Item_btn {
width: 110rpx;
height: 150rpx;
border: 1rpx solid red;
position: absolute;
left: 100rpx;
opacity: 0;
}
.shadowBox2Item_btn {
width: 110rpx;
height: 150rpx;
border: 1rpx solid red;
position: absolute;
right: 100rpx;
opacity: 0;
}
.shadowBox1Item {
flex: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
font-size: 26rpx;
color: #000000;
}
.shadowBox1Item image {
width: 100rpx;
height: 100rpx;
margin-bottom: 26rpx;
}
.shadowBoxInfo {
display: flex;
align-items: center;
margin-left: 62rpx;
margin-top: 11rpx;
}
.shadowboxInfo_left {
width: 130rpx;
height: 130rpx;
background: #EFEFEF;
border-radius: 50%;
overflow: hidden;
display: flex;
align-items: center;
justify-content: center;
margin-right: 36rpx;
}
.shadowboxInfo_right_1 {
font-size: 32rpx;
color: #222222;
margin-bottom: 10rpx;
}
.shadowboxInfo_right_2 {
font-size: 26rpx;
color: #999999;
}
.shadowBox_btn {
font-size: 36rpx;
color: #FFFFFF;
width: 600rpx;
height: 90rpx;
background: linear-gradient(91deg, #FF7658 0%, #FF370B 100%);
border-radius: 100rpx 100rpx 100rpx 100rpx;
display: flex;
align-items: center;
justify-content: center;
margin-top: 60rpx;
}
.empty-tip {
height: 200rpx;
font-size: 28rpx;
color: #999999;
text-align: center;
line-height: 200rpx;
background-color: #fff;
}

View File

@ -0,0 +1,469 @@
<template>
<view class="container">
<!-- 顶部切换栏 -->
<view class="tab-bar">
<view :class="{ active: activeTab === 'delivery' }" class="tab-item" @click="switchTab('delivery')">配送
</view>
</view>
<!-- 分隔线 -->
<view class="divider"></view>
<!-- 配送信息 -->
<view class="info-section" v-if="activeTab === 'delivery'">
<view class="address-section">
<view class="section-title">
收货地址
<view v-if="!defAddress" class="addNewAddress" @click="chooseAddress">添加新地址 &gt;</view>
</view>
<view class="address-info" @click="chooseAddress" v-if="defAddress">
<view class="address-main">
<view class="address-name-phone">
<text class="name">{{ defAddress.name }}</text>
<text class="phone">{{ defAddress.phone }}</text>
</view>
<view class="address-detail">
{{ defAddress.address }}{{ defAddress.house_number }}
<view class="copy-icon" @click.stop="copyAddress" />
</view>
</view>
<view class="address-arrow"><u-icon name="arrow-right" size="25"></u-icon></view>
</view>
</view>
</view>
<!-- 分隔线 -->
<view class="divider"></view>
<!-- 商品信息 -->
<view v-if="activeTab === 'delivery' && orderList.length > 0">
<view class="goods-list">
<view class="goods-item" v-for="(item, index) in orderList" :key="index">
<view class="goods-image">
<image :src="item.commodity_goods_info.commodity_pic" mode="aspectFill"></image>
</view>
<view class="goods-info">
<view class="goods-name">{{ item.commodity_goods_info.goods_name }}</view>
<view class="goods-desc">{{ item.commodity_goods_info.goods_spec }}</view>
<view class="price-container">
<view class="group-price">
<view>{{ item.commodity_goods_info.sales_price }}/{{
item.commodity_goods_info.goods_unit
}}</view>
<!-- 运费 -->
<view class="goods-desc" style="margin-top: 10rpx;">运费 {{
item.commodity_goods_info.freight ? item.commodity_goods_info.freight : 0
}}</view>
</view>
<view class="quantity-control">
<view class="decrease-btn" @tap.stop="decreaseQuantity(item)">-</view>
<view class="quantity">{{ item.count }}</view>
<view class="increase-btn" @tap.stop="increaseQuantity(item)">+</view>
</view>
</view>
</view>
</view>
</view>
<!-- 总金额 -->
<view class="total-section">
<view class="total-name">总金额</view>
<view class="total-value">{{ calculateTotal() }}</view>
</view>
<!-- 支付方式 -->
<view class="payment-section">
<view class="payment-item" @click="selectPayment('wechat')">
<view class="payment-icon">
<image
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_wechat.png"
mode="aspectFit"></image>
</view>
<view class="payment-content">
<view class="payment-name">微信支付</view>
<view class="payment-desc"><text
style="color: #f03d0e;margin-right: 15rpx;">可用优惠券</text>单笔支付限额:¥10000.00</view>
</view>
<view class="payment-select" v-if="selectedPayment === 'wechat'">
<image
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check2.png"
mode="aspectFit" style="width: 40rpx; height: 40rpx;"></image>
</view>
<view class="payment-select" v-else>
<image
src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/com_check1.png"
mode="aspectFit" style="width: 40rpx; height: 40rpx;"></image>
</view>
</view>
</view>
</view>
<view v-if="activeTab === 'delivery' && orderList.length == 0" class="empty-tip">
暂无商品数据
</view>
<!-- 立即支付按钮 -->
<view class="pay-button" @click="submitPayment">立即支付</view>
<!-- 弹窗 - 支付成功 -->
<view class="shadow" @click="changeShadow" v-if="boxshadow1">
<view class="shadowBox2">
<view class="shadowBox_img">
<view class="boxshadow_tit">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/af_√.png"
class="boxshadow_tit_img">
</image>
已支付成功
</view>
<view class="boxshadow_img">
<view v-if="verifyCode">核销码{{ verifyCode }}</view>
</view>
<view>
<view class="wealBoxTit">
<view class="wealBoxTit1">下单福利</view>
<view class="wealBoxTit2">已获得</view>
</view>
<view class="wealBox">
<view class="wealBoxItem wealBoxItem1">
<view class="wealBoxItemTop">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_fen.png"
mode="aspectFit">
</image>
<view>石榴分</view>
</view>
<view>
{{ slFen }}
</view>
<view class="wealBoxItemBottom">
可抵扣 {{ slFen }}
</view>
</view>
<view class="wealBoxItem wealBoxItem2">
<view class="wealBoxItemTop">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_zi.png"
mode="aspectFit">
</image>
<view>石榴籽</view>
</view>
<view>
{{ slZi }}
</view>
<view class="wealBoxItemBottom">
可抵扣 {{ slZi }}
</view>
</view>
<view class="wealBoxItem wealBoxItem3">
<view class="wealBoxItemTop">
<image src="https://wechat-img-file.oss-cn-beijing.aliyuncs.com/activity_jin.png"
mode="aspectFit" />
<view>石榴金</view>
</view>
<view>
{{ slJin }}
</view>
<view class="wealBoxItemBottom">
可抵扣 {{ slJin }}
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { picUrl, menuButtonInfo, request, NavgateTo } from "../../../utils";
import { apiArr } from "../../../api/shop";
export default {
data() {
return {
activeTab: 'delivery', //
quantity: 1, //
selectedPayment: 'wechat',
boxshadow1: false,
boxshadow2: false,
defAddress: {},
orderList: [],
carList: [],
slJin: 0,
slFen: 0,
slZi: 0,
//
verifyCode: '',
};
},
onLoad(options) {
this.carList = JSON.parse(options.shopCarList)
},
onShow() {
this.getUserAddress()
this.getGoodsList()
},
onUnload() {
uni.removeStorageSync('changeZTAddress')
},
methods: {
switchTab(tab) {
this.activeTab = tab;
},
//
getUserAddress() {
request(apiArr.getUserDefAddress, "POST", {}).then(res => {
this.defAddress = res.default_address
})
},
//
getGoodsList() {
this.orderList = []
this.carList.forEach(item => {
// URLhttpspicUrl
if (item.commodity_goods_info.commodity_pic && item.commodity_goods_info.commodity_pic.indexOf('https') !== 0) {
item.commodity_goods_info.commodity_pic = picUrl + item.commodity_goods_info.commodity_pic
}
this.orderList.push(item)
})
},
chooseAddress() {
NavgateTo('/packages/shop/address/index')
},
decreaseQuantity(item) {
if (item.count > 0) {
item.count--
// 0carList
if (item.count === 0) {
const index = this.carList.findIndex(carItem => carItem.goods_id === item.goods_id);
if (index > -1) {
this.carList.splice(index, 1);
//
this.getGoodsList();
}
}
this.changeCart(item)
}
},
increaseQuantity(item) {
if (item.count >= item.commodity_goods_info.stock_quantity) {
uni.showToast({
title: '库存不足',
icon: 'none'
});
return
}
item.count++;
this.changeCart(item);
},
//
changeCart(item) {
const params = {
goods_id_and_count: [
{
goods_id: item.goods_id,
count: item.count,
},
],
}
request(apiArr.updateCar, "POST", params).then(res => {
uni.showToast({
title: "操作成功!",
success() { },
});
})
},
//
calculateTotal() {
let total = 0;
this.orderList.forEach(goods => {
total += goods.commodity_goods_info.sales_price * goods.count + (goods.commodity_goods_info.freight || 0);
});
return total.toFixed(2);
},
selectPayment(payment) {
this.selectedPayment = payment;
},
submitPayment() {
//
if (!this.defAddress || Object.keys(this.defAddress).length === 0) {
uni.showToast({
title: '请选择收货地址',
icon: 'none'
});
return;
}
// isafterSaletrue
const hasAfterSaleItem = this.carList.some(item => item.isafterSale === true);
const orderIdFromAfterSale = hasAfterSaleItem ? this.carList.find(item => item.isafterSale === true)?.orderId : null;
// trans_type
// : 71, App: 51
const systemInfo = uni.getSystemInfoSync();
let trans_type = 51; // App
//
if (systemInfo.platform === 'devtools' || systemInfo.platform === 'unknown') {
trans_type = 71; //
}
//
// #ifdef MP
trans_type = 71; //
// #endif
// #ifdef APP-PLUS
trans_type = 51; // App
// #endif
// isafterSaletruecreateOrder
if (hasAfterSaleItem && orderIdFromAfterSale) {
const param = {
order_id: orderIdFromAfterSale,
user_id: uni.getStorageSync('userId'),
trans_type: trans_type
}
request(apiArr.mergePreorder, "POST", param).then(res => {
this.handleMergePreorderResponse(res, orderIdFromAfterSale);
})
} else {
//
const params = {
user_id: uni.getStorageSync('userId'),
// shopCarListisAdvertrue
order_cate: this.carList.some(item => item.isAdver === true) ? 3 : 1,
goods_list: [{
supplier_id: this.orderList[0].supplier_id,
supplier_name: this.orderList[0].supplier_name || '',
is_same_day: this.orderList[0].commodity_goods_info.is_same_day,
receiving_name: this.defAddress.name,
receiving_phone: this.defAddress.phone,
receiving_address: this.defAddress.address + this.defAddress.house_number,
merchant_id: this.defAddress.address_id,
goods_and_count: this.orderList.map(item => ({
goods_id: item.goods_id,
count: item.count,
price: item.commodity_goods_info.sales_price,
freight: item.commodity_goods_info.freight,
}))
}]
}
request(apiArr.createOrder, "POST", params).then(resVal => {
const param = {
order_id: resVal.order_id,
user_id: uni.getStorageSync('userId'),
trans_type: trans_type
}
request(apiArr.mergePreorder, "POST", param).then(res => {
this.handleMergePreorderResponse(res, resVal.order_id);
})
})
}
},
// mergePreorder
handleMergePreorderResponse(res, orderId) {
if (res && res.timeStamp && res.nonceStr && res.package && res.signType && res.paySign) {
//
uni.requestPayment({
timeStamp: res.timeStamp,
nonceStr: res.nonceStr,
package: res.package,
signType: res.signType,
paySign: res.paySign,
success: (payRes) => {
const params = {
order_id: orderId,
from: this.carList.some(item => item.isAdver === true) ? 3 : 1,
adver_id: this.carList.some(item => item.isAdver === true) ? this.carList.find(item => item.isAdver === true).adver_id : ''
}
request(apiArr.queryOrder, "POST", params).then(res => {
this.verifyCode = res.verification_code
this.slJin = res.shiliu_money
this.boxshadow1 = true
})
},
fail: (payErr) => {
uni.showToast({
title: payErr.errMsg == 'requestPayment:fail cancel' ? '已取消支付' : '支付失败',
icon: 'none'
})
const params = {
order_ids: orderId,
}
request(apiArr.cancelPay, "POST", params).then(res => {
})
},
complete: () => {
//
}
})
} else {
console.error("获取支付参数失败,缺少必要参数")
uni.showToast({
title: '获取支付信息失败',
icon: 'none'
})
}
},
//
copyAddress() {
// 使uni-appAPI
uni.setClipboardData({
data: this.defAddress.address + this.defAddress.house_number,
success: () => {
uni.showToast({
title: '复制成功',
icon: 'success'
});
},
fail: () => {
uni.showToast({
title: '复制失败',
icon: 'none'
});
}
});
},
openSave() {
this.boxshadow1 = false;
this.boxshadow2 = true;
},
changeShadow() {
this.boxshadow1 = false;
},
changeShadow2() {
this.boxshadow2 = false;
},
//
saveImg() {
this.boxshadow2 = false;
//
uni.downloadFile({
url: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/shop_share_img.png",
success: (res) => {
if (res.statusCode === 200) {
uni.saveImageToPhotosAlbum({
filePath: res.tempFilePath,
success: (res) => {
uni.showToast({
title: "保存成功",
icon: "success",
duration: 2000,
});
},
fail: (err) => {
console.log("保存失败", err);
},
});
}
},
fail: (err) => {
console.log("下载失败", err);
},
});
},
}
};
</script>
<style>
@import url('./index.css');
</style>

View File

@ -307,7 +307,7 @@ export default {
if(this.is_group_buy){
NavgateTo(`../groupPurchaseSubmit/index?shopCarList=${JSON.stringify(updatedArr)}`);
}else{
NavgateTo(`/packages/advertising/goodsSubmit/index?shopCarList=${JSON.stringify(updatedArr)}`);
NavgateTo(`../goodsSubmit/index?shopCarList=${JSON.stringify(updatedArr)}`);
}
},

View File

@ -8,15 +8,15 @@
<view class="community">
<view class="community_left">
<image mode="aspectFill" src="../../../static/logo.png" alt="" />
<image mode="aspectFill" :src="selectedShop.album_images" alt="" />
</view>
<view class="community_right" @click="changeShow">
<view class="community_right_text">
<view class="community_right_text1">七个2锁城</view>
<view class="community_right_text2">衡水市上海公馆6A</view>
<view class="community_right_text1">{{ selectedShop.merchant_name }}</view>
<view class="community_right_text2">{{ selectedShop.address }}</view>
</view>
<view class="community_right_more">
<u-icon bold color="#999999" size="30" name="arrow-right" @click="back"></u-icon>
<u-icon bold color="#999999" size="30" name="arrow-right"></u-icon>
</view>
</view>
</view>
@ -62,20 +62,20 @@
</view>
<view class="lines"></view>
<view class="communityList">
<view class="boxshadowCon_Text2">您有n个店铺的管理权限</view>
<view class="boxshadowCon_Text2">您有{{ shopList.length }}个店铺的管理权限</view>
<view style="width: 100%;height: 200rpx;">
<view class="communityItem" v-for="(item, index) in 8" :key="index">
<view class="communityItem" v-for="(item, index) in shopList" :key="index">
<view class="community_left">
<image mode="aspectFill" src="../../../static/logo.png" alt="" />
<image mode="aspectFill" :src="item.album_images" alt="" />
</view>
<view class="community_right" @click="changeShow2">
<view class="community_right" @click="changeShow2(item)">
<view class="community_right_text">
<view class="community_right_text1">七个2锁城</view>
<view class="community_right_text2">衡水市上海公馆6A</view>
<view class="community_right_text1">{{ item.merchant_name }}</view>
<view class="community_right_text2">{{ item.address }}</view>
</view>
</view>
<view class="communityItem_radio">
<radio></radio>
<view class="communityItem_radio" @click="changeShow2(item)">
<radio :checked="selectedShop.merchant_name === item.merchant_name"></radio>
</view>
</view>
</view>
@ -108,6 +108,8 @@ export default {
active: 1,
show: false,
show2: false,
shopList: [],
selectedShop: {},
baseList: [
{
image: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com/property-img-file/page_user_Group_1568.png",
@ -130,10 +132,23 @@ export default {
this.top = meun.top;
// this.top = meun.height + meun.top;
this.localHeight = meun.height;
this.getShopList();
},
methods: {
//
getShopList() {
request(apiArr.getShopList, 'POST', {}, { silent: false }).then(res => {
res.rows.map(item => {
item.album_images = picUrl + item.album_images;
})
this.shopList = res.rows;
if (this.shopList.length > 0) {
this.selectedShop = this.shopList[0];
}
})
},
goWallet(type) {
NavgateTo('/packages/storeManagement/wallet/index?type=' + type);
},
@ -148,11 +163,11 @@ export default {
changeShow() {
this.show = !this.show
},
changeShow2() {
this.show2 = !this.show
changeShow2(item) {
this.selectedShop = item;
this.show = false;
},
click(item) {
console.log("🚀 ~ click ~ item:", item)
// itemurl
if (item.url) {
NavgateTo(item.url)

View File

@ -26,26 +26,36 @@
<view class="records-container">
<view class="records-title">{{ topVal }}变动记录</view>
<view class="records-list">
<view class="record-item" v-for="(record, index) in records" :key="index">
<view class="record-info">
<view class="record-name">{{ record.name }}</view>
<view class="record-time">{{ record.time }}</view>
</view>
<view class="record-amount">
<view>
<text :class="['amount-sign', record.amount.startsWith('+') ? 'positive' : 'negative']">{{
record.amount.startsWith('+') ? '+' : '-' }}</text>
<text :class="['amount-value', record.amount.startsWith('+') ? 'positive' : 'negative']">¥{{
record.amount.replace(/[+-]/, '') }}</text>
<view v-if="records.length > 0">
<view class="record-item" v-for="(record, index) in records" :key="index">
<view class="record-info">
<view class="record-name">{{ record.change_reason }} - {{
record.community_order_pay ? record.community_order_pay.order_pay_no :
record.quick_payment_record.order_no }}</view>
<view class="record-time">{{ record.create_time }}</view>
</view>
<view class="record-amount">
<view>
<text
:class="['amount-sign', record.change_reason == '下单' ? 'positive' : 'negative']">{{
record.change_reason == '下单' ? '+' : '-' }}</text>
<text
:class="['amount-value', record.change_reason == '下单' ? 'positive' : 'negative']">¥{{
record.amount_change }}</text>
</view>
<view class="record-balance">:¥{{ record.balance_after }}</view>
</view>
<view class="record-balance">:¥{{ record.remain }}</view>
</view>
</view>
<view v-else>
<view class="no-record">暂无变动记录</view>
</view>
</view>
</view>
</view>
</template>
<script>
import { apiArr } from '../../../api/v2User';
import { menuButtonInfo, NavgateTo, picUrl, request } from '../../../utils/index';
export default {
data() {
@ -54,7 +64,7 @@ export default {
localHeight: "",
topVal: "",
photoVal: '',
balance: "160.80",
balance: "",
records: [
{
name: "退单-1312312317972",
@ -68,7 +78,11 @@ export default {
amount: "-1808.5",
remain: "286.79"
}
]
],
itemObj: {},
itemType: '',
page_num: 1,
page_size: 10,
}
},
onLoad(options) {
@ -77,6 +91,9 @@ export default {
this.localHeight = meun.height;
this.topVal = options.type == 1 ? '积分' : (options.type == 2 ? '物业公积金' : '红包卡券');
this.photoVal = options.type == 1 ? 'http://localhost:8080/user_wallet1.png' : (options.type == 2 ? 'http://localhost:8080/user_wallet2.png' : 'http://localhost:8080/user_wallet3.png');
this.itemObj = JSON.parse(options.item);
this.itemType = options.type;
this.balance = options.type == 1 ? this.itemObj.points : (options.type == 2 ? this.itemObj.property_housing_fund : 0)
this.getWalletInfo();
},
methods: {
@ -87,16 +104,19 @@ export default {
},
//
getWalletInfo() {
//
// 使
console.log('获取钱包信息');
//
// request('/api/wallet/info', 'GET').then(res => {
// if (res.code === 0) {
// this.balance = res.data.balance;
// this.records = res.data.records;
// }
// })
const params = {
page_num: this.page_num,
page_size: this.page_size,
}
if (this.itemType == 1) {
request(apiArr.getPoints, 'POST', params, { silent: false }).then(res => {
this.records = res.rows;
})
} else if (this.itemType == 2) {
request(apiArr.getAccumulationFund, 'POST', params, { silent: false }).then(res => {
this.records = res.rows;
})
}
}
}
}

View File

@ -724,6 +724,13 @@
"navigationStyle": "custom"
}
},
{
"path": "goodsSubmit/index",
"style": {
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "提交团单"
}
},
{
"path": "groupPurchaseSubmit/index",
"style": {

View File

@ -34,7 +34,7 @@
</view>
</view>
<input class="search_input" placeholder='请输入内容' confirm-type='search' @input="searchInput"
@confirm="searchInput" :value="selectKeyWord" />
@confirm="searchInput" :value="selectKeyWord" @click="goSearchView"/>
</view>
</view>
</view>
@ -93,14 +93,13 @@
<!-- 广告横幅 -->
<view class="serverList1">
<view class="serverList1_left" @click="toAdvertisingView(serverLeftList)">
<image :src="serverLeft" mode="aspectFill" />
<view class="serverList1_left" v-if="serverLeftList.length > 0">
<image :src="serverLeft" mode="aspectFill" @tap="toAdvertisingView(serverLeftList)"/>
</view>
<view class="serverList1_right">
<view class="serverList1_right" v-if="serverRightList.length > 0">
<view :class="['serverItemRight', `serverItemRight${index + 1}`]"
@tap="index === 1 ? toAdvertisingView(serverRightList) : headerServerClick(item)"
v-for="(item, index) in serverRightList" :key="index">
<image :src="item.pic_src" mode="" />
<image :src="item.pic_src" mode="" @tap="index === 0 ? toAdvertisingView(serverRightList) : headerServerClick(item)"/>
</view>
</view>
</view>
@ -326,6 +325,9 @@ export default {
},
methods: {
goSearchView(){
NavgateTo('/packages/shop/search/index');
},
goToShop() {
uni.showModal({
title: '提示',
@ -680,6 +682,9 @@ export default {
page_num: 1,
page_size: 10
}, { silent: false });
if (!res.rows.length) {
this.serverLeftList = []
}
if (res.rows.length) {
this.serverLeftList = res.rows
@ -705,6 +710,9 @@ export default {
page_num: 1,
page_size: 10
}, { silent: false });
if (!res.rows.length) {
this.serverRightList = []
}
if (res.rows.length) {
let filterRes = this.filterShowList(res?.rows, 1);
filterRes.forEach(item => {

View File

@ -24,15 +24,15 @@
</view>
</view>
<view class="section section1">
<view class="section_label" @click="goWallet(1)">
<view>{{ userInfo.property_housing_fund }}</view>
<view class="section_label" @click="goWallet(1,userInfo)">
<view>{{ userInfo.points }}</view>
<view>积分</view>
</view>
<view class="section_label">
<view>0.00</view>
<view>繁华币</view>
</view>
<view class="section_label" @click="goWallet(2)">
<view class="section_label" @click="goWallet(2,userInfo)">
<view>{{ userInfo.property_housing_fund }}</view>
<view>物业费公积金</view>
</view>
@ -267,8 +267,8 @@ export default {
},
methods: {
goWallet(type) {
NavgateTo('/packages/user/wallet/index?type=' + type);
goWallet(type,item) {
NavgateTo('/packages/user/wallet/index?type=' + type + '&item=' + JSON.stringify(item));
},
//
toLogin() {

View File

@ -1,33 +1,56 @@
// 环境配置
const environments = {
development: {
apiUrl: 'https://test.hshuishang.com',
picUrl: 'https://test.hshuishang.com',
aliyunOssUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com',
staticUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com'
apiUrl: "https://test.hshuishang.com",
picUrl: "https://test.hshuishang.com",
aliyunOssUrl: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com",
staticUrl: "https://static.hshuishang.com",
},
production: {
apiUrl: 'https://api.hshuishang.com',
picUrl: 'https://api.hshuishang.com',
aliyunOssUrl: 'https://wechat-img-file.oss-cn-beijing.aliyuncs.com',
staticUrl: 'http://static.hshuishang.com'
}
apiUrl: "https://api.hshuishang.com",
picUrl: "https://api.hshuishang.com",
aliyunOssUrl: "https://wechat-img-file.oss-cn-beijing.aliyuncs.com",
staticUrl: "https://static.hshuishang.com",
},
};
// 判断当前环境
const getCurrentEnvironment = () => {
// 优先通过NODE_ENV判断
// 1. 优先通过NODE_ENV判断
if (process && process.env && process.env.NODE_ENV) {
return process.env.NODE_ENV;
}
// 通过全局配置判断例如Vercel等平台的环境变量
if (typeof global !== 'undefined' && global.env) {
// 2. 微信小程序环境判断
if (typeof wx !== "undefined" && wx.getAccountInfoSync) {
try {
const accountInfo = wx.getAccountInfoSync();
const envVersion = accountInfo.miniProgram.envVersion;
// 根据微信小程序环境返回对应环境标识
if (envVersion === "release") {
return "production"; // 正式版
} else if (envVersion === "trial") {
return "development"; // 体验版
} else if (envVersion === "develop") {
return "development"; // 开发版
}
} catch (e) {
console.warn("获取小程序环境信息失败:", e);
}
}
// 3. 通过全局配置判断例如Vercel等平台的环境变量
if (typeof global !== "undefined" && global.env) {
return global.env;
}
// 默认返回开发环境
return 'development';
// 4. 检查是否有全局的uni对象可能是uni-app环境
if (typeof uni !== "undefined") {
// 可以根据实际情况添加更多uni-app环境的判断逻辑
}
// 默认返回生产环境,避免线上环境使用开发地址
return "production";
};
// 获取当前环境配置
@ -46,14 +69,16 @@ export const staticUrl = envConfig.staticUrl; // 静态资源地址
*/
export const processImageUrl = (url) => {
if (!url) return url;
// 如果URL包含阿里云OSS地址则根据环境替换
if (url.includes(aliyunOssUrl)) {
if (currentEnv === 'production') {
return url.replace(aliyunOssUrl, staticUrl);
if (currentEnv === "production") {
url = url.replace(aliyunOssUrl, staticUrl);
return url;
}
}
return url;
};
@ -64,51 +89,51 @@ export const processImageUrl = (url) => {
* @param {Object} options - 配置选项对象
* @param {Boolean} options.isLogin - 是否需要校验登录态默认为 true
* @param {Boolean} options.forceReplace - 是否强制替换当前页面解决webview数量限制问题默认为 false
*/
*/
export const NavgateTo = (path, options = {}) => {
// 首页不需要登录验证
if (path === '/pages/index/index') {
if (path === "/pages/index/index") {
uni.navigateTo({ url: path });
return;
}
const { isLogin = true, forceReplace = false } = options;
const ctoken = uni.getStorageSync('ctoken');
const ctoken = uni.getStorageSync("ctoken");
// 登录校验
if (isLogin && !ctoken) {
uni.redirectTo({ url: '/pages/login/login' })
return
uni.redirectTo({ url: "/pages/login/login" });
return;
}
// 返回上一页
if (path == '1') {
if (path == "1") {
uni.navigateBack({
delta: 1
})
return
delta: 1,
});
return;
}
// 选择合适的跳转方式
const navigateOptions = {
url: path,
fail: (err) => {
// 处理webview数量限制错误
if (err.errMsg && err.errMsg.includes('webview count limit')) {
console.warn('检测到webview数量限制自动切换为redirectTo模式');
if (err.errMsg && err.errMsg.includes("webview count limit")) {
console.warn("检测到webview数量限制自动切换为redirectTo模式");
uni.redirectTo({ url: path });
} else {
console.error('页面跳转失败:', err);
console.error("页面跳转失败:", err);
}
}
},
};
// 如果强制替换使用redirectTo
if (forceReplace) {
uni.redirectTo(navigateOptions);
} else {
uni.navigateTo(navigateOptions);
}
}
};
/**
* 封装请求方法
@ -119,66 +144,68 @@ export const NavgateTo = (path, options = {}) => {
* @param {Boolean} options.silent - 是否显示loading默认为 true
* @param {Boolean} options.nested - 是否平铺接口返回参数默认为 false
* @returns {Promise} 返回一个Promise对象
*/
*/
export const request = (url, method = 'POST', data = {}, options = {}) => {
export const request = (url, method = "POST", data = {}, options = {}) => {
const { silent = true, nested = false } = options;
let ctoken = null;
if (options.token) {
ctoken = options.token;
} else {
ctoken = uni.getStorageSync('ctoken'); // 后续接口强依赖强校验该字段
ctoken = uni.getStorageSync("ctoken"); // 后续接口强依赖强校验该字段
}
if (silent) {
uni.showLoading({
title: '加载中',
mask: true
})
};
let params = {
user_id: uni.getStorageSync('userId'),
...data,
title: "加载中",
mask: true,
});
}
let params = {
user_id: uni.getStorageSync("userId"),
...data,
};
return new Promise((resolve, reject) => {
uni.request({
url: RequsetUrl + url,
method: method,
data: params,
header: {
'Content-Type': 'application/json',
'Authorization': ctoken,
"Content-Type": "application/json",
Authorization: ctoken,
// ...header,
},
success: (res) => {
// console.log('请求成功,接口返参', res);
if (res.statusCode == 401 || (res.statusCode == 500 && res.data.msg == "效验令牌失败")) {
uni.removeStorageSync('ctoken');
uni.removeStorageSync('userId');
uni.removeStorageSync('is_worker');
if (
res.statusCode == 401 ||
(res.statusCode == 500 && res.data.msg == "效验令牌失败")
) {
uni.removeStorageSync("ctoken");
uni.removeStorageSync("userId");
uni.removeStorageSync("is_worker");
uni.showModal({
title: '提示',
content: '请登录后查看',
title: "提示",
content: "请登录后查看",
confirmText: "去登陆",
complete: (res) => {
if (res.cancel) {
uni.hideLoading();
uni.redirectTo({
url: '/pages/index/index'
url: "/pages/index/index",
});
return
return;
}
if (res.confirm) {
uni.redirectTo({
url: '/pages/login/login',
})
url: "/pages/login/login",
});
}
}
})
return
},
});
return;
}
if (res.statusCode === 200) {
if (silent) {
@ -187,22 +214,22 @@ export const request = (url, method = 'POST', data = {}, options = {}) => {
if (options?.nested) {
let data = {
...res.data,
}
};
resolve(data); // 请求成功
return;
}
resolve(res.data.data); // 请求成功
} else {
console.log('走到这列');
console.log("走到这列");
uni.hideLoading();
uni.showToast({
title: res.data.msg || '请求失败',
icon: 'none'
})
title: res.data.msg || "请求失败",
icon: "none",
});
reject({
code: res.statusCode,
message: res.data.msg || '请求失败',
message: res.data.msg || "请求失败",
data: res.data,
});
}
@ -210,35 +237,36 @@ export const request = (url, method = 'POST', data = {}, options = {}) => {
fail: (err) => {
uni.hideLoading();
uni.showToast({
title: res.data.msg || '请求失败',
icon: 'none'
})
title: res.data.msg || "请求失败",
icon: "none",
});
reject({
code: -1,
message: '接口异常,请稍后重试',
message: "接口异常,请稍后重试",
error: err,
});
},
});
});
}
};
/**
* 校验手机号是否合法
* @param {string} option 请求方法
* @returns {Boolean} 手机号是否正确
*/
*/
export const isPhone = (option) => {
if (option.length != 11) {
return false
return false;
}
if (!(/^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(option))) {
return false
if (
!/^1(3\d|4[5-9]|5[0-35-9]|6[2567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(option)
) {
return false;
} else {
return true
return true;
}
}
};
/**
* 精确的浮点数运算
@ -246,12 +274,12 @@ export const isPhone = (option) => {
* @param {number} num2 - 第二个数字
* @param {string} operator - 运算符支持 '+', '-', '*', '/', '+='
* @returns {number} - 运算结果
*/
*/
export const floatCalculate = (num1, num2, operator) => {
// 获取小数位数
function getPrecision(num) {
const str = num.toString();
const decimalIndex = str.indexOf('.');
const decimalIndex = str.indexOf(".");
return decimalIndex === -1 ? 0 : str.length - decimalIndex - 1;
}
@ -268,45 +296,45 @@ export const floatCalculate = (num1, num2, operator) => {
// 根据运算符进行计算
let result;
switch (operator) {
case '+':
case "+":
result = (intNum1 + intNum2) / factor;
break;
case '-':
case "-":
result = (intNum1 - intNum2) / factor;
break;
case '*':
case "*":
result = (intNum1 * intNum2) / (factor * factor);
break;
case '/':
case "/":
result = intNum1 / intNum2;
break;
case '+=':
case "+=":
result = (intNum1 + intNum2) / factor;
break;
default:
throw new Error('不支持的运算符');
throw new Error("不支持的运算符");
}
return result;
}
};
/**
* 图片上传
* @param {string} filename - 图片上传地址
* @param {Function} fn - 接口回调函数
*/
*/
export const upload = (filename, fn) => {
uni.showLoading({
title: '上传中',
mask: true
})
title: "上传中",
mask: true,
});
uni.uploadFile({
url: RequsetUrl + '/api/v1/public/upload-image',
url: RequsetUrl + "/api/v1/public/upload-image",
filePath: filename,
name: 'image',
name: "image",
formData: {
'uid': uni.getStorageSync('uid'),
uid: uni.getStorageSync("uid"),
},
success: (f) => {
uni.hideLoading();
@ -316,31 +344,30 @@ export const upload = (filename, fn) => {
uni.hideLoading();
console.log(res);
uni.showToast({
title: '上传文件失败',
icon: 'none'
})
title: "上传文件失败",
icon: "none",
});
},
complete: () => { }
complete: () => {},
});
}
};
/**
* 视频上传
* @param {string} filename - 图片上传地址
* @param {Function} fn - 接口回调函数
*/
*/
export const uploadVideo = (filename, fn) => {
uni.showLoading({
title: '上传中',
mask: true
})
title: "上传中",
mask: true,
});
uni.uploadFile({
url: RequsetUrl + '/api/v1/public/upload-video',
url: RequsetUrl + "/api/v1/public/upload-video",
filePath: filename,
name: 'file',
name: "file",
formData: {
'uid': uni.getStorageSync('uid'),
uid: uni.getStorageSync("uid"),
},
success: (f) => {
uni.hideLoading();
@ -350,13 +377,13 @@ export const uploadVideo = (filename, fn) => {
uni.hideLoading();
console.log(res);
uni.showToast({
title: '上传文件失败',
icon: 'none'
})
title: "上传文件失败",
icon: "none",
});
},
complete: () => { }
complete: () => {},
});
}
};
/**
* 计算两地之间的距离
@ -365,7 +392,7 @@ export const uploadVideo = (filename, fn) => {
* @param {string} lat2 第二个点的纬度
* @param {string} lon2 第二个点的经度
* @returns {number} 距离
*/
*/
export const calculateDistance = (lat1, lon1, lat2, lon2) => {
// 将经纬度转换为弧度
const toRad = (value) => (value * Math.PI) / 180;
@ -375,18 +402,20 @@ export const calculateDistance = (lat1, lon1, lat2, lon2) => {
const dLon = toRad(lon2 - lon1);
const a =
Math.sin(dLat / 2) * Math.sin(dLat / 2) +
Math.cos(toRad(lat1)) * Math.cos(toRad(lat2)) *
Math.sin(dLon / 2) * Math.sin(dLon / 2);
Math.cos(toRad(lat1)) *
Math.cos(toRad(lat2)) *
Math.sin(dLon / 2) *
Math.sin(dLon / 2);
const c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
const distance = R * c; // 最终距离(单位:千米)
return distance;
}
//
};
//
export const menuButtonInfo = () => {
const systemInfo = uni.getSystemInfoSync();
const platform = systemInfo.platform;
if (platform === 'ios') {
if (platform === "ios") {
// TODO: ios待测试
return {
height: systemInfo.statusBarHeight,
@ -394,50 +423,50 @@ export const menuButtonInfo = () => {
};
}
if (platform === 'android') {
if (platform === "android") {
return {
height: systemInfo.statusBarHeight,
top: 44, // 自定义导航栏默认高度
};
}
if (systemInfo.uniPlatform === 'mp-weixin') {
if (systemInfo.uniPlatform === "mp-weixin") {
// 微信小程序、支付宝小程序等,平台标识以 'mp-' 开头
return uni.getMenuButtonBoundingClientRect()
return uni.getMenuButtonBoundingClientRect();
} else {
return 'Unknown';
return "Unknown";
}
}
};
/**
* 获取服务供应商
* @param {string} opt - 服务类型
* @returns {Promise} 返回一个Promise对象
*/
*/
export const getProviderPromise = (opt) => {
return new Promise((resolve, reject) => {
uni.getProvider({
service: opt,
success: (res) => {
console.log('获取支付服务提供商成功:', res.provider);
console.log("获取支付服务提供商成功:", res.provider);
resolve(res.provider);
},
fail: (err) => {
console.error('获取支付服务提供商失败:', err);
console.error("获取支付服务提供商失败:", err);
reject(err);
}
},
});
});
}
};
//数组去重
export const uniqueByField = (arr, field) => {
const seen = {};
return arr.filter(item => {
return arr.filter((item) => {
const key = item[field];
return seen.hasOwnProperty(key) ? false : (seen[key] = true);
});
}
};
// 校验邮箱地址是否合法
export const validateEmail = (email) => {
@ -447,8 +476,8 @@ export const validateEmail = (email) => {
return false;
}
return true
}
return true;
};
/**
* 防抖函数
@ -476,8 +505,7 @@ export const debounce = (fn, delay = 300, immediate = false) => {
timer = null;
}, delay);
};
}
};
/**
* 格式化日期
@ -485,11 +513,10 @@ export const debounce = (fn, delay = 300, immediate = false) => {
*/
export const formatDate = (date) => {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
const hours = String(date.getHours()).padStart(2, "0");
const minutes = String(date.getMinutes()).padStart(2, "0");
const seconds = String(date.getSeconds()).padStart(2, "0");
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
};