提交 777fb511 编写于 作者: api工厂's avatar api工厂

提交留言,允许上传图片或者视频

上级 efa23423
module.exports = {
version: '10.2.4',
note: '智能识别收货地址精度优化、绑定手机号码bug', // 这个为版本描述,无需修改
version: '10.3.0',
note: '提交留言,允许上传图片或者视频', // 这个为版本描述,无需修改
subDomain: 'tz', // 此处改成你自己的专属域名。什么是专属域名?请看教程 https://www.it120.cc/help/qr6l4m.html
sdkAppID: 1400450467, // 腾讯实时音视频应用编号,请看教程 https://www.it120.cc/help/nxoqsl.html
}
\ No newline at end of file
......@@ -14,7 +14,19 @@ Page({
},
onShow: function() {
this.checkTodayComments()
},
async checkTodayComments() {
// 判断一天只能留言5次
const res = await WXAPI.jsonList({
token: wx.getStorageSync('token'),
type: 'feedback_times'
})
if (res.code === 0) {
this.setData({
feedbackTimes: res.data[0]
})
}
},
async bindSave() {
if (!this.data.name) {
......@@ -35,6 +47,18 @@ Page({
extJsonStr['姓名'] = this.data.name
extJsonStr['联系电话'] = this.data.mobile
extJsonStr['微信'] = this.data.wx
// 批量上传附件
if (this.data.picsList) {
for (let index = 0; index < this.data.picsList.length; index++) {
const pic = this.data.picsList[index];
const res = await WXAPI.uploadFile(wx.getStorageSync('token'), pic.url)
if (res.code == 0) {
extJsonStr['file' + index] = res.data.url
}
}
}
const res = await WXAPI.addComment({
token: wx.getStorageSync('token'),
type: 1,
......@@ -42,6 +66,23 @@ Page({
content: this.data.content
})
if (res.code == 0) {
// 提交次数 + 1
let feedbackTimes = this.data.feedbackTimes
if (!feedbackTimes) {
feedbackTimes = {
id: '',
refId: 0,
content: '{}'
}
}
await WXAPI.jsonSet({
token: wx.getStorageSync('token'),
id: feedbackTimes.id,
type: 'feedback_times',
refId: feedbackTimes.refId + 1,
content: feedbackTimes.content
})
await this.checkTodayComments()
wx.showToast({
title: '提交成功',
})
......@@ -56,5 +97,22 @@ Page({
icon: 'none'
})
}
},
afterPicRead(e) {
let picsList = this.data.picsList
if (!picsList) {
picsList = []
}
picsList = picsList.concat(e.detail.file)
this.setData({
picsList
})
},
afterPicDel(e) {
let picsList = this.data.picsList
picsList.splice(e.detail.index, 1)
this.setData({
picsList
})
}
})
\ No newline at end of file
<van-field
label="姓名"
model:value="{{ name }}"
placeholder="如何称呼您"
clearable
/>
<van-field
label="联系电话"
type="number"
model:value="{{ mobile }}"
placeholder="方便我们与您联系"
clearable
/>
<van-field
label="微信号"
model:value="{{ wx }}"
placeholder="填写您的微信号"
clearable
/>
<van-field
model:value="{{ content }}"
placeholder="请留下您的宝贵建议或意见~"
type="textarea"
autosize="{{ autosize }}"
/>
<view class="block-btn btn">
<van-button type="primary" block bind:click="bindSave">提交反馈</van-button>
</view>
\ No newline at end of file
<block wx:if="{{feedbackTimes && feedbackTimes.refId > 5}}">
<van-empty image="error" description="今天你已经提交{{ feedbackTimes.refId }}次,明天再来吧" />
</block>
<block wx:else>
<van-field
label="姓名"
model:value="{{ name }}"
placeholder="如何称呼您"
clearable
/>
<van-field
label="联系电话"
type="number"
model:value="{{ mobile }}"
placeholder="方便我们与您联系"
clearable
/>
<van-field
label="微信号"
model:value="{{ wx }}"
placeholder="填写您的微信号"
clearable
/>
<view style="margin-top:16rpx;padding-left:32rpx;">
<van-uploader
accept="media"
multiple
upload-text="图片/视频"
image-fit="aspectFill"
file-list="{{ picsList }}"
bind:after-read="afterPicRead"
bind:delete="afterPicDel"
/>
</view>
<van-field
model:value="{{ content }}"
placeholder="请留下您的宝贵建议或意见~"
type="textarea"
autosize="{{ autosize }}"
/>
<view class="block-btn btn">
<van-button type="primary" block bind:click="bindSave">提交反馈</van-button>
</view>
</block>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册