var app = getApp(); var utils = require("../../../utils/http"); const util = require("../../../utils/util") var stoptime = 0; Page({ /** * 页面的初始数据 */ data: { aid: '', bType: "", pType: "", title: '志远装饰数字化平台', customerFlag: false, articleObj: {}, imgUrl: app.globalData.imgUrl, type: 1, //3是我的创作进入视频编辑列表进来的,1是我的创作的列表进入,2是裂变列表进入 nowflag: false, footflag: true, wshareshow: false, priceflag: false, showTask: true, datashow: false, isBroker: false, loading: false, showApproval: false, remark: "", trackimgarr: [], nowimagearr: [], shareApprovallist: [] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { if (!!options.clg && options.clg == 3) { wx.reLaunch({ url: '/pages/index/index?clientype=' + options.cty + "&cid=" + options.cid + "&clg=3", }) return false; } if (!!options.type) { this.setData({ footflag: false }) } if (!!options.ty) { this.setData({ bType: options.ty, showTask: false }) } if (!!options.tp) { this.setData({ pType: options.tp }) } if (app.globalData.brokeruserId) { this.setData({ isBroker: true }) } else { this.setData({ isBroker: false }) } this.setData({ aid: options.aid, type: options.type, }) wx.showLoading({ title: '加载中...', }) this.artileMsg(); }, getPhoneNumberTap: function (res) { var that = this; if (res.detail.errMsg == 'getPhoneNumber:ok') { that.setData({ loading: true, }) utils.$post({ url: app.globalData.webUrl + 'api/users/setUserMobile', data: { encryptedData: res.detail.encryptedData, iv: res.detail.iv }, header: { 'Authorization': 'bearer ' + app.globalData.token }, success: function (r) { if (r.data.code == '0') { that.submitMsg(r.data.mobile); } } }) } }, /** * 提交注册数据 */ submitMsg(mobile) { var that = this; utils.$post({ url: app.globalData.webUrl + 'api/agents/add_agents', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { name: '', phone: mobile, employee_id: app.globalData.brokerEmployeeId, wechat: '', type: app.globalData.brokerType }, success: function (res) { if (res.data.code == '0') { app.globalData.brokeruserId = res.data.data; that.setData({ isBroker: true, loading: false, wshareshow: true }) } } }) }, setpostertap: function () { if (this.data.bType == 'b') { wx.navigateTo({ url: '/index/pages/setposter/setposter?type=article&aid=' + this.data.aid + "&ty=b&listshare=", }) } else { wx.navigateTo({ url: '/index/pages/setposter/setposter?type=article&aid=' + this.data.aid + "&listshare=", }) } }, priceshowtap() { this.setData({ priceflag: true }) }, closepricetap() { this.setData({ priceflag: false }) }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, articlesharetap: function () { this.setData({ wshareshow: true }) }, artileMsg: function () { var that = this; utils.$post({ url: app.globalData.webUrl + 'api/article/info', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { article_id: that.data.aid }, success: function (res) { if (res.data.code == '0') { that.setData({ articleObj: res.data.data, title: res.data.data.title }) wx.setNavigationBarTitle({ title: res.data.data.title }) } setTimeout(function () { wx.hideLoading(); }, 1000) } }) }, /** * 生命周期函数--监听页面显示 */ onShow: function () { var that = this; if (app.globalData.sharearticle) { // wx.showToast({ // title: '即将跳转原页面', // icon: 'success', // }) setTimeout(function () { // wx.redirectTo({ // url: "/mycustomer/pages/mycreation/mycreation?type=3", // }); if (that.data.type == '2') { wx.redirectTo({ url: "/mycustomer/pages/mycreation/mycreation?type=2", }); } else if (that.data.type == '1') { wx.navigateBack({ delta: 3 }); } else { wx.navigateBack({ delta: 2 }); } }, 1000) } stoptime = 0; setTimeout(function () { stoptime = stoptime * 1 + 1; }, 1000) }, shareurltap: function () { let that = this; wx.showLoading({ title: '加载中...', }) if (this.data.bType == 'b') { util.schemefun('/share/pages/articleshare/articleshare', 'aid=' + that.data.aid + '&userid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId, that.data.aid, 'article', ''); } else { util.schemefun('/share/pages/articleshare/articleshare', 'aid=' + that.data.aid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, that.data.aid, 'article', ''); } this.sharelogtap(); }, sharealerttap: function (e) { var that = this; that.setData({ nowflag: true, }) }, sendfriendtap() { this.sharelogtap(); }, sharelogtap: function () { var that = this; this.setData({ nowflag: false, }) utils.$post({ url: app.globalData.webUrl + 'api/share/addlog', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.aid, type: 'article' }, success: function (r) {} }) }, collectTap: function () { var that = this; utils.$post({ url: app.globalData.webUrl + 'api/article/collect', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.aid, }, success: function (res) { var articleObj = that.data.articleObj; if (res.data.code == '0') { articleObj.collect = 1; that.setData({ articleObj: articleObj }) wx.showToast({ title: '收藏成功!', icon: 'none', duration: 1000 }) that.setData({ articleObj: articleObj }) } } }) }, cancleTap: function () { var that = this; utils.$post({ url: app.globalData.webUrl + 'api/article/collectCancel', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.aid, }, success: function (res) { var articleObj = that.data.articleObj; if (res.data.code == '0') { articleObj.collect = 0; that.setData({ articleObj: articleObj }) wx.showToast({ title: '取消收藏成功!', icon: 'none', duration: 1000 }) that.setData({ articleObj: articleObj }) } } }) }, zantap: function () { var that = this; utils.$post({ url: app.globalData.webUrl + 'api/article/star', header: { 'Authorization': 'bearer ' + app.globalData.token }, data: { id: that.data.aid, }, success: function (res) { var articleObj = that.data.articleObj; if (res.data.code == '0') { if (articleObj.stared == 1) { wx.showToast({ title: '您已点赞!', icon: 'none', duration: 1000 }) } else { articleObj.stared = 1; wx.showToast({ title: '点赞成功!', icon: 'none', duration: 1000 }) articleObj.star_num = articleObj.star_num * 1 + 1; } that.setData({ articleObj: articleObj }) } } }) }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { var timearr = app.globalData.timearr, flag = false; for (var i = 0; i < timearr.length; i++) { if (timearr[i].type == 'articleprelook') { timearr[i].time = timearr[i].time * 1 + stoptime * 1; flag = true; } } if (!flag) { var obj = { type: 'articleprelook', time: stoptime }; app.globalData.timearr.push(obj); } else { app.globalData.timearr = timearr; } }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { var img = this.data.articleObj.cover_share_img?this.data.articleObj.cover_share_img:this.data.articleObj.cover_img; if (this.data.bType == 'b') { this.sharelogtap(); return { title: this.data.articleObj.title, imageUrl: img, path: '/share/pages/articleshare/articleshare?aid=' + this.data.aid + '&userid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId } } else { this.sharelogtap(); return { title: this.data.articleObj.title, imageUrl: img, path: '/share/pages/articleshare/articleshare?aid=' + this.data.aid + '&userid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype } } }, onAddToFavorites(res) { var img = this.data.articleObj.cover_share_img?this.data.articleObj.cover_share_img:this.data.articleObj.cover_img; return { title: this.data.articleObj.title, imageUrl: img, query: 'cid=' + this.data.aid + '&cty=' + app.globalData.clientype + '&clg=3', } } })