details.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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 = [],
  20. dataAuth = '';
  21. (options.auth) ? auth = options.auth.split(","): getApp().globalData.queryPer.query(wx.getStorageSync('userauth'), ['营销工具'], ['通告'])[0].apps[0].meta.auth.forEach(v => auth.push(v.optionname));
  22. if (auth.includes('团队内部数据分析') && auth.includes('经销商数据分析')) {
  23. dataAuth = 'all';
  24. } else {
  25. dataAuth = options.auth.includes('团队内部数据分析') ? '内部' : '经销商'
  26. };
  27. this.setData({
  28. viewData: auth.includes('团队内部数据分析') || auth.includes('经销商数据分析'),
  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. res.data[0].leavemessage = res.data[0].leavemessage ? res.data[0].leavemessage : "";
  84. this.setData({
  85. evaluate: res.data[0],
  86. isEvaluate
  87. })
  88. });
  89. },
  90. /* 评分 */
  91. rateChange({
  92. detail
  93. }) {
  94. let rate = {
  95. nubmer: detail,
  96. text: ""
  97. };
  98. switch (detail) {
  99. case 1:
  100. rate.text = '很不满意'
  101. break;
  102. case 2:
  103. rate.text = '不满意'
  104. break;
  105. case 3:
  106. rate.text = '一般'
  107. break;
  108. case 4:
  109. rate.text = '满意'
  110. break;
  111. case 5:
  112. rate.text = '非常满意'
  113. break;
  114. }
  115. this.setData({
  116. rate
  117. })
  118. },
  119. /* 文本框输入 */
  120. textInput({
  121. detail
  122. }) {
  123. this.setData({
  124. "evaluate.leavemessage": deleteMark.queryStr(detail.value)
  125. })
  126. },
  127. /* 提交建议 */
  128. submit() {
  129. if (this.data.isEvaluate) return wx.showToast({
  130. title: '您已提交过建议',
  131. icon: "none"
  132. })
  133. const evaluate = this.data.evaluate,
  134. that = this;
  135. if (evaluate.leavemessage.length > 0) {
  136. that.updateReadRecord()
  137. } else {
  138. wx.showModal({
  139. title: "提示",
  140. content: "通告评分(建议与反馈)没有完成,是否确认提交,提交后无法修改",
  141. success: res => {
  142. if (res.confirm) that.updateReadRecord()
  143. }
  144. })
  145. }
  146. },
  147. updateReadRecord() {
  148. this.setData({
  149. loading: true
  150. })
  151. _Http.basic({
  152. "classname": "saletool.notice.notice",
  153. "method": "updateReadRecord",
  154. "content": {
  155. "sat_noticeid": this.data.detailsData.sat_noticeid,
  156. "score": this.data.rate.nubmer,
  157. "leavemessage": this.data.evaluate.leavemessage
  158. }
  159. }).then(res => {
  160. this.setData({
  161. loading: false
  162. });
  163. if (res.msg != '成功') return wx.showToast({
  164. title: res.msg,
  165. icon: "none"
  166. });
  167. wx.showToast({
  168. title: '提交成功!',
  169. });
  170. this.setData({
  171. isEvaluate: true
  172. })
  173. })
  174. },
  175. /* tabs切换 */
  176. tabChange(e) {
  177. this.setData({
  178. tabsTitle: e.detail.title
  179. })
  180. },
  181. })