Browse Source

特产搜索

master
jiazhipeng 5 months ago
parent
commit
5c4a5221e7
  1. 11
      project.private.config.json
  2. 76
      subPackages/postSearch/index.js
  3. 36
      subPackages/postSearch/index.wxml
  4. 56
      subPackages/postSearch/index.wxss

11
project.private.config.json

@ -6,12 +6,19 @@
"condition": { "condition": {
"miniprogram": { "miniprogram": {
"list": [ "list": [
{
"name": "subPackages/postSearch/index",
"pathName": "subPackages/postSearch/index",
"query": "type_id=1&ids=",
"scene": null,
"launchMode": "default"
},
{ {
"name": "pages/info/postProductInfo/index", "name": "pages/info/postProductInfo/index",
"pathName": "pages/info/postProductInfo/index", "pathName": "pages/info/postProductInfo/index",
"query": "id=462080", "query": "id=462080",
"scene": null, "launchMode": "default",
"launchMode": "default" "scene": null
}, },
{ {
"name": "pages/info/postProductInfo/index", "name": "pages/info/postProductInfo/index",

76
subPackages/postSearch/index.js

@ -26,7 +26,9 @@ Page({
totalPrice:0, //获取购物车总价--打开购物车后勾选的产品价格 totalPrice:0, //获取购物车总价--打开购物车后勾选的产品价格
nowAddListId:[], nowAddListId:[],
type:'', //购物车分类1文创,2非遗 type:'', //购物车分类1文创,2非遗
show:false show:false,
user_type: null,
}, },
/** /**
@ -60,6 +62,14 @@ Page({
}, },
// 添加产品到购物车 // 添加产品到购物车
addCart: function (e) { addCart: function (e) {
if (![0,1].includes(this.data.user_type)) {
wx.showToast({
title: "请选择配送方式",
icon:"none"
})
return
}
let item = e.currentTarget.dataset.item let item = e.currentTarget.dataset.item
app.globalData.postProduct = [] app.globalData.postProduct = []
app.globalData.list = [] app.globalData.list = []
@ -72,7 +82,8 @@ Page({
commonApi.user_post("cart_within/add_sku", { commonApi.user_post("cart_within/add_sku", {
sku_id: this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id, sku_id: this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id,
num: this.data.producNum, num: this.data.producNum,
type:this.data.type type:this.data.type,
delivery_method: this.data.user_type
}).then(res => { }).then(res => {
if (res.code == 1) { if (res.code == 1) {
let sku_id = this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id let sku_id = this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id
@ -107,6 +118,9 @@ Page({
if (element.selected == 1) { if (element.selected == 1) {
totalPrice += Number(element.num*element.sku.price) totalPrice += Number(element.num*element.sku.price)
} }
if (element.delivery_method === null) {
element.delivery_method = element.sku.sku_model.use_type == 1?1:0
}
}) })
console.log(res.data); console.log(res.data);
let status = res.data.every(el => el.selected === 1) let status = res.data.every(el => el.selected === 1)
@ -173,7 +187,7 @@ Page({
if (item.product.type == 'post') { if (item.product.type == 'post') {
product.push({ product.push({
product: item.product, product: item.product,
sku: item.sku, sku: {...item.sku, use_type: item.delivery_method||0},
productNum: item.num productNum: item.num
}) })
} else { } else {
@ -207,6 +221,29 @@ Page({
isCar: 'single' isCar: 'single'
}) })
} }
let repeatSku = product.find(x=>product.filter(v=>v.sku.id == x.sku.id).length>1)
if(repeatSku) {
let str = `${repeatSku.product.title}-${repeatSku.sku.sku_name}邮寄和自提只能选择一种`
wx.showModal({
content: str,
showCancel: false,
complete: (res) => {}
})
return
}
let useType = product[0].sku.use_type
let flag = this.data.flag, isCar = "single";
if (product.some(x=>x.sku.use_type!=useType)) {
flag = "mix"
isCar = "multiple"
}
this.setData({
flag: flag,
isCar: isCar
})
console.log(product1); console.log(product1);
app.globalData.postProduct = product; app.globalData.postProduct = product;
if (app.globalData.list) { if (app.globalData.list) {
@ -248,10 +285,10 @@ selectedIt(e) {
delAll() { delAll() {
let ids = [] let ids = []
this.data.gwcList.forEach(item => { this.data.gwcList.forEach(item => {
ids.push(item.sku_id) ids.push(item.id)
}) })
commonApi.user_post("cart_within/del_sku", { commonApi.user_post("cart_within/del_sku", {
sku_id: ids+'', id: ids+'',
type:this.data.type type:this.data.type
}).then(res => { }).then(res => {
if (res.code == 1) { if (res.code == 1) {
@ -270,9 +307,10 @@ delAll() {
del(e) { del(e) {
let item = e.currentTarget.dataset.item let item = e.currentTarget.dataset.item
let gwcList = this.data.gwcList let gwcList = this.data.gwcList
let valueNum = e.currentTarget.dataset.value
commonApi.user_post("cart_within/update_sku", { commonApi.user_post("cart_within/update_sku", {
num:item.num-1, num:item.num + valueNum,
sku_id: item.sku_id, id: item.id,
type:this.data.type type:this.data.type
}).then(res => { }).then(res => {
if (res.code == 1) { if (res.code == 1) {
@ -295,6 +333,9 @@ del(e) {
if (item.selected ==1) { if (item.selected ==1) {
totalPrice += item.num*item.sku.price totalPrice += item.num*item.sku.price
} }
if (item.delivery_method === null) {
item.delivery_method = item.sku.sku_model.use_type == 1?1:0
}
}) })
} }
let status = res.data.every(el => el.selected === 1) let status = res.data.every(el => el.selected === 1)
@ -367,6 +408,9 @@ openPopup() {
if (item.selected == 1) { if (item.selected == 1) {
totalPrice += item.num*item.sku.price totalPrice += item.num*item.sku.price
} }
if (item.delivery_method === null) {
item.delivery_method = item.sku.sku_model.use_type == 1?1:0
}
}) })
// console.log(arr); // console.log(arr);
// debugger // debugger
@ -380,7 +424,8 @@ openPopup() {
}, },
search() { search() {
this.setData({ this.setData({
list:[] list:[],
show:false
}) })
this.getList() this.getList()
}, },
@ -390,9 +435,6 @@ openPopup() {
}) })
}, },
getList() { getList() {
this.setData({
show:false
})
let list= this.data.list; let list= this.data.list;
if (this.data.keywords == '' || this.data.keywords.indexOf(' ')!==-1) { if (this.data.keywords == '' || this.data.keywords.indexOf(' ')!==-1) {
return return
@ -445,6 +487,9 @@ openPopup() {
}, },
// 添加产品弹窗 1.首先获取到该产品下的规格 // 添加产品弹窗 1.首先获取到该产品下的规格
addBuyCart(e) { addBuyCart(e) {
this.setData({
user_type: null
})
let item = e.currentTarget.dataset.item let item = e.currentTarget.dataset.item
console.log(item); console.log(item);
commonApi._post("product/get_product_detail", { commonApi._post("product/get_product_detail", {
@ -501,9 +546,16 @@ openPopup() {
selectSku: function (e) { selectSku: function (e) {
let index = e.currentTarget.dataset.index; let index = e.currentTarget.dataset.index;
this.setData({ this.setData({
skuIndex: index skuIndex: index,
user_type: null,
}) })
}, },
changeSelectSkuPost: function(e) {
let value = e.currentTarget.dataset.value;
this.setData({
user_type: value,
})
},
// 关闭弹窗 // 关闭弹窗
hideSku: function () { hideSku: function () {
this.setData({ this.setData({

36
subPackages/postSearch/index.wxml

@ -1,18 +1,18 @@
<view class="title-box{{transparent==1?' bg-box':''}}" style="height:{{isScene==1?'0':(height+padHeight)}}px;"> <view class="title-box{{transparent==1?' bg-box':''}}" style="height:{{isScene==1?'0':(height+padHeight)}}px;">
<view class="title-header" style="padding-top:{{padHeight}}px;height:{{height}}px"> <view class="title-header" style="padding-top:{{padHeight}}px;height:{{height}}px">
<icon bindtap="back" class="iconfont icon-fanhui1"></icon> <icon bindtap="back" class="iconfont icon-fanhui1"></icon>
<view bindtap="indexFocus" class="search-box" style="margin-right:{{right + 5}}px;"> <view class="search-box" style="margin-right:{{right + 5}}px;">
<icon class="iconfont icon-sousuo"></icon> <icon class="iconfont icon-sousuo"></icon>
<input placeholder-class="{{transparent==1?'phcolor':''}}" bindinput="searchInput" class="weui-input" placeholder="请输入商品名称" /> <input placeholder-class="{{transparent==1?'phcolor':''}}" bindinput="searchInput" class="weui-input" placeholder="请输入商品名称" />
<!-- <input bindfocus="inputFocus" placeholder-class="{{transparent==1?'phcolor':''}}" bindinput="getVal" class="weui-input" placeholder="搜索" /> --> <!-- <input bindfocus="inputFocus" placeholder-class="{{transparent==1?'phcolor':''}}" bindinput="getVal" class="weui-input" placeholder="搜索" /> -->
<view wx:if="{{isScene!=1}}" style="display: flex;padding-right: 12rpx;"> <view wx:if="{{isScene!=1}}" style="display: flex;padding-right: 12rpx;">
<view style="color: #ccc;">|</view> <view style="color: #ccc;">|</view>
<view style="margin-left:22rpx;font-weight: 400;font-size: 29rpx;color: #0B898E;" bindtap="getList">搜索</view> <view style="margin-left:22rpx;font-weight: 400;font-size: 29rpx;color: #0B898E;" bindtap="search">搜索</view>
</view> </view>
</view> </view>
</view> </view>
</view> </view>
<view wx:if="{{show}}"> <view>
<view class="hot-list" wx:if="{{list.length>0}}"> <view class="hot-list" wx:if="{{list.length>0}}">
<view class="hot-list-item" wx:for="{{2}}" wx:for-index="number" wx:key="this"> <view class="hot-list-item" wx:for="{{2}}" wx:for-index="number" wx:key="this">
<view class="hot-item" wx:if="{{index%2==number}}" wx:for="{{list}}" bindtap="goodsDetail" data-goods="{{item}}" wx:key="id"> <view class="hot-item" wx:if="{{index%2==number}}" wx:for="{{list}}" bindtap="goodsDetail" data-goods="{{item}}" wx:key="id">
@ -83,6 +83,25 @@
<view class="number">{{producNum}}</view> <view class="number">{{producNum}}</view>
<view class="iconfont icon-add-select" bindtap="add"></view> <view class="iconfont icon-add-select" bindtap="add"></view>
</view> </view>
<view class="delivery-method" wx:if="{{info.is_package!=1}}">
<view class="delivery-title">配送方式</view>
<view class="flex" style="display: flex;">
<view class="flex-center" wx:if="{{info.sku[skuIndex].use_type!=1}}" bind:tap="changeSelectSkuPost" data-value="{{0}}">
<view class="select-cycle" wx:if="{{user_type!==0}}"></view>
<view class="select-cycle selected" wx:else>
<image src="https://static.ticket.sz-trip.com/uploads/20240715/a961604bc708670cbdc76d1580eb3f3c.png"></image>
</view>
<view class="method-str">邮寄</view>
</view>
<view class="flex-center" wx:if="{{info.sku[skuIndex].use_type!=0}}" bind:tap="changeSelectSkuPost" data-value="{{1}}">
<view class="select-cycle" wx:if="{{user_type!==1}}"></view>
<view class="select-cycle selected" wx:else="">
<image src="https://static.ticket.sz-trip.com/uploads/20240715/a961604bc708670cbdc76d1580eb3f3c.png"></image>
</view>
<view class="method-str">自提</view>
</view>
</view>
</view>
<view style="height:138rpx"></view> <view style="height:138rpx"></view>
<view class="btn-box"> <view class="btn-box">
<!-- <view class="mask-btn" bindtap="addCart" wx:if="{{info.sku[skuIndex].flag=='on'}}">{{skuFlag=='cart'?'加入购物车':'立即购买'}} <!-- <view class="mask-btn" bindtap="addCart" wx:if="{{info.sku[skuIndex].flag=='on'}}">{{skuFlag=='cart'?'加入购物车':'立即购买'}}
@ -95,7 +114,7 @@
<!-- 购物车的弹窗 --> <!-- 购物车的弹窗 -->
<view class="mask" wx:if="{{showPopup}}"> <view class="mask" wx:if="{{showPopup}}">
<view bindtap="openPopup" class="mask-bg"></view> <view bindtap="openPopup" class="mask-bg"></view>
<view class="mask-content" style="padding: 40rpx 0 180rpx;min-height: 600rpx;"> <view class="mask-content" style="padding: 40rpx 0 180rpx;height: 900rpx;">
<view style="margin: 0 26.67rpx;"> <view style="margin: 0 26.67rpx;">
<!-- 顶部操作按钮 --> <!-- 顶部操作按钮 -->
<view class="flex" style="margin-bottom: 56.67rpx;"> <view class="flex" style="margin-bottom: 56.67rpx;">
@ -114,7 +133,10 @@
<image lazy-load wx:if="{{item.selected ==1}}" style="width: 43rpx;height: 43rpx;" src="https://static.ticket.sz-trip.com/uploads/20240715/a961604bc708670cbdc76d1580eb3f3c.png" mode="" /> <image lazy-load wx:if="{{item.selected ==1}}" style="width: 43rpx;height: 43rpx;" src="https://static.ticket.sz-trip.com/uploads/20240715/a961604bc708670cbdc76d1580eb3f3c.png" mode="" />
<view wx:else style="width: 40rpx;height: 40rpx;border-radius: 50%;border: 1px solid #999999;"></view> <view wx:else style="width: 40rpx;height: 40rpx;border-radius: 50%;border: 1px solid #999999;"></view>
</view> </view>
<image lazy-load style="width:179rpx;height: 179rpx;border-radius: 13rpx;flex-shrink: 0;margin-right: 26rpx;" src="{{item.sku.headimg}}" mode="" /> <view style="position: relative;height: 179rpx;border-radius: 13rpx;flex-shrink: 0;margin-right: 26rpx;">
<image lazy-load style="width:179rpx;height: 179rpx;border-radius: 13rpx;" src="{{item.sku.headimg}}" mode="" />
<view class="use-type">{{item.delivery_method==1?"自提":"邮寄"}}</view>
</view>
<view class="main"> <view class="main">
<view> <view>
<view class="title textOver">{{item.product.title}}</view> <view class="title textOver">{{item.product.title}}</view>
@ -123,9 +145,9 @@
<view class="main-bottom"> <view class="main-bottom">
<view class="price">{{item.sku.price/100}}</view> <view class="price">{{item.sku.price/100}}</view>
<view class="num-box"> <view class="num-box">
<image lazy-load class="reduce" catchtap="del" data-item="{{item}}" src="https://static.ticket.sz-trip.com/uploads/20240715/054627e5d3864a9a4a8b397cae47754e.png" mode="" /> <image lazy-load class="reduce" catchtap="del" data-item="{{item}}" data-value="{{-1}}" src="https://static.ticket.sz-trip.com/uploads/20240715/054627e5d3864a9a4a8b397cae47754e.png" mode="" />
<view style="margin: 0 25.33rpx;">{{item.num}}</view> <view style="margin: 0 25.33rpx;">{{item.num}}</view>
<image lazy-load class="grow" catchtap="addCart" data-item="{{item}}" src="https://static.ticket.sz-trip.com/uploads/20240715/3ad59eac0088d47ff4bc2fec6ffd8f56.png" mode="" /> <image lazy-load class="grow" catchtap="del" data-item="{{item}}" data-value="{{1}}" src="https://static.ticket.sz-trip.com/uploads/20240715/3ad59eac0088d47ff4bc2fec6ffd8f56.png" mode="" />
</view> </view>
</view> </view>
</view> </view>

56
subPackages/postSearch/index.wxss

@ -318,7 +318,7 @@
display: flex; display: flex;
font-size: 29rpx; font-size: 29rpx;
color: #333; color: #333;
margin: 0 40rpx; margin: 0 30rpx;
text-align: center; text-align: center;
flex-wrap: wrap; flex-wrap: wrap;
margin-bottom: 20rpx; margin-bottom: 20rpx;
@ -472,3 +472,57 @@
font-size: 24rpx; font-size: 24rpx;
font-weight: 500; font-weight: 500;
} }
.delivery-method{
font-weight: 400;
font-size: 29rpx;
color: #1E1E1E;
display: flex;
justify-content: space-between;
align-items: center;
padding: 0 40rpx 40rpx;
}
.delivery-method .select-cycle{
width: 32rpx;
height: 32rpx;
border-radius: 50%;
border: 1px solid #999999;
overflow: hidden;
flex-shrink: 0;
}
.delivery-method .select-cycle image{
width: 100%;
height: 100%;
}
.delivery-method .select-cycle.selected {
border: none;
}
.delivery-method .select-cycle.selected image{
width: 32rpx;
height: 32rpx;
border-radius: 50%;
}
.delivery-method .method-str{
padding-left: 10rpx;
flex-shrink: 0;
}
.delivery-method .flex-center{
width: 150rpx;
justify-content: flex-end;
display: flex;
align-items: center;
}
.use-type{
position: absolute;
left: 0;
bottom: 0;
width: 100%;
border-radius: 0rpx 0rpx 7rpx 7rpx;
height: 33rpx;
background: rgba(0,0,0,0.3);
font-weight: 400;
font-size: 24rpx;
color: #FFFFFF;
text-align: center;
line-height: 33rpx;
}
Loading…
Cancel
Save