details.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. let auth = options.auth.split(","),
  23. dataAuth = '';
  24. if (auth.includes('团队内部数据分析') && 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. auth,
  34. sat_noticeid: options.id
  35. });
  36. this.queryNoticeMain(); //获取详情
  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. if (this.data.viewData) this.queryReadRecord(); //查询数据
  52. let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')), //过滤封面文件
  53. videoList = [], //视频附件列表
  54. attinfos = []; //其他附件
  55. list.forEach(v => v.fileType == 'video' ? videoList.push(v) : attinfos.push(v));
  56. res.data.attinfos = attinfos;
  57. if (res.data.content.length) res.data.content = weAtob(res.data.content); //解码富文本
  58. this.setData({
  59. detailsData: res.data,
  60. videoList
  61. });
  62. const pages = getCurrentPages(),
  63. page = pages[pages.length - 2].route == 'pages/tabbar/home/index' ? pages[pages.length - 2] : pages[pages.length - 3];
  64. page.queryNoticeList(); //通知首页,更新已读数据
  65. });
  66. },
  67. /* 查询数据 */
  68. queryReadRecord() {
  69. _Http.basic({
  70. "classname": "saletool.notice.notice",
  71. "method": "queryReadRecord",
  72. "content": {
  73. "sat_noticeid": this.data.sat_noticeid
  74. }
  75. }).then(res => {
  76. if (res.msg != '成功') return wx.showToast({
  77. title: res.msg,
  78. icon: "none"
  79. });
  80. let isEvaluate = false;
  81. if (res.data[0].score != 0) {
  82. this.rateChange({
  83. detail: res.data[0].score
  84. })
  85. isEvaluate = true;
  86. }
  87. this.setData({
  88. evaluate: res.data[0],
  89. isEvaluate
  90. })
  91. });
  92. },
  93. /* 评分 */
  94. rateChange({
  95. detail
  96. }) {
  97. let rate = {
  98. nubmer: detail,
  99. text: ""
  100. };
  101. switch (detail) {
  102. case 1:
  103. rate.text = '很不满意'
  104. break;
  105. case 2:
  106. rate.text = '不满意'
  107. break;
  108. case 3:
  109. rate.text = '一般'
  110. break;
  111. case 4:
  112. rate.text = '满意'
  113. break;
  114. case 5:
  115. rate.text = '非常满意'
  116. break;
  117. }
  118. this.setData({
  119. rate
  120. })
  121. },
  122. textInput({
  123. detail
  124. }) {
  125. this.setData({
  126. "evaluate.leavemessage": deleteMark.queryStr(detail.value)
  127. })
  128. },
  129. submit() {
  130. if (this.data.isEvaluate) return wx.showToast({
  131. title: '您已提交过建议',
  132. icon: "none"
  133. })
  134. const evaluate = this.data.evaluate,
  135. that = this;
  136. if (evaluate.leavemessage.length > 0) {
  137. that.updateReadRecord()
  138. } else {
  139. wx.showModal({
  140. title: "提示",
  141. content: "通告评分(建议与反馈)没有完成,是否确认提交,提交后无法修改",
  142. success: res => {
  143. if (res.confirm) that.updateReadRecord()
  144. }
  145. })
  146. }
  147. },
  148. updateReadRecord() {
  149. this.setData({
  150. loading: true
  151. })
  152. _Http.basic({
  153. "classname": "saletool.notice.notice",
  154. "method": "updateReadRecord",
  155. "content": {
  156. "sat_noticeid": this.data.detailsData.sat_noticeid,
  157. "score": this.data.rate.nubmer,
  158. "leavemessage": this.data.evaluate.leavemessage
  159. }
  160. }).then(res => {
  161. this.setData({
  162. loading: false
  163. });
  164. if (res.msg != '成功') return wx.showToast({
  165. title: res.msg,
  166. icon: "none"
  167. });
  168. wx.showToast({
  169. title: '提交成功!',
  170. });
  171. this.setData({
  172. isEvaluate: true
  173. })
  174. })
  175. },
  176. /* tabs切换 */
  177. tabChange(e) {
  178. this.setData({
  179. tabsTitle: e.detail.title
  180. })
  181. },
  182. })