From 480427105eb51376dbc1829419e6205aa9ea96d9 Mon Sep 17 00:00:00 2001 From: liuyongli <1598631486@qq.com> Date: Tue, 31 May 2022 09:48:43 +0800 Subject: [PATCH] 0531 --- app.js | 4 +- components/spu-preview/index.js | 7 +- components/spu-preview/index.wxml | 12 +- pages/index/index.js | 4 +- pages/index/index.wxml | 13 +- pages/index/index.wxss | 2 +- pages/index/subpage/brand/brand.wxss | 2 +- .../brand/brandDetails/brandDetails.js | 130 +++++++++++++----- .../brand/brandDetails/brandDetails.wxml | 28 ++-- .../brand/brandDetails/brandDetails.wxss | 13 +- utils/config.js | 8 +- 11 files changed, 148 insertions(+), 75 deletions(-) diff --git a/app.js b/app.js index 385af53..320ae63 100644 --- a/app.js +++ b/app.js @@ -1,5 +1,5 @@ // app.js -import {host} from "./utils/config" +import {host,cdn} from "./utils/config" App({ onLaunch() { // 展示本地存储能力 @@ -16,6 +16,6 @@ App({ }, globalData: { userInfo: null, - host + host,cdn } }) diff --git a/components/spu-preview/index.js b/components/spu-preview/index.js index 5f81ac2..4d2314f 100644 --- a/components/spu-preview/index.js +++ b/components/spu-preview/index.js @@ -24,7 +24,8 @@ Component({ * 组件的初始数据 */ data: { - tags:Array + tags:Array, + cdn:getApp().globalData.cdn, }, /** @@ -32,7 +33,9 @@ Component({ */ methods: { //跳转详情 - detail(){ + detail(e){ + console.log(e) + wx.setStorageSync('info', e.currentTarget.dataset.cycle_id) wx.navigateTo({ url:"/pages/index/subpage/brand/brandDetails/brandDetails?type=3" }) diff --git a/components/spu-preview/index.wxml b/components/spu-preview/index.wxml index 2be76d5..e4dfb06 100644 --- a/components/spu-preview/index.wxml +++ b/components/spu-preview/index.wxml @@ -1,11 +1,15 @@ - - {{data.type === 1 ? '视频' : '文章'}} + + + 视频 + 图片 + 文章 + - + - + - + + diff --git a/pages/index/index.wxss b/pages/index/index.wxss index 2a90100..bd6aa71 100644 --- a/pages/index/index.wxss +++ b/pages/index/index.wxss @@ -94,7 +94,7 @@ .brand_mes { padding: 32rpx; margin: 24rpx 32rpx 0rpx 32rpx; - height: 596rpx; + height: 600rpx; border-radius: 15rpx; background-color: white; display: flex; diff --git a/pages/index/subpage/brand/brand.wxss b/pages/index/subpage/brand/brand.wxss index 066393a..40fb71e 100644 --- a/pages/index/subpage/brand/brand.wxss +++ b/pages/index/subpage/brand/brand.wxss @@ -1,7 +1,7 @@ /* pages/index/subpage/brand/brand.wxss */ .body{ width: 100%; - height: 1000rpx; + min-height: 100vh; background-color: #F9F9F9; } .top_tip { diff --git a/pages/index/subpage/brand/brandDetails/brandDetails.js b/pages/index/subpage/brand/brandDetails/brandDetails.js index 8cb0eb9..ab0c9d9 100644 --- a/pages/index/subpage/brand/brandDetails/brandDetails.js +++ b/pages/index/subpage/brand/brandDetails/brandDetails.js @@ -1,11 +1,14 @@ // pages/quest/quest.js import {http} from '../../../../../utils/util' +// import {DownloadSaveFile,downloadFile +// } from '../../../../../utils/downloadSaveFile.js' Page({ /** * 页面的初始数据 */ data: { + cdn:getApp().globalData.cdn, type:0, // questes: [ // { @@ -69,7 +72,8 @@ Page({ records:[], questes:[], infoObject:{}, - isClick:false + isClick:false, + // imageUrl:"/pages/index/shortimage/img_xingtue@2x.png" }, back(){ @@ -90,30 +94,34 @@ to(e) { console.log(e) wx.setStorageSync('info', e.currentTarget.dataset.cycle_id) wx.navigateTo({ - url:"/pages/index/subpage/brand/brandDetails/brandDetails?type=3" + url:"/pages/index/subpage/brand/brandDetails/brandDetails" }) - }, - getcollection(){ - }, //收藏 collection(e){ + var that = this let userId = this.data.infoObject.id let referenceId = this.data.infoObject.id + // let referenceId = wx.getStorageSync('referenceId') + let isClick = this.data.isClick console.log(e) - // wx.navigateTo({ - // url:"/pages/user/subpage/newest/newest" - // }) - http("/userReference/add", "post", {userId,referenceId - }).then(res =>{ - this.setData({ - // userId:e.currentTarget.dataset.cycle_id, - // referenceId:this.id - + if(!isClick){ + that.setData({ + isClick:true }) - }) - + wx.showToast({ + title: '收藏成功', + icon: 'none' + }) + http("/userReference/add", "post", {userId,referenceId + }).then(res =>{ + this.setData({ + // userId:e.currentTarget.dataset.cycle_id, + // referenceId:this.id + }) + }) + } }, /** @@ -129,7 +137,11 @@ to(e) { infoObject:wx.getStorageSync('info') }) this.getrecordslist() - this.getcollection() + // var htmls = + //

解析

+ // var that = this + // WxParse.wxParse('htmls','html',htmls,that,5); + }, getrecordslist(){ @@ -187,32 +199,74 @@ to(e) { * 用户点击右上角分享 */ onShareAppMessage:function() { - // if (res.from === 'button') { // 来自页面内分享按钮 - // console.log(e) - // } + var that = this return { - title:this.data.infoObject.title, - path:"pages/index/subpage/brand/brandDetails/brandDetails?type=3", - imageUrl:"/pages/index/shortimage/img_xingtusi@2x.png", + title:that.data.infoObject.title, + path:"pages/index/subpage/brand/brandDetails/brandDetails", + // imageUrl:that.cdn+infoObject.cover, } }, //保存 preserve(){ - // if(type=1){ - // 视频 - wx.saveVideoToPhotosAlbum({ - filePath: 'wxfile://xxx', - success (res) { - console.log(res.errMsg) - } - }) - // }else{ - //图片 - wx.saveImageToPhotosAlbum({ - filePath:"../../../shortimage/img_xingtue@2x.png", - success(res) { } - }) + // if(){ + wx.showModal({ + title: '提示', + content: '确定要保存吗?', + success: function (res) { + if (res.confirm) { + console.log('用户点击确定') + wx.getImageInfo({ + src: '/pages/index/shortimage/img_xingtue@2x.png', + success: function (res) { + console.log(res); + var path = res.path; + wx.saveImageToPhotosAlbum({ + filePath: path, + success: function (res) { + console.log('已保存'); + }, + fail: function (res) { + console.log('保存失败'); + } + }) + } + }); + } else if (res.cancel) { + console.log('用户点击取消') + } + } + }) + // }else{ + // wx.showLoading({ + // title: '下载中...', + // }) + // wx.downloadFile({ + // //视频信息的Url + // url: app.serverUrl + me.data.videoInfo.videoPath, + // success: function (res) { + // // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容 + // if (res.statusCode === 200) { + // console.log(res.tempFilePath); + + // wx.saveVideoToPhotosAlbum({ + // filePath: res.tempFilePath, + // success:function(res) { + // console.log(res.errMsg) + // wx.hideLoading(); + // } + // }) + // } + // } + // }) + + + + // } + }, + // downloadSaveFile(e) { + // let url = e.currentTarget.dataset.url; + // // 保存到相册 + // DownloadSaveFile.downloadFile('video', url); //video或image // } - } }) \ No newline at end of file diff --git a/pages/index/subpage/brand/brandDetails/brandDetails.wxml b/pages/index/subpage/brand/brandDetails/brandDetails.wxml index 73f057f..489374b 100644 --- a/pages/index/subpage/brand/brandDetails/brandDetails.wxml +++ b/pages/index/subpage/brand/brandDetails/brandDetails.wxml @@ -1,11 +1,16 @@ - -