From a75b18a4157ab486e0b51c438ac165ab3a08e3e0 Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期四, 25 七月 2024 18:10:00 +0800
Subject: [PATCH] 代码提交
---
wechat_staff/pages/kefu/fond.js | 127 +++++++++++++++++++++++++++++++++++++-----
1 files changed, 111 insertions(+), 16 deletions(-)
diff --git a/wechat_staff/pages/kefu/fond.js b/wechat_staff/pages/kefu/fond.js
index cb63da1..789e2eb 100644
--- a/wechat_staff/pages/kefu/fond.js
+++ b/wechat_staff/pages/kefu/fond.js
@@ -1,4 +1,5 @@
import moment from "moment";
+import { getContentShareImg } from '../../api/index'
Page({
/**
@@ -6,6 +7,7 @@
*/
data: {
bottomLift: 0,
+ checkAll: false,
enjoyList: []
},
@@ -17,6 +19,11 @@
this.setData({
bottomLift: app.bottomLift
})
+ let enjoyList = wx.getStorageSync('enjoyList') || []
+ enjoyList.forEach(item => {
+ item.checked = false
+ })
+ wx.setStorageSync('enjoyList', enjoyList)
this.initData()
},
@@ -26,10 +33,13 @@
enjoyList = enjoyList.sort((a,b)=>{
return b.timestamp - a.timestamp
})
+ let count = 0
enjoyList.forEach(item => {
+ if(item.checked){
+ count++
+ }
item.joinDate = moment(item.timestamp).format('YYYY骞碝M鏈圖D鏃�')
item.joinTime = moment(item.timestamp).format('HH:mm')
- item.checked = false
const index = temp.findIndex( i => i.joinDate === item.joinDate )
if(index === -1){
temp.push({
@@ -39,37 +49,69 @@
}else{
temp[index].list.push(item)
}
- });
+ })
+ this.setData({ checkAll: count === enjoyList.length })
this.setData({ enjoyList: temp })
-
-
console.log('enjoyList', temp);
},
itemCheck(e){
- const { enjoyList } = this.data
- const { index, inde } = e.currentTarget.dataset
- enjoyList[index].list[inde].check = !enjoyList[index].list[inde].check
- this.setData({ enjoyList })
+ const enjoyList = wx.getStorageSync('enjoyList') || []
+ const { id } = e.currentTarget.dataset
+ console.log(id);
+ enjoyList.forEach(item => {
+ if(item.id === id){
+ item.checked = !item.checked
+ }
+ })
+ wx.setStorageSync('enjoyList', enjoyList)
+ this.initData()
+ },
+ itemClick(e) {
+ let map = [
+ '/pages/detailDis/product',
+ '/pages/detailDis/case',
+ '/pages/detailDis/realpic',
+ '/pages/consult/detail',
+ ]
+ const { id, type } = e.currentTarget.dataset
+ wx.navigateTo({
+ url: map[type] + '?id=' + id,
+ })
+ },
+ bind() {
+ const enjoyList = wx.getStorageSync('enjoyList') || []
+ const temp = enjoyList.filter(i => i.checked)
+ if(temp.length == 0) return wx.showToast({
+ title: '璇峰厛閫夋嫨瑕佸叧鑱旂殑鍟嗗搧',icon:'none'
+ })
+ wx.navigateTo({
+ url: '/pages/kefu/select',
+ })
},
handleDown() {
- const {
- info,
- path
- } = this.data
+ const { enjoyList } = this.data
+ let obj = {}
+ enjoyList.forEach(item => {
+ item.list.forEach(ite => {
+ if(ite.checked){
+ obj = ite
+ }
+ })
+ })
+ console.log('obj', obj);
let that = this
getContentShareImg({
- articleId: path + '&' + info.id,
+ articleId: obj.id + '&' + obj.joinType,
type: '1',
// pageUrl: path,
- imgurl: info.coverImage,
+ imgurl: obj.coverImage,
}).then(res => {
this.setData({
isShowPoster: true,
showShare: false,
posterUrl: res.data
})
-
})
},
saveCard() {
@@ -108,8 +150,61 @@
closeCard() {
this.setData({ isShowPoster: false })
},
+ itemDel() {
+ let that = this
+ let ids = []
+ let { enjoyList } = this.data
+ enjoyList.forEach(item => {
+ item.list.forEach(ite => {
+ if(ite.checked){
+ ids.push(ite.id)
+ }
+ })
+ })
+ if(ids.length === 0) return wx.showToast({
+ title: '璇峰厛閫夋嫨瑕佸垹闄ょ殑浜у搧',icon: 'none'
+ })
+ wx.showModal({
+ title: '鎻愮ず',
+ content: '浣犵‘璁よ鍒犻櫎璇ヤ骇鍝佸悧',
+ success (res) {
+ if (res.confirm) {
+ let enjoyListTemp = wx.getStorageSync('enjoyList') || []
+ ids.forEach(item => {
+ const index = enjoyListTemp.findIndex(i => i.id == item)
+ console.log('index', index);
+ if(index > -1){
+ enjoyListTemp.splice(index, 1)
+ }
+ })
+ wx.setStorageSync('enjoyList', enjoyListTemp)
+ that.initData()
+ }
+ }
+ })
+
+ },
+ checkAll() {
+ let enjoyList = wx.getStorageSync('enjoyList') || []
+ enjoyList.forEach(item => {
+ item.checked = !item.checked
+ })
+ wx.setStorageSync('enjoyList', enjoyList)
+ this.initData()
+ },
openShare() {
- console.log('鐐瑰嚮鎵撳紑');
+ let count = 0
+ const { enjoyList } = this.data
+ enjoyList.forEach(item => {
+ item.list.forEach(ite => {
+ if(ite.checked){
+ count ++
+ }
+ })
+ })
+ if(count != 1) return wx.showToast({
+ title: '鏈変笖鍙兘閫夋嫨涓�涓骇鍝�',icon: 'none'
+ })
this.setData({
showShare: true
})
--
Gitblit v1.9.3