130 lines
2.4 KiB
JavaScript
130 lines
2.4 KiB
JavaScript
// pages/newFriendCircle/newFriendCircle.js
|
|
Page({
|
|
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
showAdd: true,
|
|
selectedType: '',
|
|
selectedList: [],
|
|
isPublic: '' //朋友圈是否公开
|
|
},
|
|
changepublic: function (e) {
|
|
this.setData({
|
|
isPublic: e.detail.value
|
|
})
|
|
},
|
|
selectContent: function () {
|
|
var self = this
|
|
wx.chooseMedia({
|
|
count: 9 - self.data.selectedList.length,
|
|
mediaType: ['image','video'],
|
|
sourceType: ['album', 'camera'],
|
|
success: function (res) {
|
|
console.log(res)
|
|
if (res.type == 'image') {
|
|
self.setData({
|
|
selectedType: res.type,
|
|
selectedList: self.data.selectedList.concat(res.tempFiles)
|
|
})
|
|
} else {
|
|
self.setData({
|
|
selectedType: res.type,
|
|
selectedList: self.data.selectedList.concat(res.tempFiles)
|
|
})
|
|
}
|
|
self.isShowAdd()
|
|
console.log(self.data.selectedList)
|
|
}
|
|
})
|
|
},
|
|
deletePhoto: function (e) {
|
|
var self = this
|
|
var now = e.currentTarget.dataset.idx
|
|
var result = self.data.selectedList
|
|
result.splice(now, 1)
|
|
this.setData({
|
|
selectedList: result
|
|
})
|
|
self.isShowAdd('delete')
|
|
},
|
|
isShowAdd: function (from) {
|
|
if (this.data.selectedType == 'image') {
|
|
if (this.data.selectedList.length < 9) {
|
|
this.setData({
|
|
showAdd: true
|
|
})
|
|
} else {
|
|
this.setData({
|
|
showAdd: false
|
|
})
|
|
}
|
|
} else {
|
|
if (from) {
|
|
this.setData({
|
|
showAdd: true
|
|
})
|
|
} else {
|
|
this.setData({
|
|
showAdd: false
|
|
})
|
|
}
|
|
}
|
|
},
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function (options) {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面隐藏
|
|
*/
|
|
onHide: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面卸载
|
|
*/
|
|
onUnload: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
*/
|
|
onPullDownRefresh: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 页面上拉触底事件的处理函数
|
|
*/
|
|
onReachBottom: function () {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function () {
|
|
|
|
}
|
|
}) |