details.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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.auth)
  23. let auth = options.auth.split(","),
  24. dataAuth = '';
  25. if (auth.includes('团队内部数据分析') && auth.includes('经销商数据分析')) {
  26. dataAuth = 'all';
  27. } else {
  28. dataAuth = options.auth.includes('团队内部数据分析') ? '内部' : '经销商'
  29. };
  30. let viewData = options.auth.includes('团队内部数据分析') || options.auth.includes('经销商数据分析');
  31. this.setData({
  32. viewData,
  33. dataAuth,
  34. auth,
  35. sat_noticeid: options.id
  36. });
  37. this.queryNoticeMain(); //获取详情
  38. },
  39. /* 通告详情 */
  40. queryNoticeMain() {
  41. _Http.basic({
  42. "classname": "saletool.notice.notice",
  43. "method": "queryNoticeMain",
  44. "content": {
  45. "sat_noticeid": this.data.sat_noticeid
  46. }
  47. }).then(res => {
  48. if (res.msg != '成功') return wx.showToast({
  49. title: res.msg,
  50. icon: "none"
  51. });
  52. if (this.data.viewData) this.queryReadRecord(); //查询数据
  53. let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')), //过滤封面文件
  54. videoList = [], //视频附件列表
  55. attinfos = []; //其他附件
  56. list.forEach(v => v.fileType == 'video' ? videoList.push(v) : attinfos.push(v));
  57. res.data.attinfos = attinfos;
  58. if (res.data.content.length) res.data.content = weAtob(res.data.content); //解码富文本
  59. this.setData({
  60. detailsData: res.data,
  61. videoList
  62. });
  63. });
  64. },
  65. /* 查询数据 */
  66. queryReadRecord() {
  67. _Http.basic({
  68. "classname": "saletool.notice.notice",
  69. "method": "queryReadRecord",
  70. "content": {
  71. "sat_noticeid": this.data.sat_noticeid
  72. }
  73. }).then(res => {
  74. if (res.msg != '成功') return wx.showToast({
  75. title: res.msg,
  76. icon: "none"
  77. });
  78. let isEvaluate = false;
  79. if (res.data[0].score != 0) {
  80. this.rateChange({
  81. detail: res.data[0].score
  82. })
  83. isEvaluate = true;
  84. }
  85. this.setData({
  86. evaluate: res.data[0],
  87. isEvaluate
  88. })
  89. });
  90. },
  91. /* 评分 */
  92. rateChange({
  93. detail
  94. }) {
  95. let rate = {
  96. nubmer: detail,
  97. text: ""
  98. };
  99. switch (detail) {
  100. case 1:
  101. rate.text = '很不满意'
  102. break;
  103. case 2:
  104. rate.text = '不满意'
  105. break;
  106. case 3:
  107. rate.text = '一般'
  108. break;
  109. case 4:
  110. rate.text = '满意'
  111. break;
  112. case 5:
  113. rate.text = '非常满意'
  114. break;
  115. }
  116. this.setData({
  117. rate
  118. })
  119. },
  120. textInput({
  121. detail
  122. }) {
  123. this.setData({
  124. "evaluate.leavemessage": deleteMark.queryStr(detail.value)
  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. })