details.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. const _Http = getApp().globalData.http,
  2. MFT = require("../../utils/matchingFeilType"),
  3. deleteMark = require("../../utils/deleteMark");
  4. import {
  5. weAtob
  6. } from "../../utils/weapp-jwt.js";
  7. Page({
  8. /**
  9. * 页面的初始数据
  10. */
  11. data: {
  12. tabsTitle: "详情",
  13. rate: {
  14. nubmer: 5,
  15. text: "非常满意"
  16. },
  17. videoList: [],
  18. loading: false,
  19. isEvaluate: false
  20. },
  21. onLoad(options) {
  22. console.log(options)
  23. let dataAuth = '';
  24. if (options.auth.includes('团队内部数据分析') && options.auth.includes('经销商数据分析')) {
  25. dataAuth = 'all';
  26. } else {
  27. dataAuth = options.auth.includes('团队内部数据分析') ? '内部' : '经销商'
  28. };
  29. let viewData = options.auth.includes('团队内部数据分析') || options.auth.includes('经销商数据分析');
  30. this.setData({
  31. viewData,
  32. dataAuth,
  33. sat_noticeid: options.id
  34. });
  35. this.queryNoticeMain(); //获取详情
  36. if (viewData) this.queryReadRecord(); //查询数据
  37. },
  38. /* 通告详情 */
  39. queryNoticeMain() {
  40. _Http.basic({
  41. "classname": "saletool.notice.notice",
  42. "method": "queryNoticeMain",
  43. "content": {
  44. "sat_noticeid": this.data.sat_noticeid
  45. }
  46. }).then(res => {
  47. if (res.msg != '成功') return wx.showToast({
  48. title: res.msg,
  49. icon: "none"
  50. });
  51. let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')), //过滤封面文件
  52. videoList = [], //视频附件列表
  53. attinfos = []; //其他附件
  54. list.forEach(v => v.fileType == 'video' ? videoList.push(v) : attinfos.push(v));
  55. res.data.attinfos = attinfos;
  56. if (res.data.content.length) res.data.content = weAtob(res.data.content); //解码富文本
  57. this.setData({
  58. detailsData: res.data,
  59. videoList
  60. });
  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. textInput({
  119. detail
  120. }) {
  121. this.setData({
  122. "evaluate.leavemessage": deleteMark.queryStr(detail.value)
  123. })
  124. },
  125. submit() {
  126. if (this.data.isEvaluate) return wx.showToast({
  127. title: '您已提交过建议',
  128. icon: "none"
  129. })
  130. const evaluate = this.data.evaluate,
  131. that = this;
  132. if (evaluate.leavemessage.length > 0) {
  133. that.updateReadRecord()
  134. } else {
  135. wx.showModal({
  136. title: "提示",
  137. content: "通告评分(建议与反馈)没有完成,是否确认提交,提交后无法修改",
  138. success: res => {
  139. if (res.confirm) that.updateReadRecord()
  140. }
  141. })
  142. }
  143. },
  144. updateReadRecord() {
  145. this.setData({
  146. loading: true
  147. })
  148. _Http.basic({
  149. "classname": "saletool.notice.notice",
  150. "method": "updateReadRecord",
  151. "content": {
  152. "sat_noticeid": this.data.detailsData.sat_noticeid,
  153. "score": this.data.rate.nubmer,
  154. "leavemessage": this.data.evaluate.leavemessage
  155. }
  156. }).then(res => {
  157. this.setData({
  158. loading: false
  159. });
  160. if (res.msg != '成功') return wx.showToast({
  161. title: res.msg,
  162. icon: "none"
  163. });
  164. wx.showToast({
  165. title: '提交成功!',
  166. });
  167. this.setData({
  168. isEvaluate: true
  169. })
  170. })
  171. },
  172. /* tabs切换 */
  173. tabChange(e) {
  174. this.setData({
  175. tabsTitle: e.detail.title
  176. })
  177. },
  178. })