From 04b4bddaac0a222760113899568d20b45af701f4 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期五, 27 九月 2024 19:04:14 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
wechat_staff/pages/detailDis/product.js | 255 +++++++++++++++++++++++++++++++++++++++++++-------
1 files changed, 217 insertions(+), 38 deletions(-)
diff --git a/wechat_staff/pages/detailDis/product.js b/wechat_staff/pages/detailDis/product.js
index 8f0de89..7ffee42 100644
--- a/wechat_staff/pages/detailDis/product.js
+++ b/wechat_staff/pages/detailDis/product.js
@@ -1,13 +1,32 @@
-// pages/detailDis/product.js
+import {
+ shareContent,
+ getProductInfo,
+ actionDo,
+ refreshEnjoy
+} from '../../api/index'
+import moment from "moment";
Page({
-
/**
* 椤甸潰鐨勫垵濮嬫暟鎹�
*/
data: {
- bottomLift: 0
+ bottomLift: 0,
+ current: 0,
+ id: '',
+ info: {},
+ spaceList: [],
+ member: {},
+ showShare: false,
+ isFold: false,
+ enjoyList: []
},
-
+ onShow(){
+ console.log('onShow')
+ refreshEnjoy(this)
+ },
+ onHide() {
+ console.log('onHide')
+ },
/**
* 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍔犺浇
*/
@@ -16,54 +35,214 @@
this.setData({
bottomLift: app.bottomLift
})
+ this.getDetail(options.id)
+ actionDo({
+ actionType: 'view',
+ id: options.id
+ })
+ const member = wx.getStorageSync('member')
+ this.setData({
+ id: options.id,
+ member
+ })
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍒濇娓叉煋瀹屾垚
- */
- onReady() {
-
+
+ // 缁勪欢浜嬩欢
+ handleEnjoy(e) {
+ const info = this.data.info
+ if(info.id == null ){
+ return
+ }
+ const enjoyList = wx.getStorageSync('enjoyList') || []
+ const { type, flag } = e.detail
+ console.log('type', type);
+ console.log('flag', flag);
+ 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: '0',
+ timestamp: new Date().getTime()
+ })
+ }else{
+ info.isEnjoy = false
+ this.setData({ info })
+ enjoyList.splice(index, 1)
+ }
+ wx.setStorageSync('enjoyList', enjoyList)
+ refreshEnjoy(this)
+ }else{
+ actionDo({
+ id: info.id,
+ actionType: flag ? 'collect' : 'collect_cancel'
+ }).then(res => {
+ info.isCollection = flag
+ wx.showToast({title: flag ? '鏀惰棌鎴愬姛' : '鍙栨秷鏀惰棌', icon: 'none'})
+ this.setData({
+ info
+ })
+ wx.setStorageSync('conentCountTemp', this.data.info)
+ })
+ }
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鏄剧ず
- */
- onShow() {
-
+ priviewBanner(e) {
+ const url = e.currentTarget.dataset.url
+ const {
+ info
+ } = this.data
+ wx.previewImage({
+ urls: info.bannerImgList,
+ current: url
+ })
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰闅愯棌
- */
+ bindchange(e) {
+ this.setData({ current: e.detail.current })
+ },
+ priviewSpace(e) {
+ return
+ const url = e.currentTarget.dataset.url
+ const {
+ info
+ } = this.data
+ wx.previewImage({
+ urls: info.spaceList.map(i => i.spaceImg),
+ current: url
+ })
+ },
+ onShareAppMessage() {
+ console.log('鐢ㄦ埛鐐瑰嚮浜嗗垎浜�');
+ },
+ getDetail(id) {
+ const enjoyList = wx.getStorageSync('enjoyList') || []
+ getProductInfo({
+ id
+ }).then(res => {
+ const index = enjoyList.findIndex( i =>(res.data && i.id === res.data.id) )
+ this.setData({
+ spaceList: res.data.spaceList || [],
+ info: {
+ ...res.data,
+ isEnjoy: index > -1
+ }
+ })
+ const { info} = this.data
+ wx.setStorageSync('conentCountTemp', info)
+ wx.setNavigationBarTitle({
+ title: res.data.title
+ })
+ })
+ },
+ playVideo() {
+ wx.previewMedia({
+ sources: [{
+ url: this.data.info.video,
+ type: 'video'
+ }]
+ })
+ },
+ bannerbindload(e) {
+ const {
+ height,
+ width
+ } = e.detail
+ let activeHeight = height * 670 / width
+ this.setData({
+ bannerHeight: activeHeight
+ })
+ },
+ handleDesign() {
+ wx.navigateTo({
+ url: '/pages/design/design',
+ })
+ },
+ openShare() {
+ this.setData({
+ showShare: true
+ })
+ },
+ handleShare() {
+ console.log('鐐瑰嚮浜嗗垎浜�');
+ actionDo({
+ actionType: 'share',
+ id: this.data.info.id
+ })
+ // shareContent({id: this.data.info.id || this.data.id}).then(res => {
+ // this.setData({showShare: false})
+ // })
+ },
+ changeFold() {
+ this.setData({ isFold: !this.data.isFold })
+ },
+ // onShareAppMessage: function () {
+ // // let { productDetail, userInfo } = this.data
+ // return {
+ // title: productDetail.title,
+ // path: '/pages/index/index?id=' + productDetail.id + '&shareuserid=' + userInfo.id + '&type=0'
+ // }
+ // },
+ handleDown() {
+ let {
+ info
+ } = this.data
+ wx.showToast({
+ title: '涓嬭浇涓�',
+ icon: 'loading'
+ })
+ console.log('info.picUrls', info)
+ wx.downloadFile({
+ url: info.picUrls,
+ success(res) {
+ // console.log(res)
+ wx.saveImageToPhotosAlbum({
+ filePath: res.tempFilePath,
+ success(data) {
+ that.toSaveCaseShare()
+ wx.showToast({
+ title: '涓嬭浇鎴愬姛',
+ })
+ },
+ fail(error) {
+ console.log(error)
+ wx.showToast({
+ title: '涓嬭浇澶辫触',
+ icon: 'error'
+ })
+ }
+ })
+ },
+ fail(err) {
+ console.log(err.errMsg)
+ wx.showToast({
+ title: '涓嬭浇澶辫触',
+ icon: 'error'
+ })
+ }
+ })
+ },
onHide() {
},
-
- /**
- * 鐢熷懡鍛ㄦ湡鍑芥暟--鐩戝惉椤甸潰鍗歌浇
- */
+ goTestPage(){
+ wx.navigateTo({
+ url: '/pages/webView/index',
+ success: function(res) {
+ // 閫氳繃eventChannel鍚戣鎵撳紑椤甸潰浼犻�佹暟鎹�
+ res.eventChannel.emit('data',{link:'http://crmtest.zhibang.com:8000/core/oauth/authorize/jump?timestamp=-465385833&agent_phone_number=18055151023&bindKey=mpAddIntention&sign=cdfe13abfe2727b40eee160085c80d11'} );
+ }
+ })
+ },
onUnload() {
},
-
- /**
- * 椤甸潰鐩稿叧浜嬩欢澶勭悊鍑芥暟--鐩戝惉鐢ㄦ埛涓嬫媺鍔ㄤ綔
- */
onPullDownRefresh() {
},
-
- /**
- * 椤甸潰涓婃媺瑙﹀簳浜嬩欢鐨勫鐞嗗嚱鏁�
- */
onReachBottom() {
},
- /**
- * 鐢ㄦ埛鐐瑰嚮鍙充笂瑙掑垎浜�
- */
- onShareAppMessage() {
-
- }
})
\ No newline at end of file
--
Gitblit v1.9.3