From 076b2a90d0ddd75e4e27d3813b6143abbca25597 Mon Sep 17 00:00:00 2001
From: liukangdong <898885815@qq.com>
Date: 星期三, 24 七月 2024 17:40:09 +0800
Subject: [PATCH] Merge branch 'master' of http://139.186.142.91:10010/r/productDev/zbomyoujia
---
wechat_staff/pages/detailDis/product.js | 68 ++++++++++++++++++++++-----------
1 files changed, 45 insertions(+), 23 deletions(-)
diff --git a/wechat_staff/pages/detailDis/product.js b/wechat_staff/pages/detailDis/product.js
index 0d00d28..7458b00 100644
--- a/wechat_staff/pages/detailDis/product.js
+++ b/wechat_staff/pages/detailDis/product.js
@@ -3,6 +3,7 @@
getProductInfo,
actionDo
} from '../../api/index'
+import moment from "moment";
Page({
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
@@ -33,30 +34,57 @@
member
})
},
- handleAction(e) {
- const actionType = e.currentTarget.dataset.code
- const {
- info
- } = this.data
- actionDo({
- actionType,
- id: this.data.info.id
- }).then(res => {
- info.collection = !info.collection
- this.setData({
- info
+ // 缁勪欢浜嬩欢
+ handleEnjoy(e) {
+ const enjoyList = wx.getStorageSync('enjoyList') || []
+ const { type, flag } = e.detail
+ console.log('type', type);
+ console.log('flag', flag);
+ const info = this.data.info
+ if(type == 'enjoy'){
+ // 鐐瑰嚮浜嗗枩娆�
+ const index = enjoyList.findIndex( i => i.id === info.id )
+ if(index === -1){
+ info.isEnjoy = true
+ this.setData({ info })
+ enjoyList.push({
+ ...info,
+ joinType: 'product',
+ timestamp: new Date().getTime()
+ })
+ }else{
+ info.isEnjoy = false
+ this.setData({ info })
+ enjoyList.splice(index, 1)
+ }
+ wx.setStorageSync('enjoyList', enjoyList)
+ }else{
+ actionDo({
+ id: info.id,
+ actionType: flag ? 'collect' : 'collect_cancel'
+ }).then(res => {
+ info.isCollection = flag
+ wx.showToast({title: flag ? '鏀惰棌鎴愬姛' : '鍙栨秷鏀惰棌'})
+ this.setData({
+ info
+ })
})
- wx.showToast({
- title: actionType == 'collect' ? '鏀惰棌鎴愬姛' : '鍙栨秷鏀惰棌',
- })
- })
+ }
+ },
+ onShareAppMessage() {
+ console.log('鐢ㄦ埛鐐瑰嚮浜嗗垎浜�');
},
getDetail(id) {
+ const enjoyList = wx.getStorageSync('enjoyList') || []
getProductInfo({
id
}).then(res => {
+ const index = enjoyList.findIndex( i => i.id === res.data.id )
this.setData({
- info: res.data
+ info: {
+ ...res.data,
+ isEnjoy: index > -1
+ }
})
wx.setNavigationBarTitle({
title: res.data.title
@@ -165,10 +193,4 @@
},
- /**
- * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
- */
- onShareAppMessage() {
-
- }
})
\ No newline at end of file
--
Gitblit v1.9.3