|
|
@@ -23,7 +23,7 @@
|
|
|
商品名称<span v-if="tabIndex == '0'">*</span>
|
|
|
</view>
|
|
|
<view class="picker">
|
|
|
- <u-input :disabled="tabIndex == 1" v-model="form.productName" placeholder="输入商品名称" />
|
|
|
+ <u-input :disabled="tabIndex == 1" v-model="form.productName" placeholder="请输入" />
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="item">
|
|
|
@@ -31,7 +31,7 @@
|
|
|
商品分类<span v-if="tabIndex == '0'">*</span>
|
|
|
</view>
|
|
|
<view class="picker" @click="selectProductType">
|
|
|
- <span v-if="showText == ''">选择商品分类</span>
|
|
|
+ <span v-if="showText == ''">请选择</span>
|
|
|
<span v-else style="color: #333333;">{{ showText }}</span>
|
|
|
<u-icon name="arrow-right"></u-icon>
|
|
|
</view>
|
|
|
@@ -47,7 +47,7 @@
|
|
|
商品分组<span v-if="tabIndex == '0'">*</span>
|
|
|
</view>
|
|
|
<view class="picker" @click="selectGrouping">
|
|
|
- <span v-if="form.groupingName == ''">选择商品分组</span>
|
|
|
+ <span v-if="form.groupingName == ''">请选择</span>
|
|
|
<span v-else style="color: #333333;">{{ form.groupingName }}</span>
|
|
|
<u-icon name="arrow-right"></u-icon>
|
|
|
</view>
|
|
|
@@ -193,7 +193,8 @@
|
|
|
商品售价<span>*</span>
|
|
|
</view>
|
|
|
<view class="picker">
|
|
|
- <u-input v-model="form.price" placeholder="请输入" />
|
|
|
+ <u-input type="number" v-model.number="form.price" placeholder="请输入"
|
|
|
+ @blur="checkPriceAndSoldPrice('price')" />
|
|
|
</view>
|
|
|
<view class="unit">
|
|
|
元
|
|
|
@@ -204,7 +205,8 @@
|
|
|
商品市场价<span v-if="tabIndex == '1'">*</span>
|
|
|
</view>
|
|
|
<view class="picker">
|
|
|
- <u-input type="num" v-model="form.soldPrice" placeholder="请输入" />
|
|
|
+ <u-input type="number" v-model.number="form.soldPrice" placeholder="请输入"
|
|
|
+ @blur="checkPriceAndSoldPrice('soldPrice')" />
|
|
|
</view>
|
|
|
<view class="unit">
|
|
|
元
|
|
|
@@ -240,19 +242,62 @@
|
|
|
每天
|
|
|
</span>
|
|
|
<span v-if="form.sellingTimeType == '2'" style="margin-left: 26rpx;">
|
|
|
- <u-button type="primary" size="mini" @click="selectSaleDate">添加时间段</u-button>
|
|
|
+ <u-button type="primary" size="mini" @click="selectSaleDate">添加时间</u-button>
|
|
|
+ </span>
|
|
|
+ </u-radio>
|
|
|
+ <u-radio @change="form.sellingTimeType = '3'" name="week" style="width: 100%;margin-top: 16rpx;">
|
|
|
+ <span>
|
|
|
+ 每周
|
|
|
</span>
|
|
|
</u-radio>
|
|
|
</u-radio-group>
|
|
|
- <uni-card v-show="form.sellingDay && form.sellingDay.length > 0" :is-shadow="false" is-full
|
|
|
- style="border:1rpx solid #E5E5E5;">
|
|
|
+ <!-- 每天售卖时间选择 -->
|
|
|
+ <uni-card v-show="form.sellingTimeType == '2' && form.sellingDay && form.sellingDay.length > 0"
|
|
|
+ :is-shadow="false" is-full style="border:1rpx solid #E5E5E5;">
|
|
|
<view v-for="item, index in form.sellingDay" :key="index"
|
|
|
style="display: flex; justify-content: space-between;">
|
|
|
<span>{{ item[0] }}</span>
|
|
|
- <span style="color: #2979ff;" @click="deleteTime(index)"><u-icon name="minus-circle-fill"
|
|
|
+ <!-- <span>{{ item[0] ? item[0] + '-' + item[1] : '' }}</span> -->
|
|
|
+ <span style="color: #dd524d;" @click="deleteTime(index)"><u-icon name="minus-circle-fill"
|
|
|
style="margin-left: 17rpx;"></u-icon></span>
|
|
|
</view>
|
|
|
</uni-card>
|
|
|
+ <view class="item_tips saletime" v-show="form.sellingTimeType == '2' && form.sellingDay.length == 0">
|
|
|
+ 请添加起止时间段
|
|
|
+ </view>
|
|
|
+ <!-- 每周售卖时间选择 -->
|
|
|
+ <uni-table v-show="form.sellingTimeType == '3'">
|
|
|
+ <!-- 表头 -->
|
|
|
+ <uni-tr class="table-header">
|
|
|
+ <uni-th width="200rpx" align="left"><u-checkbox v-model:checked="allChecked"
|
|
|
+ @change="handleAllCheckChange"></u-checkbox>工作日</uni-th>
|
|
|
+ <uni-th align="center">时间</uni-th>
|
|
|
+ <uni-th width="100rpx" align="center">操作</uni-th>
|
|
|
+ </uni-tr>
|
|
|
+ <!-- 数据行 -->
|
|
|
+ <uni-tr v-for="(item, index) in form.localProductSellingWeeks" :key="index" class="table-row">
|
|
|
+ <uni-td width="200rpx" align="left">
|
|
|
+ <u-checkbox v-model="item.checked"
|
|
|
+ @change="handleItemCheckChange($event, item, index)"></u-checkbox>{{
|
|
|
+ item.weekDay }}
|
|
|
+ </uni-td>
|
|
|
+ <uni-td align="left">
|
|
|
+ <view v-for="(date, timeIndex) in item.sellingStartTimeList" :key="timeIndex" class="item_weekTime">
|
|
|
+ <span>{{ date[0] }}</span>
|
|
|
+ <!-- <span>{{ date[0] ? date[0] + '-' + date[1] : '' }}</span> -->
|
|
|
+ <span v-show="date[0]" style="color: #dd524d;" @click="deleteWeekTime(item, timeIndex)">
|
|
|
+ <u-icon name="minus-circle-fill" style="margin-left: 17rpx;"></u-icon>
|
|
|
+ </span>
|
|
|
+ </view>
|
|
|
+ </uni-td>
|
|
|
+ <uni-td width="100rpx" align="center">
|
|
|
+ <view class="uni-group">
|
|
|
+ <span style="color: #007aff;" @click="addWeekTime(item)"><u-icon
|
|
|
+ name="plus-circle-fill"></u-icon></span>
|
|
|
+ </view>
|
|
|
+ </uni-td>
|
|
|
+ </uni-tr>
|
|
|
+ </uni-table>
|
|
|
<view>
|
|
|
</view>
|
|
|
</view>
|
|
|
@@ -282,13 +327,11 @@
|
|
|
</view>
|
|
|
</view>
|
|
|
<view class="item upload" style="border: none;">
|
|
|
- <view class="label">
|
|
|
+ <view class="label" style="margin-bottom: 8rpx;">
|
|
|
服务说明<span>*</span>
|
|
|
</view>
|
|
|
- <!-- <view class="radio-group"> -->
|
|
|
<uni-data-checkbox multiple v-model="form.serviceDescription"
|
|
|
:localdata="optionsDescription"></uni-data-checkbox>
|
|
|
- <!-- </view> -->
|
|
|
</view>
|
|
|
<!-- <view class="form" style="margin-bottom: 24rpx;">
|
|
|
<view class="titl ">
|
|
|
@@ -398,6 +441,7 @@
|
|
|
</view>
|
|
|
<rangTime ref="rangTime" :mode="mode" @onSubmit="onEndTimeChange" :title="timeTitle" />
|
|
|
<rangTime ref="rangSaleTime" :mode="mode" @onSubmit="onSaleTimeChange" :title="timeTitle" />
|
|
|
+ <rangTime ref="rangWeekTime" :mode="mode" @onSubmit="onWeekTimeChange" :title="timeTitle" />
|
|
|
<refund v-show="isRefund" :Confirm="form.refundConfirm" :Label="form.refundLabel" @confirm="saveFound"
|
|
|
@close="cutRule" />
|
|
|
<view class="popup" v-if="isSelectType">
|
|
|
@@ -461,6 +505,7 @@ export default {
|
|
|
video: '',
|
|
|
tabIndex: '0',
|
|
|
mode: 5,
|
|
|
+ allChecked: false,
|
|
|
form: {
|
|
|
instructions: '',
|
|
|
preBook: 0,
|
|
|
@@ -475,6 +520,7 @@ export default {
|
|
|
richText: '',
|
|
|
// 为"每天"选项添加单独的时间段数组
|
|
|
sellingDay: [],
|
|
|
+ localProductSellingWeeks: []
|
|
|
// categoryId:'',
|
|
|
// productName: '',
|
|
|
// productImage: '',
|
|
|
@@ -538,7 +584,45 @@ export default {
|
|
|
timeTitle: '选择售卖时间',
|
|
|
// 商品分组列表
|
|
|
showGroupPicker: false,
|
|
|
- groupOptions: []
|
|
|
+ groupOptions: [],
|
|
|
+ // 为"每周"选项添加单独的时间段数组
|
|
|
+ localProductSellingWeeks: [
|
|
|
+ {
|
|
|
+ weekDay: '周一',
|
|
|
+ sellingStartTimeList: [],
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ weekDay: '周二',
|
|
|
+ sellingStartTimeList: [],
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ weekDay: '周三',
|
|
|
+ sellingStartTimeList: [],
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ weekDay: '周四',
|
|
|
+ sellingStartTimeList: [],
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ weekDay: '周五',
|
|
|
+ sellingStartTimeList: [],
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ weekDay: '周六',
|
|
|
+ sellingStartTimeList: [],
|
|
|
+ checked: false
|
|
|
+ },
|
|
|
+ {
|
|
|
+ weekDay: '周日',
|
|
|
+ sellingStartTimeList: [],
|
|
|
+ checked: false
|
|
|
+ }
|
|
|
+ ]
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
@@ -711,7 +795,48 @@ export default {
|
|
|
uni.navigateTo({
|
|
|
url: '/pages/product/usable'
|
|
|
})
|
|
|
+ },
|
|
|
+ // 更新时间
|
|
|
+ updateRangeTime() {
|
|
|
+ uni.getStorage({
|
|
|
+ key: 'smdate',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.data.useType == 2) {
|
|
|
+ this.showSellDate = res.data.availableStartDate + '-' + res.data.availableEndDate
|
|
|
+ this.form.availableStartDate = res.data.availableStartDate
|
|
|
+ this.form.availableEndDate = res.data.availableEndDate
|
|
|
+ this.form.expirationDays = null
|
|
|
+ this.form.useType = 2
|
|
|
+ } else if (res.data.useType == 1) {
|
|
|
+ this.form.expirationDays = res.data.expirationDays
|
|
|
+ this.form.availableEndDate = null
|
|
|
+ this.form.availableStartDate = null
|
|
|
+ this.form.useType = 1
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.showSellDate = res.data.expirationDays + '天后失效'
|
|
|
+ });
|
|
|
+ } else if (res.data.useType == 3) {
|
|
|
+ this.form.useType = 3
|
|
|
+ this.showSellDate = '长期有效'
|
|
|
+ }
|
|
|
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ // 校验商品市场价必须大于商品售价
|
|
|
+ checkPriceAndSoldPrice(field) {
|
|
|
+ if ((field == 'price' && this.form.soldPrice) || (field == 'soldPrice' && this.form.price)) {
|
|
|
+ if (this.form.soldPrice <= this.form.price) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '商品市场价必须大于商品售价',
|
|
|
+ icon: 'none',
|
|
|
+ duration: 2000
|
|
|
+ });
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.form[field] = '';
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
},
|
|
|
// 保存退款规则
|
|
|
saveFound(rules) {
|
|
|
@@ -821,7 +946,7 @@ export default {
|
|
|
},
|
|
|
//获取商品分组列表
|
|
|
getProductGroup() {
|
|
|
- this.$http.get("/localProductGrouping/localProductGrouping/getList").then(res => {
|
|
|
+ this.$http.get("/localProductGrouping/localProductGrouping/getAppList?sourceType=1").then(res => {
|
|
|
if (res.data.success) {
|
|
|
this.groupOptions = res.data.result || []
|
|
|
}
|
|
|
@@ -843,11 +968,14 @@ export default {
|
|
|
this.showDate = val.startDate + '-' + val.endDate
|
|
|
this.$forceUpdate(); // 强制刷新视图
|
|
|
},
|
|
|
+ // 选择售卖时间
|
|
|
selectSaleDate() {
|
|
|
this.$refs.rangSaleTime.open()
|
|
|
},
|
|
|
onSaleTimeChange(val) {
|
|
|
if (val && val.startDate && val.endDate) {
|
|
|
+ // const timeRange = [val.startDate, val.endDate];
|
|
|
+ // this.form.sellingDay.push(timeRange)
|
|
|
const timeRange = `${val.startDate}-${val.endDate}`;
|
|
|
this.form.sellingDay.push([timeRange])
|
|
|
}
|
|
|
@@ -857,10 +985,93 @@ export default {
|
|
|
this.form.sellingDay.splice(index, 1);
|
|
|
this.$forceUpdate(); // 强制刷新视图
|
|
|
},
|
|
|
+ // 选择每周售卖时间
|
|
|
+ // 全选/全不选处理
|
|
|
+ handleAllCheckChange(e) {
|
|
|
+ const checked = e.value;
|
|
|
+ if (!checked) {
|
|
|
+ // 显示确认提示框
|
|
|
+ uni.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '取消全选将清空每周已添加的时间段,是否继续',
|
|
|
+ success: (res) => {
|
|
|
+ if (res.confirm) {
|
|
|
+ // 用户确认取消全选,清空时间段数据
|
|
|
+ this.allChecked = checked;
|
|
|
+ this.form.localProductSellingWeeks.forEach(item => {
|
|
|
+ item.checked = checked;
|
|
|
+ // 当取消全选时,清空所有时间段
|
|
|
+ if (!checked) {
|
|
|
+ item.sellingStartTimeList = [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.allChecked = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.allChecked = checked;
|
|
|
+ this.form.localProductSellingWeeks.forEach(item => {
|
|
|
+ item.checked = checked;
|
|
|
+ // 当取消全选时,清空所有时间段
|
|
|
+ if (!checked) {
|
|
|
+ item.sellingStartTimeList = [];
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 单个复选框变化处理
|
|
|
+ handleItemCheckChange(e, row) {
|
|
|
+ // 获取最新的复选框状态
|
|
|
+ const isChecked = e.value;
|
|
|
+ // 判断如果checked状态是false,清空该行的sellingStartTimeList日期
|
|
|
+ if (!isChecked) {
|
|
|
+ // 确保sellingStartTimeList是响应式的
|
|
|
+ if (!row.sellingStartTimeList) {
|
|
|
+ this.$set(row, 'sellingStartTimeList', []);
|
|
|
+ } else {
|
|
|
+ // 清空数组,保持引用
|
|
|
+ row.sellingStartTimeList.splice(0, row.sellingStartTimeList.length);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ // 每周添加时间
|
|
|
+ addWeekTime(item) {
|
|
|
+ // 判断如果当前行的checked状态是false,提示用户先勾选
|
|
|
+ if (!item.checked) {
|
|
|
+ uni.showToast({
|
|
|
+ title: '请先勾选当前行',
|
|
|
+ icon: 'none'
|
|
|
+ });
|
|
|
+ return; // 终止后续操作
|
|
|
+ }
|
|
|
+ this.addWeekDay = item.weekDay
|
|
|
+ this.$refs.rangWeekTime.open()
|
|
|
+ },
|
|
|
+ // 每周删除时间
|
|
|
+ deleteWeekTime(item, timeIndex) {
|
|
|
+ // 使用splice删除指定索引的时间段
|
|
|
+ item.sellingStartTimeList.splice(timeIndex, 1);
|
|
|
+ this.$forceUpdate(); // 强制刷新视图
|
|
|
+ },
|
|
|
+ onWeekTimeChange(val) {
|
|
|
+ if (val && val.startDate && val.endDate) {
|
|
|
+ const timeRange = `${val.startDate}-${val.endDate}`;
|
|
|
+ // const timeRange = [val.startDate, val.endDate];
|
|
|
+ this.form.localProductSellingWeeks.forEach(item => {
|
|
|
+ if (item.weekDay == this.addWeekDay) {
|
|
|
+ item.sellingStartTimeList.push([timeRange])
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ this.$forceUpdate(); // 强制刷新视图
|
|
|
+ },
|
|
|
//提交审核
|
|
|
submit() {
|
|
|
console.log(this.form)
|
|
|
this.form.specItems = this.selectProductSunItem
|
|
|
+ this.form.isApp = '1'
|
|
|
this.makeChecked ? this.form.preBook = 1 : this.form.preBook = 0
|
|
|
// if (!this.form.saleStartDate) {
|
|
|
// uni.showToast({
|
|
|
@@ -923,6 +1134,11 @@ export default {
|
|
|
});
|
|
|
return
|
|
|
} else {
|
|
|
+ if(this.form.sellingTimeType == '3') {
|
|
|
+ this.form.sellingDay = []
|
|
|
+ } else if(this.form.sellingTimeType == '2') {
|
|
|
+ this.form.localProductSellingWeeks = this.localProductSellingWeeks
|
|
|
+ }
|
|
|
if (this.productId == '') {
|
|
|
this.$http.post("/app/product/add", this.form).then(res => {
|
|
|
if (res.data.code == 200) {
|
|
|
@@ -976,7 +1192,10 @@ export default {
|
|
|
},
|
|
|
//回显数据
|
|
|
getForm() {
|
|
|
- this.$http.get("/app/product/queryById?id=" + this.productId, {}).then(res => {
|
|
|
+ this.$http.post("/app/product/queryByIdNew", {
|
|
|
+ id: this.productId,
|
|
|
+ isApp: '1'
|
|
|
+ }).then(res => {
|
|
|
if (res.data.code == 200) {
|
|
|
this.form = res.data.result
|
|
|
|
|
|
@@ -1017,6 +1236,9 @@ export default {
|
|
|
if (!res.data.result.sellingDay) {
|
|
|
this.form.sellingDay = []
|
|
|
}
|
|
|
+ if (!res.data.result.localProductSellingWeeks) {
|
|
|
+ this.form.localProductSellingWeeks = this.localProductSellingWeeks
|
|
|
+ }
|
|
|
if (!res.data.result.serviceDescription) {
|
|
|
this.form.serviceDescription = []
|
|
|
}
|
|
|
@@ -1107,9 +1329,11 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
mounted() {
|
|
|
+ this.form.localProductSellingWeeks = this.localProductSellingWeeks
|
|
|
this.getProductGroup()
|
|
|
this.getLeftTree()
|
|
|
this.getForm()
|
|
|
+ this.updateRangeTime()
|
|
|
},
|
|
|
onLoad(options) {
|
|
|
if (options.productId) {
|
|
|
@@ -1127,30 +1351,7 @@ export default {
|
|
|
that.form.merchantId = res.data.merchantId
|
|
|
}
|
|
|
})
|
|
|
- uni.getStorage({
|
|
|
- key: 'smdate',
|
|
|
- success: (res) => {
|
|
|
- if (res.data.availableEndDate) {
|
|
|
- this.showSellDate = res.data.availableStartDate + '-' + res.data.availableEndDate
|
|
|
- this.form.availableStartDate = res.data.availableStartDate
|
|
|
- this.form.availableEndDate = res.data.availableEndDate
|
|
|
- this.form.expirationDays = null
|
|
|
- this.form.useType = 2
|
|
|
- } else if (res.data.expirationDays) {
|
|
|
- this.form.expirationDays = res.data.expirationDays
|
|
|
- this.form.availableEndDate = null
|
|
|
- this.form.availableStartDate = null
|
|
|
- this.form.useType = 1
|
|
|
- this.$nextTick(() => {
|
|
|
- this.showSellDate = res.data.expirationDays + '天后失效'
|
|
|
- });
|
|
|
- } else if (res.data.useType == 3) {
|
|
|
- this.form.useType = 3
|
|
|
- this.showSellDate = '长期有效'
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- })
|
|
|
+ that.updateRangeTime()
|
|
|
uni.getStorage({
|
|
|
key: 'group',
|
|
|
success: function (res) {
|
|
|
@@ -1604,7 +1805,7 @@ export default {
|
|
|
right: 0;
|
|
|
top: 5upx;
|
|
|
|
|
|
- color: #FFFFFF;
|
|
|
+ color: #FFFFFF !important;
|
|
|
z-index: 999;
|
|
|
border-top-right-radius: 20upx;
|
|
|
border-bottom-left-radius: 20upx;
|
|
|
@@ -1623,6 +1824,10 @@ export default {
|
|
|
margin-top: -15rpx;
|
|
|
}
|
|
|
|
|
|
+.saletime {
|
|
|
+ padding-top: 10rpx;
|
|
|
+}
|
|
|
+
|
|
|
/* 添加radio样式 */
|
|
|
.radio-group {
|
|
|
display: flex;
|
|
|
@@ -1639,4 +1844,20 @@ export default {
|
|
|
::v-deep .editor-container {
|
|
|
height: 260rpx;
|
|
|
}
|
|
|
+
|
|
|
+::v-deep .uni-table-tr .checkbox {
|
|
|
+ padding: 0;
|
|
|
+ width: 30rpx;
|
|
|
+ // width: 24px; /* 可以根据需要调整宽度 */
|
|
|
+ // height: 24px; /* 保持宽高一致 */
|
|
|
+}
|
|
|
+
|
|
|
+::v-deep .uni-table-th[data-v-511e81f9] {
|
|
|
+ padding: 15rpx;
|
|
|
+}
|
|
|
+
|
|
|
+.item_weekTime {
|
|
|
+ display: flex;
|
|
|
+ justify-content: space-around;
|
|
|
+}
|
|
|
</style>
|