details.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. const _Http = getApp().globalData.http,
  2. MFT = require("../../utils/matchingFeilType"),
  3. deleteMark = require("../../utils/deleteMark");
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. tabsTitle: "详情",
  10. rate: {
  11. nubmer: 5,
  12. text: "非常满意"
  13. },
  14. videoList: [],
  15. loading: false,
  16. isEvaluate: false
  17. },
  18. onLoad(options) {
  19. let auth = wx.getStorageSync('authList').wnotice.optionnames,
  20. dataAuth = '';
  21. if (auth.some(v => v == '团队内部数据分析') && auth.some(v => v == '经销商数据分析')) {
  22. dataAuth = 'all';
  23. } else {
  24. dataAuth = auth.some(v => v == '团队内部数据分析') ? '内部' : '经销商'
  25. };
  26. this.setData({
  27. viewData: auth.some(v => v == '团队内部数据分析') || auth.some(v => v == '经销商数据分析'),
  28. dataAuth,
  29. auth,
  30. sat_noticeid: options.id
  31. });
  32. this.queryNoticeMain(); //获取详情
  33. },
  34. /* 通告详情 */
  35. queryNoticeMain() {
  36. _Http.basic({
  37. "classname": "saletool.notice.notice",
  38. "method": "queryNoticeMain",
  39. "content": {
  40. "sat_noticeid": this.data.sat_noticeid
  41. }
  42. }).then(res => {
  43. if (res.msg != '成功') return wx.showToast({
  44. title: res.msg,
  45. icon: "none"
  46. });
  47. if (this.data.viewData) this.queryReadRecord(); //查询数据
  48. let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')), //过滤封面文件
  49. videoList = [], //视频附件列表
  50. attinfos = []; //其他附件
  51. list.forEach(v => v.fileType == 'video' ? videoList.push(v) : attinfos.push(v));
  52. res.data.attinfos = attinfos;
  53. this.setData({
  54. detailsData: res.data,
  55. videoList
  56. });
  57. getCurrentPages().forEach(v => {
  58. if (v.__route__ == 'pages/tabbar/home/index') v.queryNoticeList()
  59. })
  60. });
  61. },
  62. /* 查询数据 */
  63. queryReadRecord() {
  64. _Http.basic({
  65. "classname": "saletool.notice.notice",
  66. "method": "queryReadRecord",
  67. "content": {
  68. "sat_noticeid": this.data.sat_noticeid
  69. }
  70. }).then(res => {
  71. if (res.msg != '成功') return wx.showToast({
  72. title: res.msg,
  73. icon: "none"
  74. });
  75. let isEvaluate = false;
  76. if (res.data[0].score != 0) {
  77. this.rateChange({
  78. detail: res.data[0].score
  79. })
  80. isEvaluate = true;
  81. }
  82. res.data[0].leavemessage = res.data[0].leavemessage ? res.data[0].leavemessage : "";
  83. this.setData({
  84. evaluate: res.data[0],
  85. isEvaluate
  86. })
  87. });
  88. },
  89. /* 评分 */
  90. rateChange({
  91. detail
  92. }) {
  93. let rate = {
  94. nubmer: detail,
  95. text: ""
  96. };
  97. switch (detail) {
  98. case 1:
  99. rate.text = '很不满意'
  100. break;
  101. case 2:
  102. rate.text = '不满意'
  103. break;
  104. case 3:
  105. rate.text = '一般'
  106. break;
  107. case 4:
  108. rate.text = '满意'
  109. break;
  110. case 5:
  111. rate.text = '非常满意'
  112. break;
  113. }
  114. this.setData({
  115. rate
  116. })
  117. },
  118. /* 文本框输入 */
  119. textInput({
  120. detail
  121. }) {
  122. this.setData({
  123. "evaluate.leavemessage": deleteMark.queryStr(detail.value)
  124. })
  125. },
  126. /* 提交建议 */
  127. submit() {
  128. if (this.data.isEvaluate) return wx.showToast({
  129. title: '您已提交过建议',
  130. icon: "none"
  131. })
  132. const evaluate = this.data.evaluate,
  133. that = this;
  134. if (evaluate.leavemessage.length > 0) {
  135. that.updateReadRecord()
  136. } else {
  137. wx.showModal({
  138. title: "提示",
  139. content: "通告评分(建议与反馈)没有完成,是否确认提交,提交后无法修改",
  140. success: res => {
  141. if (res.confirm) that.updateReadRecord()
  142. }
  143. })
  144. }
  145. },
  146. updateReadRecord() {
  147. this.setData({
  148. loading: true
  149. })
  150. _Http.basic({
  151. "classname": "saletool.notice.notice",
  152. "method": "updateReadRecord",
  153. "content": {
  154. "sat_noticeid": this.data.detailsData.sat_noticeid,
  155. "score": this.data.rate.nubmer,
  156. "leavemessage": this.data.evaluate.leavemessage
  157. }
  158. }).then(res => {
  159. this.setData({
  160. loading: false
  161. });
  162. if (res.msg != '成功') return wx.showToast({
  163. title: res.msg,
  164. icon: "none"
  165. });
  166. wx.showToast({
  167. title: '提交成功!',
  168. });
  169. this.setData({
  170. isEvaluate: true
  171. })
  172. })
  173. },
  174. /* tabs切换 */
  175. tabChange(e) {
  176. this.setData({
  177. tabsTitle: e.detail.title
  178. })
  179. },
  180. /* 下载附件 */
  181. downLoadRecord() {
  182. _Http.basic({
  183. "classname": "saletool.notice.notice",
  184. "method": "updateDownloadRecord",
  185. "content": {
  186. "sat_noticeid": this.data.detailsData.sat_noticeid
  187. }
  188. })
  189. }
  190. })