details.js 4.2 KB

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