2024-05-10 17:37:36 +08:00
|
|
|
|
<template>
|
|
|
|
|
<view class="page">
|
2024-07-20 18:56:42 +08:00
|
|
|
|
<u-navbar title="套餐列表" :border-bottom="false" :background="bgc" title-color='#fff' back-icon-color="#fff"
|
|
|
|
|
title-size='36' height='42'></u-navbar>
|
|
|
|
|
|
2024-07-11 18:02:47 +08:00
|
|
|
|
<view class="box" v-if="loading">
|
2024-07-20 18:56:42 +08:00
|
|
|
|
<view class="" style="width: 100%;color: #ccc;font-weight: 600;">
|
|
|
|
|
长按拖动可更改排序
|
|
|
|
|
</view>
|
|
|
|
|
<!-- <view class="box_list" v-for="(item, index) in list" :key="index" @click="btnactive(item.suitId,index)" >
|
|
|
|
|
<view :class="['boxlist', { active: tcidlist.includes(item.suitId) }]">
|
|
|
|
|
<view :class="['toptime', { activewz: tcidlist.includes(item.suitId) }]">
|
|
|
|
|
<text>{{item.name.length > 5 ? item.name.substring(0,4) + '...' : item.name}}(通电时长:{{item.value}} <text v-if="item.timeUnit == 1">日</text> <text
|
|
|
|
|
v-if="item.timeUnit == 2">时</text> <text v-if="item.timeUnit == 3">分钟</text> <text
|
|
|
|
|
v-if="item.timeUnit == 4">秒</text> )</text> <text>¥{{item.price}}</text>
|
|
|
|
|
</view>
|
|
|
|
|
<view class="ccc">
|
|
|
|
|
<view class="bumday" v-if="item.description == null">
|
|
|
|
|
<text class="shi"></text></text>
|
2024-05-10 17:37:36 +08:00
|
|
|
|
</view>
|
2024-07-20 18:56:42 +08:00
|
|
|
|
<view class="bumday" v-else>
|
|
|
|
|
<text
|
|
|
|
|
:class="['shi', { activewz: tcidlist.includes(item.suitId) }]">{{item.description.length > 20 ? item.description.substring(0, 20) + '...' : item.description}}</text></text>
|
2024-05-10 17:37:36 +08:00
|
|
|
|
</view>
|
2024-07-20 18:56:42 +08:00
|
|
|
|
</view>
|
2024-05-10 17:37:36 +08:00
|
|
|
|
</view>
|
2024-07-20 18:56:42 +08:00
|
|
|
|
</view> -->
|
2024-07-22 18:03:27 +08:00
|
|
|
|
|
|
|
|
|
<HM-dragSorts ref="dragSorts" :list="newobj" :tcidlist="tcidlist"
|
|
|
|
|
@update:tcidlist="handleTcidlistUpdate" :autoScroll="true" :feedbackGenerator="false"
|
|
|
|
|
@newList="handleNewList" rowHeight='50' @change="change" @confirm="confirm" @onclick="onclick"
|
|
|
|
|
:listBackgroundColor='F7FAFE'></HM-dragSorts>
|
|
|
|
|
|
2024-08-03 18:03:02 +08:00
|
|
|
|
<view class="" v-if="newobj == ''"
|
2024-07-20 18:56:42 +08:00
|
|
|
|
style="color: #ccc;font-size: 36rpx;margin-top: 200rpx;text-align: center;">
|
2024-08-03 18:03:02 +08:00
|
|
|
|
暂无可用套餐
|
2024-05-10 17:37:36 +08:00
|
|
|
|
</view>
|
2024-07-20 18:56:42 +08:00
|
|
|
|
<view class="anniu">
|
|
|
|
|
<!-- <view class="xinz" @click="btnadd">
|
|
|
|
|
新建套餐
|
|
|
|
|
</view> -->
|
|
|
|
|
<view class="xinz" @click="btnqd">
|
|
|
|
|
确定
|
|
|
|
|
</view>
|
2024-05-10 17:37:36 +08:00
|
|
|
|
</view>
|
|
|
|
|
</view>
|
2024-08-02 18:00:50 +08:00
|
|
|
|
<view v-if="btnmsk" style="width: 100%;height: 100vh;position: fixed;top: 0;left: 0;background-color: #000;opacity: .1;z-index: 999;"></view>
|
2024-07-22 18:03:27 +08:00
|
|
|
|
|
2024-05-10 17:37:36 +08:00
|
|
|
|
</view>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
<script>
|
2024-07-20 18:56:42 +08:00
|
|
|
|
import dragSorts from '@/page_fenbao/HM-dragSorts/HM-dragSorts.vue'
|
2024-05-10 17:37:36 +08:00
|
|
|
|
export default {
|
2024-07-20 18:56:42 +08:00
|
|
|
|
components: {
|
|
|
|
|
'HM-dragSorts': dragSorts
|
|
|
|
|
},
|
2024-05-10 17:37:36 +08:00
|
|
|
|
data() {
|
|
|
|
|
return {
|
2024-08-02 18:00:50 +08:00
|
|
|
|
btnmsk:false,
|
2024-07-20 18:56:42 +08:00
|
|
|
|
list: '',
|
|
|
|
|
loading: false,
|
2024-05-10 17:37:36 +08:00
|
|
|
|
disabled: false,
|
|
|
|
|
btnWidth: 180,
|
|
|
|
|
show: false,
|
|
|
|
|
options: [{
|
|
|
|
|
text: '删除',
|
|
|
|
|
style: {
|
|
|
|
|
backgroundColor: '#dd524d'
|
|
|
|
|
}
|
|
|
|
|
}],
|
2024-07-20 18:56:42 +08:00
|
|
|
|
deviceId: '',
|
2024-06-04 14:50:30 +08:00
|
|
|
|
bgc: {
|
|
|
|
|
backgroundColor: "#8883f0",
|
|
|
|
|
},
|
2024-07-20 18:56:42 +08:00
|
|
|
|
activeid: '',
|
|
|
|
|
checkboxes: [],
|
|
|
|
|
tcidlist: [],
|
|
|
|
|
titaoc: [],
|
2024-07-22 18:03:27 +08:00
|
|
|
|
newobj: []
|
2024-05-10 17:37:36 +08:00
|
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
onLoad(option) {
|
|
|
|
|
this.deviceId = option.id
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
// 初始化checkboxes数组,每个元素都设为false(表示初始时不显示复选框)
|
|
|
|
|
this.checkboxes = new Array(this.list.length).fill(false);
|
2024-05-10 17:37:36 +08:00
|
|
|
|
},
|
|
|
|
|
onShow() {
|
2024-07-20 18:56:42 +08:00
|
|
|
|
this.tcidlist = []
|
2024-05-10 17:37:36 +08:00
|
|
|
|
this.getlist()
|
2024-07-22 18:03:27 +08:00
|
|
|
|
|
2024-05-10 17:37:36 +08:00
|
|
|
|
},
|
2024-07-17 17:59:51 +08:00
|
|
|
|
// 分享到好友(会话)
|
2024-07-20 18:56:42 +08:00
|
|
|
|
onShareAppMessage: function() {
|
|
|
|
|
return {
|
|
|
|
|
title: '创想物联',
|
|
|
|
|
path: '/pages/shouye/index'
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 分享到朋友圈
|
|
|
|
|
onShareTimeline: function() {
|
|
|
|
|
return {
|
|
|
|
|
title: '创想物联',
|
|
|
|
|
query: '',
|
|
|
|
|
path: '/pages/shouye/index'
|
|
|
|
|
}
|
|
|
|
|
},
|
2024-05-10 17:37:36 +08:00
|
|
|
|
methods: {
|
2024-07-22 18:03:27 +08:00
|
|
|
|
handleTcidlistUpdate(newTcidlist) {
|
|
|
|
|
// 这里是处理接收到的新 tcidlist 的地方
|
2024-07-29 18:03:40 +08:00
|
|
|
|
// console.log('接收到的 tcidlist:', newTcidlist);
|
2024-07-22 18:03:27 +08:00
|
|
|
|
this.tcidlist = newTcidlist
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
2024-07-20 18:56:42 +08:00
|
|
|
|
handleNewList(newList) {
|
2024-07-22 18:03:27 +08:00
|
|
|
|
let list = [this.list, ...newList]
|
|
|
|
|
const newSortedList = list.map((item, index) => {
|
|
|
|
|
return {
|
|
|
|
|
suitId: item.suitId,
|
|
|
|
|
sort: index + 1 // 使用索引值加 1 作为 groupSort
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
let filteredArr = newSortedList.filter(item => item.suitId !== undefined)
|
2024-07-29 18:03:40 +08:00
|
|
|
|
// console.log("新的排列数据:", filteredArr)
|
2024-07-22 18:03:27 +08:00
|
|
|
|
setTimeout(() => {
|
|
|
|
|
this.$u.put("/app/suit/sort", filteredArr).then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
// this.getgroup()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}, 200)
|
2024-07-20 18:56:42 +08:00
|
|
|
|
},
|
2024-07-22 18:03:27 +08:00
|
|
|
|
change() {
|
|
|
|
|
|
2024-07-20 18:56:42 +08:00
|
|
|
|
},
|
|
|
|
|
confirm(e) {
|
2024-07-22 18:03:27 +08:00
|
|
|
|
|
2024-07-20 18:56:42 +08:00
|
|
|
|
},
|
|
|
|
|
onclick(e) {
|
2024-07-22 18:03:27 +08:00
|
|
|
|
|
2024-07-20 18:56:42 +08:00
|
|
|
|
},
|
2024-07-22 18:03:27 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-07-20 18:56:42 +08:00
|
|
|
|
// 查询本人套餐
|
|
|
|
|
getao() {
|
|
|
|
|
this.$u.get(`/app/suit/listByDeviceId/${this.deviceId}`).then(res => {
|
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
if (res.data.length > 0) {
|
|
|
|
|
this.titaoc = res.data
|
2024-07-29 18:03:40 +08:00
|
|
|
|
let uniqueSuitIds = new Set()
|
2024-07-22 18:03:27 +08:00
|
|
|
|
this.list.forEach(item => {
|
|
|
|
|
if (this.titaoc.some(titaocItem => titaocItem.sourceId === item.suitId || titaocItem.suitId === item.suitId)) {
|
2024-07-29 18:03:40 +08:00
|
|
|
|
uniqueSuitIds.add(item.suitId)
|
2024-07-22 18:03:27 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
2024-07-29 18:03:40 +08:00
|
|
|
|
this.tcidlist = Array.from(uniqueSuitIds)
|
2024-07-22 18:03:27 +08:00
|
|
|
|
let matchedItems = this.list.filter(item => uniqueSuitIds.has(item.suitId))
|
|
|
|
|
let unmatchedItems = this.list.filter(item => !uniqueSuitIds.has(item.suitId))
|
|
|
|
|
this.list = matchedItems.concat(unmatchedItems)
|
|
|
|
|
this.newobj = this.list
|
|
|
|
|
}else{
|
2024-07-20 18:56:42 +08:00
|
|
|
|
this.newobj = this.list
|
2024-08-03 18:03:02 +08:00
|
|
|
|
if(this.newobj.length == 0){
|
|
|
|
|
uni.showModal({
|
|
|
|
|
title: '提示',
|
|
|
|
|
content: '未存有套餐,是否去新建?',
|
|
|
|
|
success: function(res) {
|
|
|
|
|
if (res.confirm) {
|
|
|
|
|
uni.navigateTo({
|
|
|
|
|
url:'/page_fenbao/statulist/taocanlist/addtaocan/index'
|
|
|
|
|
})
|
|
|
|
|
} else if (res.cancel) {
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-07-22 18:03:27 +08:00
|
|
|
|
this.tcidlist = []
|
2024-07-20 18:56:42 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-07-22 18:03:27 +08:00
|
|
|
|
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
btnactive(id, index) {
|
|
|
|
|
const indexInTcidList = this.tcidlist.indexOf(id);
|
|
|
|
|
if (indexInTcidList !== -1) {
|
|
|
|
|
this.tcidlist.splice(indexInTcidList, 1);
|
|
|
|
|
} else {
|
|
|
|
|
this.tcidlist.push(id);
|
|
|
|
|
}
|
|
|
|
|
// console.log(this.tcidlist);
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// 点击确定
|
|
|
|
|
btnqd() {
|
2024-08-02 18:00:50 +08:00
|
|
|
|
this.btnmsk = true
|
2024-07-22 18:03:27 +08:00
|
|
|
|
this.$u.delete(`/app/suit/delByDevice/${this.deviceId}`).then(res => {})
|
2024-07-20 18:56:42 +08:00
|
|
|
|
let numArr = this.tcidlist.map(item => parseInt(item, 10))
|
|
|
|
|
let data = {
|
|
|
|
|
deviceId: this.deviceId,
|
|
|
|
|
suitIds: numArr
|
|
|
|
|
}
|
2024-07-31 18:01:34 +08:00
|
|
|
|
this.$u.put(`/app/device`, data).then((res) => {
|
2024-07-20 18:56:42 +08:00
|
|
|
|
if (res.code == 200) {
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: res.msg,
|
|
|
|
|
icon: 'success',
|
|
|
|
|
duration: 1000,
|
|
|
|
|
})
|
|
|
|
|
this.getao()
|
|
|
|
|
setTimeout(() => {
|
2024-08-02 18:00:50 +08:00
|
|
|
|
this.btnmsk = false
|
2024-07-20 18:56:42 +08:00
|
|
|
|
uni.navigateBack()
|
|
|
|
|
}, 1000)
|
2024-08-02 18:00:50 +08:00
|
|
|
|
}else{
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: res.msg,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1000,
|
|
|
|
|
})
|
|
|
|
|
this.btnmsk = false
|
2024-07-20 18:56:42 +08:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getlist() {
|
|
|
|
|
let data = {
|
|
|
|
|
pageNum: 1,
|
|
|
|
|
pageSize: 99
|
|
|
|
|
}
|
|
|
|
|
this.$u.get(`/app/suit/tempList`, data).then((res) => {
|
2024-05-10 17:37:36 +08:00
|
|
|
|
if (res.code == 200) {
|
2024-07-20 18:56:42 +08:00
|
|
|
|
this.getao()
|
|
|
|
|
this.list = res.rows
|
|
|
|
|
this.list = this.list.map(item => ({
|
|
|
|
|
...item,
|
2024-07-22 18:03:27 +08:00
|
|
|
|
tcidlist: this.tcidlist
|
2024-07-20 18:56:42 +08:00
|
|
|
|
}))
|
|
|
|
|
// console.log(this.list);
|
2024-07-11 18:02:47 +08:00
|
|
|
|
this.loading = true
|
2024-05-10 17:37:36 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
btnedit(item) {
|
2024-05-10 17:37:36 +08:00
|
|
|
|
uni.navigateTo({
|
2024-07-20 18:56:42 +08:00
|
|
|
|
url: '/page_fenbao/statulist/taocanlist/addtaocan/index?id=' + this.deviceId + '&suitId=' +
|
|
|
|
|
item.suitId
|
2024-05-10 17:37:36 +08:00
|
|
|
|
})
|
|
|
|
|
},
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
click(item) {
|
2024-05-10 17:37:36 +08:00
|
|
|
|
this.$u.delete(`/app/suit/${item.suitId}`).then((res) => {
|
|
|
|
|
if (res.code == 200) {
|
2024-07-20 18:56:42 +08:00
|
|
|
|
this.$u.toast(`删除成功`);
|
2024-05-10 17:37:36 +08:00
|
|
|
|
this.getlist()
|
2024-07-20 18:56:42 +08:00
|
|
|
|
} else {
|
2024-06-14 20:22:07 +08:00
|
|
|
|
uni.showToast({
|
|
|
|
|
title: res.msg,
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1000,
|
|
|
|
|
})
|
2024-05-10 17:37:36 +08:00
|
|
|
|
}
|
|
|
|
|
});
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
2024-05-10 17:37:36 +08:00
|
|
|
|
},
|
|
|
|
|
open(index) {
|
2024-06-04 14:50:30 +08:00
|
|
|
|
this.list[index].show = true
|
2024-05-10 17:37:36 +08:00
|
|
|
|
this.list.map((val, idx) => {
|
|
|
|
|
if (index != idx) this.list[idx].show = false;
|
|
|
|
|
})
|
|
|
|
|
},
|
2024-07-20 18:56:42 +08:00
|
|
|
|
btnadd() {
|
2024-05-10 17:37:36 +08:00
|
|
|
|
uni.navigateTo({
|
2024-07-20 18:56:42 +08:00
|
|
|
|
url: '/page_fenbao/statulist/taocanlist/addtaocan/index?id=' + ''
|
2024-05-10 17:37:36 +08:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<style lang="scss">
|
2024-07-20 18:56:42 +08:00
|
|
|
|
// /deep/ .u-title {
|
|
|
|
|
// padding-bottom: 22rpx;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// /deep/ .u-icon__icon {
|
|
|
|
|
// padding-bottom: 22rpx;
|
|
|
|
|
// }
|
|
|
|
|
.active {
|
|
|
|
|
background-color: #8883F0 !important;
|
|
|
|
|
border-radius: 20rpx;
|
2024-05-24 16:48:42 +08:00
|
|
|
|
}
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
.activewz {
|
|
|
|
|
color: #fff !important;
|
2024-05-24 16:48:42 +08:00
|
|
|
|
}
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
2024-05-10 17:37:36 +08:00
|
|
|
|
page {
|
2024-06-04 14:50:30 +08:00
|
|
|
|
background: #F4F5F7;
|
2024-05-10 17:37:36 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.page {
|
|
|
|
|
width: 750rpx;
|
2024-07-31 18:01:34 +08:00
|
|
|
|
padding-bottom: 200rpx;
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
2024-05-10 17:37:36 +08:00
|
|
|
|
.box {
|
|
|
|
|
width: 750rpx;
|
2024-07-20 18:56:42 +08:00
|
|
|
|
height: 100%;
|
2024-05-10 17:37:36 +08:00
|
|
|
|
background: #F4F5F7;
|
|
|
|
|
border-radius: 0rpx 0rpx 0rpx 0rpx;
|
|
|
|
|
padding: 50rpx;
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
.box_list {
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
margin-top: 20rpx;
|
|
|
|
|
border-radius: 20rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.anniu {
|
|
|
|
|
position: fixed;
|
|
|
|
|
bottom: 0;
|
|
|
|
|
left: 50%;
|
|
|
|
|
transform: translateX(-50%);
|
|
|
|
|
display: flex;
|
|
|
|
|
height: 200rpx;
|
|
|
|
|
padding-top: 40rpx;
|
|
|
|
|
background-color: #fff;
|
|
|
|
|
// justify-content: space-between;
|
|
|
|
|
width: 100%;
|
|
|
|
|
padding-left: 50rpx;
|
|
|
|
|
padding-right: 50rpx;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.xinz {
|
|
|
|
|
width: 100%;
|
2024-05-10 17:37:36 +08:00
|
|
|
|
height: 84rpx;
|
|
|
|
|
background: #8883F0;
|
|
|
|
|
filter: blur(0px);
|
|
|
|
|
text-align: center;
|
|
|
|
|
line-height: 84rpx;
|
|
|
|
|
font-size: 36rpx;
|
2024-07-20 18:56:42 +08:00
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
border-radius: 18rpx;
|
2024-05-10 17:37:36 +08:00
|
|
|
|
}
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
.boxlist {
|
2024-05-10 17:37:36 +08:00
|
|
|
|
padding: 40rpx 42rpx;
|
|
|
|
|
box-sizing: border-box;
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
.ccc {
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.toptime {
|
2024-05-10 17:37:36 +08:00
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
color: #000000;
|
|
|
|
|
display: flex;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
}
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
.bumday {
|
2024-05-10 17:37:36 +08:00
|
|
|
|
margin-top: 10rpx;
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
|
|
|
|
text {
|
2024-05-10 17:37:36 +08:00
|
|
|
|
font-size: 32rpx;
|
|
|
|
|
color: #95989D;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-07-20 18:56:42 +08:00
|
|
|
|
|
2024-05-10 17:37:36 +08:00
|
|
|
|
/deep/ .u-swipe-action {
|
|
|
|
|
margin-top: 30rpx;
|
|
|
|
|
border-radius: 20rpx;
|
|
|
|
|
width: 654rpx;
|
|
|
|
|
height: 182rpx;
|
|
|
|
|
background: #FFFFFF;
|
|
|
|
|
box-shadow: 0rpx 16rpx 40rpx 0rpx rgba(42, 130, 228, 0.1);
|
|
|
|
|
filter: blur(0px);
|
|
|
|
|
border: 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/deep/ .u-swipe-del {
|
|
|
|
|
height: 190rpx;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
</style>
|