feedback.page.js
1.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/**
* 个人中心--意见反馈
* @author: Lixia Zhang<lixia.zhang@yoho.cn>
* @date: 2016/07/20
*/
import $ from 'jquery';
import tip from 'common/tip';
import yoho from 'yoho';
import interceptClick from 'common/intercept-click';
import HeaderBox from 'component/header.vue';
import Vue from 'vue';
new Vue({
el: '#header',
render: h => h(HeaderBox, {
props: {
title: '意见反馈'
}
})
});
$(() => {
setTimeout(() => {
yoho.addNativeMethod('saveFeedback', function() {
var suggestText = $('#suggest-textarea').val(),
textReg = /\S+/;
if (!textReg.test(suggestText)) {
tip('意见不能为空');
return;
}
$('#suggest-textarea').blur();
$.ajax({
type: 'post',
url: '/me/save-feedback',
data: {
content: suggestText,
}
}).then(function(data) {
if (data.code === 200) {
tip('提交成功');
setTimeout(() => {
yoho.goBack();
}, 2000);
} else {
tip('提交失败~');
}
}).fail(function() {
tip('网络错误~');
});
});
const header = Object.assign({}, interceptClick.defaultTitleMap[3]);
header.title.des = '意见反馈';
header.right = {
des: '提交',
action: 'saveFeedback'
};
yoho.updateNavigationBar({
header: header,
url: location.origin + '/me/feedback'
});
}, 200);
});