Commit 0f3a539d by 王志慧

套餐

1 parent d5f0d55b
// components/SetMeal/SetMeal.js
import api from '../../tabWorkOrder/api'
Component({
/**
* 组件的属性列表
*/
properties: {
show: {
type: Boolean,
observer: function (n) {
if (n) this.getMerchantPackageGoods()
}
},
chooseGoodsList: {
type: Array
},
},
/**
* 组件的初始数据
*/
data: {
goodsData: [],
selectData: [],
matchPackageName: ''
},
/**
* 组件的方法列表
*/
methods: {
choose(e) {
let {
goodsData
} = this.data, {
index
} = e.currentTarget.dataset;
let thisPage = wx.$router.getPageInstance();
goodsData[index].active = !goodsData[index].active
this.setData({
goodsData
}, () => {
this.handleSelectData()
})
},
addCount(e) {
let {
index,
count,
item
} = e.currentTarget.dataset
let target = `goodsData[${index}].count`
if (!item.count) item.count = 1
item.count += count
if (item.count < 1) item.count = 1
if (item.count > 999) item.count = 999;
let total =item.price*item.count
item.totalPrice=wx.$util.decimal(total, 2)
this.setData({
[target]: item.count,
[`goodsData[${index}].totalPrice`]: item.totalPrice
}, () => {
this.handleSelectData()
})
},
input(e) {
let {goodsData}=this.data;
let {
index
} = e.currentTarget.dataset
let target = `goodsData[${index}].count`
let {
value
} = e.detail
if (value < 1) value = 1
if (value > 999) value = 999
let total = wx.$util.decimal(goodsList[index].price * value, 2)
this.setData({
[target]: Number(value),
[`goodsData[${index}].totalPrice`]: total
}, () => {
this.handleSelectData()
})
},
handleSelectData() {
let {
selectData,
goodsData
} = this.data;
selectData = goodsData.filter(item => {
if (item.active) {
return item
}
})
this.setData({
selectData
}, () => {
this.handleSelectData()
})
},
getMerchantPackageGoods() {
let userInfo = wx.$util.getUserInfo()
let merchantId, params;
if (!userInfo.isSuper) {
merchantId = userInfo?.shopMerchantId
}
params = {
merchantId,
matchPackageName: this.data.matchPackageName
}
try {
api.getGoodsList(params).then(res => {
if (res.code == 0) {
res.data.forEach(item => {
item.active = false
item.goodsList.forEach(g => {
g.price = g.sellPrice
})
item.price = item.goodsList.reduce((prev, cur) => {
return prev + cur.price
}, 0)
item.upgradePrice = item.goodsList.reduce((prev, cur) => {
return prev + cur.sellPrice
}, 0)
item.count = 1
let total =item.price *item.count
item.totalPrice=wx.$util.decimal(total, 2)
item.isType = 'meal'
})
this.setData({
goodsData: res.data
}, () => {
this.setGoodsActive()
})
console.log(res.data)
}
})
} catch (err) {
console.log(err)
}
},
setGoodsActive() {
let {
chooseGoodsList,
goodsData
} = this.data
if (chooseGoodsList.length == 0) {
goodsData.map(e => {
c.active = false
})
} else {
goodsData.map((e, index) => {
e.active = false
chooseGoodsList.map(s => {
if (s.packageCode == e.packageCode) {
Object.assign(e, s)
}
})
})
}
this.setData({
goodsData
}, () => {
this.handleSelectData()
})
},
searchGoods(e) {
let {
value
} = e.detail;
this.data.matchPackageName = value
},
getChooseList(selectData, alreadyData) {
const map = new Map();
// 遍历array1,将对象以id为键存入Map
alreadyData.forEach(item => {
map.set(item.id || item.packageCode, item);
});
selectData.forEach(item => {
if (map.has(item.packageCode)) {
map.set(item.packageCode, Object.assign(item, {
price: map.get(item.packageCode).price
}));
} else {
map.set(item.packageCode, item)
}
});
return Array.from(map.values());
},
confirm() {
let {
chooseGoodsList,
selectData
} = this.data;
let chooseList = this.getChooseList(selectData, chooseGoodsList)
console.log(chooseList)
let thisPage = wx.$router.getPageInstance();
if (!selectData.length) return wx.$util.showToast('请勾选套餐')
this.setData({
show: false
})
thisPage?.setGoodsTotal && thisPage.setGoodsTotal(chooseList)
thisPage.setData({
goodsList: chooseList
})
this.triggerEvent('confirm', chooseList)
},
cancel() {
this.setData({
show: false
})
},
}
})
\ No newline at end of file \ No newline at end of file
{
"component": true,
"usingComponents": {}
}
\ No newline at end of file \ No newline at end of file
/* components/SetMeal/SetMeal.wxss */
.coupon-box {
height: 100vh;
overflow: hidden;
}
.set-meal {
height: calc(100% - 560rpx);
overflow-y: scroll;
.sign-text {
color: #292d33;
font-size: 28rpx;
font-weight: 400;
line-height: 44rpx;
margin: 22rpx 0;
text {
color: #999ea8;
}
}
}
.goods-item {
padding: 24rpx 8rpx;
box-sizing: border-box;
border-bottom:2rpx solid #EBEDF0;
.item-hd {
display: flex;
align-items: center;
.packageName {
max-width: 400rpx;
font-weight: 400;
font-size: 28rpx;
color: #292D33;
margin-left: 20rpx;
overflow: hidden;
text-overflow: ellipsis;
}
.total-price {
font-weight: 500;
font-size: 28rpx;
color: #347BFF;
margin-left: auto;
}
.icon {
display: block;
width: var(--fontSize32);
height: var(--fontSize32);
}
.icon .arc {
width: 100%;
height: 100%;
border: var(--fontSize2) solid #979797;
border-radius: 100%;
box-sizing: border-box;
}
.control {
display: flex;
align-items: center;
margin-left: auto;
}
.control .minus,
.control .add {
width: var(--fontSize44);
height: var(--fontSize44);
color: #347BFF;
background: #F7F7F7;
border-radius: var(--fontSize6);
display: flex;
align-items: center;
justify-content: center;
font-size: var(--fontSize32);
font-weight: 700;
}
.control .input {
width: var(--fontSize72);
height: var(--fontSize40);
text-align: center;
font-size: var(--fontSize28);
color: #333333;
margin: 0 var(--fontSize5);
}
}
.item-bd {
padding: 24rpx;
margin: 20px 0 8rpx 70rpx;
background: #F7F8FA;
border-radius: 8rpx;
.upgrade-item {
display: flex;
align-items: center;
margin-bottom: 16rpx;
.dot {
width: 12rpx;
height: 12rpx;
background: #347BFF;
border-radius: 100%;
}
.name {
width: 420rpx;
font-weight: 400;
font-size: 24rpx;
color: #5A5E66;
line-height: 32rpx;
margin-left: 12rpx;
margin-right: auto;
white-space: wrap;
}
.price {
font-weight: 500;
font-size: 24rpx;
color: #5A5E66;
line-height: 32rpx;
}
}
}
}
.select-text{
display: flex;
color: #888888;
font-size: 28rpx;
font-weight: 400;
text-align: center;
justify-content: center;
margin:28rpx 0;
.number{
color: #347bff;
margin:0 10rpx;
}
}
\ No newline at end of file \ No newline at end of file
<popup show="{{show}}" title="选择套餐" bindconfirm="confirm" bindcancel="cancel">
<view class="coupon-box">
<search-input bindsearch="searchGoods" />
<scroll-view class="set-meal" scroll-y>
<view class="sign-text">套餐<text>丨建议价</text></view>
<view class="goods-item" wx:for="{{goodsData}}" wx:key="{{item.packageCode}}">
<view class="item-hd">
<view
class="icon"
catchtap="choose"
data-index="{{index}}">
<block wx:if="{{item.active}}">
<image src="../images/radio.png" />
</block>
<block wx:else>
<view class="arc" />
</block>
</view>
<!-- <checkbox value="{{item.packageCode}}" active="{{item.active}}" /> -->
<view class="packageName">{{item.packageName}}</view>
<block wx:if="{{!item.active}}">
<view class="total-price">¥{{item.upgradePrice}}</view>
</block>
<view class="control" wx:else>
<view
class="minus"
catchtap="addCount"
data-count="{{-1}}"
data-index="{{index}}"
data-item="{{item}}">
-
</view>
<input
type="number"
catchtap="noScroll"
class="input"
value="{{item.count || 1}}"
catchinput="input"
data-index="{{index}}" />
<view
class="add"
catchtap="addCount"
data-count="{{1}}"
data-index="{{index}}"
data-item="{{item}}">
+
</view>
</view>
</view>
<view class="item-bd">
<view class="upgrade-item" wx:for="{{item.goodsList}}" wx:for-item='i' wx:for-index='ind'>
<view class="dot"></view>
<view class="name">{{i.upgradeGoodsName}}</view>
<view class="price">¥{{i.sellPrice}}</view>
</view>
</view>
</view>
<!-- <block wx:else>
<view class="nothing">暂无数据</view>
</block> -->
</scroll-view>
<view class="select-text">已选套餐 <view class="number">{{selectData.length}}</view> 件</view>
</view>
</popup>
\ No newline at end of file \ No newline at end of file
...@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd"; ...@@ -18,7 +18,7 @@ export const appId = "wx570d9331f9ace0bd";
* 4预发布 * 4预发布
* 5cdptest * 5cdptest
*/ */
let index = 4; let index = 0;
const accountInfo = wx.getAccountInfoSync(); const accountInfo = wx.getAccountInfoSync();
const systemInfo = wx.getSystemInfoSync(); const systemInfo = wx.getSystemInfoSync();
const envName = accountInfo.miniProgram.envVersion; const envName = accountInfo.miniProgram.envVersion;
......
...@@ -2,6 +2,10 @@ ...@@ -2,6 +2,10 @@
import api from '~/utils/request/request.js' import api from '~/utils/request/request.js'
// const api = wx.$request // const api = wx.$request
module.exports = { module.exports = {
/**根据商户号获取可选套餐商品列表 */
getGoodsList(data) {
return api.post('dj.api.smartcarlife.MerchantPackageGoods.list', data)
},
/** 工单列表 */ /** 工单列表 */
getWorkList(data) { getWorkList(data) {
let params = data || {} let params = data || {}
......
...@@ -95,6 +95,7 @@ Page({ ...@@ -95,6 +95,7 @@ Page({
type: 1, type: 1,
name: '售后' name: '售后'
}], }],
packageBox: false
}, },
remarkInput(e) { remarkInput(e) {
...@@ -299,12 +300,38 @@ Page({ ...@@ -299,12 +300,38 @@ Page({
couponName: name couponName: name
}) })
}, },
//修改套餐价格
changeMealPrice(e) {
console.log(e)
let {
goodsList
} = this.data
let {
value
} = e.detail
let {
index,
gindex,
} = e.currentTarget.dataset
let number = wx.$util.removeLeadingZerosAndEnsureNonNegative(value)
goodsList[index].goodsList[gindex].price = number
//获取套餐内商品价格
goodsList[index].price = goodsList[index].goodsList.reduce((prev, cur) => {
return Number(prev) + Number(cur.price)
}, 0)
//获取套餐内商品总价
let total = goodsList[index].price * goodsList[index].count
goodsList[index].totalPrice = wx.$util.decimal(total, 2)
this.setData({
goodsList
}, () => {
this.setGoodsTotal(goodsList)
})
},
changePrice(e) { changePrice(e) {
// orderObj.selectPayType
let { let {
orderObj orderObj,
} = this.data } = this.data
// if (orderObj.selectPayType == 0) return
let { let {
value value
} = e.detail } = e.detail
...@@ -313,41 +340,12 @@ Page({ ...@@ -313,41 +340,12 @@ Page({
item item
} = e.currentTarget.dataset } = e.currentTarget.dataset
let target = `goodsList[${index}].price` let target = `goodsList[${index}].price`
// 添加金额 开头为.自动补全
// let money
// if (key == '.' && payMoney == '') {
// money = '0.'
// } else {
// money = payMoney + key
// }
// console.log(/^(\d+\.?\d{0,2})$/.test(money), money, 'money')
// console.log(/^(\d{0,7}\.?\d{0,2})$/.test(money), money, 'money')
let number = wx.$util.removeLeadingZerosAndEnsureNonNegative(value) let number = wx.$util.removeLeadingZerosAndEnsureNonNegative(value)
// if (/^(\d{0,6}\.?\d{0,2})$/.test(money)) {
// // 此处控制的是如果没有小数点,首位不能为类似于 01、02的金额
// if (money.indexOf('.') < 0 && money != '') {
// // console.log(parseFloat(money))
// money = parseFloat(money).toString()
// }
// // 金额0不能给支付
this.setData({ this.setData({
[target]: number //价格不能低于0 [target]: number //价格不能低于0
}) })
let {
goodsList
} = this.data
this.setGoodsTotal(goodsList) this.setGoodsTotal(goodsList)
// that.setData({
// payMoney: money,
// canPay: !unPayMoneyList.includes(money)
// })
// }
// let [number, decimal] = value.split('.')
// if (decimal != undefined) {
// decimal = decimal.substring(0, 2)
// number += `.${decimal}`
// }
}, },
removeLeadingZerosAndEnsureNonNegative(inputStr) { removeLeadingZerosAndEnsureNonNegative(inputStr) {
...@@ -616,7 +614,9 @@ Page({ ...@@ -616,7 +614,9 @@ Page({
checkGoods(save, subOrderList, priceDisabled, goodsList, orderObj) { checkGoods(save, subOrderList, priceDisabled, goodsList, orderObj) {
if (save) return false if (save) return false
// if (orderObj.selectPayType != 0) { // if (orderObj.selectPayType != 0) {
let { baseConfigData } = this.data let {
baseConfigData
} = this.data
let filmArr = [] let filmArr = []
if (goodsList) { if (goodsList) {
goodsList.map(e => { goodsList.map(e => {
...@@ -1209,7 +1209,9 @@ Page({ ...@@ -1209,7 +1209,9 @@ Page({
}, },
onChangeSource(e) { onChangeSource(e) {
console.log(e); console.log(e);
const { type } = e.detail.value const {
type
} = e.detail.value
this.setData({ this.setData({
showSource: false, showSource: false,
'orderObj.customer.salesType': type 'orderObj.customer.salesType': type
...@@ -1225,24 +1227,24 @@ Page({ ...@@ -1225,24 +1227,24 @@ Page({
/** /**
* 生命周期函数--监听页面隐藏 * 生命周期函数--监听页面隐藏
*/ */
onHide: function () { }, onHide: function () {},
/** /**
* 生命周期函数--监听页面卸载 * 生命周期函数--监听页面卸载
*/ */
onUnload: function () { }, onUnload: function () {},
/** /**
* 页面相关事件处理函数--监听用户下拉动作 * 页面相关事件处理函数--监听用户下拉动作
*/ */
onPullDownRefresh: function () { }, onPullDownRefresh: function () {},
/** /**
* 页面上拉触底事件的处理函数 * 页面上拉触底事件的处理函数
*/ */
onReachBottom: function () { }, onReachBottom: function () {},
/** /**
* 用户点击右上角分享 * 用户点击右上角分享
*/ */
onShareAppMessage: function () { } onShareAppMessage: function () {}
}) })
\ No newline at end of file \ No newline at end of file
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
"customerInfo": "/components/CustomerInfo/CustomerInfo", "customerInfo": "/components/CustomerInfo/CustomerInfo",
"sub-shop-merchant" : "/components/subShopMerchant/subShopMerchant", "sub-shop-merchant" : "/components/subShopMerchant/subShopMerchant",
"van-picker": "@vant/weapp/picker/index", "van-picker": "@vant/weapp/picker/index",
"van-popup": "@vant/weapp/popup/index" "van-popup": "@vant/weapp/popup/index",
"set-meal":"/components/SetMeal/SetMeal"
} }
} }
...@@ -415,3 +415,43 @@ page { ...@@ -415,3 +415,43 @@ page {
flex-direction: column; flex-direction: column;
justify-content: space-between; justify-content: space-between;
} }
.meal-wrap{
background: #F7F8FA;
border-radius: var(--fontSize16);
margin: var(--fontSize16) var(--fontSize20);
display: flex;
flex-flow: column;
justify-content: space-between;
font-size: var(--fontSize28);
}
.meal-wrap .meal-th{
padding: var(--fontSize32) var(--fontSize24);
display: flex;
align-items:center;
border-bottom:var(--fontSize1) solid #E4E8EE;
}
.meal-wrap .meal-th .icon{
width: var(--fontSize32);
height: var(--fontSize32);
}
.meal-th .meal-name{
width: var(--fontSize394);
color: #292D33;
font-weight: 400;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
margin-right:auto;
margin-left: var(--fontSize16)
}
.meal-th .meal-price{
color: #292D33;
}
.meal-wrap .goods{
margin:0 0;
border-bottom:var(--fontSize1) solid #E4E8EE;
}
.meal-wrap :last-child{
border-bottom:none;
}
\ No newline at end of file \ No newline at end of file
...@@ -60,16 +60,16 @@ const domain_items = { ...@@ -60,16 +60,16 @@ const domain_items = {
// dj: 'http://192.168.1.104:8292', //叶立庆 // dj: 'http://192.168.1.104:8292', //叶立庆
// dj: "http://192.168.1.169:8292", //蔡远明 // dj: "http://192.168.1.169:8292", //蔡远明
// dj: 'http://192.168.1.174:8292',//范富荣 // dj: 'http://192.168.1.174:8292',//范富荣
// dj: 'http://192.168.1.88:8292', //周杭 dj: 'http://192.168.1.82:8292', //周杭
// dj: 'http://192.168.1.116:8292',//陈希 // dj: 'http://192.168.1.116:8292',//陈希
// dj: 'http://192.168.1.60:8292',//周立明 // dj: 'http://192.168.1.60:8292',//周立明
// dj: 'http://192.168.148.235:8292',// 熊正顺 // dj: 'http://192.168.148.235:8292',// 熊正顺
dj: 'http://192.168.148.221:8292', // dj: 'http://192.168.148.221:8292',
// scrm: 'http://192.168.1.165:8292' // scrm: 'http://192.168.1.165:8292'
scrm: "https://scrm.dev.glsx.com.cn", scrm: "https://scrm.dev.glsx.com.cn",
}, },
dev: { dev: {
dj: "https://dj.dev.glsx.com.cn", dj: "http://dj.dev.glsx.com.cn",
// dj: 'http://192.168.3.226:9711', // dj: 'http://192.168.3.226:9711',
scrm: "https://scrm.dev.glsx.com.cn", scrm: "https://scrm.dev.glsx.com.cn",
merchants: "http://rop-merchant.dev.glsx.com.cn", merchants: "http://rop-merchant.dev.glsx.com.cn",
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!