talkskillmsg.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308
  1. const app=getApp();
  2. var utils=require("../../../utils/http");
  3. let page=1;
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. vid:'',
  10. imgUrl:app.globalData.imgUrl,
  11. wordMsg:{},
  12. scorevalue: 0,
  13. readonly:false,
  14. allcommentNum:0,
  15. commentArr:[],
  16. sayflag:false,
  17. comments:'',
  18. datashow:false
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad: function (options) {
  24. wx.showLoading({
  25. title: '加载中...',
  26. })
  27. this.setData({
  28. vid:options.vid
  29. })
  30. this.commentfun();
  31. },
  32. commentfun:function(){
  33. let that=this;
  34. utils.$post({
  35. url: app.globalData.webUrl + 'api/talkskill/talkskill_xq',
  36. header: {
  37. 'Authorization':'bearer '+app.globalData.token
  38. },
  39. data:{
  40. id: that.data.vid,
  41. user_id:app.globalData.personMsg.id
  42. },
  43. success: function (res) {
  44. if (res.data.code == "0") {
  45. that.setData({
  46. wordMsg:res.data.data
  47. })
  48. that.setData({
  49. // readonly:res.data.data.isScore>0?true:false
  50. })
  51. // if(that.data.wordMsg.isScore>0){
  52. // that.setData({
  53. // scorevalue:that.wordMsg.score/2
  54. // })
  55. // }
  56. if(res.data.data.collect=='1'){
  57. that.setData({
  58. collectflag:true
  59. })
  60. }else{
  61. that.setData({
  62. collectflag:false
  63. })
  64. }
  65. }
  66. that.comment();
  67. }
  68. })
  69. },
  70. comment:function(){
  71. let that=this;
  72. page=1;
  73. utils.$post({
  74. url: app.globalData.webUrl + 'api/talkskill/commentList',
  75. header: {
  76. 'Authorization':'bearer '+app.globalData.token
  77. },
  78. data:{
  79. taid:that.data.vid,//话术id
  80. page:1,
  81. limit:'15',
  82. user_id:app.globalData.personMsg.id
  83. },
  84. success: function (res) {
  85. if (res.data.code == "0") {
  86. that.setData({
  87. allcommentNum:res.data.count,
  88. commentArr:res.data.data,
  89. datashow:true
  90. })
  91. }
  92. wx.hideLoading()
  93. }
  94. })
  95. },
  96. sayTap:function(){
  97. this.setData({
  98. sayflag:true
  99. })
  100. },
  101. sayshowTap:function(){
  102. this.setData({
  103. sayflag:false
  104. })
  105. },
  106. bindKeyInput: function (e) {
  107. this.setData({
  108. comments: e.detail.value
  109. })
  110. },
  111. dothis:function(){},
  112. copyText:function(){
  113. wx.setClipboardData({
  114. data: this.data.wordMsg.content,
  115. success (res) {
  116. },fail(res){
  117. console.log(res)
  118. }
  119. })
  120. },
  121. screenchatting: function (options) {
  122. let that=this;
  123. if(!this.data.comments){
  124. wx.showToast({
  125. title: '评论内容不能为空!',
  126. icon: 'none',
  127. duration: 2000
  128. })
  129. return false;
  130. }
  131. wx.showLoading({
  132. title: '评论中...',
  133. })
  134. utils.$post({
  135. url: app.globalData.webUrl + 'api/talkskill/addComment',
  136. header: {
  137. 'Authorization':'bearer '+app.globalData.token
  138. },
  139. data:{
  140. taid:that.data.vid,//话术id
  141. content:that.data.comments,//内容
  142. user_id:app.globalData.personMsg.id
  143. },
  144. success: function (res) {
  145. if (res.data.code == "0") {
  146. wx.showToast({
  147. title: '评论成功!',
  148. icon: 'none',
  149. duration: 2000
  150. })
  151. that.setData({
  152. sayflag:false,
  153. comments:''
  154. })
  155. that.comment();
  156. wx.hideLoading()
  157. }
  158. }
  159. })
  160. },
  161. collectTap:function(){
  162. let that=this;
  163. var surl="";
  164. if(!that.data.collectflag){
  165. surl="api/talkskill/collect";
  166. }else{
  167. surl="/api/talkskill/collectCancel";
  168. }
  169. utils.$post({
  170. url: app.globalData.webUrl + surl,
  171. header: {
  172. 'Authorization':'bearer '+app.globalData.token
  173. },
  174. data:{
  175. id:that.data.vid,//话术id
  176. },
  177. success: function (res) {
  178. if (res.data.code == "0") {
  179. if(!that.data.collectflag){
  180. that.setData({
  181. collectflag:true
  182. })
  183. wx.showToast({
  184. title: res.data.msg,
  185. icon: 'none',
  186. duration: 2000
  187. })
  188. }else{
  189. that.setData({
  190. collectflag:false
  191. })
  192. wx.showToast({
  193. title: res.data.msg,
  194. icon: 'none',
  195. duration: 2000
  196. })
  197. }
  198. } else {
  199. if(res.data.msg=='您已收藏'){
  200. that.setData({
  201. collectflag:true
  202. })
  203. }
  204. }
  205. setTimeout(function(){
  206. wx.hideLoading()
  207. },1200)
  208. }
  209. })
  210. },
  211. // 评分
  212. onChange(event) {
  213. console.log('当前值:' + event.detail);
  214. this.setData({
  215. scorevalue:event.detail,
  216. readonly:true
  217. })
  218. },
  219. /**
  220. * 生命周期函数--监听页面初次渲染完成
  221. */
  222. onReady: function (options) {
  223. },
  224. /**
  225. * 生命周期函数--监听页面显示
  226. */
  227. onShow: function () {
  228. },
  229. /**
  230. * 生命周期函数--监听页面隐藏
  231. */
  232. onHide: function () {
  233. },
  234. /**
  235. * 生命周期函数--监听页面卸载
  236. */
  237. onUnload: function () {
  238. },
  239. /**
  240. * 页面相关事件处理函数--监听用户下拉动作
  241. */
  242. onPullDownRefresh: function () {
  243. let that=this;
  244. page=1;
  245. utils.$post({
  246. url: app.globalData.webUrl + 'api/talkskill/commentList',
  247. header: {
  248. 'Authorization':'bearer '+app.globalData.token
  249. },
  250. data:{
  251. taid:that.data.vid,//话术id
  252. page:1,
  253. limit:'15',
  254. user_id:app.globalData.personMsg.id
  255. },
  256. success: function (res) {
  257. wx.stopPullDownRefresh();
  258. if (res.data.code == "0") {
  259. that.setData({
  260. commentArr:res.data.data,
  261. })
  262. }
  263. wx.hideLoading()
  264. }
  265. })
  266. },
  267. /**
  268. * 页面上拉触底事件的处理函数
  269. */
  270. onReachBottom: function () {
  271. let that=this;
  272. page=page*1+1;
  273. utils.$post({
  274. url: app.globalData.webUrl + 'api/talkskill/commentList',
  275. header: {
  276. 'Authorization':'bearer '+app.globalData.token
  277. },
  278. data:{
  279. taid:that.data.vid,//话术id
  280. page:page,
  281. limit:'15',
  282. user_id:app.globalData.personMsg.id
  283. },
  284. success: function (res) {
  285. let commentArr=that.data.commentArr;
  286. if (res.data.code == "0") {
  287. commentArr=commentArr.concatres.data.data()
  288. that.setData({
  289. commentArr:commentArr,
  290. })
  291. }
  292. wx.hideLoading()
  293. }
  294. })
  295. },
  296. })