details.js 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. const _Http = getApp().globalData.http,
  2. MFT = require("../../utils/FormatTheAttachment"),
  3. deleteMark = require("../../utils/Check");
  4. Page({
  5. data: {
  6. tabsTitle: "详情",
  7. rate: {
  8. nubmer: 5,
  9. text: "非常满意"
  10. },
  11. videoList: [],
  12. loading: false,
  13. isEvaluate: false
  14. },
  15. onLoad(options) {
  16. /* let auth = wx.getStorageSync('auth').wnotice.optionnames,
  17. dataAuth = '';
  18. if (auth.some(v => v == '团队内部数据分析') && auth.some(v => v == '经销商数据分析')) {
  19. dataAuth = 'all';
  20. } else {
  21. dataAuth = auth.some(v => v == '团队内部数据分析') ? '内部' : '经销商'
  22. };
  23. this.setData({
  24. viewData: auth.some(v => v == '团队内部数据分析') || auth.some(v => v == '经销商数据分析'),
  25. dataAuth,
  26. auth,
  27. }) */
  28. this.setData({
  29. sat_noticeid: options.id
  30. });
  31. this.queryNoticeMain(); //获取详情
  32. },
  33. /* 通告详情 */
  34. queryNoticeMain() {
  35. _Http.basic({
  36. "classname": "saletool.notice.notice",
  37. "method": "queryNoticeMain",
  38. "content": {
  39. "sat_noticeid": this.data.sat_noticeid
  40. }
  41. }).then(res => {
  42. if (res.msg != '成功') return wx.showToast({
  43. title: res.msg,
  44. icon: "none"
  45. });
  46. if (this.data.viewData) this.queryReadRecord(); //查询数据
  47. let list = MFT.fileList(res.data.attinfos.filter(v => v.usetype != 'cover')), //过滤封面文件
  48. videoList = [], //视频附件列表
  49. attinfos = []; //其他附件
  50. list.forEach(v => v.fileType == 'video' ? videoList.push(v) : attinfos.push(v));
  51. res.data.attinfos = attinfos;
  52. this.setData({
  53. detailsData: res.data,
  54. videoList
  55. });
  56. /* getCurrentPages().forEach(v => {
  57. if (v.__route__ == 'pages/tabbar/home/index') v.queryNoticeList()
  58. }) */
  59. });
  60. },
  61. /* 查询数据 */
  62. queryReadRecord() {
  63. _Http.basic({
  64. "classname": "saletool.notice.notice",
  65. "method": "queryReadRecord",
  66. "content": {
  67. "sat_noticeid": this.data.sat_noticeid
  68. }
  69. }).then(res => {
  70. if (res.msg != '成功') return wx.showToast({
  71. title: res.msg,
  72. icon: "none"
  73. });
  74. let isEvaluate = false;
  75. if (res.data[0].score != 0) {
  76. this.rateChange({
  77. detail: res.data[0].score
  78. })
  79. isEvaluate = true;
  80. }
  81. res.data[0].leavemessage = res.data[0].leavemessage ? res.data[0].leavemessage : "";
  82. this.setData({
  83. evaluate: res.data[0],
  84. isEvaluate
  85. })
  86. });
  87. },
  88. /* 评分 */
  89. rateChange({
  90. detail
  91. }) {
  92. let rate = {
  93. nubmer: detail,
  94. text: ""
  95. };
  96. switch (detail) {
  97. case 1:
  98. rate.text = '很不满意'
  99. break;
  100. case 2:
  101. rate.text = '不满意'
  102. break;
  103. case 3:
  104. rate.text = '一般'
  105. break;
  106. case 4:
  107. rate.text = '满意'
  108. break;
  109. case 5:
  110. rate.text = '非常满意'
  111. break;
  112. }
  113. this.setData({
  114. rate
  115. })
  116. },
  117. /* 文本框输入 */
  118. textInput({
  119. detail
  120. }) {
  121. this.setData({
  122. "evaluate.leavemessage": deleteMark.queryStr(detail.value)
  123. })
  124. },
  125. /* 提交建议 */
  126. submit() {
  127. if (this.data.isEvaluate) return wx.showToast({
  128. title: '您已提交过建议',
  129. icon: "none"
  130. })
  131. const evaluate = this.data.evaluate,
  132. that = this;
  133. if (evaluate.leavemessage.length > 0) {
  134. that.updateReadRecord()
  135. } else {
  136. wx.showModal({
  137. title: "提示",
  138. content: "通告评分(建议与反馈)没有完成,是否确认提交,提交后无法修改",
  139. success: res => {
  140. if (res.confirm) that.updateReadRecord()
  141. }
  142. })
  143. }
  144. },
  145. updateReadRecord() {
  146. this.setData({
  147. loading: true
  148. })
  149. _Http.basic({
  150. "classname": "saletool.notice.notice",
  151. "method": "updateReadRecord",
  152. "content": {
  153. "sat_noticeid": this.data.detailsData.sat_noticeid,
  154. "score": this.data.rate.nubmer,
  155. "leavemessage": this.data.evaluate.leavemessage
  156. }
  157. }).then(res => {
  158. this.setData({
  159. loading: false
  160. });
  161. if (res.msg != '成功') return wx.showToast({
  162. title: res.msg,
  163. icon: "none"
  164. });
  165. wx.showToast({
  166. title: '提交成功!',
  167. });
  168. this.setData({
  169. isEvaluate: true
  170. })
  171. })
  172. },
  173. /* tabs切换 */
  174. tabChange(e) {
  175. this.setData({
  176. tabsTitle: e.detail.title
  177. })
  178. },
  179. /* 下载附件 */
  180. downLoadRecord() {
  181. _Http.basic({
  182. "classname": "saletool.notice.notice",
  183. "method": "updateDownloadRecord",
  184. "content": {
  185. "sat_noticeid": this.data.detailsData.sat_noticeid
  186. }
  187. })
  188. }
  189. })