123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710 |
- var app = getApp();
- var utils = require("../../../utils/http");
- var customerflag = false, videoContext = null;
- let time = 0, timer = null, designTimer = null;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- imgUrl: app.globalData.imgUrl,
- videoUrl: '',
- title: '志远装饰',
- btflag: false,
- loginFlag: false,
- phoneFlag: false,
- errorText: '请求错误!',
- oneButton: [{ text: '确定' }],
- ght: '100%',
- headimgurl: "",
- nickname: "",
- vid: "",
- star_num: "",
- shareuserid: "",
- customerFlag: true,
- videoflag: false,
- playBtn: true,
- videoObj: {},
- mobileflag: false,
- autoplay: false,
- covercustomerFlag: true,
- canIUseGetUserProfile: false,
- loadflag: false,
- imgsrc: '',
- shareobj: {},
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- employeeflag: false,//false是用户,true是员工
- companyobj: {},
- showDsc: false,
- priceflag: false,
- designPlan: false,
- playflag: 2,//1是播放中,2是暂停
- isBroker: false,
- showMask: false,
- fPhone: "",
- agid: ""
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- if (wx.getUserProfile) {
- this.setData({
- canIUseGetUserProfile: true
- })
- }
- time = 0;
- wx.hideHomeButton();
- if (!!options.scene) {
- options = unescape(options.scene);
- let arr = options.split('&');
- let obj = {};
- for (let i = 0; i < arr.length; i++) {
- let arr1 = arr[i].split('=');
- obj[arr1[0]] = arr1[1];
- }
- if (obj.g) {
- that.setData({
- vid: obj.v,
- isBroker: true,
- agid: obj.g
- })
- app.globalData.clientype = obj.c;
- app.globalData.shareuserid = obj.u;
- app.globalData.brokeruserId = obj.g;
- } else {
- that.setData({
- vid: obj.vid
- })
- app.globalData.clientype = obj.ctp;
- app.globalData.shareuserid = obj.userid;
- }
- } else {
- that.setData({
- vid: options.vid
- })
- if (!!options.agid) {
- this.setData({
- isBroker: true,
- agid: options.agid
- })
- app.globalData.brokeruserId = options.agid;
- }
- app.globalData.clientype = options.ctp;
- app.globalData.shareuserid = options.userid;
- }
- this.setData({
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- })
- wx.showLoading({
- title: '加载中',
- })
- that.login();
- },
- showdscMsg: function () {
- if (this.data.videoObj.description.length > 28) {
- this.data.showDsc = !this.data.showDsc;
- this.setData({
- showDsc: this.data.showDsc
- })
- }
- },
- /**
- * 弹出报价弹窗
- */
- priceshowtap() {
- videoContext.pause();
- this.setData({
- priceflag: true
- })
- },
- /**
- * 关闭报价弹窗
- */
- closepricetap() {
- this.setData({
- priceflag: false
- })
- },
- closeDesigntap(e) {
- if (designTimer) {
- clearTimeout(designTimer);
- }
- if (e.detail.type == 'success') {
- this.setData({
- designPlan: false
- })
- } else {
- this.setData({
- designPlan: false
- })
- }
- },
- sharecompany: function () {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'client/index/content_belong_company',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- client_type: app.globalData.clientype,
- uid: app.globalData.shareuserid
- },
- success: function (res) {
- if (res.data.code == '0') {
- app.globalData.companyobj = res.data.data;
- that.setData({
- companyobj: res.data.data
- })
- }
- },
- complete(res) {
- wx.hideLoading()
- }
- })
- },
- login: function () {
- var that = this;
- wx.login({
- success: function (data) {
- if (data.errMsg == 'login:ok') {
- utils.$post({
- url: app.globalData.webUrl + 'api/users/code2sessionmini',
- data: {
- code: data.code,
- share: app.globalData.shareuserid,
- client_type: app.globalData.clientype,
- share_agent_id: app.globalData.brokeruserId
- },
- success: function (r) {
- if (r.data.code == '0') {
- app.globalData.token = r.data.token;
- app.globalData.sharepersonobj = r.data.share;
- that.setData({
- shareobj: r.data.share
- })
- that.sharecompany();
- app.globalData.personMsg = r.data.user;
- app.globalData.companyname=r.data.company;
- app.globalData.official_openid = r.data.official_openid;
- app.globalData.agentEmployeEid = r.data.agent_employee_id;
- if (!!r.data.user.phone) {
- that.setData({
- fPhone: r.data.user.phone,
- loginFlag: false,
- phoneFlag: false,
- employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false
- })
- app.globalData.use_id = r.data.user.id;
- app.globalData.userflag = false;//有个人信息
- app.globalData.phone = true;//有手机号
- if (!!r.data.user.binded && r.data.user.binded.state == '在职'){
- app.globalData.currentUserId = r.data.user.binded.id;
- }
- var obj = {
- detail: 1
- }
- that.videofun(obj);
- } else {
- that.videofun();
- wx.hideLoading();
- that.setData({
- errorflag: true,
- loginFlag: false,
- phoneFlag: true
- })
- }
- }
- }
- })
- }
- }
- })
- },
- cancelGetPhone() {
- designTimer = setTimeout(() => {
- this.setData({
- designPlan: true
- })
- }, 4000)
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- prelooktap() {
- if (!app.globalData.sharepersonobj.qrcode) {
- wx.showToast({
- title: "当前专属客服的二维码为空!",
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- wx.previewImage({
- current: app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode, // 当前显示图片的http链接
- urls: [app.globalData.imgUrl + app.globalData.sharepersonobj.qrcode]// 需要预览的图片http链接列表
- })
- },
- callphonetap: function () {
- wx.makePhoneCall({
- phoneNumber: app.globalData.sharepersonobj.phone
- })
- },
- videofun: function (type) {
- var that = this;
- if (!!type && type.detail == '1') {
- that.setData({
- articlelogin: true,
- phoneFlag: false,
- mobileflag: false,
- })
- }
- utils.$post({
- url: app.globalData.webUrl + 'client/video/info',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- video_id: that.data.vid,
- user: app.globalData.shareuserid,
- },
- success: function (r) {
- setTimeout(function () {
- wx.hideLoading()
- }, 600)
- if (r.data.code == '0') {
- r.data.data.description = r.data.data.title + '#' + r.data.data.description + '#';
- that.setData({
- title: r.data.data.title,
- videoObj: r.data.data,
- loadflag: true,
- customerFlag: false,
- })
- videoContext = that.selectComponent("#myVideo1");
- wx.setNavigationBarTitle({
- title: r.data.data.title
- })
- that.setData({
- imgsrc: r.data.data.cover_share_img?r.data.data.cover_share_img:r.data.data.cover ? r.data.data.cover : r.data.data.video_url + '?x-oss-process=video/snapshot,t_100,f_jpg,w_500,m_fast',
- })
- if (!!type && type.detail == '1') {
- that.setData({
- autoplay: true
- })
- videoContext.play();
- }
- }
- }
- })
- },
- bindplay: function (e) {
- setTimeout(function () {
- wx.hideLoading();
- }, 1000)
- videoContext.play();
- },
- bindended: function (e) {
- var that = this;
- videoContext.play();
- },
- lookvidoefun() {
- videoContext.play();
- },
- getUserInfoTap: function (res) {
- var that = this;
- wx.showLoading();
- if (res.detail.errMsg == 'getUserInfo:ok') {
- utils.$post({
- method: "POST",//TESTAPIURL APIURL/users/auth
- url: app.globalData.webUrl + 'api/users/setUserInfo',
- data: {
- encryptedData: res.detail.encryptedData,
- iv: res.detail.iv,
- rawData: res.detail.rawData,
- signature: res.detail.signature,
- },
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- success: function (r) {
- if (r.data.code == '0') {
- that.loginfun();
- that.setData({
- loginFlag: false,
- autoplay: true,
- phoneFlag: false
- })
- videoContext.play();
- app.globalData.userflag = true;//有个人信息
- } else {
- if (r.data.code == '403') {
- that.login();
- return false
- }
- wx.showToast({
- title: r.data.msg,
- icon: "none",
- duration: 2000
- });
- }
- }
- })
- }
- },
- getUserProfile: function () {
- var that = this;
- wx.getUserProfile({
- lang: 'zh_CN',
- desc: '为了更好的体验申请获取以下信息', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
- success: (res) => {
- if (res.errMsg == "getUserProfile:ok") {
- wx.showLoading();
- utils.$post({
- method: "POST",//TESTAPIURL APIURL/users/auth
- url: app.globalData.webUrl + 'api/users/setUserInfo',
- data: {
- encryptedData: res.encryptedData,
- iv: res.iv,
- rawData: res.rawData,
- signature: res.signature,
- },
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- success: function (r) {
- setTimeout(res => {
- wx.hideLoading()
- }, 500)
- if (r.data.code == '0') {
- that.loginfun();
- that.setData({
- loginFlag: false,
- phoneFlag: false,
- autoplay: true,
- })
- videoContext.play();
- app.globalData.userflag = true;//有个人信息
- } else {
- if (r.data.code == '403') {
- that.login();
- return false
- }
- wx.showToast({
- title: r.data.msg,
- icon: "none",
- duration: 2000
- });
- }
- }
- })
- }
- }
- })
- },
- loginfun() {
- var that = this;
- wx.login({
- success: function (data) {
- if (data.errMsg == 'login:ok') {
- utils.$post({
- url: app.globalData.webUrl + 'api/users/code2sessionmini',
- data: {
- code: data.code,
- share: app.globalData.shareuserid,
- client_type: app.globalData.clientype
- },
- success: function (r) {
- if (r.data.code == '0') {
- app.globalData.sharepersonobj = r.data.share;
- app.globalData.token = r.data.token;
- if (!!r.data.user.phone) {
- that.setData({
- employeeflag: (!!r.data.user.binded && r.data.user.binded.state == '在职') ? true : false
- })
- app.globalData.personMsg = r.data.user;
- app.globalData.use_id = r.data.user.id;
- app.globalData.userflag = false;//有个人信息
- if (r.data.user.phone == '') {
- designTimer = setTimeout(() => {
- that.setData({
- designPlan: true
- })
- }, 4000)
- }
- }
- }
- }
- })
- }
- }
- })
- },
- hiddenMaskFunc() {
- this.setData({
- showMask: false
- })
- },
- getPhoneNumberTap: function (res) {
- var that = this;
- let type = res.currentTarget.dataset.type;
- if (res.detail.errMsg == 'getPhoneNumber:ok') {
- this.setData({
- articlelogin: true,
- phoneFlag: false,
- })
- 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') {
- app.globalData.phone = true;
- that.setData({
- phoneFlag: false,
- fPhone: r.data.mobile,
- })
- if (type == 'broker') {
- that.setData({
- showMask: true
- })
- return false;
- }
- if (!res.target.dataset.type) {
- that.setData({
- autoplay: true
- })
- videoContext.play();
- } else {
- that.signup(r.data.mobile);
- }
- } else {
- that.setData({
- errorText: r.data.msg,
- errorflag: true
- })
- }
- }
- })
- } else {
- this.setData({
- showMask: true
- })
- }
- },
- signup: function (mobile) {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'client/index/signUp',
- data: {
- name: '',
- remark: '',
- mobile: mobile,
- type: 'video',
- id: that.data.vid,
- },
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- success: function (r) {
- if (r.data.code == '0') {
- }
- }
- })
- },
- clickzanTap: function () {
- var that = this;
- var videoObj = that.data.videoObj;
- utils.$post({
- url: app.globalData.webUrl + 'client/video/star',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- video_id: that.data.vid,
- },
- success: function (res) {
- wx.showToast({
- title: res.data.msg,
- icon: "none",
- duration: 2000
- });
- if (res.data.code == '0') {
- if (res.data.msg == '点赞成功') {
- videoObj.star_num = videoObj.star_num * 1 + 1;
- videoObj.stared = 1;
- } else {
- videoObj.star_num = videoObj.star_num * 1 - 1;
- videoObj.stared = 0;
- }
- that.setData({
- videoObj: videoObj
- })
- }
- }
- })
- },
- golastap: function () {
- wx.navigateBack({
- delta: 1,
- success:function(r){
- },
- fail:function(r){
- wx.reLaunch({
- url: '/pages/index/index',
- })
- },
- })
- },
- goindextap: function () {
- if(!this.data.employeeflag){
- wx.reLaunch({
- url: '/pages/index/index',
- })
- }else{
- wx.reLaunch({
- url: '/pages/consoledesk/consoledesk',
- })
- }
- },
- sharelogtap: function () {
- var that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/share/addlog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.vid,
- type: 'video'
- },
- success: function (r) {
- }
- })
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function (options) {
- this.setData({
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- })
- timer = setInterval(function () {
- time = time * 1 + 1;
- }, 1000)
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- if (designTimer) {
- clearTimeout(designTimer);
- }
- if (timer) {
- clearInterval(timer);
- }
- this.visitimefun();
- },
- visitimefun() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'client/index/visit_due_time',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.vid,
- pipe_type: 'video',
- time: time,
- },
- success: function (res) {
- }
- })
- },
- videotap() {
- videoContext = this.selectComponent('#myVideo1');
- videoContext.play();
- wx.showLoading()
- },
- bindprogress() {
- wx.hideLoading();
- this.setData({
- playflag: 1
- })
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- if (designTimer) {
- clearTimeout(designTimer);
- }
- this.visitimefun();
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- if (app.globalData.brokeruserId) {
- var that = this;
- that.sharelogtap();
- videoContext.pause();
- var video_url = this.data.imgsrc;
- return {
- title: that.data.title,
- imageUrl: video_url,
- path: '/share/pages/videoshare/videoshare?vid=' + that.data.vid + '&userid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId
- }
- } else {
- var that = this;
- that.sharelogtap();
- videoContext.pause();
- var video_url = this.data.imgsrc;
- return {
- title: that.data.title,
- imageUrl: video_url,
- path: '/share/pages/videoshare/videoshare?vid=' + that.data.vid + '&userid=' + app.globalData.shareuserid + '&ctp=' + app.globalData.clientype
- }
- }
- }
- })
|