123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- const app=getApp();
- var utils=require("../../../utils/http");
- let page=1;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- vid:'',
- imgUrl:app.globalData.imgUrl,
- wordMsg:{},
- scorevalue: 0,
- readonly:false,
- allcommentNum:0,
- commentArr:[],
- sayflag:false,
- comments:'',
- datashow:false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- wx.showLoading({
- title: '加载中...',
- })
- this.setData({
- vid:options.vid
- })
- this.commentfun();
- },
- commentfun:function(){
- let that=this;
- utils.$post({
- url: app.globalData.webUrl + 'api/talkskill/talkskill_xq',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- id: that.data.vid,
- user_id:app.globalData.personMsg.id
- },
- success: function (res) {
- if (res.data.code == "0") {
- that.setData({
- wordMsg:res.data.data
- })
- that.setData({
- // readonly:res.data.data.isScore>0?true:false
- })
- // if(that.data.wordMsg.isScore>0){
- // that.setData({
- // scorevalue:that.wordMsg.score/2
- // })
- // }
- if(res.data.data.collect=='1'){
- that.setData({
- collectflag:true
- })
- }else{
- that.setData({
- collectflag:false
- })
- }
- }
- that.comment();
- }
- })
- },
- comment:function(){
- let that=this;
- page=1;
- utils.$post({
- url: app.globalData.webUrl + 'api/talkskill/commentList',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- taid:that.data.vid,//话术id
- page:1,
- limit:'15',
- user_id:app.globalData.personMsg.id
- },
- success: function (res) {
- if (res.data.code == "0") {
- that.setData({
- allcommentNum:res.data.count,
- commentArr:res.data.data,
- datashow:true
- })
- }
- wx.hideLoading()
- }
- })
- },
- sayTap:function(){
- this.setData({
- sayflag:true
- })
- },
- sayshowTap:function(){
- this.setData({
- sayflag:false
- })
- },
- bindKeyInput: function (e) {
- this.setData({
- comments: e.detail.value
- })
- },
- dothis:function(){},
- copyText:function(){
- wx.setClipboardData({
- data: this.data.wordMsg.content,
- success (res) {
- },fail(res){
- console.log(res)
- }
- })
- },
- screenchatting: function (options) {
- let that=this;
- if(!this.data.comments){
- wx.showToast({
- title: '评论内容不能为空!',
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- wx.showLoading({
- title: '评论中...',
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/talkskill/addComment',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- taid:that.data.vid,//话术id
- content:that.data.comments,//内容
- user_id:app.globalData.personMsg.id
- },
- success: function (res) {
- if (res.data.code == "0") {
- wx.showToast({
- title: '评论成功!',
- icon: 'none',
- duration: 2000
- })
- that.setData({
- sayflag:false,
- comments:''
- })
- that.comment();
- wx.hideLoading()
- }
- }
- })
- },
- collectTap:function(){
- let that=this;
- var surl="";
- if(!that.data.collectflag){
- surl="api/talkskill/collect";
- }else{
- surl="/api/talkskill/collectCancel";
- }
- utils.$post({
- url: app.globalData.webUrl + surl,
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- id:that.data.vid,//话术id
- },
- success: function (res) {
- if (res.data.code == "0") {
- if(!that.data.collectflag){
- that.setData({
- collectflag:true
- })
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }else{
- that.setData({
- collectflag:false
- })
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- }
- } else {
- if(res.data.msg=='您已收藏'){
- that.setData({
- collectflag:true
- })
- }
- }
- setTimeout(function(){
- wx.hideLoading()
- },1200)
- }
- })
- },
- // 评分
- onChange(event) {
- console.log('当前值:' + event.detail);
- this.setData({
- scorevalue:event.detail,
- readonly:true
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function (options) {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- let that=this;
- page=1;
- utils.$post({
- url: app.globalData.webUrl + 'api/talkskill/commentList',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- taid:that.data.vid,//话术id
- page:1,
- limit:'15',
- user_id:app.globalData.personMsg.id
- },
- success: function (res) {
- wx.stopPullDownRefresh();
- if (res.data.code == "0") {
- that.setData({
- commentArr:res.data.data,
- })
- }
- wx.hideLoading()
- }
- })
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- let that=this;
- page=page*1+1;
- utils.$post({
- url: app.globalData.webUrl + 'api/talkskill/commentList',
- header: {
- 'Authorization':'bearer '+app.globalData.token
- },
- data:{
- taid:that.data.vid,//话术id
- page:page,
- limit:'15',
- user_id:app.globalData.personMsg.id
- },
- success: function (res) {
- let commentArr=that.data.commentArr;
- if (res.data.code == "0") {
- commentArr=commentArr.concatres.data.data()
- that.setData({
- commentArr:commentArr,
- })
- }
- wx.hideLoading()
- }
- })
- },
- })
|