[200~1.兼容中国台湾、中国香港手机号码

This commit is contained in:
liuyuan
2025-07-10 14:29:44 +08:00
parent c7bab5afb4
commit f71ab1b442
27 changed files with 5393 additions and 4190 deletions

View File

@@ -2,7 +2,7 @@
<view class="container commonPageBox commonDetailPage">
<!-- 公共组件-每个页面必须引入 -->
<public-module></public-module>
<z-nav-bar title="商品详情" bgColor="#258feb" fontColor="#fff"></z-nav-bar>
<z-nav-bar title="商品详情"></z-nav-bar>
<view
class="contentBox commonPageContentBox"
@@ -424,7 +424,7 @@
:fill="true"
:options="buyOptions"
:button-group="customButtonGroup1"
@click="onHandleClickBuy"
@click="onHandleClick"
@buttonClick="onHandleClickBuy1"
/>
</view>
@@ -540,7 +540,10 @@ export default {
parameterList: [],
booksList: [],
coursesList: [],
buyOptions: [],
buyOptions: [{
icon: "cart",
text: "购物车",
}],
swiperList: [],
goodsList: [],
@@ -611,14 +614,21 @@ export default {
visitorDetailInfo: "visitor/getProductDetail", // 游客状态下的商品详情
},
customButtonGroup1: [
{
text: "加入购物车",
backgroundColor: "linear-gradient(90deg, #FFCD1E, #FF8A18)",
color: "#fff",
},
{
with: 200,
text: "立即购买",
backgroundColor: "linear-gradient(90deg, #FE6035, #EF1224)",
color: "#fff",
text: "立即购买",
backgroundColor: "linear-gradient(90deg, #FE6035, #EF1224)",
color: "#fff",
},
],
requestType: "", // 数据请求类型是否为游客登陆状态
buttonType: '', //点击的是加入购物车还是购买
cartList: [], // 购物车列表
productAmount: 1, // 商品数量
};
},
filters: {
@@ -749,11 +759,19 @@ export default {
}
this.selectGoodsData = data;
this.$refs.commonSelectGoods.open();
// this.show = true;
this.$forceUpdate();
},
onHandleClickBuy1() {
//点击购物车
onHandleClick(){
console.log('点击购物车')
uni.navigateTo({
url: "/pages/goods/shopping/index",
});
},
//点击筛选商品
onHandleClickBuy1(e) {
this.buttonType = e.index;
if (this.requestType == "visitor") {
uni.showModal({
content: "登陆后可购买本商品",
@@ -770,34 +788,126 @@ export default {
return;
}
this.$refs.commonSelectGoods.open();
// this.show = true;
},
//点击下单按钮
onHandleClickBuy() {
console.log(
this.selectGoodsData,
"this.selectGoodsDatathis.selectGoodsDatathis.selectGoodsData"
);
var mynavData = JSON.stringify({
goods: [
{
productImages: this.selectGoodsData.productImages,
productId: this.selectGoodsData.productId,
productName: this.selectGoodsData.productName,
activityPrice: this.selectGoodsData.activityPrice,
price: this.selectGoodsData.price,
goodsType: this.selectGoodsData.goodsType,
},
],
navTitle: this.options.navTitle,
title: this.options.title,
typeId: 0,
}); // 这里转换成 字符串
uni.navigateTo({
url: `/pages/goods/order/index?data=${mynavData}`,
});
if(this.buttonType==0){ //如果是加入购物车
console.log('剩余', this.selectGoodsData.productStock)
if(this.selectGoodsData.productStock==0){
uni.showToast({
title: "商品库存不足",
icon: "none",
duration: 1000,
});
}else{
this.$http.post(`book/ordercart/getCartList?userId=${this.userInfo.id}`)
.then((res) => {
this.cartList = res.cartList;
this.isAddLink(this.selectGoodsData);
});
}
}else{
var mynavData = JSON.stringify({
goods: [
{
productImages: this.selectGoodsData.productImages,
productId: this.selectGoodsData.productId,
productName: this.selectGoodsData.productName,
activityPrice: this.selectGoodsData.activityPrice,
price: this.selectGoodsData.price,
goodsType: this.selectGoodsData.goodsType,
productAmount: 1,
},
],
navTitle: this.options.navTitle,
title: this.options.title,
typeId: 0,
});
uni.navigateTo({
url: `/pages/goods/order/index?data=${mynavData}`,
});
}
},
//统计商品信息
isAddLink(item) {
let data = {
userId: this.userInfo.id,
productId: item.productId,
productAmount: this.productAmount,
price: item.price,
};
// 判断列表是否为空
if (this.cartList.length > 0) {
let flag = "";
let shagnpin = {};
// 循环购物车列表
flag = this.cartList.some((item, index) => {
if (item.productId == data.productId) {
shagnpin = item;
shagnpin.productAmount = item.productAmount + 1;
return true;
}
});
if (flag) {
// 已在购物车中添加
$http.request({
url: "book/ordercart/update",
method: "POST",
data: shagnpin,
header: {
"Content-Type": "application/json",
},
})
.then((res) => {
if (res.code == 0) {
uni.showToast({
title: "加入购物车成功",
duration: 1000,
});
}
});
} else {
// 加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST",
data,
header: {
"Content-Type": "application/json",
},
})
.then((res) => {
if (res.code == 0) {
uni.showToast({
title: "加入购物车成功",
duration: 1000,
});
}
});
}
} else {
// 购物车列表为空时直接加入购物车
$http.request({
url: "book/ordercart/save",
method: "POST",
data,
header: {
"Content-Type": "application/json",
},
})
.then((res) => {
if (res.code == 0) {
uni.showToast({
title: "加入购物车成功",
duration: 1000,
});
}
});
}
this.$refs.commonSelectGoods.close();
},
buttonClick(e) {
this.options[2].info++;
},