details.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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 = options.auth.split(","),
  20. dataAuth = '';
  21. if (auth.includes('团队内部数据分析') && auth.includes('经销商数据分析')) {
  22. dataAuth = 'all';
  23. } else {
  24. dataAuth = options.auth.includes('团队内部数据分析') ? '内部' : '经销商'
  25. };
  26. let viewData = options.auth.includes('团队内部数据分析') || options.auth.includes('经销商数据分析');
  27. this.setData({
  28. viewData,
  29. dataAuth,
  30. auth,
  31. sat_noticeid: options.id
  32. });
  33. this.queryNoticeMain(); //获取详情
  34. },
  35. /* 通告详情 */
  36. queryNoticeMain() {
  37. _Http.basic({
  38. "classname": "saletool.notice.notice",
  39. "method": "queryNoticeMain",
  40. "content": {
  41. "sat_noticeid": this.data.sat_noticeid
  42. }
  43. }).then(res => {
  44. if (res.msg != '成功') return wx.showToast({
  45. title: res.msg,
  46. icon: "none"
  47. });
  48. if (this.data.viewData) this.queryReadRecord(); //查询数据
  49. let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')), //过滤封面文件
  50. videoList = [], //视频附件列表
  51. attinfos = []; //其他附件
  52. list.forEach(v => v.fileType == 'video' ? videoList.push(v) : attinfos.push(v));
  53. res.data.attinfos = attinfos;
  54. this.setData({
  55. detailsData: res.data,
  56. videoList
  57. });
  58. const pages = getCurrentPages(),
  59. page = pages[pages.length - 2].route == 'pages/tabbar/home/index' ? pages[pages.length - 2] : pages[pages.length - 3];
  60. page.queryNoticeList(); //通知首页,更新已读数据
  61. });
  62. },
  63. /* 查询数据 */
  64. queryReadRecord() {
  65. _Http.basic({
  66. "classname": "saletool.notice.notice",
  67. "method": "queryReadRecord",
  68. "content": {
  69. "sat_noticeid": this.data.sat_noticeid
  70. }
  71. }).then(res => {
  72. if (res.msg != '成功') return wx.showToast({
  73. title: res.msg,
  74. icon: "none"
  75. });
  76. let isEvaluate = false;
  77. if (res.data[0].score != 0) {
  78. this.rateChange({
  79. detail: res.data[0].score
  80. })
  81. isEvaluate = true;
  82. }
  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. })