Commit fc5ab983 authored by lvtz's avatar lvtz

fix

parent d80ab4d5
import {
wxChooseImage,
wxUploadFile
} from '../../../utilities/wxApi.js';
import {
bOssAccess
} from '../../../service/business/common.js';
import {
getRandomFilename,
imagify,
} from '../../../utilities/index.js';
import { wxChooseImage, wxUploadFile } from "../../../utilities/wxApi.js";
import { bOssAccess } from "../../../service/business/common.js";
import { getRandomFilename, imagify } from "../../../utilities/index.js";
import { postfeed } from '../../../service/business/feedback.js';
var app = getApp();
Page({
data: {
imageRoot: app.globalData.imageRoot,
imageVersion: app.globalData.imageVersion,
localImageRoot: '../../../images/',
localImageRoot: "../../../images/",
sid: 0,
banner:[],
remark: "",
mobile: "",
swiperIndex: 0,
uploadType: 'mainImg',
imgs: [],
content: "",
contact: "",
publishing: false
},
onLoad: function (options) {
// const {sid} = options;
// this.setData({
// sid,
// })
onLoad: function(options) {
const {sid} = options;
this.setData({
sid: sid || 3
})
},
imgUpload (e) {
if (this.data.banner.length >= 4) {
imgUpload(e) {
if (this.data.imgs.length >= 4) {
wx.showToast({
title: '最多上传4张图片',
icon: 'none'
})
title: "最多上传4张图片",
icon: "none"
});
return;
}
let access = {};
let filename = '';
let filename = "";
bOssAccess({
school_id: this.data.sid
}).then((acc) => {
access = acc.data;
return wxChooseImage({})
}).then((res) => {
const {tempFiles} = res;
filename = `${access.dir}${getRandomFilename(tempFiles[0].path)}`;
return wxUploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: '200'
},
filePath: tempFiles[0].path,
name: 'file',
})
.then(acc => {
access = acc.data;
return wxChooseImage({});
})
}).then((res) => {
const {data} = res;
if (data == '{"status":"ok"}') {
let banner = this.data.banner;
banner.push(filename);
this.setData({
banner: banner
})
} else {
.then(res => {
const { tempFiles } = res;
filename = `${access.dir}${getRandomFilename(tempFiles[0].path)}`;
return wxUploadFile({
url: access.host,
formData: {
key: filename,
policy: access.policy,
OSSAccessKeyId: access.accessid,
signature: access.signature,
callback: access.callback,
success_action_status: "200"
},
filePath: tempFiles[0].path,
name: "file"
});
})
.then(res => {
const { data } = res;
if (data == '{"status":"ok"}') {
let imgs = this.data.imgs;
imgs.push(filename);
this.setData({
imgs: imgs
});
} else {
wx.hideLoading();
wx.showModal({
title: "提示",
content: "上传失败",
showCancel: false
});
}
})
.catch(err => {
wx.hideLoading();
wx.showModal({
title: '提示',
content: '上传失败',
showCancel: false
})
}
}).catch((err) => {
wx.hideLoading();
});
});
},
remarkInput(e) {
const {
value
} = e.detail;
contentInput(e) {
const { value } = e.detail;
this.setData({
remark: value.length > 100 ? value.substr(0, 100) : value
})
content: value
});
},
contactInput (e) {
const {
value
} = e.detail;
contactInput(e) {
const { value } = e.detail;
this.setData({
mobile: value
})
contact: value
});
},
publish () {
publish() {
let that = this;
if (this.data.remark.trim() == '') {
if (this.data.content.trim() == "") {
wx.showToast({
title: '请输入商品说明',
icon: 'none'
})
return
title: "请输入您的问题和意见",
icon: "none"
});
return;
}
// if (this.data.banner.length == 0) {
// wx.showToast({
// title: '请上传',
// icon: 'none'
// })
// return
// }
if (this.data.publishing) {
return
return;
}
wx.showLoading({
title: '保存中...'
})
title: "提交中..."
});
this.data.publishing = true;
return
goodsAdd({
postfeed({
school_id: this.data.sid,
banner: JSON.stringify(this.data.banner),
remark: this.data.remark,
mobile: this.data.mobile,
}).then((res) => {
const {code, data} = res;
if (code == 200) {
wx.showToast({
title: '提交成功'
})
wx.navigateBack({
delta: 1,
success: function() {
that.data.publishing = false;
wx.hideLoading();
}
})
} else {
this.data.publishing = false;
wx.hideLoading();
}
}).catch(() => {
wx.hideLoading();
this.data.publishing = false;
wx.showToast({
title: '提交失败',
icon: 'none'
})
content: this.data.content,
img: JSON.stringify(this.data.imgs),
contact: this.data.contact
})
.then(res => {
const { code, data } = res;
if (code == 200) {
wx.showToast({
title: "提交成功"
});
wx.navigateBack({
delta: 1,
success: function() {
that.data.publishing = false;
wx.hideLoading();
}
});
} else {
this.data.publishing = false;
wx.hideLoading();
}
})
.catch(() => {
wx.hideLoading();
this.data.publishing = false;
wx.showToast({
title: "提交失败",
icon: "none"
});
});
},
delImg (e) {
delImg(e) {
const { index } = e.currentTarget.dataset;
const banner = this.data.banner;
banner.splice(index, 1);
const imgs = this.data.imgs;
imgs.splice(index, 1);
this.setData({
banner: banner
imgs: imgs
});
},
// 我的反馈
toByfeedback() {
wx.navigateTo({
url: `/business/pages/helpcenter/myfeedback?sid=${this.data.sid}`
})
}
})
\ No newline at end of file
});
<wxs src="../../../filter/index.wxs" module="filter" />
<view class="container">
<view class="section">
<view class="section-title">问题和意见</view>
<textarea placeholder="请详细描述您的建议,我们将及时跟进解决。(建议添加相关问题截图或视频)。" value="{{remark}}"></textarea>
<view class="picbox-wrap">
<view class="picbox">
<block wx:for="{{banner}}" wx:key="index">
<view class="item">
<image class="item-img" src="{{filter.imagify(item)}}" mode="aspectFill" ></image>
<image class="icon-del" src="{{localImageRoot}}2b/helpcenter/icon_del.png?{{imageVersion}}" bindtap="delImg" data-index="{{index}}"></image>
</view>
</block>
<view class="item item-add" wx:if="{{banner.length<4}}" bindtap="imgUpload">+
<!-- <image class="pic-add" src="{{imageRoot}}2b/helpcenter/pic_add.png?{{imageVersion}}"></image> -->
</view>
</view>
</view>
<view class="section">
<view class="section-title">问题和意见</view>
<view class="form-itembox">
<textarea class="input-item form-remark" placeholder="请详细描述您的建议,我们将及时跟进解决。(建议添加相关问题截图或视频)。" maxlength="1000" value="{{content}}" auto-height bindinput="contentInput"></textarea>
</view>
<view class="section">
<view class="section-title">联系方式</view>
<view >
<input type="text" value="{{mobile}}" placeholder="请留下您的手机号/微信号 (可选)"/>
<view class="picbox-wrap">
<view class="picbox">
<block wx:for="{{imgs}}" wx:key="index">
<view class="item">
<image class="item-img" src="{{filter.imagify(item)}}" mode="aspectFill" ></image>
<image class="icon-del" src="{{localImageRoot}}2b/helpcenter/icon_del.png?{{imageVersion}}" bindtap="delImg" data-index="{{index}}"></image>
</view>
</block>
<view class="item item-add" wx:if="{{imgs.length<4}}" bindtap="imgUpload">+
<!-- <image class="pic-add" src="{{imageRoot}}2b/helpcenter/pic_add.png?{{imageVersion}}"></image> -->
</view>
</view>
</view>
</view>
<view class="section section-contact">
<view class="section-title">联系方式</view>
<view class="form-itembox">
<input class="input-item" type="text" value="{{contact}}" placeholder="请留下您的手机号/微信号 (可选)"/>
</view>
<view class="submitbtn" bindtap="publish">提交</view>
</view>
<view class="submitbtn {{!content? 'submitbtn-disabled' : ''}}" bindtap="publish">提交</view>
<view class="btn-mine" bindtap="toByfeedback">我的反馈</view>
</view>
<expiredTip/>
\ No newline at end of file
.container {
padding-bottom: 100rpx;
}
.section{
border-top: 20rpx solid #F5F5F5;
padding: 24rpx 30rpx;
.section {
border-top: 20rpx solid #f5f5f5;
padding: 24rpx 30rpx;
position: relative;
}
.section:first-of-type {
border-top: 0;
}
.section-contact::after{
content: '';
width: 690rpx;
height: 1px;
background: rgba(241,242,243,1);
position: absolute;
left: 50%;
bottom: 0;
transform: translateX(-50%);
}
.section .section-title {
font-size: 30rpx;
color: #666;
line-height: 42rpx;
padding-bottom: 34rpx;
}
.section:first-of-type{
border-top: 0;
.section .input-item {
line-height: 36rpx;
width: 100%;
}
.section .section-title{
font-size: 30rpx;
color: #666;
line-height: 42rpx;
.section .input-item.form-remark {
height: 196rpx;
min-height: 196rpx;
}
.picbox-wrap {
width: 100%;
padding: 20rpx 0 10rpx;
padding-top: 18rpx;
}
.picbox {
display: flex;
flex-wrap: wrap;
padding: 11rpx 0 19rpx;
}
.picbox .item {
width: 116rpx;
......@@ -29,6 +49,9 @@
display: flex;
align-items: center;
justify-content: center;
font-size: 60rpx;
color: #ccc;
font-weight: bold;
}
.picbox .item:last-of-type {
margin-right: 0;
......@@ -37,8 +60,8 @@
width: 100%;
height: 100%;
}
.picbox .item.item-add{
border: 2rpx solid #CCC;
.picbox .item.item-add {
border: 2rpx solid #ccc;
}
.picbox .item .icon-del {
width: 36rpx;
......@@ -51,3 +74,25 @@
width: 100%;
height: 100%;
}
.submitbtn {
margin: 130rpx auto 96rpx;
width: 630rpx;
height: 90rpx;
background: rgba(22,176,253,1);
font-size: 32rpx;
color: #fff;
display: flex;
align-items: center;
justify-content: center;
border-radius: 49rpx;
box-shadow: 0 0 20rpx rgba(22, 176, 253, 0.8);
}
.submitbtn-disabled{
background: rgba(185,199,213,1);
box-shadow: none;
}
.btn-mine {
font-size: 28rpx;
color: #16b0fd;
text-align: center;
}
// business/pages/helpcenter/myfeedback.js
Page({
import { myfeed } from '../../../service/business/feedback.js';
import {
imagify,
} from '../../../utilities/index.js';
/**
* 页面的初始数据
*/
var app = getApp();
Page({
data: {
imageRoot: app.globalData.imageRoot,
imageVersion: app.globalData.imageVersion,
localImageRoot: "../../../images/",
sid: 0,
page: 1,
perPage: 10,
list: [],
tatol: '',
hasmore: true,
emptyPage: false,
listLoading: false
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
onLoad: function(options) {
const {sid} = options;
this.setData({
sid
})
this.getlist('init')
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
this.setData({
hasmore: true,
page: 1,
})
this.getlist('down')
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
this.getlist('up')
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
getlist(type) {
if (!this.data.hasmore) {
return;
}
if (this.data.listLoading) {
return
}
this.setData({
listLoading: true
})
myfeed({
page: this.data.page,
perPage: this.data.perPage,
school_id: this.data.sid,
}).then((res) => {
const { code, data } = res;
wx.hideLoading();
this.setData({
listLoading: false
})
if (code != 200) { // 失败的处理
} else {
if (data.total) {
this.setData({
total: data.total
})
}
data.list.forEach(item=>
item.imgs = JSON.parse(item.img)
)
switch (type) {
case 'init': //页面进来第一次加载
this.setData({
list: [data.list]
})
if (data.total > this.caculateArrLength(this.data.list)) {
let page = this.data.page + 1;
this.setData({
page,
})
} else { // 没有更多了
this.setData({
hasmore: false
})
}
console.log(this.data.list,'11')
break;
case 'down': // 页面下拉刷新
this.setData({
list: [data.list]
})
if (data.total > this.caculateArrLength(this.data.list)) {
let page = this.data.page + 1;
this.setData({
page,
})
} else { // 没有更多了
this.setData({
hasmore: false
})
}
wx.stopPullDownRefresh();
break;
case 'up': // 页面上拉刷新
this.setData({
[`list[${this.data.page - 1}]`]: data.list
})
if (this.data.total > this.caculateArrLength(this.data.list)) {
let page = this.data.page + 1;
this.setData({
page,
})
} else { // 没有更多了
this.setData({
hasmore: false
})
}
break;
default:
break;
}
if (this.caculateArrLength(this.data.list) == 0) {
this.setData({
emptyPage: true
})
} else {
this.setData({
emptyPage: false,
})
}
}
}).catch((e) => {
this.setData({
listLoading: false
})
})
},
caculateArrLength(array) {
let _length = 0;
array.forEach(ele => {
_length = _length + ele.length;
})
return _length;
},
prevImg(e) {
const { imglist, src } = e.currentTarget.dataset;
let urls = imglist.map(ele => imagify(ele));
wx.previewImage({
urls: urls,
current: imagify(src)
})
}
})
\ No newline at end of file
});
{
"navigationBarTitleText": "我的反馈",
"usingComponents": {
"expiredTip": "../../components/expiredTip"
"expiredTip": "../../../components/expiredTip",
"list-loading": "../../../components/listloading",
"empty-content": "../../../components/emptycontent"
}
}
\ No newline at end of file
<!--business/pages/helpcenter/myfeedback.wxml-->
<text>business/pages/helpcenter/myfeedback.wxml</text>
<wxs src="../../../filter/index.wxs" module="filter" />
<view class="container">
<view class="list" wx:if="{{list.length>0}}">
<block wx:for="{{list}}" wx:for-item="bigitem" wx:key="bigindex" wx:for-index="bigindex">
<view class="list-item" wx:for="{{bigitem}}" wx:for-item="item" wx:key="index">
<view class="qa-box q-box">
<view class="nickname-box">{{item.teacher_id}}</view>
<view class="time">{{filter.formatDateWithChinese(item.created_at)}}</view>
<view class="content-box">
<view class="text">{{item.content}} {{item.img.length}}</view>
<view class="imgbox" wx:if="{{item.imgs.length>0}}">
<view class="imgitem" wx:for="{{item.imgs}}" wx:key="imgidx" wx:for-index="imgidx" wx:for-item="imgitem" bindtap="prevImg" data-src="{{imgitem}}" data-imglist="{{item.imgs}}">
<image class="img" src="{{filter.imagify(imgitem)}}" mode="aspectFill" ></image>
</view>
</view>
</view>
</view>
<view class="qa-box a-box" wx:if="{{item.reply_content}}">
<view class="nickname-box">轻校回复</view>
<view class="content-box">
<view class="text">{{item.reply_content}}</view>
</view>
</view>
</view>
</block>
</view>
<empty-content text="暂无反馈" emptyimg="common/empty/empty_b_search.png" width="255" height="198" wx:else></empty-content>
<list-loading loading="{{listLoading}}"></list-loading>
<view class="has-nomore" wx:if="{{!hasmore && page>1}}">没有更多了</view>
</view>
\ No newline at end of file
/* business/pages/helpcenter/myfeedback.wxss */
\ No newline at end of file
page{
background: #F6F5F8;
}
.container{
}
.list{}
.list .list-item{
background: #fff;
margin-bottom: 20rpx;
padding: 0 30rpx;
}
.list .list-item:last-of-type{
margin-bottom: 0;
}
.list .list-item .qa-box{
padding: 24rpx 0;
}
.list .list-item .a-box{
border-top: 1px solid #F5F5F7;
}
.list .list-item .qa-box .nickname-box{
font-size: 30rpx;
color: #666;
line-height: 42rpx;
}
.list .list-item .qa-box .time{
font-size: 26rpx;
color: #999;
line-height: 36rpx;
padding: 8rpx 0 2rpx;
}
.list .list-item .qa-box .content-box{
padding-top: 14rpx;
}
.list .list-item .qa-box .content-box .text{
font-size: 26rpx;
color: #222;
line-height: 36rpx;
padding-bottom: 14rpx;
}
.imgbox{
display: flex;
align-items: center;
padding: 42rpx 0 8rpx;
}
.imgbox .imgitem{
width: 116rpx;
height: 116rpx;
margin-right: 50rpx;
}
.imgbox .imgitem:last-of-type{
margin-right: 0;
}
.list .list-item .qa-box .content-box .imgbox .imgitem .img{
width: 100%;
height: 116rpx;
}
.has-nomore{
font-size: 26rpx;
color: #9C9C9D;
padding: 75rpx 0;
text-align: center;
}
\ No newline at end of file
......@@ -475,7 +475,9 @@ const apis = {
detailGet: `${api}member/clock/record/show`
},
feedback: {
postfeed: `${api}consumer/clock/feedback/add`
// postfeed: `${api}consumer/clock/feedback/add`,//
postfeed: `${api}member/feedbacks`,//新增
myfeed: `${api}member/feedback/my`,//我的反馈
},
rankingList: {
totalList: `${api}consumer/clock/rank/total_index`,
......
export default {
imageRoot: 'https://cdn.img.shangjiadao.cn/qingxiao/daka/images/',
host: 'https://qxapi.qingxiao.online/daka',
host2: 'https://wx.m.shangjiadao.cn',
// host: 'https://qxapi.qingxiao.online/daka',
// host2: 'https://wx.m.shangjiadao.cn',
storageVersion: '5.0',
imageVersion: '20200117',
// host: 'https://clock.wp53.cn',
// host2: 'https://test.wp53.cn',
host: 'https://clock.wp53.cn',
host2: 'https://test.wp53.cn',
appId: 'wxc1246ea029394785',
miniProgram: {
clock: 'wxdeee20e52a1fd7ee'
......
......@@ -65,6 +65,23 @@ function formatDate2(date) {
var minute = mi < 10 ? '0' + mi : mi;
return y + '-' + month + '-' + day + ' ' + hour + ':' + minute;
}
function formatDateWithChinese(date) {
if (!date) {
return ''
};
var regexp = getRegExp('-', 'g');
var time = getDate(date.replace(regexp, '/'));
var y = time.getFullYear();
var m = time.getMonth() + 1;
var month = m < 10 ? '0' + m : m;
var d = time.getDate();
var day = d < 10 ? '0' + d : d;
var h = time.getHours();
var hour = h < 10 ? '0' + h : h;
var mi = time.getMinutes();
var minute = mi < 10 ? '0' + mi : mi;
return y + '年' + month + '月' + day + ' ' + hour + ':' + minute;
}
function formatDateRemoveYear (date) {
var time = getDate(date * 1000);
var y = time.getFullYear();
......@@ -700,6 +717,7 @@ module.exports = {
checkStudentSelect: checkStudentSelect,
formatDateToHourMinute: formatDateToHourMinute,
formatDate2: formatDate2,
formatDateWithChinese: formatDateWithChinese,
formatWebsiteBarrage: formatWebsiteBarrage,
mediaPng:mediaPng,
Mathceil:Mathceil,
......
......@@ -12,6 +12,16 @@ function postfeed (data) {
errorresolve: 1,
})
}
function myfeed (data) {
return wxRequest({
role: '2b',
url: apis.business.feedback.myfeed,
data,
method: 'GET',
errorresolve: 1,
})
}
export {
postfeed,
myfeed
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment