Commit fa6b1e5d by 高淑倩

种草社区

parent aad87fe8
// component/waterFlowLayout/waterFlowLayout.js // component/waterFlowLayout/waterFlowLayout.js
var app = getApp()
const wxService = require('../../utils/wxService') const wxService = require('../../utils/wxService')
const utils = require('../../utils/util') const utils = require('../../utils/util')
...@@ -10,7 +11,7 @@ Component({ ...@@ -10,7 +11,7 @@ Component({
currentHasUserInfo: { currentHasUserInfo: {
type: Boolean, type: Boolean,
value: false, value: false,
observer(val){ observer(val) {
} }
}, },
imageData: { imageData: {
...@@ -22,25 +23,37 @@ Component({ ...@@ -22,25 +23,37 @@ Component({
value: [], value: [],
} }
}, },
attached() {
this.setData({
baseImgUrl: app.globalData.imageUrl
})
},
/** /**
* 组件的初始数据 * 组件的初始数据
*/ */
data: { data: {
// imageheight: 0 // imageheight: 0
userIsLogin : false userIsLogin: false,
baseImgUrl: '',
}, },
observers: { observers: {
'**': function (e) {
// 每次 setData 都触发
},
currentHasUserInfo(val) { currentHasUserInfo(val) {
console.log(val)
this.setData({ this.setData({
userIsLogin: val userIsLogin: val
}) })
} },
baseImgUrl(e) {
console.log('eeeee', e)
}, // this.setData({
// baseImgUrl:e
// })
},
},
/** /**
* 组件的方法列表 * 组件的方法列表
*/ */
...@@ -76,16 +89,16 @@ Component({ ...@@ -76,16 +89,16 @@ Component({
if (this.data.type == 1) { if (this.data.type == 1) {
wxService.router(`/pages/wantToBuyDetail/wantToBuyDetail?id=${e.currentTarget.dataset.id}`) wxService.router(`/pages/wantToBuyDetail/wantToBuyDetail?id=${e.currentTarget.dataset.id}`)
} else if (this.data.type == 2) { } else if (this.data.type == 2) {
if (e.currentTarget.dataset.currentType == 2){ if (e.currentTarget.dataset.currentType == 2) {
wxService.router(`/subPackage/page/pages/myReleaseDetail/myReleaseDetail?id=${e.currentTarget.dataset.id}`) wxService.router(`/subPackage/page/pages/myReleaseDetail/myReleaseDetail?id=${e.currentTarget.dataset.id}`)
} }
} }
}, },
//授權 //授權
_getUserInfo(res){ _getUserInfo(res) {
wxService.nextTick(() => { wxService.nextTick(() => {
this.triggerEvent('getAuth',res); this.triggerEvent('getAuth', res);
}) })
} }
//获取图片高度 //获取图片高度
......
<!--component/waterFlowLayout/waterFlowLayout.wxml--> <!--component/waterFlowLayout/waterFlowLayout.wxml-->
<!-- {{userIsLogin}} --> <wxs src="../../wxs/utils.wxs" module="utils" />
<view class="water-wrap {{type == 2 ? 'release-water' : ''}}">
<view class="left">
<block wx:for="{{imageData}}" wx:key="">
<template is="water-list" data="{{...item}}" wx:if="{{index%2==0}}"></template>
</block>
</view>
<view class="right">
<block wx:for="{{imageData}}" wx:key="">
<template is="water-list" data="{{...item}}" wx:if="{{index%2==1}}"></template>
</block>
</view>
</view>
<template name="water-list">
<view class="item" data-current-type="{{currentType}}" data-id="{{id}}" bindtap="gotoDetail"> <view class="water-wrap {{type == 2 ? 'release-water' : ''}}">
<view class="no-audited" wx:if="{{currentType != 2}}"> <view class="left">
{{currentType == 1 ? '待审核' : (currentType == 3 ? '已驳回' : '已通过')}} <block wx:for="{{imageData}}" wx:key="">
</view> <template is="water-list" data="{{...item}}" wx:if="{{index%2==0}}" />
<image class="item-img" src="{{url}}" data-id="{{id}}" mode="widthFix" bindload="imageLoad" bindtap="gotoDetail"></image> </block>
<view class="item-title-box" > </view>
<view class="item-title">{{headline}}</view> <view class="right">
</view> <block wx:for="{{imageData}}" wx:key="">
<view> <template is="water-list" data="{{...item}}" wx:if="{{index%2==1}}" />
</view> </block>
<!-- 未登錄時 --> </view>
<!-- <view class="share-wrap" wx:if="{{!userIsLogin}}"> </view>
<template name="water-list">
<view
class="item"
data-current-type="{{currentType}}"
data-id="{{id}}"
bindtap="gotoDetail"
>
<view class="no-audited" wx:if="{{currentType != 2}}">
{{currentType == 1 ? '待审核' : (currentType == 3 ? '已驳回' : '已通过')}}
</view>
<image
class="item-img"
src="{{utils.formateUrl(url,baseImgUrl)}}"
data-id="{{id}}"
mode="widthFix"
bindload="imageLoad"
bindtap="gotoDetail"
/>
<view class="item-title-box">
<view class="item-title">{{headline}}</view>
</view>
<view/>
<!-- 未登錄時 -->
<!-- <view class="share-wrap" wx:if="{{!userIsLogin}}">
<button wx:if="{{!userIsLogin}}" <button wx:if="{{!userIsLogin}}"
bindgetuserinfo="_getUserInfo" bindgetuserinfo="_getUserInfo"
open-type='getUserInfo' class="clear-btn"> open-type='getUserInfo' class="clear-btn">
...@@ -45,30 +56,39 @@ ...@@ -45,30 +56,39 @@
</button> </button>
</view> --> </view> -->
<view class="share-wrap" > <view class="share-wrap">
<view class="share-oprate" catchtap="onTapLike" data-id="{{id}}" data-type="{{type}}" data-current-type="{{currentType}}"> <view
<image class="share-img" src="{{type ? '/assets/imgs/heart-primary.png' : '/assets/imgs/heart-default.png'}}"></image> class="share-oprate"
<text class="share-number">{{enjoySum || 0}}</text> catchtap="onTapLike"
</view> data-id="{{id}}"
<view class="share-oprate" data-type="{{type}}"
catchtap="onTapShare" data-current-type="{{currentType}}"
data-title="{{explain}}" >
data-url="{{url}}" <image class="share-img" src="{{type ? '/assets/imgs/heart-primary.png' : '/assets/imgs/heart-default.png'}}" />
data-headline="{{headline}}" <text class="share-number">{{enjoySum || 0}}</text>
data-describe="{{describe}}" </view>
data-id="{{id}}" <view
data-current-type="{{currentType}}"> class="share-oprate"
<image class="share-img" src="/assets/imgs/share.png"></image> catchtap="onTapShare"
<text class="share-number">{{transmitSum || 0}}</text> data-title="{{explain}}"
</view> data-url="{{url}}"
</view> data-headline="{{headline}}"
<!-- 标签 --> data-describe="{{describe}}"
<view class="tabs-list {{tagsName ? 'tags-list' : ''}}"> data-id="{{id}}"
<image class="lock-image" src="/assets/imgs/7_1_0/lock.png"></image> data-current-type="{{currentType}}"
<view class="tab-item" wx:if="{{tagsName}}"> >
<image class="tab-image" src="/assets/imgs/7_1_0/tab.png"></image> <image class="share-img" src="/assets/imgs/share.png" />
<text class="tab-text">{{tagsName}}</text> <text class="share-number">{{transmitSum || 0}}</text>
</view> </view>
</view> </view>
</view> <!-- 标签 -->
<view class="tabs-list {{tagsName ? 'tags-list' : ''}}">
<image class="lock-image" src="/assets/imgs/7_1_0/lock.png" />
<view class="tab-item" wx:if="{{tagsName}}">
<image class="tab-image" src="/assets/imgs/7_1_0/tab.png" />
<text class="tab-text">{{tagsName}}</text>
</view>
</view>
</view>
</template> </template>
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
const app = getApp() const app = getApp()
const wxService = require('../../../../utils/wxService') const wxService = require('../../../../utils/wxService')
const utils = require('../../../../utils/util') const utils = require('../../../../utils/util')
const { memberId } = wx.getStorageSync('_baseUserInfo')
const envInfo = require('../../../../config/index').envInfo const envInfo = require('../../../../config/index').envInfo
wxService.page({ wxService.page({
...@@ -11,21 +10,21 @@ wxService.page({ ...@@ -11,21 +10,21 @@ wxService.page({
* 页面的初始数据 * 页面的初始数据
*/ */
data: { data: {
pics:[], pics: [],
showSelectRelatedGoods: false, showSelectRelatedGoods: false,
proGoods:[], proGoods: [],
params:{ params: {
article: "", article: "",
headline: "", headline: "",
sspList: [], sspList: [],
stcList: [], stcList: [],
userId: memberId, userId: wx.getStorageSync('_baseUserInfo') && wx.getStorageSync('_baseUserInfo').memberId || '',
tagsId:'' tagsId: ''
}, },
tabName:'', tabName: '',
video:'', video: '',
pageNo:1, pageNo: 1,
pageSize:100, pageSize: 100,
requesting: false, requesting: false,
showSelectTabModal: false showSelectTabModal: false
}, },
...@@ -35,10 +34,10 @@ wxService.page({ ...@@ -35,10 +34,10 @@ wxService.page({
*/ */
onLoad: function (options) { onLoad: function (options) {
console.log(options) console.log(options)
if(options && options.id){ if (options && options.id) {
this.setData({ this.setData({
'params.id': options.id 'params.id': options.id
},() => { }, () => {
this.getInitInfo() this.getInitInfo()
}) })
} }
...@@ -52,7 +51,7 @@ wxService.page({ ...@@ -52,7 +51,7 @@ wxService.page({
}, },
// 获取编辑详情 // 获取编辑详情
getInitInfo(){ getInitInfo() {
const { memberId } = wx.getStorageSync('_baseUserInfo') const { memberId } = wx.getStorageSync('_baseUserInfo')
let params = { let params = {
id: this.data.params.id, id: this.data.params.id,
...@@ -62,19 +61,19 @@ wxService.page({ ...@@ -62,19 +61,19 @@ wxService.page({
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
this.setData({ this.setData({
params:{ params: {
article: data.article, article: data.article,
headline: data.headline, headline: data.headline,
sspList: data.sspList, sspList: data.sspList,
userId: memberId, userId: memberId,
id:data.id id: data.id
} }
}) })
for (var i in data.sspList){ for (var i in data.sspList) {
if (data.sspList[i].url){ if (data.sspList[i].url) {
this.data.pics.push(data.sspList[i].url) this.data.pics.push(data.sspList[i].url)
} }
if (data.sspList[i].videoUrl){ if (data.sspList[i].videoUrl) {
this.setData({ this.setData({
video: data.sspList[i].videoUrl video: data.sspList[i].videoUrl
}) })
...@@ -91,9 +90,9 @@ wxService.page({ ...@@ -91,9 +90,9 @@ wxService.page({
}, },
// 获取关联商品 // 获取关联商品
getInitPro(productIds){ getInitPro(productIds) {
if (productIds && productIds.length > 0){ if (productIds && productIds.length > 0) {
wxService.post(`/sale/product/buyer/listPage?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`,{ wxService.post(`/sale/product/buyer/listPage?pageNo=${this.data.pageNo}&pageSize=${this.data.pageSize}`, {
productIds: productIds productIds: productIds
}).then(res => { }).then(res => {
const { result, data } = res.data const { result, data } = res.data
...@@ -117,18 +116,18 @@ wxService.page({ ...@@ -117,18 +116,18 @@ wxService.page({
}, },
// 关联商品 // 关联商品
handleRelatedGoods(){ handleRelatedGoods() {
console.log('关联商品') console.log('关联商品')
this.setData({ this.setData({
showSelectRelatedGoods: true showSelectRelatedGoods: true
}) })
}, },
uploadImg(){ uploadImg() {
this.chooseImg() this.chooseImg()
}, },
chooseImg(){ chooseImg() {
let that = this; let that = this;
let pics = this.data.pics ; let pics = this.data.pics;
var url = envInfo.ctx + '/merchant/upload/pic' var url = envInfo.ctx + '/merchant/upload/pic'
wx.chooseImage({ wx.chooseImage({
count: 5 - pics.length, // 最多可以选择的图片5张, count: 5 - pics.length, // 最多可以选择的图片5张,
...@@ -156,9 +155,9 @@ wxService.page({ ...@@ -156,9 +155,9 @@ wxService.page({
} }
}) })
}, },
// 关联商品 // 关联商品
_selectGoods(e){ _selectGoods(e) {
this.setData({ this.setData({
proGoods: e.detail proGoods: e.detail
}) })
...@@ -168,14 +167,14 @@ wxService.page({ ...@@ -168,14 +167,14 @@ wxService.page({
commodityId: this.data.proGoods[i].productId commodityId: this.data.proGoods[i].productId
}) })
this.setData({ this.setData({
'params.stcList': stcList 'params.stcList': stcList
}) })
} }
}, },
//关联标签 //关联标签
_selectTab(e){ _selectTab(e) {
console.log(e) console.log(e)
this.setData({ this.setData({
'params.tagsId': e.detail.id, 'params.tagsId': e.detail.id,
...@@ -184,7 +183,7 @@ wxService.page({ ...@@ -184,7 +183,7 @@ wxService.page({
}, },
// 标签选择 // 标签选择
selectTab(){ selectTab() {
this.setData({ this.setData({
showSelectTabModal: true showSelectTabModal: true
}) })
...@@ -197,46 +196,46 @@ wxService.page({ ...@@ -197,46 +196,46 @@ wxService.page({
i = data.i ? data.i : 0,//当前上传的哪张图片 i = data.i ? data.i : 0,//当前上传的哪张图片
success = data.success ? data.success : 0,//上传成功的个数 success = data.success ? data.success : 0,//上传成功的个数
fail = data.fail ? data.fail : 0;//上传失败的个数 fail = data.fail ? data.fail : 0;//上传失败的个数
wx.uploadFile({ wx.uploadFile({
url: data.url, url: data.url,
filePath: data.path[i], filePath: data.path[i],
header : { header: {
'buyer-token' : wx.getStorageSync('token') 'buyer-token': wx.getStorageSync('token')
}, },
name: 'imgs',//这里根据自己的实际情况改 name: 'imgs',//这里根据自己的实际情况改
formData: null,//这里是上传图片时一起上传的数据 formData: null,//这里是上传图片时一起上传的数据
success: (res) => { success: (res) => {
if (res.statusCode == 200){ if (res.statusCode == 200) {
var imgdata = JSON.parse(res.data); var imgdata = JSON.parse(res.data);
var img = imgdata.data[0]; var img = imgdata.data[0];
success++;//图片上传成功,图片上传成功的变量+1 success++;//图片上传成功,图片上传成功的变量+1
this.data.params.sspList.push({ this.data.params.sspList.push({
cover: 0, cover: 0,
url: envInfo.imgCtx + img.url url: envInfo.imgCtx + img.url
}); });
that.setData({ that.setData({
'params.sspList': this.data.params.sspList 'params.sspList': this.data.params.sspList
}) })
} }
}, },
fail: (res) => { fail: (res) => {
fail++;//图片上传失败,图片上传失败的变量+1 fail++;//图片上传失败,图片上传失败的变量+1
}, },
complete: (res) => { complete: (res) => {
i++; i++;
if (i == data.path.length) { //当图片传完时,停止调用 if (i == data.path.length) { //当图片传完时,停止调用
}else {//若图片还没有传完,则继续调用函数 } else {//若图片还没有传完,则继续调用函数
console.log('00000',i); console.log('00000', i);
data.i = i; data.i = i;
data.success = success; data.success = success;
data.fail = fail; data.fail = fail;
that.moreImgUpload(data); that.moreImgUpload(data);
}
} }
}) }
})
}, },
// 删除图片 // 删除图片
deleteImage(event) { deleteImage(event) {
var pics = this.data.pics var pics = this.data.pics
...@@ -256,7 +255,7 @@ wxService.page({ ...@@ -256,7 +255,7 @@ wxService.page({
}, },
// 上传视频 // 上传视频
_uploadVideo(e){ _uploadVideo(e) {
this.data.params.sspList.push({ this.data.params.sspList.push({
cover: 0, cover: 0,
videoUrl: e.detail videoUrl: e.detail
...@@ -267,40 +266,65 @@ wxService.page({ ...@@ -267,40 +266,65 @@ wxService.page({
}, },
// 删除视频 // 删除视频
_deleteVideo(e){ _deleteVideo(e) {
var sspList = this.data.params.sspList var sspList = this.data.params.sspList
for (var i in sspList){ for (var i in sspList) {
if (sspList[i].videoUrl){ if (sspList[i].videoUrl) {
console.log(i) console.log(i)
sspList.splice(i,1) sspList.splice(i, 1)
} }
} }
this.setData({ this.setData({
'params.sspList': sspList 'params.sspList': sspList
}) })
},
bindWordLimit(e) {
var keyWord = e.detail.value
this.throttle(this.queryData, null, 400, keyWord)
}, },
queryData(e) {
this.data.params.article = e // 此处打印出来的就是 用户输入的值
},
// 节流
throttle(fn, context, delay, text) {
clearTimeout(fn.timeoutId)
fn.timeoutId = setTimeout(function () {
fn.call(context, text)
}, delay)
},
// 发布笔记 // 发布笔记
formSubmit(e){ formSubmit(e) {
if (this.data.requesting){ console.log('e', this.data.requesting)
return; if (this.data.requesting) {
}
if (!this.data.params.sspList || this.data.params.sspList.length < 1) {
wx.showToast({
title: '请上传至少一张图片',
icon: 'none'
})
return; return;
} }
if (this.data.params.sspList && this.data.params.sspList[0].videoUrl && !this.data.params.sspList[1]) { // if (!this.data.params.sspList || this.data.params.sspList.length < 1) {
// wx.showToast({
// title: '请上传至少一张图片',
// icon: 'none'
// })
// return;
// }
// if (this.data.params.sspList && this.data.params.sspList[0].videoUrl && !this.data.params.sspList[1]) {
// wx.showToast({
// title: '请上传视频',
// // title: '请上传至少一张图片',
// icon: 'none'
// })
// return;
// }
const { sspList } = this.data.params
if (!sspList.length) {
wx.showToast({ wx.showToast({
title: '请上传至少一张图片', title: '请上传至少一张图片/视频',
icon: 'none' icon: 'none'
}) })
return; return;
} }
if (!e.detail.value.headline){
if (!e.detail.value.headline) {
wx.showToast({ wx.showToast({
title: '请添加标题', title: '请添加标题',
icon: 'none' icon: 'none'
...@@ -314,15 +338,26 @@ wxService.page({ ...@@ -314,15 +338,26 @@ wxService.page({
'params.article': e.detail.value.article, 'params.article': e.detail.value.article,
'params.userId': memberId 'params.userId': memberId
}) })
this.data.params.sspList.forEach((item,index) => {
if (index == 0){ var curSspList = this.data.params.sspList
var count = 0;
curSspList.forEach(item => {
if (count === 0 && item.url) {
item.cover = 1; item.cover = 1;
count++
} else {
item.cover = 0;
} }
});
this.setData({
requesting: true
}) })
this.setData({
requesting: true,
'params.sspList': curSspList
},()=>{
this.saveGrass()
})
},
saveGrass() {
wxService.post(`/merchant/contentMobileTerminal/contentSave`, this.data.params).then(res => { wxService.post(`/merchant/contentMobileTerminal/contentSave`, this.data.params).then(res => {
const { result, data } = res.data const { result, data } = res.data
if (result == 0) { if (result == 0) {
......
...@@ -27,7 +27,8 @@ wxService.page({ ...@@ -27,7 +27,8 @@ wxService.page({
contentPermission: false, contentPermission: false,
currentShareContent: null, currentShareContent: null,
scene: '', scene: '',
validContentSetExplain: '' validContentSetExplain: '',
baseImgUrl: ''
}, },
/** /**
...@@ -54,6 +55,9 @@ wxService.page({ ...@@ -54,6 +55,9 @@ wxService.page({
* 生命周期函数--监听页面显示 * 生命周期函数--监听页面显示
*/ */
onShow() { onShow() {
this.setData({
baseImgUrl: app.globalData.imageUrl
})
const { memberId, member } = wx.getStorageSync('_baseUserInfo') const { memberId, member } = wx.getStorageSync('_baseUserInfo')
const premiumExpireTime = member && member.premiumExpireTime || '' const premiumExpireTime = member && member.premiumExpireTime || ''
// ios 兼容 是不是plus vip // ios 兼容 是不是plus vip
...@@ -68,7 +72,7 @@ wxService.page({ ...@@ -68,7 +72,7 @@ wxService.page({
plus: 0 plus: 0
}) })
} }
this.getValidContentSetExplain() // 获取有效的种草配置文案 // this.getValidContentSetExplain() // 获取有效的种草配置文案
this.getBannerInfo() this.getBannerInfo()
this.getContentPermission() this.getContentPermission()
this.data.currentShareContent = null; this.data.currentShareContent = null;
......
<!--subPackage/page/pages/myRelease/myRelease.wxml--> <!--subPackage/page/pages/myRelease/myRelease.wxml-->
<view class="release-num weui-flex df-j--bt"> <view class="release-num weui-flex df-j--bt">
<view class="num-invite df-1 border_box"> <view class="num-invite df-1 border_box">
<view class="num">{{inviteSum || 0}}</view> <view class="num">{{inviteSum || 0}}</view>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment