栏目列表,栏目内容发布,页面接口对接
3
app.js
@ -31,6 +31,7 @@ App({
|
||||
})
|
||||
},
|
||||
globalData: {
|
||||
userInfo: {}
|
||||
userInfo: {},
|
||||
token: 'T3hrM2Y1eFB5eERaNXQ2bDdxZ3Y4elZVQnl6U3FWdlNBT3dGUENFNlNObjA5MWpTMW1CMG1iaSsvZmxGcERlMzV5RWw5TnplZjVIbmVQRTQ5SkVnWFF3YjdvWnVaRHhrL2l5TUNGWmFZcnJZVzI5UEhJdFVzdG55b3RLOTdKTzhmeFZvZ1hTd29qbnlYeWVSMURiTmpNNGJDOTFVbDVsMk5Ed3FiREh2QnpCN0RRSTM3eVViN2NvK1VQbzZiMXQyL1VodDhPaUwrd2pSU3RTWWFiYWlCbFQ4blZoRHo2c3BObFRaY1pTMjR3cW5VLzl6SEswemNoS0V2SGNLMXJiU2QrdGxOajJXeWtqYWEwbDhOTzRod00xQTdWNUxFOU9Wd1FkUWJwSHoramFPdUJ0MG9UbEJocFUzTkZiUy83Q2xaL2RVSXhLYnNMNGZhYm5DZ1VXOUtVUVVQR2FMQjFqaCs0NVowVDJrMFpjUFdpK0dZb0JKVWxTOCswamVXbkZQUWk5Vi9hQ0h3ci93QzJpVDA1aEt2ZlM1NWlPOW5MTGFNdmhLZDM4K0lscC9jejR2c29ON1dLeXhSbXF3QVNtNQ=='
|
||||
},
|
||||
})
|
117
app.json
@ -1,59 +1,64 @@
|
||||
{
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/mine/index/index"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "dark",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "名片",
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationStyle": "custom"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#8F8F8F",
|
||||
"selectedColor": "#1296db",
|
||||
"borderStyle": "black",
|
||||
"list": [{
|
||||
"text": "首页",
|
||||
"pagePath": "pages/index/index",
|
||||
"iconPath": "images/ic_card_normal.png",
|
||||
"selectedIconPath": "images/ic_card_sel.png"
|
||||
},
|
||||
{
|
||||
"text": "我的",
|
||||
"pagePath": "pages/mine/index/index",
|
||||
"iconPath": "images/ic_mine_normal.png",
|
||||
"selectedIconPath": "images/ic_mine_sel.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"usingComponents": {
|
||||
"cu-custom": "/components/cuicustom/cu-custom",
|
||||
"customcart": "/components/cartfoot/customcart",
|
||||
"van-tabbar": "/vant/dist/tabbar/index",
|
||||
"van-tabbar-item": "/vant/dist/tabbar-item/index",
|
||||
"van-swipe-cell": "/vant/dist/swipe-cell/index",
|
||||
"van-cell-group": "/vant/dist/cell-group/index",
|
||||
"van-cell": "/vant/dist/cell/index",
|
||||
"van-empty": "/vant/dist/empty/index",
|
||||
"van-action-sheet": "/vant/dist/action-sheet/index",
|
||||
"van-submit-bar": "/vant/dist/submit-bar/index",
|
||||
"van-stepper": "/vant/dist/stepper/index",
|
||||
"van-image": "/vant/dist/image/index",
|
||||
"van-loading": "/vant/dist/loading/index"
|
||||
},
|
||||
"plugins": {
|
||||
"chooseLocation": {
|
||||
"version": "1.0.6",
|
||||
"provider": "wx76a9a06e5b4e693e"
|
||||
"pages": [
|
||||
"pages/index/index",
|
||||
"pages/mine/index/index",
|
||||
"pages/moments/publish/momentpublish",
|
||||
"pages/moments/edit/momentedit",
|
||||
"pages/moments/list/momentslist",
|
||||
"pages/moments/publish/momentpublishline"
|
||||
],
|
||||
"window": {
|
||||
"backgroundTextStyle": "dark",
|
||||
"navigationBarBackgroundColor": "#fff",
|
||||
"navigationBarTitleText": "名片",
|
||||
"navigationBarTextStyle": "black",
|
||||
"navigationStyle": "custom"
|
||||
},
|
||||
"tabBar": {
|
||||
"color": "#8F8F8F",
|
||||
"selectedColor": "#1296db",
|
||||
"borderStyle": "black",
|
||||
"list": [
|
||||
{
|
||||
"text": "首页",
|
||||
"pagePath": "pages/index/index",
|
||||
"iconPath": "images/ic_card_normal.png",
|
||||
"selectedIconPath": "images/ic_card_sel.png"
|
||||
},
|
||||
{
|
||||
"text": "我的",
|
||||
"pagePath": "pages/mine/index/index",
|
||||
"iconPath": "images/ic_mine_normal.png",
|
||||
"selectedIconPath": "images/ic_mine_sel.png"
|
||||
}
|
||||
]
|
||||
},
|
||||
"style": "v2",
|
||||
"sitemapLocation": "sitemap.json",
|
||||
"usingComponents": {
|
||||
"cu-custom": "/components/cuicustom/cu-custom",
|
||||
"customcart": "/components/cartfoot/customcart",
|
||||
"van-tabbar": "/vant/dist/tabbar/index",
|
||||
"van-tabbar-item": "/vant/dist/tabbar-item/index",
|
||||
"van-swipe-cell": "/vant/dist/swipe-cell/index",
|
||||
"van-cell-group": "/vant/dist/cell-group/index",
|
||||
"van-cell": "/vant/dist/cell/index",
|
||||
"van-empty": "/vant/dist/empty/index",
|
||||
"van-action-sheet": "/vant/dist/action-sheet/index",
|
||||
"van-submit-bar": "/vant/dist/submit-bar/index",
|
||||
"van-stepper": "/vant/dist/stepper/index",
|
||||
"van-image": "/vant/dist/image/index",
|
||||
"van-loading": "/vant/dist/loading/index"
|
||||
},
|
||||
"plugins": {
|
||||
"chooseLocation": {
|
||||
"version": "1.0.6",
|
||||
"provider": "wx76a9a06e5b4e693e"
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "你的位置信息将用于小程序定位"
|
||||
}
|
||||
}
|
||||
},
|
||||
"permission": {
|
||||
"scope.userLocation": {
|
||||
"desc": "你的位置信息将用于小程序定位"
|
||||
}
|
||||
}
|
||||
}
|
@ -2415,7 +2415,6 @@ button.icon.lg {
|
||||
|
||||
.cu-form-group {
|
||||
background-color: var(--white);
|
||||
padding: 1rpx 20rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-height: 100rpx;
|
||||
@ -3008,6 +3007,10 @@ scroll-view.cu-steps .cu-item {
|
||||
align-self: flex-center;
|
||||
}
|
||||
|
||||
.selfcenter {
|
||||
align-self: center;
|
||||
}
|
||||
|
||||
.self-end {
|
||||
align-self: flex-end;
|
||||
}
|
||||
@ -4125,6 +4128,29 @@ l .text-depblack {
|
||||
padding: 10rpx 0rpx;
|
||||
}
|
||||
|
||||
.play-box-arrow-flex {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
position: absolute;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.play-box-arrow-pos {
|
||||
top: 40rpx;
|
||||
left: 40rpx;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.shadow-box {
|
||||
width: 100%;
|
||||
border-radius: 10rpx;
|
||||
border: 1rpx solid #f5f5f5;
|
||||
}
|
||||
|
||||
.border-blue-radius {
|
||||
border-radius: 20rpx;
|
||||
border: 1rpx solid #0054bd;
|
||||
@ -4166,7 +4192,7 @@ l .text-depblack {
|
||||
}
|
||||
|
||||
.line-gray-ssm {
|
||||
background-color: #cecece;
|
||||
background-color: #eee;
|
||||
height: 2rpx;
|
||||
}
|
||||
|
||||
|
BIN
images/ic_arrow_down.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
images/ic_arrow_up.png
Normal file
After Width: | Height: | Size: 1.0 KiB |
BIN
images/ic_audio_play.png
Normal file
After Width: | Height: | Size: 2.4 KiB |
BIN
images/ic_audio_playing.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
BIN
images/ic_audio_rewind.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
images/ic_audio_speed.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
images/ic_empty_desc.png
Normal file
After Width: | Height: | Size: 113 KiB |
BIN
images/ic_empty_map.png
Normal file
After Width: | Height: | Size: 120 KiB |
BIN
images/ic_empty_text.png
Normal file
After Width: | Height: | Size: 105 KiB |
BIN
images/ic_empty_voice.png
Normal file
After Width: | Height: | Size: 103 KiB |
BIN
images/ic_record_start.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
images/ic_squareness_del.png
Normal file
After Width: | Height: | Size: 1023 B |
BIN
images/ic_temp.png
Normal file
After Width: | Height: | Size: 41 KiB |
BIN
images/ic_video_play.png
Normal file
After Width: | Height: | Size: 808 B |
BIN
images/ic_voice_record.gif
Normal file
After Width: | Height: | Size: 97 KiB |
BIN
images/title-bg.png
Normal file
After Width: | Height: | Size: 2.0 KiB |
22
pages/common/webpage/webpage.js
Normal file
@ -0,0 +1,22 @@
|
||||
// pages/common/webpage.js
|
||||
const app = getApp()
|
||||
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
url: ''
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.setData({
|
||||
url: options.url
|
||||
})
|
||||
},
|
||||
|
||||
})
|
3
pages/common/webpage/webpage.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
4
pages/common/webpage/webpage.wxml
Normal file
@ -0,0 +1,4 @@
|
||||
<!--pages/common/webpage.wxml-->
|
||||
<web-view src="{{url}}">
|
||||
|
||||
</web-view>
|
1
pages/common/webpage/webpage.wxss
Normal file
@ -0,0 +1 @@
|
||||
/* pages/common/webpage.wxss */
|
@ -6,5 +6,63 @@ Page({
|
||||
data: {
|
||||
nameTxt: '名片'
|
||||
},
|
||||
onLoad(options) {
|
||||
this.doLogin()
|
||||
},
|
||||
show() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/moments/publish/momentpublish',
|
||||
})
|
||||
},
|
||||
showList() {
|
||||
wx.navigateTo({
|
||||
url: '/pages/moments/list/momentslist',
|
||||
})
|
||||
},
|
||||
// 登录
|
||||
doLogin() {
|
||||
var self = this;
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
})
|
||||
wx.login({
|
||||
success(res) {
|
||||
app.http.post(app.urls.wxLogin, {
|
||||
data: {
|
||||
jsCode: res.code
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
console.log(res)
|
||||
var token = res.data.data.split('_')[0]
|
||||
wx.setStorageSync('token', token)
|
||||
wx.setStorageSync('bindPhone', res.data.data.split('_')[1])
|
||||
app.globalData.token = token
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
console.log(err)
|
||||
})
|
||||
|
||||
|
||||
// {
|
||||
// jsCode: res.code
|
||||
// }, null, function (code, data) {
|
||||
// var token = data.data.split('_')[0]
|
||||
// self.setData({
|
||||
// token: token,
|
||||
// bindPhone: data.data.split('_')[1]
|
||||
// })
|
||||
// wx.setStorageSync('token', token)
|
||||
// wx.setStorageSync('bindPhone', data.data.split('_')[1])
|
||||
// app.globalData.token = token
|
||||
// self.getUserInfo()
|
||||
// self.getHomeColumnList()
|
||||
// }, function (code, data) {
|
||||
// app.dialog.msg(data.msg);
|
||||
// });
|
||||
}
|
||||
})
|
||||
},
|
||||
})
|
@ -1,3 +1,11 @@
|
||||
<cu-custom id="head" isCustom="{{false}}" isBack="{{false}}" isIndex="{{true}}">
|
||||
<view slot="content">{{nameTxt}}</view>
|
||||
</cu-custom>
|
||||
</cu-custom>
|
||||
|
||||
<view bindtap="show">
|
||||
测试
|
||||
</view>
|
||||
|
||||
<view bindtap="showList">
|
||||
列表
|
||||
</view>
|
@ -1,6 +1,5 @@
|
||||
// pages/mine/index/index.js
|
||||
const app = getApp()
|
||||
var audioContext = wx.createInnerAudioContext()
|
||||
Page({
|
||||
|
||||
/**
|
||||
@ -12,17 +11,6 @@ Page({
|
||||
userIcon: '../../../images/ic_user_default.png',
|
||||
menuList: [],
|
||||
imgUrl: app.urls.baseImgUrl,
|
||||
audioFile: {
|
||||
path: 'http://www.170mv.com/kw/antiserver.kuwo.cn/anti.s?rid=MUSIC_96145895&response=res&format=mp3|aac&type=convert_url&br=128kmp3&agent=iPhone&callback=getlink&jpcallback=getlink.mp3',
|
||||
isPlay: false,
|
||||
duration: 0,
|
||||
curDuration: 0
|
||||
},
|
||||
speedStep: 5, //快进快退秒数
|
||||
curTimeStr: '00:00',
|
||||
totalTimeStr: '00:60', //总时长
|
||||
waitFlag: false,
|
||||
url: 'https://ossweb-img.qq.com/images/lol/img/champion/Morgana.png'
|
||||
},
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
@ -32,8 +20,8 @@ Page({
|
||||
_self.setData({
|
||||
nickName: app.globalData.userInfo.name
|
||||
})
|
||||
_self.checkPermission()
|
||||
|
||||
// _self.checkPermission()
|
||||
_self.getItemList()
|
||||
},
|
||||
getItemList() {
|
||||
wx.showLoading({
|
||||
@ -46,9 +34,12 @@ Page({
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
var data = res.data
|
||||
wx.stopPullDownRefresh({})
|
||||
wx.hideLoading({})
|
||||
data.sort((a, b) => a.configSort - b.configSort)
|
||||
data.forEach(it => {
|
||||
it.configColumnList.sort((a, b) => a.configColumnOrder - b.configColumnOrder)
|
||||
})
|
||||
_self.setData({
|
||||
menuList: data
|
||||
})
|
||||
@ -77,7 +68,7 @@ Page({
|
||||
success(res) {
|
||||
console.log(res)
|
||||
if (res.confirm) {
|
||||
_self.getUserProfile(3)
|
||||
// _self.getUserProfile(3)
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -137,16 +128,18 @@ Page({
|
||||
})
|
||||
},
|
||||
choosePage(e) {
|
||||
// 栏目列表页跳转方式1:小程序页面,2:其他小程序,3:网址
|
||||
var path = e.currentTarget.dataset.path
|
||||
var type = e.currentTarget.dataset.type
|
||||
var item = e.currentTarget.dataset.item
|
||||
switch (type) {
|
||||
case 'mini': //跳转小程序内部
|
||||
case 'webview': //链接
|
||||
case '1': //跳转小程序内部
|
||||
case '3': //链接
|
||||
wx.navigateTo({
|
||||
url: path,
|
||||
url: path + '?id=' + item.configColumnId + '&mode=' + item.configTableMode + '&type=' + item.configColumnType
|
||||
})
|
||||
break
|
||||
case 'othermini': //其他小程序
|
||||
case '2': //其他小程序
|
||||
wx.navigateToMiniProgram({
|
||||
appId: '',
|
||||
success(res) {
|
||||
@ -159,105 +152,5 @@ Page({
|
||||
onPullDownRefresh() {
|
||||
this.getItemList()
|
||||
},
|
||||
play() {
|
||||
var _self = this
|
||||
if (_self.data.audioFile.isPlay) {
|
||||
audioContext.stop()
|
||||
} else {
|
||||
audioContext.src = _self.data.audioFile.path
|
||||
audioContext.autoplay = true
|
||||
}
|
||||
audioContext.onCanplay((res) => {
|
||||
if (_self.data.waitFlag) {
|
||||
audioContext.play()
|
||||
_self.setData({
|
||||
waitFlag: false
|
||||
})
|
||||
}
|
||||
})
|
||||
audioContext.onPlay((res) => {
|
||||
_self.data.audioFile.isPlay = true
|
||||
_self.setData({
|
||||
audioFile: _self.data.audioFile
|
||||
})
|
||||
})
|
||||
audioContext.onStop((res) => {
|
||||
_self.data.audioFile.isPlay = false
|
||||
_self.data.audioFile.curDuration = 0
|
||||
_self.setData({
|
||||
audioFile: _self.data.audioFile,
|
||||
curTimeStr: '00:00'
|
||||
})
|
||||
})
|
||||
audioContext.onEnded((res) => {
|
||||
_self.data.audioFile.isPlay = false
|
||||
_self.data.audioFile.curDuration = 0
|
||||
_self.setData({
|
||||
audioFile: _self.data.audioFile,
|
||||
curTimeStr: '00:00'
|
||||
})
|
||||
})
|
||||
audioContext.onError((res) => {
|
||||
_self.data.audioFile.isPlay = false
|
||||
_self.data.audioFile.curDuration = 0
|
||||
_self.setData({
|
||||
audioFile: _self.data.audioFile,
|
||||
curTimeStr: '00:00'
|
||||
})
|
||||
})
|
||||
audioContext.onSeeking(() => {
|
||||
console.log(audioContext.currentTime)
|
||||
})
|
||||
audioContext.onWaiting(() => {
|
||||
audioContext.pause()
|
||||
_self.setData({
|
||||
waitFlag: true
|
||||
})
|
||||
})
|
||||
audioContext.onTimeUpdate(() => {
|
||||
_self.data.audioFile.curDuration = parseInt(audioContext.currentTime)
|
||||
_self.data.audioFile.duration = parseInt(audioContext.duration)
|
||||
var curM = parseInt(audioContext.currentTime / 60) //分钟
|
||||
var curS = parseInt(audioContext.currentTime % 60) //秒
|
||||
var tM = parseInt(audioContext.duration / 60) //分钟
|
||||
var tS = parseInt(audioContext.duration % 60) //秒
|
||||
var curMStr = curM > 9 ? curM : '0' + curM
|
||||
var curSStr = curS > 9 ? curS : '0' + curS
|
||||
var totalMStr = tM > 9 ? tM : '0' + tM
|
||||
var totalSStr = +tS > 9 ? tS : '0' + tS
|
||||
_self.setData({
|
||||
audioFile: _self.data.audioFile,
|
||||
curTimeStr: curMStr + ':' + curSStr,
|
||||
totalTimeStr: totalMStr + ':' + totalSStr
|
||||
})
|
||||
})
|
||||
},
|
||||
//倒退5秒
|
||||
rewind() {
|
||||
var _self = this
|
||||
if (_self.data.audioFile.isPlay) {
|
||||
_self.data.audioFile.curDuration = _self.data.audioFile.curDuration - _self.data.speedStep
|
||||
audioContext.seek(_self.data.audioFile.curDuration)
|
||||
_self.setData({
|
||||
audioFile: _self.data.audioFile
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
//快进5秒
|
||||
speed() {
|
||||
var _self = this
|
||||
if (_self.data.audioFile.isPlay) {
|
||||
_self.data.audioFile.curDuration = _self.data.audioFile.curDuration + _self.data.speedStep
|
||||
audioContext.seek(_self.data.audioFile.curDuration)
|
||||
_self.setData({
|
||||
audioFile: _self.data.audioFile
|
||||
})
|
||||
}
|
||||
},
|
||||
slider4change(e) {
|
||||
if (this.data.audioFile.isPlay) {
|
||||
audioContext.seek(e.detail.value)
|
||||
}
|
||||
}
|
||||
})
|
@ -11,12 +11,60 @@
|
||||
</view>
|
||||
</view>
|
||||
<view class="scroll-content">
|
||||
<!-- 我的订单 -->
|
||||
<!-- 菜单 -->
|
||||
<view wx:if="{{menuList.length>0}}" style="width:100%;">
|
||||
<view class="cu-list menu card-menu shadow-lg radius" style="margin-top:0rpx;" wx:for="{{menuList}}" wx:key="index"
|
||||
wx:if="{{item.configType=='1' && item.isOpen == '1'}}">
|
||||
<!-- 标题 -->
|
||||
<view class="cu-item arrow border-bottom-sm" data-path="{{item.jumpUrl}}" data-type="{{item.jumpType}}"
|
||||
<view class="cu-list menu card-menu shadow-lg radius" style="margin-top:20rpx;margin-left:0rpx;margin-right:0rpx;"
|
||||
wx:for-item="group" wx:for="{{menuList}}" wx:key="index" wx:if="{{group.configColumnGroupStatus=='1'}}">
|
||||
<!-- 横向 -->
|
||||
<view wx:if="{{group.configColumnGroupDirection=='1'}}">
|
||||
<view class="cu-list grid col-4 no-border">
|
||||
<view class="cu-item align-center justify-center" data-path="{{item.configColumnTargetUrl}}"
|
||||
wx:if="{{item.configColumnStatus=='1'}}" data-type="{{item.configColumnTargetMode}}" bindtap="choosePage"
|
||||
data-item="{{item}}" wx:for="{{group.configColumnList}}" wx:for-index="idx" wx:for-item="item" wx:key="idx">
|
||||
<image style="width:96rpx;height:96rpx;border-radius:10rpx;" src="{{imgUrl+item.configColumnPhoto}}"
|
||||
mode="scaleToFill">
|
||||
</image>
|
||||
<text class="text-df text-black">{{item.configColumnName}}</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 纵向 -->
|
||||
<view wx:else>
|
||||
<view wx:for="{{group.configColumnList}}" wx:for-item="item" data-path="{{item.configColumnTargetUrl}}"
|
||||
data-type="{{item.configColumnTargetMode}}" wx:key="index" data-item="{{item}}" bindtap="choosePage">
|
||||
<view class="cu-list menu card-menu shadow-lg radius">
|
||||
<view class="cu-item arrow">
|
||||
<view wx:if="{{item.configColumnPhoto.length>0}}" class="cu-avatar radius lg"
|
||||
style="background-image:url({{imgUrl+ item.configColumnPhoto}});">
|
||||
</view>
|
||||
<view class="content padding-left-xs" style="width:80%;">
|
||||
<view class="text-black">
|
||||
<text class="text-cut">{{item.configColumnName}}</text>
|
||||
</view>
|
||||
<view class="text-gray text-sm flex">
|
||||
<text class="text-cut">{{item.configColumnRemark}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="action">
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else style="margin-top:200rpx;width:100%;">
|
||||
<van-empty description="暂无数据" image="../../../images/ic_empty_data.png" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- 标题 -->
|
||||
<!-- <view class="cu-item arrow border-bottom-sm" data-path="{{item.jumpUrl}}" data-type="{{item.jumpType}}"
|
||||
bindtap="choosePage">
|
||||
<view class="content flex align-center">
|
||||
<image src="{{imgUrl+item.logo}}" mode="scaleToFill" style="width:40rpx;height:40rpx;"></image>
|
||||
@ -25,20 +73,13 @@
|
||||
<view class="text-sm">
|
||||
{{item.otherName}}
|
||||
</view>
|
||||
</view>
|
||||
<!-- 子集横向 -->
|
||||
<view wx:if="{{item.subList.length>0}}">
|
||||
<view class="cu-list grid col-4 no-border" wx:if="{{item.showType=='1'}}">
|
||||
<view class="cu-item align-center justify-center" data-path="{{subItem.jumpUrl}}"
|
||||
data-type="{{subItem.jumpType}}" bindtap="choosePage" wx:for="{{item.subList}}" wx:for-index="idx"
|
||||
wx:for-item="subItem" wx:key="idx">
|
||||
<image style="width:64rpx;height:64rpx;" src="{{imgUrl+subItem.logo}}" mode="scaleToFill">
|
||||
</image>
|
||||
<text class="text-df text-depblack">{{subItem.name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 子集竖向 -->
|
||||
<view wx:else>
|
||||
</view> -->
|
||||
<!-- 子集横向 -->
|
||||
<!-- <view wx:if="{{item.subList.length>0}}">
|
||||
|
||||
</view> -->
|
||||
<!-- 子集竖向 -->
|
||||
<!-- <view wx:else>
|
||||
<view class="cu-item arrow border-bottom-sm " style="margin-top:0rpx;" wx:for="{{item.subList}}"
|
||||
wx:for-index="idx" wx:for-item="subItem" wx:key="idx">
|
||||
<view class="content flex align-center" data-path="{{subItem.jumpUrl}}" data-type="{{subItem.jumpType}}"
|
||||
@ -51,29 +92,4 @@
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else style="margin-top:200rpx;width:100%;">
|
||||
<van-empty description="暂无数据" image="../../../images/ic_empty_data.png" />
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- <view wx:for="{{items}}" wx:key="index">
|
||||
<view class="cu-list menu card-menu shadow-lg radius">
|
||||
<view class="cu-item arrow">
|
||||
<view wx:if="{{item.url.length>0}}" class="cu-avatar radius lg" style="background-image:url({{item.url}});">
|
||||
</view>
|
||||
<view class="content padding-left-xs">
|
||||
<view class="text-black">
|
||||
<text class="text-cut">{{item.name}}</text>
|
||||
</view>
|
||||
<view class="text-gray text-sm flex">
|
||||
<text class="text-cut">{{item.name}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="action">
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view> -->
|
834
pages/moments/edit/momentedit.js
Normal file
@ -0,0 +1,834 @@
|
||||
const app = getApp()
|
||||
const recorderManager = wx.getRecorderManager()
|
||||
var innerAudioContext = wx.createInnerAudioContext()
|
||||
const chooseLocation = requirePlugin('chooseLocation');
|
||||
const key = 'Y6FBZ-GLQC3-6273Q-3DRTL-W43G5-G6BXN'; //使用在腾讯位置服务申请的key
|
||||
const referer = '名片-小程序'; //调用插件的app的名称
|
||||
const location = JSON.stringify({
|
||||
latitude: 39.89631551,
|
||||
longitude: 116.323459711
|
||||
});
|
||||
const category = '生活服务,娱乐休闲';
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
uploadCount: 0,
|
||||
uploadVideoCount: 0,
|
||||
textList: [], //文本添加内容
|
||||
textareaList: [], //文本域添加内容
|
||||
audioList: [], //音频添加内容
|
||||
videoList: [], //视频添加内容
|
||||
photoList: [], //视频添加内容
|
||||
linkList: [], //连接添加内容
|
||||
locationList: [], //定位添加内容
|
||||
isShowText: false, //文本弹窗开关
|
||||
isShowDesc: false, //文本域弹窗开关
|
||||
isShowPhoto: false, //图片选择弹框
|
||||
isShowLink: false, //链接弹窗
|
||||
isShowAudio: false, //录音弹窗
|
||||
isShowVideo: false, //视频弹窗
|
||||
tempText: '',
|
||||
tempDesc: '',
|
||||
linkStr: '',
|
||||
map: null,
|
||||
waitFlag: false,
|
||||
isStartRecord: false, //是否录音中
|
||||
speck_time: 0,
|
||||
speedStep: 5, //快进快退秒数
|
||||
setInter: '', //定时器
|
||||
currentItem: undefined,
|
||||
items: [{
|
||||
title: '标题', //标题
|
||||
count: 3, //数量
|
||||
type: 'TEXT', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 9, //数量
|
||||
type: 'TEXTAREA', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 2, //数量
|
||||
type: 'AUDIO', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 3, //数量
|
||||
type: 'VIDEO', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 9, //数量
|
||||
type: 'PHOTO', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 9, //数量
|
||||
type: 'LINK', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 2, //数量
|
||||
type: 'LOCATION', //类型
|
||||
}],
|
||||
isAuthAudio: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
|
||||
this.checkPermission()
|
||||
},
|
||||
//申请录音权限
|
||||
checkPermission() {
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
var isAuth = res.authSetting['scope.record']
|
||||
if (typeof (isAuth) == 'undefined') {
|
||||
wx.authorize({
|
||||
scope: 'scope.record',
|
||||
success() {
|
||||
_self.setData({
|
||||
isAuthAudio: true
|
||||
})
|
||||
},
|
||||
fail() {
|
||||
_self.setData({
|
||||
isAuthAudio: false
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (!isAuth) {
|
||||
_self.openSetting()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
openSetting() {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '发布内容需要您授权录音权限.',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
wx.openSetting({
|
||||
withSubscriptions: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
onShow() {
|
||||
if (chooseLocation.getLocation() != null) {
|
||||
if (this.data.locationList.length < this.data.currentItem.count) {
|
||||
this.data.locationList.push(chooseLocation.getLocation())
|
||||
this.setData({
|
||||
locationList: this.data.locationList
|
||||
})
|
||||
}
|
||||
}
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
withSubscriptions: true,
|
||||
success(res) {
|
||||
var isAuth = res.authSetting['scope.record']
|
||||
_self.setData({
|
||||
isAuthAudio: isAuth
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
chooseLocation.setLocation(null)
|
||||
this.setData({
|
||||
map: null
|
||||
})
|
||||
},
|
||||
//选择视频来源
|
||||
chooseVideo(e) {
|
||||
var _self = this
|
||||
var countNum = _self.data.currentItem.count - _self.data.videoList.length
|
||||
console.log(countNum)
|
||||
var type = e.currentTarget.dataset.type
|
||||
wx.chooseMedia({
|
||||
count: Number.parseInt(countNum),
|
||||
mediaType: ['video'],
|
||||
sourceType: [type],
|
||||
maxDuration: 60,
|
||||
success: (res) => {
|
||||
if (res.tempFiles.length > 0) {
|
||||
_self.doUploadVideo(1, res.tempFiles, _self.data.uploadVideoCount)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
// console.log(err)
|
||||
// wx.showToast({
|
||||
// title: '选取视频失败,(拍摄时长:60秒)',
|
||||
// icon: 'none'
|
||||
// })
|
||||
}
|
||||
})
|
||||
},
|
||||
//上传视频
|
||||
doUploadVideo(type, paths, curIndex) {
|
||||
console.log(paths)
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
var count = paths.length //几次
|
||||
if (_self.data.uploadVideoCount < count) {
|
||||
app.http.upload(app.urls.doUploadVideo, {
|
||||
path: paths[_self.data.uploadVideoCount].tempFilePath,
|
||||
name: 'video',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
var item = {
|
||||
id: id,
|
||||
path: pathStr,
|
||||
imgPath: paths[_self.data.uploadVideoCount].thumbTempFilePath
|
||||
}
|
||||
_self.data.videoList.push(item)
|
||||
_self.setData({
|
||||
videoList: _self.data.videoList
|
||||
})
|
||||
_self.setData({
|
||||
uploadVideoCount: ++_self.data.uploadVideoCount
|
||||
})
|
||||
_self.doUploadVideo(1, paths, _self.data.uploadVideoCount)
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadVideoCount: ++_self.data.uploadVideoCount
|
||||
})
|
||||
_self.doUploadVideo(1, paths, _self.data.uploadVideoCount)
|
||||
})
|
||||
} else {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadVideoCount: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
//预览视频
|
||||
viewVideo(e) {
|
||||
var tempList = [{
|
||||
url: e.currentTarget.dataset.url,
|
||||
type: 'video'
|
||||
}]
|
||||
wx.previewMedia({
|
||||
sources: tempList,
|
||||
current: 0,
|
||||
showmenu: false
|
||||
})
|
||||
},
|
||||
//删除视频
|
||||
delVideo(e) {
|
||||
let _self = this
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该视频吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
_self.data.videoList.splice(e.currentTarget.dataset.index, 1)
|
||||
_self.setData({
|
||||
videoList: _self.data.videoList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//添加链接
|
||||
addLink() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'LINK') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.linkList.length < item.count) {
|
||||
if (_self.data.linkStr == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.linkList.push(_self.data.linkStr)
|
||||
_self.setData({
|
||||
linkList: _self.data.linkList,
|
||||
linkStr: ''
|
||||
})
|
||||
if (_self.data.linkList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowLink: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//文本域添加输入的文字
|
||||
addDesc() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'TEXTAREA') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.textareaList.length < item.count) {
|
||||
if (_self.data.tempDesc == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.textareaList.push(_self.data.tempDesc)
|
||||
_self.setData({
|
||||
textareaList: _self.data.textareaList,
|
||||
tempDesc: ''
|
||||
})
|
||||
if (_self.data.textareaList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowDesc: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//添加输入的文字
|
||||
addStr() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'TEXT') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.textList.length < item.count) {
|
||||
if (_self.data.tempText == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.textList.push(_self.data.tempText)
|
||||
_self.setData({
|
||||
textList: _self.data.textList,
|
||||
tempText: ''
|
||||
})
|
||||
if (_self.data.textList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowText: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//删除
|
||||
delText(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.textList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
textList: this.data.textList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
delLink(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.linkList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
linkList: this.data.linkList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
delDesc(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.textareaList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
textareaList: this.data.textareaList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//监听输入的文字
|
||||
textInput(e) {
|
||||
this.setData({
|
||||
[e.currentTarget.id]: e.detail.value
|
||||
})
|
||||
},
|
||||
//关闭弹窗
|
||||
onHide(e) {
|
||||
this.setData({
|
||||
isShowText: false,
|
||||
isShowDesc: false,
|
||||
isShowPhoto: false,
|
||||
isShowLink: false,
|
||||
isShowAudio: false,
|
||||
isShowVideo: false
|
||||
})
|
||||
},
|
||||
//选择图片
|
||||
choosePhoto(e) {
|
||||
var _self = this
|
||||
var countNum = _self.data.currentItem.count - _self.data.photoList.length
|
||||
var type = e.currentTarget.dataset.type
|
||||
wx.chooseImage({
|
||||
count: Number.parseInt(countNum),
|
||||
sourceType: [type],
|
||||
success: (res) => {
|
||||
_self.doUploadImg(1, res.tempFilePaths, _self.data.uploadCount)
|
||||
},
|
||||
fail: (err) => {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
//删除图片
|
||||
delImg(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该图片吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.photoList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
photoList: this.data.photoList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//预览图片
|
||||
viewImg(e) {
|
||||
var tempList = [e.currentTarget.dataset.url]
|
||||
wx.previewImage({
|
||||
urls: tempList,
|
||||
current: e.currentTarget.dataset.url
|
||||
});
|
||||
},
|
||||
doUploadImg(type, paths, curIndex) {
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
var count = paths.length //几次
|
||||
if (_self.data.uploadCount < count) {
|
||||
app.http.upload(app.urls.doUploadImg, {
|
||||
path: paths[_self.data.uploadCount],
|
||||
name: 'image',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
var item = {
|
||||
id: id,
|
||||
path: pathStr
|
||||
}
|
||||
_self.data.photoList.push(item)
|
||||
_self.setData({
|
||||
photoList: _self.data.photoList
|
||||
})
|
||||
_self.setData({
|
||||
uploadCount: ++_self.data.uploadCount
|
||||
})
|
||||
_self.doUploadImg(1, paths, _self.data.uploadCount)
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadCount: ++_self.data.uploadCount
|
||||
})
|
||||
_self.doUploadImg(1, paths, _self.data.uploadCount)
|
||||
})
|
||||
} else {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadCount: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
//地图选点
|
||||
chooseLocation() {
|
||||
this.data.items.forEach(it => {
|
||||
if (it.type == 'LOCATION') {
|
||||
this.setData({
|
||||
currentItem: it
|
||||
})
|
||||
}
|
||||
})
|
||||
wx.navigateTo({
|
||||
url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}&category=${category}`
|
||||
});
|
||||
},
|
||||
delMap(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.locationList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
locationList: this.data.locationList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//删除视频
|
||||
delAudio(e) {
|
||||
let _self = this
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该音频吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
_self.data.audioList.splice(e.currentTarget.dataset.index, 1)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
doStartRecord() {
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting['scope.record']) {
|
||||
wx.authorize({
|
||||
scope: 'scope.record',
|
||||
success() {
|
||||
_self.startRecord()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_self.startRecord()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
startRecord() {
|
||||
var that = this
|
||||
that.data.setInter = setInterval(
|
||||
function () {
|
||||
var speck_time = parseInt(that.data.speck_time + 1);
|
||||
that.setData({
|
||||
speck_time: parseInt(speck_time),
|
||||
isStartRecord: true
|
||||
});
|
||||
if (that.data.speck_time > 0 && that.data.speck_time <= 59) {
|
||||
that.start();
|
||||
} else {
|
||||
clearInterval(that.data.setInter);
|
||||
// 获取到结束时间
|
||||
that.stop();
|
||||
wx.showToast({
|
||||
title: '录音最长60S哦!',
|
||||
duration: 2000,
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
doEndRecord() {
|
||||
var _self = this;
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
if (_self.data.speck_time > 3) {
|
||||
//清除计时器 即清除setInter
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
_self.stop(true);
|
||||
_self.setData({
|
||||
speck_time: "0",
|
||||
isStartRecord: false
|
||||
})
|
||||
} else {
|
||||
//清除计时器 即清除setInter
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
_self.stop(false);
|
||||
wx.showToast({
|
||||
title: '录制时间过短',
|
||||
duration: 2000,
|
||||
icon: "none"
|
||||
})
|
||||
_self.setData({
|
||||
speck_time: "0",
|
||||
isStartRecord: false
|
||||
})
|
||||
}
|
||||
},
|
||||
//开始录音的时候
|
||||
start() {
|
||||
const options = {
|
||||
duration: 60000,
|
||||
format: 'mp3', //音频格式,有效值 aac/mp3
|
||||
}
|
||||
//开始录音
|
||||
recorderManager.start(options);
|
||||
recorderManager.onStart(() => {
|
||||
console.log('recorder start')
|
||||
});
|
||||
//错误回调
|
||||
recorderManager.onError((res) => {
|
||||
console.log(res);
|
||||
_self.stop(false);
|
||||
})
|
||||
},
|
||||
//停止录音
|
||||
stop(success) {
|
||||
var _self = this
|
||||
recorderManager.stop();
|
||||
recorderManager.onStop((res) => {
|
||||
if (success) {
|
||||
//进行录音文件上传
|
||||
_self.doUploadAudio(res)
|
||||
}
|
||||
})
|
||||
},
|
||||
doUploadAudio(audio) {
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
app.http.upload(app.urls.doUploadAudio, {
|
||||
path: audio.tempFilePath,
|
||||
name: 'audio',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
if (_self.data.audioList.length < _self.data.currentItem.count) {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
//计算时长
|
||||
var dur = parseInt(audio.duration / 1000)
|
||||
var tM = parseInt(dur / 60) //分钟
|
||||
var tS = parseInt(dur % 60) //秒
|
||||
var totalMStr = tM > 9 ? tM : '0' + tM
|
||||
var totalSStr = +tS > 9 ? tS : '0' + tS
|
||||
var totalStr = totalMStr + ':' + totalSStr
|
||||
var item = {
|
||||
id: id, //id
|
||||
path: pathStr, //地址
|
||||
isPlay: false, //是否播放中
|
||||
duration: dur, //时长
|
||||
curDuation: 0,
|
||||
curDurationStr: '00:00',
|
||||
totalDurationStr: totalStr
|
||||
}
|
||||
_self.data.audioList.push(item)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
console.log(_self.data.audioList)
|
||||
if (_self.data.audioList.length == _self.data.currentItem.count) {
|
||||
_self.setData({
|
||||
isShowAudio: false
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => {})
|
||||
},
|
||||
play(e) {
|
||||
|
||||
//进行播放
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
var _self = this
|
||||
_self.data.audioList.forEach(it => {
|
||||
if (it.isPlay) {
|
||||
innerAudioContext.stop()
|
||||
}
|
||||
it.isPlay = false
|
||||
it.curDuation = 0
|
||||
it.curDuationStr = '00:00'
|
||||
})
|
||||
if (!item.isPlay) {
|
||||
// innerAudioContext.stop()
|
||||
//找到该文件
|
||||
innerAudioContext = wx.createInnerAudioContext()
|
||||
// 播放音频文件
|
||||
innerAudioContext.src = _self.data.audioList[index].path
|
||||
innerAudioContext.autoplay = true
|
||||
}
|
||||
//先需要停止其他录音文件的播放
|
||||
|
||||
innerAudioContext.onPlay(() => {
|
||||
_self.data.audioList[index].isPlay = true
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
});
|
||||
|
||||
innerAudioContext.onCanplay((res) => {
|
||||
if (_self.data.waitFlag) {
|
||||
innerAudioContext.play()
|
||||
_self.setData({
|
||||
waitFlag: false
|
||||
})
|
||||
}
|
||||
})
|
||||
innerAudioContext.onStop((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onEnded((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onError((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onSeeking(() => {
|
||||
console.log(innerAudioContext.currentTime)
|
||||
})
|
||||
innerAudioContext.onWaiting(() => {
|
||||
innerAudioContext.pause()
|
||||
_self.setData({
|
||||
waitFlag: true
|
||||
})
|
||||
})
|
||||
innerAudioContext.onTimeUpdate(() => {
|
||||
if (innerAudioContext.duration != Infinity) {
|
||||
_self.data.audioList[index].curDuration = parseInt(innerAudioContext.currentTime)
|
||||
_self.data.audioList[index].duration = parseInt(innerAudioContext.duration)
|
||||
console.log(innerAudioContext.duration)
|
||||
var curM = parseInt(innerAudioContext.currentTime / 60) //分钟
|
||||
var curS = parseInt(innerAudioContext.currentTime % 60) //秒
|
||||
var tM = parseInt(innerAudioContext.duration / 60) //分钟
|
||||
var tS = parseInt(innerAudioContext.duration % 60) //秒
|
||||
var curMStr = curM > 9 ? curM : '0' + curM
|
||||
var curSStr = curS > 9 ? curS : '0' + curS
|
||||
var totalMStr = tM > 9 ? tM : '0' + tM
|
||||
var totalSStr = +tS > 9 ? tS : '0' + tS
|
||||
_self.data.audioList[index].curDurationStr = curMStr + ':' + curSStr
|
||||
_self.data.audioList[index].totalDurationStr = totalMStr + ':' + totalSStr
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//倒退5秒
|
||||
rewind(e) {
|
||||
var _self = this
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration - _self.data.speedStep
|
||||
innerAudioContext.seek(_self.data.audioList[index].curDuration)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
//快进5秒
|
||||
speed(e) {
|
||||
var _self = this
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration + _self.data.speedStep
|
||||
innerAudioContext.seek(_self.data.audioList[index].curDuration)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
},
|
||||
slider4change(e) {
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
innerAudioContext.seek(e.detail.value)
|
||||
}
|
||||
},
|
||||
//显示弹框
|
||||
showDialog(e) {
|
||||
var type = e.currentTarget.dataset.type
|
||||
var keyType = e.currentTarget.dataset.keytype
|
||||
console.log(e)
|
||||
this.data.items.forEach(it => {
|
||||
if (it.type == type) {
|
||||
this.setData({
|
||||
currentItem: it
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
this.setData({
|
||||
[keyType]: true
|
||||
})
|
||||
}
|
||||
})
|
3
pages/moments/edit/momentedit.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
309
pages/moments/edit/momentedit.wxml
Normal file
@ -0,0 +1,309 @@
|
||||
<cu-custom isBack="{{true}}">
|
||||
<view slot="content">内容修改</view>
|
||||
</cu-custom>
|
||||
<!-- 内容 -->
|
||||
<view wx:for="{{items}}" wx:key="index">
|
||||
<!-- 文本 -->
|
||||
<view class="flex flex-direction" wx:if="{{item.type=='TEXT'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>文本内容</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{textList.length>0}}" class="flex flex-direction" style="width:100%;">
|
||||
<!--输入的文本内容 -->
|
||||
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{textList}}" wx:key="index"
|
||||
wx:for-item="txt" style="width:100%;">
|
||||
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delText" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{textList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" bindtap="showDialog" data-type="TEXT" data-keyType="isShowText">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 文本域 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='TEXTAREA'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>文本域内容</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{textareaList.length>0}}" class="flex flex-direction" style="width:100%;">
|
||||
<!--输入的文本内容 -->
|
||||
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{textareaList}}" wx:key="index"
|
||||
wx:for-item="txt" style="width:100%;">
|
||||
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delDesc" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{textareaList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" bindtap="showDialog" data-type="TEXTAREA" data-keyType="isShowDesc">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 图片 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='PHOTO'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>图片内容</text>
|
||||
</view>
|
||||
<view class="flex flex-direction bg-white margin-sm radius padding-sm">
|
||||
<view class="flex flex-direction self-end" style="width:100%;text-align:right;"
|
||||
wx:if="{{photoList.length>0}}">
|
||||
{{'数量'+'('+photoList.length+'/'+ currentItem.count+')'}}
|
||||
</view>
|
||||
<view wx:if="{{photoList.length>0}}" class="cu-form-group">
|
||||
<view class="grid col-4 grid-square flex-sub">
|
||||
<view class="bg-img" wx:for="{{photoList}}" wx:key="index" wx:for-item="photo" bindtap="viewImg"
|
||||
data-url="{{photo.path}}">
|
||||
<image src='{{photo.path}}' mode='scaleToFill'></image>
|
||||
<view class="cu-tag bg-red" catchtap="delImg" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{photoList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm selfcenter"
|
||||
style="width:60%;" bindtap="showDialog" data-type="PHOTO" data-keyType="isShowPhoto">点击添加</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- 音频 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='AUDIO'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>语音介绍</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{audioList.length > 0}}" style="width:100%;">
|
||||
<view class="flex align-center shadow-box margin-top-xs" style="width:100%;" wx:for="{{audioList}}"
|
||||
wx:key="index" wx:for-item="audio">
|
||||
<image src="/images/ic_user_default.png" mode="scaleToFill" style="width:80rpx;height:80rpx;">
|
||||
</image>
|
||||
<view class="play-box">
|
||||
<view class="flex justify-between align-center" style="width:80%;">
|
||||
<text>{{audio.curDurationStr}}</text>
|
||||
<slider class="flex-sub" bindchange="slider4change" min="{{0}}" max="{{audio.duration}}"
|
||||
value="{{audio.curDuration}}" backgroundColor="#cacaca" activeColor="#1296db" data-index="{{index}}" data-item="{{audio}}"
|
||||
block-size="14" block-color="#1296db" />
|
||||
<text>{{audio.totalDurationStr}}</text>
|
||||
</view>
|
||||
<view class="flex justify-between" style="width:80%;">
|
||||
<image src="/images/ic_audio_rewind.png" mode="scaleToFill" data-index="{{index}}" data-item="{{audio}}" bindtap="rewind"></image>
|
||||
<image
|
||||
src="{{audio.isPlay ? '/images/ic_audio_playing.png':'/images/ic_audio_play.png'}}"
|
||||
mode="scaleToFill" bindtap="play" data-index="{{index}}" data-item="{{audio}}"></image>
|
||||
<image src="/images/ic_audio_speed.png" mode="scaleToFill" bindtap="speed" data-index="{{index}}" data-item="{{audio}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cu-tag bg-gray margin-left-xs" style="border-radius:50%;" catchtap="delAudio"
|
||||
data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_voice.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
|
||||
<text class="text-gray">
|
||||
语音,可以给名片访客留下更深的印象
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{audioList.length<item.count}}" class="cu-btn bg-blue radius margin-top-sm" style="width:60%;"
|
||||
data-type="AUDIO" data-keyType="isShowAudio" bindtap="showDialog">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 视频 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='VIDEO'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>视频内容</text>
|
||||
</view>
|
||||
<view class="flex flex-direction bg-white margin-sm radius padding-sm">
|
||||
<view class="flex flex-direction self-end" style="width:100%;text-align:right;"
|
||||
wx:if="{{videoList.length>0}}">
|
||||
{{'数量'+'('+videoList.length+'/'+ currentItem.count+')'}}
|
||||
</view>
|
||||
<view wx:if="{{videoList.length>0}}" class="cu-form-group">
|
||||
<view class="grid col-1 grid-square flex-sub">
|
||||
<view class="bg-img" wx:for="{{videoList}}" wx:key="index" wx:for-item="video" bindtap="viewVideo"
|
||||
style="height:280rpx;padding-bottom:0rpx;" data-url="{{video.path}}">
|
||||
<image src='{{video.imgPath}}' mode='scaleToFill'></image>
|
||||
<view class="cu-tag bg-red" catchtap="delVideo" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{videoList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm selfcenter"
|
||||
style="width:60%;" bindtap="showDialog" data-type="VIDEO" data-keyType="isShowVideo">点击添加</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- 连接 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='LINK'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>链接</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{linkList.length>0}}" class="flex flex-direction" style="width:100%;">
|
||||
<!--输入的文本内容 -->
|
||||
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{linkList}}" wx:key="index"
|
||||
wx:for-item="txt" style="width:100%;">
|
||||
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delLink" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{linkList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" bindtap="showDialog" data-type="LINK" data-keyType="isShowLink">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 定位 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='LOCATION'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>定位</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{locationList.length>0}}">
|
||||
<view wx:for="{{locationList}}" wx:key="index" wx:for-item="m" style="width:100%;"
|
||||
class="margin-top-xs">
|
||||
<view class="flex justify-between">
|
||||
<view>
|
||||
{{m.name}}-{{m.address}}
|
||||
</view>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delMap" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view style="border-radius:10rpx;overflow:hidden;margin-top:10rpx;">
|
||||
<map style="width:100%;height:300rpx;" longitude="{{m.longitude}}" latitude="{{m.latitude}}"
|
||||
scale="12" markers="{{[{latitude:m.latitude,longitude:m.longitude}]}}"></map>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_map.png" mode="scaleToFill" style="width:200rpx;height:200rpx;"></image>
|
||||
<text class="text-gray">
|
||||
在地图上选取一个地点
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{locationList.length < item.count}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" bindtap="chooseLocation">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 语音弹框 -->
|
||||
<van-action-sheet show="{{ isShowAudio }}" title="语音介绍添加" bind:close="onHide" data-type="1"
|
||||
style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:80rpx;"
|
||||
wx:if="{{audioFile==null}}">
|
||||
<image src="{{isRecording? '/images/ic_voice_record.gif':'/images/ic_record_start.png'}}" mode="heightFix"
|
||||
style="width:300rpx;height:300rpx;"></image>
|
||||
<text>00:{{speck_time>9 ? speck_time : '0'+ speck_time}}</text>
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" style="width:70%;" bindlongpress="startRecord"
|
||||
bindtouchend="doEndRecord">长按录音</view>
|
||||
</view>
|
||||
<!-- 存在录音文件 -->
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:80rpx;" wx:else>
|
||||
<image src="{{audioFile.isPlay? '/images/ic_voice_record.gif':'/images/ic_record_start.png'}}" mode="heightFix"
|
||||
style="width:300rpx;height:300rpx;"></image>
|
||||
<text>{{audioFile.isPlay ? '播放中:'+speck_time+'秒' : '时长:'+audioFile.duration+'秒'}}</text>
|
||||
<view class="flex" style="width:80%;">
|
||||
<view class="cu-btn bg-blue radius margin-top-sm flex-sub" bindtap="playAudio">点击播放</view>
|
||||
<view class="cu-btn bg-red radius margin-top-sm flex-sub margin-left" bindtap="delAudio">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 文本域弹框 -->
|
||||
<van-action-sheet show="{{ isShowDesc }}" title="{{'文本内容'+'('+textareaList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="2" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<textarea id="tempDesc" placeholder="请输入文本内容" style="width:90%;" value="{{tempDesc}}"
|
||||
bindinput="textInput"></textarea>
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addDesc">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 文本内容弹框 -->
|
||||
<van-action-sheet show="{{ isShowText }}" title="{{'文本内容'+'('+textList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="3" style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<input id="tempText" placeholder="请输入文本内容" style="width:90%;" value="{{tempText}}" bindinput="textInput" />
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addStr">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 图片弹框 -->
|
||||
<van-action-sheet show="{{ isShowPhoto }}" title="图片选取" bind:close="onHide" data-type="4" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<view class="text-lg line" catchtap="choosePhoto" data-type="album">
|
||||
相册
|
||||
</view>
|
||||
<view class="text-lg noline" catchtap="choosePhoto" data-type="camera">
|
||||
相机
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 视频弹框 -->
|
||||
<van-action-sheet show="{{ isShowVideo }}" title="视频选取" bind:close="onHide" data-type="6" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<view class="text-lg line" catchtap="chooseVideo" data-type="album">
|
||||
相册
|
||||
</view>
|
||||
<view class="text-lg noline" catchtap="chooseVideo" data-type="camera">
|
||||
相机
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
|
||||
<!-- 文本内容弹框 -->
|
||||
<van-action-sheet show="{{ isShowLink }}" title="{{'链接内容'+'('+linkList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="5" style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<input id="linkStr" placeholder="请输入链接地址(https://www.baidu.com)" style="width:90%;" value="{{linkStr}}"
|
||||
bindinput="textInput" />
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addLink">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
49
pages/moments/edit/momentedit.wxss
Normal file
@ -0,0 +1,49 @@
|
||||
/* pages/moments/publish/momentpublish.wxss */
|
||||
|
||||
|
||||
van-action-sheet input {
|
||||
border: 1px solid rgb(194, 194, 194);
|
||||
border-radius: 10rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-top: 9rpx;
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
|
||||
van-action-sheet textarea {
|
||||
border: 1px solid rgb(194, 194, 194);
|
||||
border-radius: 10rpx;
|
||||
margin-top: 9rpx;
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
van-action-sheet .line {
|
||||
height: 90rpx;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
width: 90%;
|
||||
border-top-width: 1rpx;
|
||||
border-top-color: #f5f5f5;
|
||||
border-top-style: solid;
|
||||
border-bottom-width: 1rpx;
|
||||
border-bottom-color: #f5f5f5;
|
||||
border-bottom-style: solid;
|
||||
}
|
||||
|
||||
van-action-sheet .noline {
|
||||
height: 90rpx;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
|
||||
van-action-sheet .line:active {
|
||||
color: black;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
van-action-sheet .noline:active {
|
||||
color: black;
|
||||
background-color: #f5f5f5;
|
||||
}
|
316
pages/moments/list/momentslist.js
Normal file
@ -0,0 +1,316 @@
|
||||
// pages/moments/list/momentslist.js
|
||||
const app = getApp()
|
||||
var innerAudioContext = wx.createInnerAudioContext()
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
columnId: '',
|
||||
type: '',
|
||||
speedStep: 5, //快进快退秒数
|
||||
waitFlag: false,
|
||||
configMode: '2', //1单条数据 2多条数据
|
||||
dataList: [],
|
||||
trendsList: [{
|
||||
auto: false,
|
||||
seeMore: false,
|
||||
text: '小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟',
|
||||
}, {
|
||||
auto: false,
|
||||
seeMore: false,
|
||||
text: '小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟小老弟',
|
||||
}],
|
||||
photoList: [{
|
||||
path: 'https://t7.baidu.com/it/u=2604797219,1573897854&fm=193&f=GIF'
|
||||
},
|
||||
{
|
||||
path: 'https://t7.baidu.com/it/u=2942499027,2479446682&fm=193&f=GIF'
|
||||
},
|
||||
{
|
||||
path: 'https://t7.baidu.com/it/u=3165657288,4248157545&fm=193&f=GIF'
|
||||
},
|
||||
{
|
||||
path: 'https://t7.baidu.com/it/u=3240224891,3518615655&fm=193&f=GIF'
|
||||
},
|
||||
{
|
||||
path: 'https://t7.baidu.com/it/u=3240224891,3518615655&fm=193&f=GIF'
|
||||
}
|
||||
],
|
||||
videoList: [{
|
||||
imgPath: '../../../images/ic_temp.png',
|
||||
path: 'https://media.w3.org/2010/05/sintel/trailer.mp4'
|
||||
}],
|
||||
locationList: [{
|
||||
name: '满都海公园',
|
||||
address: '乌兰察布西街南',
|
||||
latitude: 40.816084,
|
||||
longitude: 111.688774
|
||||
}],
|
||||
audioList: [{
|
||||
id: '', //id
|
||||
path: 'http://em.sycdn.kuwo.cn/0e15005756dcda91a39bec26dd824614/60d99781/resource/n3/30/66/2205407643.mp3', //地址
|
||||
isPlay: false, //是否播放中
|
||||
duration: 100, //时长
|
||||
curDuation: 0,
|
||||
curDurationStr: '00:00',
|
||||
totalDurationStr: '00:56'
|
||||
}, {
|
||||
id: '', //id
|
||||
path: 'http://em.sycdn.kuwo.cn/0e15005756dcda91a39bec26dd824614/60d99781/resource/n3/30/66/2205407643.mp3', //地址
|
||||
isPlay: false, //是否播放中
|
||||
duration: 100, //时长
|
||||
curDuation: 0,
|
||||
curDurationStr: '00:00',
|
||||
totalDurationStr: '00:56'
|
||||
}],
|
||||
linkList: [{
|
||||
url: 'https://www.baidu.com'
|
||||
}, {
|
||||
url: 'https://www.baidu.com'
|
||||
}, {
|
||||
url: 'https://www.baidu.com'
|
||||
}],
|
||||
count: 2,
|
||||
isLoadMore: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
const query = wx.createSelectorQuery()
|
||||
let _self = this
|
||||
console.log(options.type)
|
||||
_self.setData({
|
||||
columnId: options.id,
|
||||
configMode: options.mode,
|
||||
type: options.type
|
||||
})
|
||||
query.selectAll('.textFour_box').boundingClientRect(res => {
|
||||
var lineHeight = 26
|
||||
for (var i = 0; i < res.length; i++) {
|
||||
if (res[i].height / lineHeight > 3) {
|
||||
_self.data.trendsList[i].auto = true
|
||||
_self.data.trendsList[i].seeMore = true
|
||||
}
|
||||
}
|
||||
_self.setData({
|
||||
trendsList: _self.data.trendsList
|
||||
})
|
||||
}).exec()
|
||||
query.select('#it').boundingClientRect(res => {
|
||||
if (res.height > app.globalData.windowHeight) {
|
||||
|
||||
}
|
||||
}).exec()
|
||||
_self.getList()
|
||||
},
|
||||
//获取栏目数据
|
||||
getList() {
|
||||
var _self = this
|
||||
wx.showLoading({})
|
||||
app.http.get(app.urls.getMomentsList.format({
|
||||
configColumnId: _self.data.columnId
|
||||
}), {
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
dataList: res.data
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
//展开更多
|
||||
toggleHandler: function (e) {
|
||||
var that = this;
|
||||
var index = e.currentTarget.dataset.index;
|
||||
for (var i = 0; i < that.data.trendsList.length; i++) {
|
||||
if (index == i) {
|
||||
that.data.trendsList[index].auto = true;
|
||||
that.data.trendsList[index].seeMore = false;
|
||||
}
|
||||
}
|
||||
that.setData({
|
||||
trendsList: that.data.trendsList
|
||||
})
|
||||
},
|
||||
//收起更多
|
||||
toggleContent: function (e) {
|
||||
var that = this;
|
||||
var index = e.currentTarget.dataset.index;
|
||||
for (var i = 0; i < that.data.trendsList.length; i++) {
|
||||
if (index == i) {
|
||||
that.data.trendsList[index].auto = true;
|
||||
that.data.trendsList[index].seeMore = true;
|
||||
}
|
||||
}
|
||||
that.setData({
|
||||
trendsList: that.data.trendsList
|
||||
})
|
||||
},
|
||||
//预览图片
|
||||
viewImg(e) {
|
||||
wx.previewImage({
|
||||
urls: [e.currentTarget.dataset.url],
|
||||
})
|
||||
},
|
||||
viewVideo(e) {
|
||||
var url = e.currentTarget.dataset.url
|
||||
wx.previewMedia({
|
||||
sources: [{
|
||||
url: url,
|
||||
type: 'video'
|
||||
}],
|
||||
})
|
||||
},
|
||||
onPullDownRefresh() {
|
||||
wx.stopPullDownRefresh({})
|
||||
},
|
||||
onReachBottom() {
|
||||
console.log('触底了')
|
||||
},
|
||||
play(e) {
|
||||
|
||||
//进行播放
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
var _self = this
|
||||
_self.data.audioList.forEach(it => {
|
||||
if (it.isPlay) {
|
||||
innerAudioContext.stop()
|
||||
}
|
||||
it.isPlay = false
|
||||
it.curDuation = 0
|
||||
it.curDuationStr = '00:00'
|
||||
})
|
||||
if (!item.isPlay) {
|
||||
// innerAudioContext.stop()
|
||||
//找到该文件
|
||||
innerAudioContext = wx.createInnerAudioContext()
|
||||
// 播放音频文件
|
||||
innerAudioContext.src = _self.data.audioList[index].path
|
||||
innerAudioContext.autoplay = true
|
||||
}
|
||||
//先需要停止其他录音文件的播放
|
||||
|
||||
innerAudioContext.onPlay(() => {
|
||||
_self.data.audioList[index].isPlay = true
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
});
|
||||
|
||||
innerAudioContext.onCanplay((res) => {
|
||||
if (_self.data.waitFlag) {
|
||||
innerAudioContext.play()
|
||||
_self.setData({
|
||||
waitFlag: false
|
||||
})
|
||||
}
|
||||
})
|
||||
innerAudioContext.onStop((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onEnded((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onError((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onSeeking(() => {
|
||||
console.log(innerAudioContext.currentTime)
|
||||
})
|
||||
innerAudioContext.onWaiting(() => {
|
||||
innerAudioContext.pause()
|
||||
_self.setData({
|
||||
waitFlag: true
|
||||
})
|
||||
})
|
||||
innerAudioContext.onTimeUpdate(() => {
|
||||
if (innerAudioContext.duration != Infinity) {
|
||||
_self.data.audioList[index].curDuration = parseInt(innerAudioContext.currentTime)
|
||||
_self.data.audioList[index].duration = parseInt(innerAudioContext.duration)
|
||||
console.log(innerAudioContext.duration)
|
||||
var curM = parseInt(innerAudioContext.currentTime / 60) //分钟
|
||||
var curS = parseInt(innerAudioContext.currentTime % 60) //秒
|
||||
var tM = parseInt(innerAudioContext.duration / 60) //分钟
|
||||
var tS = parseInt(innerAudioContext.duration % 60) //秒
|
||||
var curMStr = curM > 9 ? curM : '0' + curM
|
||||
var curSStr = curS > 9 ? curS : '0' + curS
|
||||
var totalMStr = tM > 9 ? tM : '0' + tM
|
||||
var totalSStr = +tS > 9 ? tS : '0' + tS
|
||||
_self.data.audioList[index].curDurationStr = curMStr + ':' + curSStr
|
||||
_self.data.audioList[index].totalDurationStr = totalMStr + ':' + totalSStr
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//倒退5秒
|
||||
rewind(e) {
|
||||
var _self = this
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration - _self.data.speedStep
|
||||
innerAudioContext.seek(_self.data.audioList[index].curDuration)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
//快进5秒
|
||||
speed(e) {
|
||||
var _self = this
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration + _self.data.speedStep
|
||||
innerAudioContext.seek(_self.data.audioList[index].curDuration)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
},
|
||||
slider4change(e) {
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
innerAudioContext.seek(e.detail.value)
|
||||
}
|
||||
},
|
||||
//删除
|
||||
delItem(e) {
|
||||
|
||||
},
|
||||
doPublish() {
|
||||
wx.navigateTo({
|
||||
url: '../publish/momentpublishline?id=' + this.data.columnId,
|
||||
})
|
||||
}
|
||||
})
|
4
pages/moments/list/momentslist.json
Normal file
@ -0,0 +1,4 @@
|
||||
{
|
||||
"usingComponents": {},
|
||||
"enablePullDownRefresh": true
|
||||
}
|
113
pages/moments/list/momentslist.wxml
Normal file
@ -0,0 +1,113 @@
|
||||
<cu-custom isBack="{{true}}">
|
||||
<view slot="content">内容列表</view>
|
||||
</cu-custom>
|
||||
<view id="it" class="flex flex-direction bg-white margin-sm radius padding-sm">
|
||||
<view class="flex justify-between padding-xs align-center">
|
||||
<view class="text-black text-df text-bold ">
|
||||
发表时间:2021年12月12日 12:12:12
|
||||
</view>
|
||||
<image src="../../../images/ic_squareness_del.png" mode="scaleToFill" style="width:48rpx;height:48rpx;"
|
||||
catchtap="delItem"></image>
|
||||
</view>
|
||||
<!-- 文本 -->
|
||||
<view wx:for="{{trendsList}}" wx:key='index'>
|
||||
<view class="box">
|
||||
<view class="textFour_box {{item.seeMore?'three':''}}">{{item.text}}</view>
|
||||
<view class="text_toggle_box" style="display:flex;align-items:center;" wx:if='{{item.seeMore}}'
|
||||
data-index='{{index}}' catchtap='toggleHandler'>
|
||||
<text class="text_toggle_text">查看更多</text>
|
||||
<image class="toggle-icon" src="/images/ic_arrow_down.png"></image>
|
||||
</view>
|
||||
<view class="text_toggle_box" style="display:flex;align-items:center;"
|
||||
wx:if='{{!item.seeMore && item.auto}}' data-index='{{index}}' catchtap='toggleContent'>
|
||||
<text class="text_toggle_text">收起</text>
|
||||
<image class="toggle-icon" src="/images/ic_arrow_up.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 图片 -->
|
||||
<view wx:if="{{photoList.length>0}}" class="cu-form-group margin-top-xs">
|
||||
<view class="grid col-4 grid-square flex-sub">
|
||||
<view class="bg-img" wx:for="{{photoList}}" wx:key="index" wx:for-item="photo" catchtap="viewImg"
|
||||
data-url="{{photo.path}}">
|
||||
<image src='{{photo.path}}' mode='scaleToFill'></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 视频 -->
|
||||
<view wx:if="{{videoList.length>0}}" class="cu-form-group">
|
||||
<view class="grid col-{{count>3 ? count : 1}} grid-square flex-sub">
|
||||
<view class="bg-img" wx:for="{{videoList}}" wx:key="index" wx:for-item="video" catchtap="viewVideo"
|
||||
style="{{count > 3 ? '' :'height:280rpx;width:100%;padding-bottom:0px;'}}" data-url="{{video.path}}">
|
||||
<image style="width:100%;height:100%;" src='{{video.imgPath}}' mode='scaleToFill'></image>
|
||||
<view class="{{count > 3 ? 'play-box-arrow-pos':'play-box-arrow-flex'}}">
|
||||
<image src="/images/ic_video_play.png" mode="scaleToFill"
|
||||
style="{{count > 3 ? 'width:32px;height:32px':'height:64px;width:64px;'}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 音频 -->
|
||||
<view wx:if="{{audioList.length > 0}}" style="width:100%;">
|
||||
<view class="flex align-center shadow-box margin-top-xs" style="width:100%;" wx:for="{{audioList}}"
|
||||
wx:key="index" wx:for-item="audio">
|
||||
<image src="/images/ic_user_default.png" mode="scaleToFill" style="width:80rpx;height:80rpx;">
|
||||
</image>
|
||||
<view class="play-box">
|
||||
<view class="flex justify-between align-center" style="width:80%;">
|
||||
<text>{{audio.curDurationStr}}</text>
|
||||
<slider class="flex-sub" bindchange="slider4change" min="{{0}}" max="{{audio.duration}}"
|
||||
value="{{audio.curDuration}}" backgroundColor="#cacaca" activeColor="#1296db"
|
||||
data-index="{{index}}" data-item="{{audio}}" block-size="14" block-color="#1296db" />
|
||||
<text>{{audio.totalDurationStr}}</text>
|
||||
</view>
|
||||
<view class="flex justify-between" style="width:80%;">
|
||||
<image src="/images/ic_audio_rewind.png" mode="scaleToFill" data-index="{{index}}"
|
||||
data-item="{{audio}}" bindtap="rewind"></image>
|
||||
<image src="{{audio.isPlay ? '/images/ic_audio_playing.png':'/images/ic_audio_play.png'}}"
|
||||
mode="scaleToFill" bindtap="play" data-index="{{index}}" data-item="{{audio}}"></image>
|
||||
<image src="/images/ic_audio_speed.png" mode="scaleToFill" bindtap="speed" data-index="{{index}}"
|
||||
data-item="{{audio}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 连接 -->
|
||||
<view wx:if="{{linkList.length > 0}}" style="width:100%;">
|
||||
<view class="flex align-center margin-top-xs" style="width:100%;" wx:for="{{linkList}}" wx:key="index"
|
||||
wx:for-item="link">
|
||||
<view class="flex-sub">
|
||||
{{link.url}}
|
||||
</view>
|
||||
<view class="cu-btn bg-blue radius">
|
||||
打开
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 地图定位 -->
|
||||
<view wx:for="{{locationList}}" wx:key="index" wx:for-item="m" style="width:100%;" class="margin-top-xs">
|
||||
<view class="flex justify-between">
|
||||
<view>
|
||||
{{m.name}}-{{m.address}}
|
||||
</view>
|
||||
<view></view>
|
||||
</view>
|
||||
<view style="border-radius:10rpx;overflow:hidden;margin-top:10rpx;">
|
||||
<map style="width:100%;height:300rpx;" longitude="{{m.longitude}}" latitude="{{m.latitude}}" scale="12"
|
||||
enable-scroll="{{false}}" enable-zoom="{{false}}" enable-rotate="{{false}}" enable-traffic="{{false}}"
|
||||
markers="{{[{latitude:m.latitude,longitude:m.longitude}]}}"></map>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
|
||||
<view class="padding-xs foot bg-white" wx:if="{{configMode == '2' || dataList.length <= 0}}">
|
||||
<button class="cu-btn bg-blue" style="width:100%" bindtap="doPublish">发布</button>
|
||||
</view>
|
||||
|
||||
<view
|
||||
style="width:100%;display:flex;justify-content:center;background-color:#fff;padding:20rpx 0rpx;margin-bottom:100rpx"
|
||||
wx:if="{{isLoadMore}}">
|
||||
<van-loading type="spinner" size="24px">加载中...</van-loading>
|
||||
</view>
|
50
pages/moments/list/momentslist.wxss
Normal file
@ -0,0 +1,50 @@
|
||||
/* pages/moments/list/momentslist.wxss */
|
||||
|
||||
.box {
|
||||
margin: 0rpx 10rpx;
|
||||
}
|
||||
|
||||
.text_box {
|
||||
width: 100%;
|
||||
font-size: 30rpx;
|
||||
font-weight: 400;
|
||||
line-height: 48rpx;
|
||||
}
|
||||
|
||||
.textFour_box {
|
||||
width: 100%;
|
||||
font-size: 30rpx;
|
||||
font-weight: 400;
|
||||
line-height: 26px;
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
.toggle-icon {
|
||||
width: 25rpx;
|
||||
height: 25rpx;
|
||||
}
|
||||
|
||||
.text_toggloe_box {
|
||||
display: flex;
|
||||
justify-content: left;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
margin: 10rpx 0;
|
||||
}
|
||||
|
||||
.text_toggle_text {
|
||||
font-size: 30rpx;
|
||||
line-height: 32rpx;
|
||||
margin-right: 10rpx;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.three {
|
||||
text-overflow: -o-ellipsis-lastline;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box;
|
||||
-webkit-line-clamp: 3;
|
||||
line-clamp: 3;
|
||||
-webkit-box-orient: vertical;
|
||||
}
|
862
pages/moments/publish/momentpublish.js
Normal file
@ -0,0 +1,862 @@
|
||||
const app = getApp()
|
||||
const recorderManager = wx.getRecorderManager()
|
||||
var innerAudioContext = wx.createInnerAudioContext()
|
||||
const chooseLocation = requirePlugin('chooseLocation');
|
||||
const key = 'Y6FBZ-GLQC3-6273Q-3DRTL-W43G5-G6BXN'; //使用在腾讯位置服务申请的key
|
||||
const referer = '名片-小程序'; //调用插件的app的名称
|
||||
const location = JSON.stringify({
|
||||
latitude: 39.89631551,
|
||||
longitude: 116.323459711
|
||||
});
|
||||
const category = '生活服务,娱乐休闲';
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
uploadCount: 0,
|
||||
uploadVideoCount: 0,
|
||||
columnId: '', //栏目Id
|
||||
fieldList: [], //栏目字段
|
||||
textList: [], //文本添加内容
|
||||
textareaList: [], //文本域添加内容
|
||||
audioList: [], //音频添加内容
|
||||
videoList: [], //视频添加内容
|
||||
photoList: [], //视频添加内容
|
||||
linkList: [], //连接添加内容
|
||||
locationList: [], //定位添加内容
|
||||
isShowText: false, //文本弹窗开关
|
||||
isShowDesc: false, //文本域弹窗开关
|
||||
isShowPhoto: false, //图片选择弹框
|
||||
isShowLink: false, //链接弹窗
|
||||
isShowAudio: false, //录音弹窗
|
||||
isShowVideo: false, //视频弹窗
|
||||
tempText: '',
|
||||
tempDesc: '',
|
||||
linkStr: '',
|
||||
map: null,
|
||||
waitFlag: false,
|
||||
isStartRecord: false, //是否录音中
|
||||
speck_time: 0,
|
||||
speedStep: 5, //快进快退秒数
|
||||
setInter: '', //定时器
|
||||
currentItem: undefined,
|
||||
items: [{
|
||||
title: '标题', //标题
|
||||
count: 3, //数量
|
||||
type: 'TEXT', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 9, //数量
|
||||
type: 'TEXTAREA', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 2, //数量
|
||||
type: 'AUDIO', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 3, //数量
|
||||
type: 'VIDEO', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 9, //数量
|
||||
type: 'PHOTO', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 9, //数量
|
||||
type: 'LINK', //类型
|
||||
}, {
|
||||
title: '标题', //标题
|
||||
count: 2, //数量
|
||||
type: 'LOCATION', //类型
|
||||
}],
|
||||
isAuthAudio: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.setData({
|
||||
columnId: options.id
|
||||
})
|
||||
this.checkPermission()
|
||||
this.getFieldList()
|
||||
},
|
||||
getFieldList() {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
})
|
||||
var _self = this
|
||||
app.http.get(app.urls.getMomentsField.format({
|
||||
configColumnId: _self.data.columnId
|
||||
}), {
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
fieldList: res.data
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
//申请录音权限
|
||||
checkPermission() {
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
var isAuth = res.authSetting['scope.record']
|
||||
if (typeof (isAuth) == 'undefined') {
|
||||
wx.authorize({
|
||||
scope: 'scope.record',
|
||||
success() {
|
||||
_self.setData({
|
||||
isAuthAudio: true
|
||||
})
|
||||
},
|
||||
fail() {
|
||||
_self.setData({
|
||||
isAuthAudio: false
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (!isAuth) {
|
||||
_self.openSetting()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
openSetting() {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '发布内容需要您授权录音权限.',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
wx.openSetting({
|
||||
withSubscriptions: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
onShow() {
|
||||
if (chooseLocation.getLocation() != null) {
|
||||
if (this.data.locationList.length < this.data.currentItem.count) {
|
||||
this.data.locationList.push(chooseLocation.getLocation())
|
||||
this.setData({
|
||||
locationList: this.data.locationList
|
||||
})
|
||||
}
|
||||
}
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
withSubscriptions: true,
|
||||
success(res) {
|
||||
var isAuth = res.authSetting['scope.record']
|
||||
_self.setData({
|
||||
isAuthAudio: isAuth
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
chooseLocation.setLocation(null)
|
||||
this.setData({
|
||||
map: null
|
||||
})
|
||||
},
|
||||
//选择视频来源
|
||||
chooseVideo(e) {
|
||||
var _self = this
|
||||
var countNum = _self.data.currentItem.count - _self.data.videoList.length
|
||||
console.log(countNum)
|
||||
var type = e.currentTarget.dataset.type
|
||||
wx.chooseMedia({
|
||||
count: Number.parseInt(countNum),
|
||||
mediaType: ['video'],
|
||||
sourceType: [type],
|
||||
maxDuration: 60,
|
||||
success: (res) => {
|
||||
if (res.tempFiles.length > 0) {
|
||||
_self.doUploadVideo(1, res.tempFiles, _self.data.uploadVideoCount)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
// console.log(err)
|
||||
// wx.showToast({
|
||||
// title: '选取视频失败,(拍摄时长:60秒)',
|
||||
// icon: 'none'
|
||||
// })
|
||||
}
|
||||
})
|
||||
},
|
||||
//上传视频
|
||||
doUploadVideo(type, paths, curIndex) {
|
||||
console.log(paths)
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
var count = paths.length //几次
|
||||
if (_self.data.uploadVideoCount < count) {
|
||||
app.http.upload(app.urls.doUploadVideo, {
|
||||
path: paths[_self.data.uploadVideoCount].tempFilePath,
|
||||
name: 'video',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
var item = {
|
||||
id: id,
|
||||
path: pathStr,
|
||||
imgPath: paths[_self.data.uploadVideoCount].thumbTempFilePath
|
||||
}
|
||||
_self.data.videoList.push(item)
|
||||
_self.setData({
|
||||
videoList: _self.data.videoList
|
||||
})
|
||||
_self.setData({
|
||||
uploadVideoCount: ++_self.data.uploadVideoCount
|
||||
})
|
||||
_self.doUploadVideo(1, paths, _self.data.uploadVideoCount)
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadVideoCount: ++_self.data.uploadVideoCount
|
||||
})
|
||||
_self.doUploadVideo(1, paths, _self.data.uploadVideoCount)
|
||||
})
|
||||
} else {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadVideoCount: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
//预览视频
|
||||
viewVideo(e) {
|
||||
var tempList = [{
|
||||
url: e.currentTarget.dataset.url,
|
||||
type: 'video'
|
||||
}]
|
||||
wx.previewMedia({
|
||||
sources: tempList,
|
||||
current: 0,
|
||||
showmenu: false
|
||||
})
|
||||
},
|
||||
//删除视频
|
||||
delVideo(e) {
|
||||
let _self = this
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该视频吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
_self.data.videoList.splice(e.currentTarget.dataset.index, 1)
|
||||
_self.setData({
|
||||
videoList: _self.data.videoList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//添加链接
|
||||
addLink() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'LINK') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.linkList.length < item.count) {
|
||||
if (_self.data.linkStr == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.linkList.push(_self.data.linkStr)
|
||||
_self.setData({
|
||||
linkList: _self.data.linkList,
|
||||
linkStr: ''
|
||||
})
|
||||
if (_self.data.linkList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowLink: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//文本域添加输入的文字
|
||||
addDesc() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'TEXTAREA') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.textareaList.length < item.count) {
|
||||
if (_self.data.tempDesc == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.textareaList.push(_self.data.tempDesc)
|
||||
_self.setData({
|
||||
textareaList: _self.data.textareaList,
|
||||
tempDesc: ''
|
||||
})
|
||||
if (_self.data.textareaList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowDesc: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//添加输入的文字
|
||||
addStr() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'TEXT') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.textList.length < item.count) {
|
||||
if (_self.data.tempText == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.textList.push(_self.data.tempText)
|
||||
_self.setData({
|
||||
textList: _self.data.textList,
|
||||
tempText: ''
|
||||
})
|
||||
if (_self.data.textList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowText: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//删除
|
||||
delText(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.textList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
textList: this.data.textList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
delLink(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.linkList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
linkList: this.data.linkList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
delDesc(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.textareaList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
textareaList: this.data.textareaList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//监听输入的文字
|
||||
textInput(e) {
|
||||
this.setData({
|
||||
[e.currentTarget.id]: e.detail.value
|
||||
})
|
||||
},
|
||||
//关闭弹窗
|
||||
onHide(e) {
|
||||
this.setData({
|
||||
isShowText: false,
|
||||
isShowDesc: false,
|
||||
isShowPhoto: false,
|
||||
isShowLink: false,
|
||||
isShowAudio: false,
|
||||
isShowVideo: false
|
||||
})
|
||||
},
|
||||
//选择图片
|
||||
choosePhoto(e) {
|
||||
var _self = this
|
||||
var countNum = _self.data.currentItem.count - _self.data.photoList.length
|
||||
var type = e.currentTarget.dataset.type
|
||||
wx.chooseImage({
|
||||
count: Number.parseInt(countNum),
|
||||
sourceType: [type],
|
||||
success: (res) => {
|
||||
_self.doUploadImg(1, res.tempFilePaths, _self.data.uploadCount)
|
||||
},
|
||||
fail: (err) => {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
//删除图片
|
||||
delImg(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该图片吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.photoList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
photoList: this.data.photoList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//预览图片
|
||||
viewImg(e) {
|
||||
var tempList = [e.currentTarget.dataset.url]
|
||||
wx.previewImage({
|
||||
urls: tempList,
|
||||
current: e.currentTarget.dataset.url
|
||||
});
|
||||
},
|
||||
doUploadImg(type, paths, curIndex) {
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
var count = paths.length //几次
|
||||
if (_self.data.uploadCount < count) {
|
||||
app.http.upload(app.urls.doUploadImg, {
|
||||
path: paths[_self.data.uploadCount],
|
||||
name: 'image',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
var item = {
|
||||
id: id,
|
||||
path: pathStr
|
||||
}
|
||||
_self.data.photoList.push(item)
|
||||
_self.setData({
|
||||
photoList: _self.data.photoList
|
||||
})
|
||||
_self.setData({
|
||||
uploadCount: ++_self.data.uploadCount
|
||||
})
|
||||
_self.doUploadImg(1, paths, _self.data.uploadCount)
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadCount: ++_self.data.uploadCount
|
||||
})
|
||||
_self.doUploadImg(1, paths, _self.data.uploadCount)
|
||||
})
|
||||
} else {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadCount: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
//地图选点
|
||||
chooseLocation() {
|
||||
this.data.items.forEach(it => {
|
||||
if (it.type == 'LOCATION') {
|
||||
this.setData({
|
||||
currentItem: it
|
||||
})
|
||||
}
|
||||
})
|
||||
wx.navigateTo({
|
||||
url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}&category=${category}`
|
||||
});
|
||||
},
|
||||
delMap(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.locationList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
locationList: this.data.locationList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//删除视频
|
||||
delAudio(e) {
|
||||
let _self = this
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该音频吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
_self.data.audioList.splice(e.currentTarget.dataset.index, 1)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
doStartRecord() {
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting['scope.record']) {
|
||||
wx.authorize({
|
||||
scope: 'scope.record',
|
||||
success() {
|
||||
_self.startRecord()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_self.startRecord()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
startRecord() {
|
||||
var that = this
|
||||
that.data.setInter = setInterval(
|
||||
function () {
|
||||
var speck_time = parseInt(that.data.speck_time + 1);
|
||||
that.setData({
|
||||
speck_time: parseInt(speck_time),
|
||||
isStartRecord: true
|
||||
});
|
||||
if (that.data.speck_time > 0 && that.data.speck_time <= 59) {
|
||||
that.start();
|
||||
} else {
|
||||
clearInterval(that.data.setInter);
|
||||
// 获取到结束时间
|
||||
that.stop();
|
||||
wx.showToast({
|
||||
title: '录音最长60S哦!',
|
||||
duration: 2000,
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
doEndRecord() {
|
||||
var _self = this;
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
if (_self.data.speck_time > 3) {
|
||||
//清除计时器 即清除setInter
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
_self.stop(true);
|
||||
_self.setData({
|
||||
speck_time: "0",
|
||||
isStartRecord: false
|
||||
})
|
||||
} else {
|
||||
//清除计时器 即清除setInter
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
_self.stop(false);
|
||||
wx.showToast({
|
||||
title: '录制时间过短',
|
||||
duration: 2000,
|
||||
icon: "none"
|
||||
})
|
||||
_self.setData({
|
||||
speck_time: "0",
|
||||
isStartRecord: false
|
||||
})
|
||||
}
|
||||
},
|
||||
//开始录音的时候
|
||||
start() {
|
||||
const options = {
|
||||
duration: 60000,
|
||||
format: 'mp3', //音频格式,有效值 aac/mp3
|
||||
}
|
||||
//开始录音
|
||||
recorderManager.start(options);
|
||||
recorderManager.onStart(() => {
|
||||
console.log('recorder start')
|
||||
});
|
||||
//错误回调
|
||||
recorderManager.onError((res) => {
|
||||
console.log(res);
|
||||
_self.stop(false);
|
||||
})
|
||||
},
|
||||
//停止录音
|
||||
stop(success) {
|
||||
var _self = this
|
||||
recorderManager.stop();
|
||||
recorderManager.onStop((res) => {
|
||||
if (success) {
|
||||
//进行录音文件上传
|
||||
_self.doUploadAudio(res)
|
||||
}
|
||||
})
|
||||
},
|
||||
doUploadAudio(audio) {
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
app.http.upload(app.urls.doUploadAudio, {
|
||||
path: audio.tempFilePath,
|
||||
name: 'audio',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
if (_self.data.audioList.length < _self.data.currentItem.count) {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
//计算时长
|
||||
var dur = parseInt(audio.duration / 1000)
|
||||
var tM = parseInt(dur / 60) //分钟
|
||||
var tS = parseInt(dur % 60) //秒
|
||||
var totalMStr = tM > 9 ? tM : '0' + tM
|
||||
var totalSStr = +tS > 9 ? tS : '0' + tS
|
||||
var totalStr = totalMStr + ':' + totalSStr
|
||||
var item = {
|
||||
id: id, //id
|
||||
path: pathStr, //地址
|
||||
isPlay: false, //是否播放中
|
||||
duration: dur, //时长
|
||||
curDuation: 0,
|
||||
curDurationStr: '00:00',
|
||||
totalDurationStr: totalStr
|
||||
}
|
||||
_self.data.audioList.push(item)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
console.log(_self.data.audioList)
|
||||
if (_self.data.audioList.length == _self.data.currentItem.count) {
|
||||
_self.setData({
|
||||
isShowAudio: false
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => {})
|
||||
},
|
||||
play(e) {
|
||||
|
||||
//进行播放
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
var _self = this
|
||||
_self.data.audioList.forEach(it => {
|
||||
if (it.isPlay) {
|
||||
innerAudioContext.stop()
|
||||
}
|
||||
it.isPlay = false
|
||||
it.curDuation = 0
|
||||
it.curDuationStr = '00:00'
|
||||
})
|
||||
if (!item.isPlay) {
|
||||
// innerAudioContext.stop()
|
||||
//找到该文件
|
||||
innerAudioContext = wx.createInnerAudioContext()
|
||||
// 播放音频文件
|
||||
innerAudioContext.src = _self.data.audioList[index].path
|
||||
innerAudioContext.autoplay = true
|
||||
}
|
||||
//先需要停止其他录音文件的播放
|
||||
|
||||
innerAudioContext.onPlay(() => {
|
||||
_self.data.audioList[index].isPlay = true
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
});
|
||||
|
||||
innerAudioContext.onCanplay((res) => {
|
||||
if (_self.data.waitFlag) {
|
||||
innerAudioContext.play()
|
||||
_self.setData({
|
||||
waitFlag: false
|
||||
})
|
||||
}
|
||||
})
|
||||
innerAudioContext.onStop((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onEnded((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onError((res) => {
|
||||
_self.data.audioList[index].isPlay = false
|
||||
_self.data.audioList[index].curDuration = 0
|
||||
_self.data.audioList[index].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onSeeking(() => {
|
||||
console.log(innerAudioContext.currentTime)
|
||||
})
|
||||
innerAudioContext.onWaiting(() => {
|
||||
innerAudioContext.pause()
|
||||
_self.setData({
|
||||
waitFlag: true
|
||||
})
|
||||
})
|
||||
innerAudioContext.onTimeUpdate(() => {
|
||||
if (innerAudioContext.duration != Infinity) {
|
||||
_self.data.audioList[index].curDuration = parseInt(innerAudioContext.currentTime)
|
||||
_self.data.audioList[index].duration = parseInt(innerAudioContext.duration)
|
||||
console.log(innerAudioContext.duration)
|
||||
var curM = parseInt(innerAudioContext.currentTime / 60) //分钟
|
||||
var curS = parseInt(innerAudioContext.currentTime % 60) //秒
|
||||
var tM = parseInt(innerAudioContext.duration / 60) //分钟
|
||||
var tS = parseInt(innerAudioContext.duration % 60) //秒
|
||||
var curMStr = curM > 9 ? curM : '0' + curM
|
||||
var curSStr = curS > 9 ? curS : '0' + curS
|
||||
var totalMStr = tM > 9 ? tM : '0' + tM
|
||||
var totalSStr = +tS > 9 ? tS : '0' + tS
|
||||
_self.data.audioList[index].curDurationStr = curMStr + ':' + curSStr
|
||||
_self.data.audioList[index].totalDurationStr = totalMStr + ':' + totalSStr
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//倒退5秒
|
||||
rewind(e) {
|
||||
var _self = this
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration - _self.data.speedStep
|
||||
innerAudioContext.seek(_self.data.audioList[index].curDuration)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
//快进5秒
|
||||
speed(e) {
|
||||
var _self = this
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
_self.data.audioList[index].curDuration = _self.data.audioList[index].curDuration + _self.data.speedStep
|
||||
innerAudioContext.seek(_self.data.audioList[index].curDuration)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
},
|
||||
slider4change(e) {
|
||||
var index = e.currentTarget.dataset.index
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
innerAudioContext.seek(e.detail.value)
|
||||
}
|
||||
},
|
||||
//显示弹框
|
||||
showDialog(e) {
|
||||
var type = e.currentTarget.dataset.type
|
||||
var keyType = e.currentTarget.dataset.keytype
|
||||
console.log(e)
|
||||
this.data.items.forEach(it => {
|
||||
if (it.type == type) {
|
||||
this.setData({
|
||||
currentItem: it
|
||||
})
|
||||
return
|
||||
}
|
||||
})
|
||||
this.setData({
|
||||
[keyType]: true
|
||||
})
|
||||
}
|
||||
})
|
3
pages/moments/publish/momentpublish.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
325
pages/moments/publish/momentpublish.wxml
Normal file
@ -0,0 +1,325 @@
|
||||
<cu-custom isBack="{{true}}">
|
||||
<view slot="content">内容发布</view>
|
||||
</cu-custom>
|
||||
<view wx:if="{{fieldList.length>0}}">
|
||||
<!-- 内容 1:文字,2:照片,3:音频,4:视频,5:链接,6:定位,7:文章 -->
|
||||
<view wx:for="{{fieldList}}" wx:key="index">
|
||||
<!-- 文本 -->
|
||||
<view class="flex flex-direction" wx:if="{{item.dataType=='1'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{textList.length>0}}" class="flex flex-direction" style="width:100%;">
|
||||
<!--输入的文本内容 -->
|
||||
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{textList}}" wx:key="index"
|
||||
wx:for-item="txt" style="width:100%;">
|
||||
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delText" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{textList.length < item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" bindtap="showDialog" data-type="TEXT" data-keyType="isShowText">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 文本域 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='7'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{textareaList.length>0}}" class="flex flex-direction" style="width:100%;">
|
||||
<!--输入的文本内容 -->
|
||||
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{textareaList}}" wx:key="index"
|
||||
wx:for-item="txt" style="width:100%;">
|
||||
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delDesc" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{textareaList.length < item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" bindtap="showDialog" data-type="TEXTAREA" data-keyType="isShowDesc">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 图片 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='2'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="flex flex-direction bg-white margin-sm radius padding-sm">
|
||||
<view class="flex flex-direction self-end" style="width:100%;text-align:right;"
|
||||
wx:if="{{photoList.length>0}}">
|
||||
{{'数量'+'('+photoList.length+'/'+ currentItem.maxCount+')'}}
|
||||
</view>
|
||||
<view wx:if="{{photoList.length>0}}" class="cu-form-group">
|
||||
<view class="grid col-4 grid-square flex-sub">
|
||||
<view class="bg-img" wx:for="{{photoList}}" wx:key="index" wx:for-item="photo" bindtap="viewImg"
|
||||
data-url="{{photo.path}}">
|
||||
<image src='{{photo.path}}' mode='scaleToFill'></image>
|
||||
<view class="cu-tag bg-red" catchtap="delImg" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{photoList.length < item.maxCount}}"
|
||||
class="cu-btn bg-blue radius margin-top-sm selfcenter" style="width:60%;" bindtap="showDialog"
|
||||
data-type="PHOTO" data-keyType="isShowPhoto">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 音频 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='3'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{audioList.length > 0}}" style="width:100%;">
|
||||
<view class="flex align-center shadow-box margin-top-xs" style="width:100%;" wx:for="{{audioList}}"
|
||||
wx:key="index" wx:for-item="audio">
|
||||
<image src="/images/ic_user_default.png" mode="scaleToFill" style="width:80rpx;height:80rpx;">
|
||||
</image>
|
||||
<view class="play-box">
|
||||
<view class="flex justify-between align-center" style="width:80%;">
|
||||
<text>{{audio.curDurationStr}}</text>
|
||||
<slider class="flex-sub" bindchange="slider4change" min="{{0}}" max="{{audio.duration}}"
|
||||
value="{{audio.curDuration}}" backgroundColor="#cacaca" activeColor="#1296db"
|
||||
data-index="{{index}}" data-item="{{audio}}" block-size="14"
|
||||
block-color="#1296db" />
|
||||
<text>{{audio.totalDurationStr}}</text>
|
||||
</view>
|
||||
<view class="flex justify-between" style="width:80%;">
|
||||
<image src="/images/ic_audio_rewind.png" mode="scaleToFill" data-index="{{index}}"
|
||||
data-item="{{audio}}" bindtap="rewind"></image>
|
||||
<image
|
||||
src="{{audio.isPlay ? '/images/ic_audio_playing.png':'/images/ic_audio_play.png'}}"
|
||||
mode="scaleToFill" bindtap="play" data-index="{{index}}" data-item="{{audio}}">
|
||||
</image>
|
||||
<image src="/images/ic_audio_speed.png" mode="scaleToFill" bindtap="speed"
|
||||
data-index="{{index}}" data-item="{{audio}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cu-tag bg-gray margin-left-xs" style="border-radius:50%;" catchtap="delAudio"
|
||||
data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_voice.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
语音,可以给名片访客留下更深的印象
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{audioList.length<item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" data-type="AUDIO" data-keyType="isShowAudio" bindtap="showDialog">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 视频 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='4'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="flex flex-direction bg-white margin-sm radius padding-sm">
|
||||
<view class="flex flex-direction self-end" style="width:100%;text-align:right;"
|
||||
wx:if="{{videoList.length>0}}">
|
||||
{{'数量'+'('+videoList.length+'/'+ currentItem.maxCount+')'}}
|
||||
</view>
|
||||
<view wx:if="{{videoList.length>0}}" class="cu-form-group">
|
||||
<view class="grid col-1 grid-square flex-sub">
|
||||
<view class="bg-img" wx:for="{{videoList}}" wx:key="index" wx:for-item="video"
|
||||
bindtap="viewVideo" style="height:280rpx;padding-bottom:0rpx;" data-url="{{video.path}}">
|
||||
<image src='{{video.imgPath}}' mode='scaleToFill'></image>
|
||||
<view class="cu-tag bg-red" catchtap="delVideo" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{videoList.length < item.maxCount}}"
|
||||
class="cu-btn bg-blue radius margin-top-sm selfcenter" style="width:60%;" bindtap="showDialog"
|
||||
data-type="VIDEO" data-keyType="isShowVideo">点击添加</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- 连接 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='5'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{linkList.length>0}}" class="flex flex-direction" style="width:100%;">
|
||||
<!--输入的文本内容 -->
|
||||
<view class="flex flex-nowrap align-center margin-top-xs" wx:for="{{linkList}}" wx:key="index"
|
||||
wx:for-item="txt" style="width:100%;">
|
||||
<text class="flex-sub" style="word-break:break-all" decode="true" space="nbsp">{{txt}}</text>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delLink" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_desc.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
用一段话,向名片访客介绍自己吧
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{linkList.length < item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" bindtap="showDialog" data-type="LINK" data-keyType="isShowLink">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 定位 -->
|
||||
<view class="flex flex-direction" wx:elif="{{item.type=='6'}}">
|
||||
<view class="hint-title">
|
||||
<image src="/images/title-bg.png" mode="scaleToFill"></image>
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white margin-sm radius padding-sm">
|
||||
<view wx:if="{{locationList.length>0}}">
|
||||
<view wx:for="{{locationList}}" wx:key="index" wx:for-item="m" style="width:100%;"
|
||||
class="margin-top-xs">
|
||||
<view class="flex justify-between">
|
||||
<view>
|
||||
{{m.name}}-{{m.address}}
|
||||
</view>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delMap" data-index="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view style="border-radius:10rpx;overflow:hidden;margin-top:10rpx;">
|
||||
<map style="width:100%;height:300rpx;" longitude="{{m.longitude}}" latitude="{{m.latitude}}"
|
||||
scale="12" markers="{{[{latitude:m.latitude,longitude:m.longitude}]}}"></map>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_map.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
在地图上选取一个地点
|
||||
</text>
|
||||
</view>
|
||||
|
||||
<view wx:if="{{locationList.length < item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" bindtap="chooseLocation">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view wx:else style="margin-top:200rpx;width:100%;">
|
||||
<van-empty description="暂无数据" image="../../../images/ic_empty_data.png" />
|
||||
</view>
|
||||
|
||||
<!-- 语音弹框 -->
|
||||
<van-action-sheet show="{{ isShowAudio }}" title="语音介绍添加" bind:close="onHide" data-type="1"
|
||||
style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:80rpx;"
|
||||
wx:if="{{audioFile==null}}">
|
||||
<image src="{{isRecording? '/images/ic_voice_record.gif':'/images/ic_record_start.png'}}" mode="heightFix"
|
||||
style="width:300rpx;height:300rpx;"></image>
|
||||
<text>00:{{speck_time>9 ? speck_time : '0'+ speck_time}}</text>
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" style="width:70%;" bindlongpress="startRecord"
|
||||
bindtouchend="doEndRecord">长按录音</view>
|
||||
</view>
|
||||
<!-- 存在录音文件 -->
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:80rpx;" wx:else>
|
||||
<image src="{{audioFile.isPlay? '/images/ic_voice_record.gif':'/images/ic_record_start.png'}}" mode="heightFix"
|
||||
style="width:300rpx;height:300rpx;"></image>
|
||||
<text>{{audioFile.isPlay ? '播放中:'+speck_time+'秒' : '时长:'+audioFile.duration+'秒'}}</text>
|
||||
<view class="flex" style="width:80%;">
|
||||
<view class="cu-btn bg-blue radius margin-top-sm flex-sub" bindtap="playAudio">点击播放</view>
|
||||
<view class="cu-btn bg-red radius margin-top-sm flex-sub margin-left" bindtap="delAudio">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 文本域弹框 -->
|
||||
<van-action-sheet show="{{ isShowDesc }}" title="{{'文本内容'+'('+textareaList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="2" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<textarea id="tempDesc" placeholder="请输入文本内容" style="width:90%;" value="{{tempDesc}}"
|
||||
bindinput="textInput"></textarea>
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addDesc">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 文本内容弹框 -->
|
||||
<van-action-sheet show="{{ isShowText }}" title="{{'文本内容'+'('+textList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="3" style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<input id="tempText" placeholder="请输入文本内容" style="width:90%;" value="{{tempText}}" bindinput="textInput" />
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addStr">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 图片弹框 -->
|
||||
<van-action-sheet show="{{ isShowPhoto }}" title="图片选取" bind:close="onHide" data-type="4" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<view class="text-lg line" catchtap="choosePhoto" data-type="album">
|
||||
相册
|
||||
</view>
|
||||
<view class="text-lg noline" catchtap="choosePhoto" data-type="camera">
|
||||
相机
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 视频弹框 -->
|
||||
<van-action-sheet show="{{ isShowVideo }}" title="视频选取" bind:close="onHide" data-type="6" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<view class="text-lg line" catchtap="chooseVideo" data-type="album">
|
||||
相册
|
||||
</view>
|
||||
<view class="text-lg noline" catchtap="chooseVideo" data-type="camera">
|
||||
相机
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
|
||||
<!-- 文本内容弹框 -->
|
||||
<van-action-sheet show="{{ isShowLink }}" title="{{'链接内容'+'('+linkList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="5" style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<input id="linkStr" placeholder="请输入链接地址(https://www.baidu.com)" style="width:90%;" value="{{linkStr}}"
|
||||
bindinput="textInput" />
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addLink">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
49
pages/moments/publish/momentpublish.wxss
Normal file
@ -0,0 +1,49 @@
|
||||
/* pages/moments/publish/momentpublish.wxss */
|
||||
|
||||
|
||||
van-action-sheet input {
|
||||
border: 1px solid rgb(194, 194, 194);
|
||||
border-radius: 10rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-top: 9rpx;
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
|
||||
van-action-sheet textarea {
|
||||
border: 1px solid rgb(194, 194, 194);
|
||||
border-radius: 10rpx;
|
||||
margin-top: 9rpx;
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
van-action-sheet .line {
|
||||
height: 90rpx;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
width: 90%;
|
||||
border-top-width: 1rpx;
|
||||
border-top-color: #f5f5f5;
|
||||
border-top-style: solid;
|
||||
border-bottom-width: 1rpx;
|
||||
border-bottom-color: #f5f5f5;
|
||||
border-bottom-style: solid;
|
||||
}
|
||||
|
||||
van-action-sheet .noline {
|
||||
height: 90rpx;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
|
||||
van-action-sheet .line:active {
|
||||
color: black;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
van-action-sheet .noline:active {
|
||||
color: black;
|
||||
background-color: #f5f5f5;
|
||||
}
|
847
pages/moments/publish/momentpublishline.js
Normal file
@ -0,0 +1,847 @@
|
||||
const app = getApp()
|
||||
const recorderManager = wx.getRecorderManager()
|
||||
var innerAudioContext = wx.createInnerAudioContext()
|
||||
const chooseLocation = requirePlugin('chooseLocation');
|
||||
const key = 'Y6FBZ-GLQC3-6273Q-3DRTL-W43G5-G6BXN'; //使用在腾讯位置服务申请的key
|
||||
const referer = '名片-小程序'; //调用插件的app的名称
|
||||
const location = JSON.stringify({
|
||||
latitude: 39.89631551,
|
||||
longitude: 116.323459711
|
||||
});
|
||||
const category = '生活服务,娱乐休闲';
|
||||
Page({
|
||||
|
||||
/**
|
||||
* 页面的初始数据
|
||||
*/
|
||||
data: {
|
||||
uploadCount: 0,
|
||||
uploadVideoCount: 0,
|
||||
currentIndex: 0,
|
||||
columnId: '', //栏目Id
|
||||
fieldList: [], //栏目字段
|
||||
textList: [], //文本添加内容
|
||||
textareaList: [], //文本域添加内容
|
||||
audioList: [], //音频添加内容
|
||||
videoList: [], //视频添加内容
|
||||
photoList: [], //视频添加内容
|
||||
linkList: [], //连接添加内容
|
||||
locationList: [], //定位添加内容
|
||||
isShowText: false, //文本弹窗开关
|
||||
isShowDesc: false, //文本域弹窗开关
|
||||
isShowPhoto: false, //图片选择弹框
|
||||
isShowLink: false, //链接弹窗
|
||||
isShowAudio: false, //录音弹窗
|
||||
isShowVideo: false, //视频弹窗
|
||||
tempText: '',
|
||||
tempDesc: '',
|
||||
linkStr: '',
|
||||
map: null,
|
||||
waitFlag: false,
|
||||
isStartRecord: false, //是否录音中
|
||||
speck_time: 0,
|
||||
speedStep: 5, //快进快退秒数
|
||||
setInter: '', //定时器
|
||||
currentItem: undefined,
|
||||
isAuthAudio: false
|
||||
},
|
||||
|
||||
/**
|
||||
* 生命周期函数--监听页面加载
|
||||
*/
|
||||
onLoad: function (options) {
|
||||
this.setData({
|
||||
columnId: options.id
|
||||
})
|
||||
this.checkPermission()
|
||||
this.getFieldList()
|
||||
},
|
||||
getFieldList() {
|
||||
wx.showLoading({
|
||||
title: '加载中...',
|
||||
})
|
||||
var _self = this
|
||||
app.http.get(app.urls.getMomentsField.format({
|
||||
configColumnId: _self.data.columnId
|
||||
}), {
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
res.data.forEach(it => {
|
||||
// 2:照片,3:音频,4:视频,5:链接,6:定位
|
||||
switch (it.dataType) {
|
||||
case '2':
|
||||
case '3':
|
||||
case '4':
|
||||
case '5':
|
||||
case '6':
|
||||
it.valueList = []
|
||||
break
|
||||
}
|
||||
})
|
||||
_self.setData({
|
||||
fieldList: res.data
|
||||
})
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
console.log(err)
|
||||
})
|
||||
},
|
||||
inputText(e) {
|
||||
var index = e.currentTarget.dataset.index
|
||||
var _self = this
|
||||
_self.data.fieldList[index].value = e.detail.value
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
},
|
||||
//申请录音权限
|
||||
checkPermission() {
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
var isAuth = res.authSetting['scope.record']
|
||||
if (typeof (isAuth) == 'undefined') {
|
||||
wx.authorize({
|
||||
scope: 'scope.record',
|
||||
success() {
|
||||
_self.setData({
|
||||
isAuthAudio: true
|
||||
})
|
||||
},
|
||||
fail() {
|
||||
_self.setData({
|
||||
isAuthAudio: false
|
||||
})
|
||||
}
|
||||
})
|
||||
} else {
|
||||
if (!isAuth) {
|
||||
_self.openSetting()
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
openSetting() {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '发布内容需要您授权录音权限.',
|
||||
success(res) {
|
||||
if (res.confirm) {
|
||||
wx.openSetting({
|
||||
withSubscriptions: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
onShow() {
|
||||
if (chooseLocation.getLocation() != null) {
|
||||
if (this.data.locationList.length < this.data.currentItem.count) {
|
||||
this.data.locationList.push(chooseLocation.getLocation())
|
||||
this.setData({
|
||||
locationList: this.data.locationList
|
||||
})
|
||||
}
|
||||
}
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
withSubscriptions: true,
|
||||
success(res) {
|
||||
var isAuth = res.authSetting['scope.record']
|
||||
_self.setData({
|
||||
isAuthAudio: isAuth
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
onUnload() {
|
||||
chooseLocation.setLocation(null)
|
||||
this.setData({
|
||||
map: null
|
||||
})
|
||||
},
|
||||
//选择视频来源
|
||||
chooseVideo(e) {
|
||||
var _self = this
|
||||
var item = e.currentTarget.dataset.item
|
||||
var countNum = item.maxCount - item.valueList.length
|
||||
var index = e.currentTarget.dataset.index
|
||||
wx.chooseMedia({
|
||||
count: Number.parseInt(countNum),
|
||||
mediaType: ['video'],
|
||||
sourceType: ['camera', 'album'],
|
||||
maxDuration: 60,
|
||||
success: (res) => {
|
||||
if (res.tempFiles.length > 0) {
|
||||
_self.doUploadVideo(index, res.tempFiles, _self.data.uploadVideoCount)
|
||||
}
|
||||
},
|
||||
fail: (err) => {
|
||||
// console.log(err)
|
||||
// wx.showToast({
|
||||
// title: '选取视频失败,(拍摄时长:60秒)',
|
||||
// icon: 'none'
|
||||
// })
|
||||
}
|
||||
})
|
||||
},
|
||||
//上传视频
|
||||
doUploadVideo(index, paths, curIndex) {
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
var count = paths.length //几次
|
||||
if (_self.data.uploadVideoCount < count) {
|
||||
app.http.upload(app.urls.doUploadVideo, {
|
||||
path: paths[_self.data.uploadVideoCount].tempFilePath,
|
||||
name: 'video',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
var item = {
|
||||
id: id,
|
||||
path: pathStr,
|
||||
imgPath: paths[_self.data.uploadVideoCount].thumbTempFilePath
|
||||
}
|
||||
_self.data.fieldList[index].valueList.push(item)
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
_self.setData({
|
||||
uploadVideoCount: ++_self.data.uploadVideoCount
|
||||
})
|
||||
_self.doUploadVideo(index, paths, _self.data.uploadVideoCount)
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadVideoCount: ++_self.data.uploadVideoCount
|
||||
})
|
||||
_self.doUploadVideo(1, paths, _self.data.uploadVideoCount)
|
||||
})
|
||||
} else {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadVideoCount: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
//预览视频
|
||||
viewVideo(e) {
|
||||
var tempList = [{
|
||||
url: e.currentTarget.dataset.url,
|
||||
type: 'video'
|
||||
}]
|
||||
wx.previewMedia({
|
||||
sources: tempList,
|
||||
current: 0,
|
||||
showmenu: false
|
||||
})
|
||||
},
|
||||
//删除视频
|
||||
delVideo(e) {
|
||||
let _self = this
|
||||
var index = e.currentTarget.dataset.index
|
||||
var idx = e.currentTarget.dataset.idx
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该视频吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
_self.data.fieldList[index].valueList.splice(idx, 1)
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//添加链接
|
||||
addLink() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'LINK') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.linkList.length < item.count) {
|
||||
if (_self.data.linkStr == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.linkList.push(_self.data.linkStr)
|
||||
_self.setData({
|
||||
linkList: _self.data.linkList,
|
||||
linkStr: ''
|
||||
})
|
||||
if (_self.data.linkList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowLink: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//文本域添加输入的文字
|
||||
addDesc() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'TEXTAREA') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.textareaList.length < item.count) {
|
||||
if (_self.data.tempDesc == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.textareaList.push(_self.data.tempDesc)
|
||||
_self.setData({
|
||||
textareaList: _self.data.textareaList,
|
||||
tempDesc: ''
|
||||
})
|
||||
if (_self.data.textareaList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowDesc: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//添加输入的文字
|
||||
addStr() {
|
||||
var _self = this
|
||||
var item = null
|
||||
for (var i = 0; i < _self.data.items.length; i++) {
|
||||
if (_self.data.items[i].type == 'TEXT') {
|
||||
item = _self.data.items[i]
|
||||
break
|
||||
}
|
||||
}
|
||||
if (_self.data.textList.length < item.count) {
|
||||
if (_self.data.tempText == '') {
|
||||
wx.showToast({
|
||||
title: '请输入文字内容',
|
||||
icon: 'error'
|
||||
})
|
||||
return
|
||||
}
|
||||
_self.data.textList.push(_self.data.tempText)
|
||||
_self.setData({
|
||||
textList: _self.data.textList,
|
||||
tempText: ''
|
||||
})
|
||||
if (_self.data.textList.length == item.count) {
|
||||
_self.setData({
|
||||
isShowText: false
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
//删除
|
||||
delText(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.textList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
textList: this.data.textList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
delLink(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.linkList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
linkList: this.data.linkList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
delDesc(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.textareaList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
textareaList: this.data.textareaList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//监听输入的文字
|
||||
textInput(e) {
|
||||
this.setData({
|
||||
[e.currentTarget.id]: e.detail.value
|
||||
})
|
||||
},
|
||||
//关闭弹窗
|
||||
onHide(e) {
|
||||
this.setData({
|
||||
isShowText: false,
|
||||
isShowDesc: false,
|
||||
isShowPhoto: false,
|
||||
isShowLink: false,
|
||||
isShowAudio: false,
|
||||
isShowVideo: false
|
||||
})
|
||||
},
|
||||
//选择图片
|
||||
choosePhoto(e) {
|
||||
var _self = this
|
||||
var item = e.currentTarget.dataset.item
|
||||
var index = e.currentTarget.dataset.index
|
||||
var countNum = item.maxCount - item.valueList.length
|
||||
|
||||
wx.chooseImage({
|
||||
count: Number.parseInt(countNum),
|
||||
sourceType: ['album', 'camera'],
|
||||
success: (res) => {
|
||||
_self.doUploadImg(index, res.tempFilePaths, _self.data.uploadCount)
|
||||
},
|
||||
fail: (err) => {
|
||||
|
||||
}
|
||||
})
|
||||
},
|
||||
//删除图片
|
||||
delImg(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该图片吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.fieldList[e.currentTarget.dataset.itemindex].valueList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
fieldList: this.data.fieldList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//预览图片
|
||||
viewImg(e) {
|
||||
var tempList = [e.currentTarget.dataset.url]
|
||||
wx.previewImage({
|
||||
urls: tempList,
|
||||
current: e.currentTarget.dataset.url
|
||||
});
|
||||
},
|
||||
doUploadImg(index, paths, curIndex) {
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
var count = paths.length //几次
|
||||
if (_self.data.uploadCount < count) {
|
||||
app.http.upload(app.urls.doUploadImg, {
|
||||
path: paths[_self.data.uploadCount],
|
||||
name: 'image',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
var item = {
|
||||
id: id,
|
||||
path: pathStr
|
||||
}
|
||||
_self.data.fieldList[index].valueList.push(item)
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
_self.setData({
|
||||
uploadCount: ++_self.data.uploadCount
|
||||
})
|
||||
_self.doUploadImg(index, paths, _self.data.uploadCount)
|
||||
})
|
||||
.catch(err => {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadCount: ++_self.data.uploadCount
|
||||
})
|
||||
_self.doUploadImg(index, paths, _self.data.uploadCount)
|
||||
})
|
||||
} else {
|
||||
wx.hideLoading({})
|
||||
_self.setData({
|
||||
uploadCount: 0
|
||||
})
|
||||
}
|
||||
},
|
||||
//地图选点
|
||||
chooseLocation() {
|
||||
var index = e.currentTarget.dataset.index
|
||||
this.setData({
|
||||
curMapIndex: index
|
||||
})
|
||||
wx.navigateTo({
|
||||
url: `plugin://chooseLocation/index?key=${key}&referer=${referer}&location=${location}&category=${category}`
|
||||
});
|
||||
},
|
||||
delMap(e) {
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该条数据吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
this.data.locationList.splice(e.currentTarget.dataset.index, 1)
|
||||
this.setData({
|
||||
locationList: this.data.locationList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
//删除视频
|
||||
delAudio(e) {
|
||||
let _self = this
|
||||
wx.showModal({
|
||||
title: '提示',
|
||||
content: '确定要删除该音频吗?',
|
||||
cancelText: '取消',
|
||||
confirmText: '确定',
|
||||
success: res => {
|
||||
if (res.confirm) {
|
||||
_self.data.audioList.splice(e.currentTarget.dataset.index, 1)
|
||||
_self.setData({
|
||||
audioList: _self.data.audioList
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
doStartRecord() {
|
||||
var _self = this
|
||||
wx.getSetting({
|
||||
success(res) {
|
||||
if (!res.authSetting['scope.record']) {
|
||||
wx.authorize({
|
||||
scope: 'scope.record',
|
||||
success() {
|
||||
_self.startRecord()
|
||||
}
|
||||
})
|
||||
} else {
|
||||
_self.startRecord()
|
||||
}
|
||||
}
|
||||
})
|
||||
},
|
||||
startRecord() {
|
||||
var that = this
|
||||
that.data.setInter = setInterval(
|
||||
function () {
|
||||
var speck_time = parseInt(that.data.speck_time + 1);
|
||||
that.setData({
|
||||
speck_time: parseInt(speck_time),
|
||||
isStartRecord: true
|
||||
});
|
||||
if (that.data.speck_time > 0 && that.data.speck_time <= 59) {
|
||||
that.start();
|
||||
} else {
|
||||
clearInterval(that.data.setInter);
|
||||
// 获取到结束时间
|
||||
that.stop();
|
||||
wx.showToast({
|
||||
title: '录音最长60S哦!',
|
||||
duration: 2000,
|
||||
icon: "none"
|
||||
})
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
doEndRecord() {
|
||||
var _self = this;
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
if (_self.data.speck_time > 3) {
|
||||
//清除计时器 即清除setInter
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
_self.stop(true);
|
||||
_self.setData({
|
||||
speck_time: "0",
|
||||
isStartRecord: false
|
||||
})
|
||||
} else {
|
||||
//清除计时器 即清除setInter
|
||||
clearInterval(_self.data.setInter);
|
||||
// 获取到结束时间
|
||||
_self.stop(false);
|
||||
wx.showToast({
|
||||
title: '录制时间过短',
|
||||
duration: 2000,
|
||||
icon: "none"
|
||||
})
|
||||
_self.setData({
|
||||
speck_time: "0",
|
||||
isStartRecord: false
|
||||
})
|
||||
}
|
||||
},
|
||||
//开始录音的时候
|
||||
start() {
|
||||
const options = {
|
||||
duration: 60000,
|
||||
format: 'mp3', //音频格式,有效值 aac/mp3
|
||||
}
|
||||
//开始录音
|
||||
recorderManager.start(options);
|
||||
recorderManager.onStart(() => {
|
||||
console.log('recorder start')
|
||||
});
|
||||
//错误回调
|
||||
recorderManager.onError((res) => {
|
||||
console.log(res);
|
||||
_self.stop(false);
|
||||
})
|
||||
},
|
||||
//停止录音
|
||||
stop(success) {
|
||||
var _self = this
|
||||
recorderManager.stop();
|
||||
recorderManager.onStop((res) => {
|
||||
if (success) {
|
||||
//进行录音文件上传
|
||||
_self.doUploadAudio(res)
|
||||
}
|
||||
})
|
||||
},
|
||||
doUploadAudio(audio) {
|
||||
wx.showLoading({
|
||||
title: '上传中...',
|
||||
})
|
||||
let _self = this
|
||||
app.http.upload(app.urls.doUploadAudio, {
|
||||
path: audio.tempFilePath,
|
||||
name: 'audio',
|
||||
header: {
|
||||
token: app.globalData.token
|
||||
}
|
||||
})
|
||||
.then(res => {
|
||||
wx.hideLoading({})
|
||||
if (_self.data.fieldList[_self.data.currentIndex].valueList.length < _self.data.currentItem.maxCount) {
|
||||
wx.hideLoading({})
|
||||
//插入到集合中
|
||||
var id = JSON.parse(res).data
|
||||
var pathStr = app.urls.baseImgUrl + id
|
||||
//计算时长
|
||||
var dur = parseInt(audio.duration / 1000)
|
||||
var tM = parseInt(dur / 60) //分钟
|
||||
var tS = parseInt(dur % 60) //秒
|
||||
var totalMStr = tM > 9 ? tM : '0' + tM
|
||||
var totalSStr = +tS > 9 ? tS : '0' + tS
|
||||
var totalStr = totalMStr + ':' + totalSStr
|
||||
var item = {
|
||||
id: id, //id
|
||||
path: pathStr, //地址
|
||||
isPlay: false, //是否播放中
|
||||
duration: dur, //时长
|
||||
curDuation: 0,
|
||||
curDurationStr: '00:00',
|
||||
totalDurationStr: totalStr
|
||||
}
|
||||
_self.data.fieldList[_self.data.currentIndex].valueList.push(item)
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
if (_self.data.fieldList[_self.data.currentIndex].valueList == _self.data.currentItem.maxCount) {
|
||||
_self.setData({
|
||||
isShowAudio: false
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(err => {})
|
||||
},
|
||||
play(e) {
|
||||
|
||||
//进行播放
|
||||
var index = e.currentTarget.dataset.index
|
||||
var idx = e.currentTarget.dataset.idx
|
||||
var item = e.currentTarget.dataset.item
|
||||
var _self = this
|
||||
_self.data.fieldList[index].valueList.forEach(it => {
|
||||
if (it.isPlay) {
|
||||
innerAudioContext.stop()
|
||||
}
|
||||
it.isPlay = false
|
||||
it.curDuation = 0
|
||||
it.curDuationStr = '00:00'
|
||||
})
|
||||
if (!item.isPlay) {
|
||||
// innerAudioContext.stop()
|
||||
//找到该文件
|
||||
innerAudioContext = wx.createInnerAudioContext()
|
||||
// 播放音频文件
|
||||
innerAudioContext.src = _self.data.fieldList[index].valueList[idx].path
|
||||
innerAudioContext.autoplay = true
|
||||
}
|
||||
//先需要停止其他录音文件的播放
|
||||
|
||||
innerAudioContext.onPlay(() => {
|
||||
_self.data.fieldList[index].valueList[idx].isPlay = true
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
});
|
||||
|
||||
innerAudioContext.onCanplay((res) => {
|
||||
if (_self.data.waitFlag) {
|
||||
innerAudioContext.play()
|
||||
_self.setData({
|
||||
waitFlag: false
|
||||
})
|
||||
}
|
||||
})
|
||||
innerAudioContext.onStop((res) => {
|
||||
_self.data.fieldList[index].valueList[idx].isPlay = false
|
||||
_self.data.fieldList[index].valueList[idx].curDuration = 0
|
||||
_self.data.fieldList[index].valueList[idx].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onEnded((res) => {
|
||||
_self.data.fieldList[index].valueList[idx].isPlay = false
|
||||
_self.data.fieldList[index].valueList[idx].curDuration = 0
|
||||
_self.data.fieldList[index].valueList[idx].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onError((res) => {
|
||||
_self.data.fieldList[index].valueList[idx].isPlay = false
|
||||
_self.data.fieldList[index].valueList[idx].curDuration = 0
|
||||
_self.data.fieldList[index].valueList[idx].curDurationStr = '00:00'
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList,
|
||||
})
|
||||
})
|
||||
innerAudioContext.onSeeking(() => {
|
||||
console.log(innerAudioContext.currentTime)
|
||||
})
|
||||
innerAudioContext.onWaiting(() => {
|
||||
innerAudioContext.pause()
|
||||
_self.setData({
|
||||
waitFlag: true
|
||||
})
|
||||
})
|
||||
innerAudioContext.onTimeUpdate(() => {
|
||||
if (innerAudioContext.duration != Infinity) {
|
||||
_self.data.fieldList[index].valueList[idx].curDuration = parseInt(innerAudioContext.currentTime)
|
||||
_self.data.fieldList[index].valueList[idx].duration = parseInt(innerAudioContext.duration)
|
||||
console.log(innerAudioContext.duration)
|
||||
var curM = parseInt(innerAudioContext.currentTime / 60) //分钟
|
||||
var curS = parseInt(innerAudioContext.currentTime % 60) //秒
|
||||
var tM = parseInt(innerAudioContext.duration / 60) //分钟
|
||||
var tS = parseInt(innerAudioContext.duration % 60) //秒
|
||||
var curMStr = curM > 9 ? curM : '0' + curM
|
||||
var curSStr = curS > 9 ? curS : '0' + curS
|
||||
var totalMStr = tM > 9 ? tM : '0' + tM
|
||||
var totalSStr = +tS > 9 ? tS : '0' + tS
|
||||
_self.data.fieldList[index].valueList[idx].curDurationStr = curMStr + ':' + curSStr
|
||||
_self.data.fieldList[index].valueList[idx].totalDurationStr = totalMStr + ':' + totalSStr
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
//倒退5秒
|
||||
rewind(e) {
|
||||
var _self = this
|
||||
var index = e.currentTarget.dataset.index
|
||||
var idx = e.currentTarget.dataset.idx
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
_self.data.fieldList[index].valueList[idx].curDuration = _self.data.fieldList[index].valueList[idx].curDuration - _self.data.speedStep
|
||||
innerAudioContext.seek(_self.data.fieldList[index].valueList[idx].curDuration)
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
}
|
||||
|
||||
},
|
||||
//快进5秒
|
||||
speed(e) {
|
||||
var index = e.currentTarget.dataset.index
|
||||
var idx = e.currentTarget.dataset.idx
|
||||
var item = e.currentTarget.dataset.item
|
||||
var _self = this
|
||||
if (item.isPlay) {
|
||||
_self.data.fieldList[index].valueList[idx].curDuration = _self.data.fieldList[index].valueList[idx].curDuration + _self.data.speedStep
|
||||
innerAudioContext.seek(_self.data.fieldList[index].valueList[idx].curDuration)
|
||||
_self.setData({
|
||||
fieldList: _self.data.fieldList
|
||||
})
|
||||
}
|
||||
},
|
||||
slider4change(e) {
|
||||
var item = e.currentTarget.dataset.item
|
||||
if (item.isPlay) {
|
||||
innerAudioContext.seek(e.detail.value)
|
||||
}
|
||||
},
|
||||
//显示弹框
|
||||
showDialog(e) {
|
||||
console.log(e)
|
||||
this.setData({
|
||||
isShowAudio: true,
|
||||
currentItem: e.currentTarget.dataset.item,
|
||||
currentIndex: e.currentTarget.dataset.index
|
||||
})
|
||||
}
|
||||
})
|
3
pages/moments/publish/momentpublishline.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"usingComponents": {}
|
||||
}
|
270
pages/moments/publish/momentpublishline.wxml
Normal file
@ -0,0 +1,270 @@
|
||||
<cu-custom isBack="{{true}}">
|
||||
<view slot="content">内容发布</view>
|
||||
</cu-custom>
|
||||
<view wx:if="{{fieldList.length>0}}" class="flex flex-direction radius align-center">
|
||||
<view class="flex flex-direction self-center" style="width:95%;">
|
||||
<!-- 内容 1:文字,2:照片,3:音频,4:视频,5:链接,6:定位,7:文章 -->
|
||||
<view wx:for="{{fieldList}}" wx:key="index">
|
||||
<!-- 文本 -->
|
||||
<view wx:if="{{item.dataType == '1'}}" class="margin-top-xs">
|
||||
<view class="cu-form-group">
|
||||
<view class="title margin-left-sm">{{item.comment}}</view>
|
||||
<input placeholder="请输入内容" maxlength="{{item.maxLength}}" data-key="{{item.name}}"
|
||||
data-value="{{item.value}}" bindinput="inputText" data-index="{{index}}"></input>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 文本域 -->
|
||||
<view wx:if="{{item.dataType == '7'}}" class=" margin-top-xs">
|
||||
<view class="cu-bar bg-white margin-top-xs">
|
||||
<view class="action">
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="bg-white">
|
||||
<view class="cu-form-group">
|
||||
<textarea class="border-line padding-left-xs padding-right-xs margin-left-xs margin-right-xs"
|
||||
maxlength="{{item.maxLength}}" data-key="{{item.name}}" data-value="{{item.value}}"
|
||||
bindinput="inputText" data-index="{{index}}" placeholder="请输入内容"></textarea>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 图片 -->
|
||||
<view wx:elif="{{item.dataType == '2'}}" class=" margin-top-xs">
|
||||
<view class="cu-bar bg-white margin-top-xs">
|
||||
<view class="action">
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
{{item.valueList.length}}/{{item.maxCount}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="cu-form-group">
|
||||
<view class="grid col-4 grid-square flex-sub">
|
||||
<view class="bg-img" wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx"
|
||||
bindtap="viewImg" wx:for-item="photo" data-url="{{photo.path}}">
|
||||
<image src='{{photo.path}}' mode='aspectFill'></image>
|
||||
<view class="cu-tag bg-red" catchtap="delImg" data-index="{{idx}}"
|
||||
data-itemIndex="{{index}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="solids" bindtap="choosePhoto" data-item="{{item}}" data-index="{{index}}"
|
||||
wx:if="{{item.valueList.length<item.maxCount}}">
|
||||
<text class="cuIcon-cameraadd"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 音频 -->
|
||||
<view wx:elif="{{item.dataType == '3'}}" class=" margin-top-xs">
|
||||
<view class="cu-bar bg-white margin-top-xs">
|
||||
<view class="action">
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
{{item.valueList.length}}/{{item.maxCount}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white radius padding-sm">
|
||||
<view wx:if="{{item.valueList.length > 0}}" style="width:100%;">
|
||||
<view class="flex align-center shadow-box margin-top-xs" style="width:100%;"
|
||||
wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx" wx:for-item="audio">
|
||||
<image src="/images/ic_user_default.png" mode="scaleToFill"
|
||||
style="width:80rpx;height:80rpx;">
|
||||
</image>
|
||||
<view class="play-box">
|
||||
<view class="flex justify-between align-center" style="width:80%;">
|
||||
<text>{{audio.curDurationStr}}</text>
|
||||
<slider class="flex-sub" bindchange="slider4change" min="{{0}}"
|
||||
max="{{audio.duration}}" value="{{audio.curDuration}}" backgroundColor="#cacaca"
|
||||
activeColor="#1296db" data-index="{{index}}" data-idx="{{idx}}"
|
||||
data-item="{{audio}}" block-size="14" block-color="#1296db" />
|
||||
<text>{{audio.totalDurationStr}}</text>
|
||||
</view>
|
||||
<view class="flex justify-between" style="width:80%;">
|
||||
<image src="/images/ic_audio_rewind.png" mode="scaleToFill" data-index="{{index}}"
|
||||
data-idx="{{idx}}" data-item="{{audio}}" bindtap="rewind"></image>
|
||||
<image
|
||||
src="{{audio.isPlay ? '/images/ic_audio_playing.png':'/images/ic_audio_play.png'}}"
|
||||
mode="scaleToFill" bindtap="play" data-index="{{index}}" data-idx="{{idx}}"
|
||||
data-item="{{audio}}">
|
||||
</image>
|
||||
<image src="/images/ic_audio_speed.png" mode="scaleToFill" bindtap="speed"
|
||||
data-index="{{index}}" data-idx="{{idx}}" data-item="{{audio}}"></image>
|
||||
</view>
|
||||
</view>
|
||||
<view class="cu-tag bg-gray margin-left-xs" style="border-radius:50%;" catchtap="delAudio"
|
||||
data-index="{{index}}" data-idx="{{idx}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="flex align-center flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_voice.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
语音,可以给名片访客留下更深的印象
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{item.valueList.length<item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
style="width:60%;" data-index="{{index}}" data-item="{{item}}" bindtap="showDialog">点击添加
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 视频 -->
|
||||
<view wx:elif="{{item.dataType == '4'}}" class=" margin-top-xs">
|
||||
<view class="cu-bar bg-white margin-top-xs">
|
||||
<view class="action">
|
||||
{{item.comment}}
|
||||
</view>
|
||||
<view class="action">
|
||||
{{item.valueList.length}}/{{item.maxCount}}
|
||||
</view>
|
||||
</view>
|
||||
<view class="cu-form-group">
|
||||
<view class="grid col-4 grid-square flex-sub">
|
||||
<view class="bg-img" wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx"
|
||||
wx:for-item="video" bindtap="viewVideo" data-url="{{video.path}}">
|
||||
<image src='{{video.imgPath}}' mode='aspectFill'></image>
|
||||
<view class="cu-tag bg-red" catchtap="delVideo" data-index="{{index}}" data-idx="{{idx}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view class="solids" bindtap="chooseVideo" wx:if="{{item.valueList.length<item.maxCount}}"
|
||||
data-item="{{item}}" data-index="{{index}}">
|
||||
<text class="cuIcon-cameraadd"></text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 链接 -->
|
||||
<view wx:if="{{item.dataType == '5'}}" class=" margin-top-xs">
|
||||
<view class="cu-form-group">
|
||||
<view class="title margin-left-sm">{{item.comment}}</view>
|
||||
<input placeholder="请输入内容" maxlength="{{item.maxLength}}" data-key="{{item.name}}"
|
||||
data-value="{{item.value}}" bindinput="inputText" data-index="{{index}}"></input>
|
||||
</view>
|
||||
</view>
|
||||
<!-- 定位 -->
|
||||
<view wx:elif="{{item.dataType=='6'}}" class=" margin-top-xs">
|
||||
<view class="cu-bar bg-white">
|
||||
<view class="action">
|
||||
<text>{{item.comment}}</text>
|
||||
</view>
|
||||
<view class="action">
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex flex-direction align-center bg-white radius padding-sm">
|
||||
<view wx:if="{{item.valueList.length>0}}">
|
||||
<view wx:for="{{item.valueList}}" wx:for-index="idx" wx:key="idx" wx:for-item="m"
|
||||
style="width:100%;" class="margin-top-xs">
|
||||
<view class="flex justify-between">
|
||||
<view>
|
||||
{{m.name}}-{{m.address}}
|
||||
</view>
|
||||
<view class="cu-tag bg-gray margin-left-xs" catchtap="delMap" data-index="{{index}}"
|
||||
data-idx="{{idx}}">
|
||||
<text class="cuIcon-close"></text>
|
||||
</view>
|
||||
</view>
|
||||
<view style="border-radius:10rpx;overflow:hidden;margin-top:10rpx;">
|
||||
<map style="width:100%;height:300rpx;" longitude="{{m.longitude}}"
|
||||
latitude="{{m.latitude}}" scale="12"
|
||||
markers="{{[{latitude:m.latitude,longitude:m.longitude}]}}"></map>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view class="flex align-center bg-white flex-direction" wx:else>
|
||||
<image src="/images/ic_empty_map.png" mode="scaleToFill" style="width:200rpx;height:200rpx;">
|
||||
</image>
|
||||
<text class="text-gray">
|
||||
在地图上选取一个地点
|
||||
</text>
|
||||
</view>
|
||||
<view wx:if="{{locationList.length < item.maxCount}}" class="cu-btn bg-blue radius margin-top-sm"
|
||||
data-index="{{index}}" style="width:60%;" bindtap="chooseLocation">点击添加</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view wx:else style="margin-top:200rpx;width:100%;">
|
||||
<van-empty description="暂无数据" image="../../../images/ic_empty_data.png" />
|
||||
</view>
|
||||
|
||||
<view class="padding-xs foot bg-white" wx:if="{{fieldList.length > 0}}">
|
||||
<button class="cu-btn bg-blue" style="width:100%" bindtap="doPublish">保存</button>
|
||||
</view>
|
||||
|
||||
<!-- 语音弹框 -->
|
||||
<van-action-sheet show="{{ isShowAudio }}" title="语音介绍添加" bind:close="onHide" data-type="1"
|
||||
style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:80rpx;"
|
||||
wx:if="{{audioFile==null}}">
|
||||
<image src="{{isRecording? '/images/ic_voice_record.gif':'/images/ic_record_start.png'}}" mode="heightFix"
|
||||
style="width:300rpx;height:300rpx;"></image>
|
||||
<text>00:{{speck_time>9 ? speck_time : '0'+ speck_time}}</text>
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" style="width:70%;" bindlongpress="startRecord"
|
||||
bindtouchend="doEndRecord">长按录音</view>
|
||||
</view>
|
||||
<!-- 存在录音文件 -->
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:80rpx;" wx:else>
|
||||
<image src="{{audioFile.isPlay? '/images/ic_voice_record.gif':'/images/ic_record_start.png'}}" mode="heightFix"
|
||||
style="width:300rpx;height:300rpx;"></image>
|
||||
<text>{{audioFile.isPlay ? '播放中:'+speck_time+'秒' : '时长:'+audioFile.duration+'秒'}}</text>
|
||||
<view class="flex" style="width:80%;">
|
||||
<view class="cu-btn bg-blue radius margin-top-sm flex-sub" bindtap="playAudio">点击播放</view>
|
||||
<view class="cu-btn bg-red radius margin-top-sm flex-sub margin-left" bindtap="delAudio">删除</view>
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 文本域弹框 -->
|
||||
<van-action-sheet show="{{ isShowDesc }}" title="{{'文本内容'+'('+textareaList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="2" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<textarea id="tempDesc" placeholder="请输入文本内容" style="width:90%;" value="{{tempDesc}}"
|
||||
bindinput="textInput"></textarea>
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addDesc">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 文本内容弹框 -->
|
||||
<van-action-sheet show="{{ isShowText }}" title="{{'文本内容'+'('+textList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="3" style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<input id="tempText" placeholder="请输入文本内容" style="width:90%;" value="{{tempText}}" bindinput="textInput" />
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addStr">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 图片弹框 -->
|
||||
<van-action-sheet show="{{ isShowPhoto }}" title="图片选取" bind:close="onHide" data-type="4" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<view class="text-lg line" catchtap="choosePhoto" data-type="album">
|
||||
相册
|
||||
</view>
|
||||
<view class="text-lg noline" catchtap="choosePhoto" data-type="camera">
|
||||
相机
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
<!-- 视频弹框 -->
|
||||
<van-action-sheet show="{{ isShowVideo }}" title="视频选取" bind:close="onHide" data-type="6" style="padding-bottom:20rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<view class="text-lg line" catchtap="chooseVideo" data-type="album">
|
||||
相册
|
||||
</view>
|
||||
<view class="text-lg noline" catchtap="chooseVideo" data-type="camera">
|
||||
相机
|
||||
</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
||||
|
||||
<!-- 文本内容弹框 -->
|
||||
<van-action-sheet show="{{ isShowLink }}" title="{{'链接内容'+'('+linkList.length+'/'+ currentItem.count+')'}}"
|
||||
bind:close="onHide" data-type="5" style="padding-bottom:180rpx;">
|
||||
<view class="flex flex-direction align-center" style="margin-top:10rpx;padding-bottom:30rpx;">
|
||||
<input id="linkStr" placeholder="请输入链接地址(https://www.baidu.com)" style="width:90%;" value="{{linkStr}}"
|
||||
bindinput="textInput" />
|
||||
<view class="cu-btn bg-blue radius margin-top-sm" bindtap="addLink">点击添加</view>
|
||||
</view>
|
||||
</van-action-sheet>
|
49
pages/moments/publish/momentpublishline.wxss
Normal file
@ -0,0 +1,49 @@
|
||||
/* pages/moments/publish/momentpublish.wxss */
|
||||
|
||||
|
||||
van-action-sheet input {
|
||||
border: 1px solid rgb(194, 194, 194);
|
||||
border-radius: 10rpx;
|
||||
height: 60rpx;
|
||||
line-height: 60rpx;
|
||||
margin-top: 9rpx;
|
||||
padding-left: 10rpx;
|
||||
}
|
||||
|
||||
van-action-sheet textarea {
|
||||
border: 1px solid rgb(194, 194, 194);
|
||||
border-radius: 10rpx;
|
||||
margin-top: 9rpx;
|
||||
padding: 10rpx;
|
||||
}
|
||||
|
||||
van-action-sheet .line {
|
||||
height: 90rpx;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
width: 90%;
|
||||
border-top-width: 1rpx;
|
||||
border-top-color: #f5f5f5;
|
||||
border-top-style: solid;
|
||||
border-bottom-width: 1rpx;
|
||||
border-bottom-color: #f5f5f5;
|
||||
border-bottom-style: solid;
|
||||
}
|
||||
|
||||
van-action-sheet .noline {
|
||||
height: 90rpx;
|
||||
text-align: center;
|
||||
line-height: 90rpx;
|
||||
width: 90%;
|
||||
}
|
||||
|
||||
|
||||
van-action-sheet .line:active {
|
||||
color: black;
|
||||
background-color: #f5f5f5;
|
||||
}
|
||||
|
||||
van-action-sheet .noline:active {
|
||||
color: black;
|
||||
background-color: #f5f5f5;
|
||||
}
|
@ -40,7 +40,7 @@
|
||||
},
|
||||
"compileType": "miniprogram",
|
||||
"libVersion": "2.17.0",
|
||||
"appid": "wx501e9ce64f25c418",
|
||||
"appid": "wxe17874894f7ff27b",
|
||||
"projectname": "card",
|
||||
"debugOptions": {
|
||||
"hidedInDevtools": []
|
||||
|
37
utils/api.js
@ -1,8 +1,14 @@
|
||||
var apis = {
|
||||
url: 'https://www.wgink.ink/businesscard/',
|
||||
userCenter: 'https://192.168.0.103:7001/usercenter/',
|
||||
cardUrl: 'https://www.wgink.ink/businesscard/',
|
||||
baseImgUrl: 'https://www.wgink.ink/businesscard/route/file/download/true/',
|
||||
url: 'http://192.168.0.115:8091/systemcard/',
|
||||
userCenter: 'http://192.168.0.115:8091/systemcard/',
|
||||
baseImgUrl: 'http://192.168.0.115:8091/systemcard/route/file/download/true/',
|
||||
doUploadImg: `app/file/uploadimage`, //上传图片
|
||||
doUploadVideo: `app/file/uploadvideo`, //上传视频
|
||||
doUploadAudio: `app/file/uploadaudio`, //上传音频
|
||||
/**用户相关 */
|
||||
wxLogin: `wechat/miniapp/sign/default`, //微信用户登录
|
||||
/**个人中心 */
|
||||
getMenuList: `app/configcolumngroup/list`,
|
||||
/**店铺相关 **/
|
||||
doSaveShop: `app/shop/save`, //保存商店
|
||||
doUpdateShopInfo: `app/shop/updateshop/{shopId}`, //更新店铺信息
|
||||
@ -40,25 +46,12 @@ var apis = {
|
||||
doSaveOrder: `app/orderdetail/save`, //提交订单 POST
|
||||
getMineOrderList: `app/order/listpageorder`, //我的订单列表
|
||||
getOrderDetail: `app/order/get/{orderId}`, //获取订单详情
|
||||
doUploadImg: `app/file/uploadimage`, //上传图片
|
||||
doUploadVideo: `app/file/uploadvideo`, //上传视频
|
||||
doUploadAudio: `app/file/uploadaudio`, //上传音频
|
||||
|
||||
//个人中心列表
|
||||
getMenuList: `app/menuconfig/list-ztree`, //获取个人中心菜单
|
||||
getButtonConfig: `app/menuconfig/get-button-config`, //判断是否显示发布按钮
|
||||
getMomentsCatelogList: `app/columnmng/list`, //获取栏目列表
|
||||
doSaveMomentsCagelog: `app/usercolumn/save-more`, //保存选择的栏目
|
||||
getMineMomentsCategoryList: `app/usercolumn/list-by-creator-title`, //获取自己选中的栏目
|
||||
doDelMineCategory: `app/usercolumn/remove/{ids}`, //删除自己选中的栏目
|
||||
getColumnDetail: `app/usercolumn/get/{userColumnId}`, //获取栏目详情
|
||||
getMineMomentsList: `app/usercolumndata/listpageusercolumndata`, //获取栏目内容列表
|
||||
doSaveMoments: `app/usercolumndata/save`, //保存
|
||||
doUpdateMoments: `app/usercolumndata/update/{userColumnDataId}`, //更新发布的内容
|
||||
getMomentsDetail: `app/usercolumndata/get/{userColumnDataId}`, //获取栏目内容详情
|
||||
getHomeData: `app/usercolumndata/list-my-creator`, //获取首页栏目数据
|
||||
getShareUserMoment: `app/usercolumndata/list-my-creator-id/{userId}`, //获取分享首页数据
|
||||
getShareMomentList: `app/usercolumndata/list-page-by-userId`, //获取分享栏目更多列表
|
||||
doDelMoment: `app/usercolumndata/delete/{ids}`, //删除栏目数据
|
||||
//栏目数据
|
||||
getMomentsList: `app/configcolumndata/listrelease/{configColumnId}`, //获取栏目数据列表
|
||||
doSaveMoments: `app/configcolumndata/saverelease/{configColumnId}`, //保存栏目数据
|
||||
getMomentsField: `app/configcolumndata/listfieldrelease/{configColumnId}`, //获取栏目字段列表
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -107,8 +107,8 @@ function doAjax(url, method, args) {
|
||||
} else {
|
||||
errorback(res)
|
||||
var hintMsg = '网络错误'
|
||||
if (res.msg) {
|
||||
hintMsg += ',' + res.msg
|
||||
if (res.data.msg) {
|
||||
hintMsg = res.data.msg
|
||||
}
|
||||
wx.showToast({
|
||||
title: hintMsg,
|
||||
@ -117,14 +117,14 @@ function doAjax(url, method, args) {
|
||||
}
|
||||
},
|
||||
fail: err => {
|
||||
errorback(res)
|
||||
wx.hideLoading({})
|
||||
errorback(err)
|
||||
var hintMsg = '网络错误'
|
||||
if (err.msg) {
|
||||
hintMsg += ',' + err.msg
|
||||
if (err.data.msg) {
|
||||
hintMsg = err.data.msg
|
||||
}
|
||||
wx.showToast({
|
||||
title: hintMsg,
|
||||
title: hintMsg + '(100)',
|
||||
icon: 'error'
|
||||
})
|
||||
},
|
||||
@ -241,6 +241,68 @@ function postFile(url, path, name, args, successCallback, errorCallback, complet
|
||||
}
|
||||
})
|
||||
};
|
||||
/**
|
||||
* Promise 上传文件
|
||||
*/
|
||||
function upload(url, params) {
|
||||
return new Promise((success, errorback) => {
|
||||
var requestUrl = api.apis.url + url
|
||||
wx.uploadFile({
|
||||
filePath: params.path,
|
||||
name: params.name,
|
||||
url: requestUrl,
|
||||
header: params.header,
|
||||
success: function (response) {
|
||||
console.log('success')
|
||||
if (response.statusCode == 200) {
|
||||
success(response.data);
|
||||
} else {
|
||||
errorback(response)
|
||||
if (typeof (response.data) != undefined) {
|
||||
try {
|
||||
var data = JSON.parse(response.data)
|
||||
wx.showToast({
|
||||
title: data.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
} catch (err) {
|
||||
wx.showToast({
|
||||
title: '网络错误',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '网络错误',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
fail: function (response) {
|
||||
wx.hideLoading({})
|
||||
try {
|
||||
if (typeof (response.data.msg) != undefined) {
|
||||
wx.showToast({
|
||||
title: response.data.msg,
|
||||
icon: 'none'
|
||||
})
|
||||
} else {
|
||||
wx.showToast({
|
||||
title: '网络错误(100)',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
} catch (err) {
|
||||
wx.showToast({
|
||||
title: '网络错误(100)',
|
||||
icon: 'error'
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/**
|
||||
* xss 转义
|
||||
@ -272,5 +334,6 @@ module.exports = {
|
||||
path: buildPath,
|
||||
escape: escape,
|
||||
file: postFile,
|
||||
upload: upload,
|
||||
apis: api.apis
|
||||
}
|