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 | 208 +++++++++++++++++++++++++++++++++++++++++----------
1 files changed, 166 insertions(+), 42 deletions(-)
diff --git a/wechat_staff/pages/kefu/fond.js b/wechat_staff/pages/kefu/fond.js
index 7219087..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,56 +49,170 @@
}else{
temp[index].list.push(item)
}
- });
+ })
+ this.setData({ checkAll: count === enjoyList.length })
this.setData({ enjoyList: temp })
-
-
console.log('enjoyList', temp);
},
- onReady() {
-
+ itemCheck(e){
+ 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()
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
- */
- onShow() {
-
+ 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,
+ })
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
- */
- onHide() {
-
+ 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',
+ })
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
- */
- onUnload() {
-
+ handleDown() {
+ 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: obj.id + '&' + obj.joinType,
+ type: '1',
+ // pageUrl: path,
+ imgurl: obj.coverImage,
+ }).then(res => {
+ this.setData({
+ isShowPoster: true,
+ showShare: false,
+ posterUrl: res.data
+ })
+ })
},
+ saveCard() {
+ let that = this
+ const posterUrl = this.data.posterUrl
+ wx.downloadFile({
+ url: posterUrl,
+ success: function (res) {
+ console.log('涓嬭浇鎴愬姛', res);
+ wx.saveImageToPhotosAlbum({
+ filePath: res.tempFilePath,
+ success(result) {
+ console.log(result)
+ that.setData({
+ isShowPoster: false
+ })
+ wx.showToast({
+ title: '淇濆瓨鎴愬姛',
+ icon: 'success',
+ duration: 2000
+ })
+ }
+ })
- /**
- * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
- */
- onPullDownRefresh() {
-
+ }
+ })
},
-
- /**
- * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
- */
- onReachBottom() {
-
+ batchDown() {
+ setTimeout(() => {
+ eventBus.emit('batchDown', [1,2,3])
+ }, 800)
+ wx.navigateTo({
+ url: '/pages/download/index',
+ })
},
-
- /**
- * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
- */
- onShareAppMessage() {
-
- }
+ 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() {
+ 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
+ })
+ },
+ onClose() {
+ console.log('鐐瑰嚮鍏抽棴');
+ this.setData({
+ showShare: false
+ })
+ },
})
\ No newline at end of file
--
Gitblit v1.9.3