index.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. const api = require('../../../../../utils/api.js');
  2. const login = require('../../../../../utils/index.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. data: [{ 'title': '整体满意度:' }, { 'title': '去现场次数满意度:' }, { 'title': '办事指南符合度:' }, { 'title': '办事效率:' }, { 'title': '服务质量:' }, { 'title': '网上体验:' }],
  9. items: [{ 'index': 1, 'name': '非常不满意' }, { 'index': 2, 'name': '不满意' }, { 'index': 2, 'name': '一般' },{ 'index': 3, 'name': '满意' },{ 'index': 4, 'name': '非常满意' }]
  10. },
  11. /**
  12. * 生命周期函数--监听页面加载
  13. */
  14. onLoad: function (options) {
  15. this.data.projid=options.projid
  16. },
  17. textarea:function(e){
  18. this.data.text=e.detail.value
  19. },
  20. assess:function(e){
  21. console.log(e)
  22. this.data.data[e.currentTarget.dataset.index].ind = e.currentTarget.dataset.ind
  23. this.data.data[e.currentTarget.dataset.index].name = this.data.items[e.currentTarget.dataset.ind].name
  24. this.setData({
  25. data: this.data.data
  26. })
  27. },
  28. submit:function(){
  29. let that = this
  30. for(let i=0;i<that.data.data.length;i++){
  31. if (!that.data.data[i].name){
  32. wx.showToast({
  33. title: '请对'+that.data.data[i].title+'打分',
  34. icon:'none'
  35. })
  36. return false;
  37. }
  38. }
  39. if(!that.data.text){
  40. wx.showToast({
  41. title: '请输入评价内容',
  42. icon: 'none'
  43. })
  44. return false;
  45. }
  46. let getUserInfo = login.default.getUserInfo();
  47. getUserInfo.then((resolve) => {
  48. that.data.userInfo = resolve
  49. console.log(that.data.userInfo)
  50. if(that.data.userInfo){
  51. wx.request({
  52. url: api.evaluate,
  53. method:'POST',
  54. data: {
  55. projid: that.data.projid,
  56. evaluatorName: that.data.userInfo.identity == '0' ? that.data.userInfo.name : that.data.userInfo.lInstitutionName,
  57. evaluatorPhone: that.data.userInfo.identity == '0' ? that.data.userInfo.pPhone : that.data.userInfo.lPhone,
  58. evaluatorEmail: that.data.userInfo.identity == '0' ? that.data.userInfo.pEmail : that.data.userInfo.lEmail,
  59. evaluatorAddress: that.data.userInfo.identity == '0' ? that.data.userInfo.pAddress : that.data.userInfo.lAddress,
  60. evaluateContent:that.data.text,
  61. satisfactionEvaluate: that.data.data[0].ind+1,
  62. errandNoEvaluate: that.data.data[1].ind + 1,
  63. guideEvaluate: that.data.data[2].ind + 1,
  64. efficiencyEvaluate: that.data.data[3].ind + 1,
  65. serviceQualityEvaluate: that.data.data[4].ind + 1,
  66. onlineExperienceEvaluate: that.data.data[5].ind + 1
  67. },
  68. success(res) {
  69. if(res.data.errno==0){
  70. wx.redirectTo({
  71. url: '/pages/success/index?type=assess',
  72. })
  73. }else{
  74. wx.showToast({
  75. title: '提交失败',
  76. icon:'none'
  77. })
  78. }
  79. }
  80. })
  81. }
  82. })
  83. },
  84. /**
  85. * 生命周期函数--监听页面初次渲染完成
  86. */
  87. onReady: function () {
  88. },
  89. /**
  90. * 生命周期函数--监听页面显示
  91. */
  92. onShow: function () {
  93. },
  94. /**
  95. * 生命周期函数--监听页面隐藏
  96. */
  97. onHide: function () {
  98. },
  99. /**
  100. * 生命周期函数--监听页面卸载
  101. */
  102. onUnload: function () {
  103. },
  104. /**
  105. * 页面相关事件处理函数--监听用户下拉动作
  106. */
  107. onPullDownRefresh: function () {
  108. },
  109. /**
  110. * 页面上拉触底事件的处理函数
  111. */
  112. onReachBottom: function () {
  113. },
  114. /**
  115. * 用户点击右上角分享
  116. */
  117. onShareAppMessage: function () {
  118. }
  119. })