123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817 |
- const app = getApp(),util = require("../../../utils/util"),utils = require("../../../utils/http");
- let videoContext=null;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- top: app.globalData.statusBarHeight,
- hgt: app.globalData.titleBarHeight,
- imgUrl: app.globalData.imgUrl,
- communityht: '',
- cid: '',
- casemsgobj: {},
- page: 1,
- personMsg: app.globalData.personMsg,
- wshareshow: false,
- showTask: true,
- datashow: false,
- caselist: [],
- leftcaselist: [],
- rightcaselist: [],
- companyobj: app.globalData.companyobj,
- showAddress: false,
- imgarr: [],
- type: '',
- priceflag: false,
- swiperIndex:0,
- tab: [{
- name: 'VR案例',
- type: 'vr',
- count: 0
- }, {
- name: '视频案例',
- type: 'video',
- count: 0
- }],
- activeType: '',
- bType: "",
- pType: "",
- ltype:'',//不为空是从名片中点击进去
- showCutImage: false,
- loading: false,
- showApproval: false,
- remark: "",
- trackimgarr: [],
- nowimagearr: [],
- shareApprovallist: [],
- playflag: 2,//1是播放中,2是暂停
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- var that = this;
- if(!!options.ty) {
- this.setData({
- bType: options.ty,
- showTask: false
- })
- }
- if (!!options.tp) {
- this.setData({
- pType: options.tp
- })
- }
- wx.showLoading({
- title: '加载中...',
- })
- that.setData({
- cid: options.cid,
- companyobj: app.globalData.companyobj,
- ltype:options.ltype?options.ltype:''
- })
- that.casemsgfun();
- },
- handShowUpload: function () {
- this.setData({
- trackimgarr: [],
- nowimagearr: [],
- remark: "",
- showCutImage: true
- })
- },
- handleShowApproval() {
- this.setData({
- showApproval: true
- })
- wx.showLoading({
- title: '加载中...',
- })
- this.getBrokerApprovallist();
- },
- //获取审核列表
- getBrokerApprovallist() {
- const that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/agentEmp/share_list',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.cid,
- type: "MaterialCase"
- },
- success: function (res) {
- wx.hideLoading();
- if (res.data.code == 0) {
- that.setData({
- shareApprovallist: res.data.data,
- datashow: true
- })
- }
- }
- })
- },
- previewImageEvent(e) {
- let index = parseInt(e.currentTarget.dataset.index);
- let idx = parseInt(e.currentTarget.dataset.idx);
- wx.previewImage({
- urls: this.data.shareApprovallist[index].img,
- current: this.data.shareApprovallist[index].img[idx]
- })
- },
- closeDialog: function () {
- this.setData({
- showCutImage: false,
- showApproval: false
- })
- },
- getTextarea(e) {
- this.setData({
- remark: e.detail.value
- })
- },
- //审核通过
- confirmApproval(e) {
- let id = e.currentTarget.dataset.id;
- const that = this;
- wx.showModal({
- title: '审核提醒',
- content: '您确认通过审核吗?',
- complete: (res) => {
- if (res.confirm) {
- utils.$post({
- url: app.globalData.webUrl + 'api/agentEmp/validate_share',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- share_id: id,
- status: 1
- },
- success: function (res) {
- if (res.data.code == 0) {
- wx.showToast({
- title: '已通过审核',
- icon: "none",
- duration: 1500,
- success: function() {
- setTimeout(() => {
- that.getBrokerApprovallist();
- },1000)
- }
- })
- }
- }
- })
- }
- }
- })
- },
- //审核拒绝
- rejectApproval(e) {
- let id = e.currentTarget.dataset.id;
- const that = this;
- wx.showModal({
- title: '审核提醒',
- content: '您确认驳回审核吗?',
- complete: (res) => {
- if (res.confirm) {
- utils.$post({
- url: app.globalData.webUrl + 'api/agentEmp/validate_share',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- share_id: id,
- status: 2
- },
- success: function (res) {
- if (res.data.code == 0) {
- wx.showToast({
- title: '已驳回审核',
- icon: "none",
- duration: 1500,
- success: function() {
- setTimeout(() => {
- that.getBrokerApprovallist();
- },1000)
- }
- })
- }
- }
- })
- }
- }
- })
- },
- //上传分享截图
- submitData() {
- if (!this.data.trackimgarr.length) {
- wx.showToast({
- title: '请上传分享截图!',
- icon: "none",
- duration: 1500,
- })
- return false;
- }
- this.setData({
- loading: true
- })
- this.ossuploadimg();
- },
- uploadImage() {
- let _this = this;
- wx.chooseMedia({
- count: 9,
- mediaType: ["image"],
- sourceType: ["album", "camera"],
- sizeType: ['original', 'compressed'],
- success: function (res) {
- if (res.errMsg == "chooseMedia:ok") {
- _this.createImagePayment(res.tempFiles);
- }
- }
- })
- },
- imageDel(e) {
- let index = e.currentTarget.dataset.index;
- this.data.trackimgarr.splice(index, 1);
- this.setData({
- trackimgarr: this.data.trackimgarr
- })
- },
- createImagePayment: function (imgUrl) {
- var that = this;
- if (imgUrl.length == 0) return;
- var lent = that.data.trackimgarr.length + imgUrl.length;
- if (lent > 9) {
- lent = 9
- } else {
- lent = lent;
- }
- let trackimgarr = that.data.trackimgarr;
- let len = imgUrl.length;
- if ((trackimgarr.length + len) > 9) {
- for (let j = 0; j < len; j++) {
- if (trackimgarr.length < 9) {
- trackimgarr.push(imgUrl[j]);
- }
- }
- } else {
- trackimgarr = trackimgarr.concat(imgUrl);
- }
- that.setData({
- trackimgarr: trackimgarr
- })
- },
- ossuploadimg: function (e) {
- let that = this;
- let trackimgarr = that.data.trackimgarr;
- var arr = [];
- for (let i = 0; i < trackimgarr.length; i++) {
- //获取文件后缀
- // 随机生成文件名称
- let rstr = trackimgarr[i].tempFilePath.split('.');
- var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
- var imgName = fileRandName + '.' + 'png';
- // var fileName = that.data.;
- var date = new Date();
- var time = date.getFullYear() + '' + (date.getMonth() * 1 + 1) + '' + date.getDate();
- var imgstr = 'broker/' + time + '/' + imgName;
- var nowimagearr = that.data.nowimagearr;
- nowimagearr.push(imgstr);
- that.setData({
- nowimagearr: nowimagearr
- })
- wx.uploadFile({
- url: 'https://wzh-zqxg.oss-cn-hangzhou.aliyuncs.com',
- filePath: trackimgarr[i].tempFilePath,
- name: 'file',
- formData: {
- // name: that.data.imgSrc[0],
- key: 'broker/' + time + '/' + imgName,
- policy: "eyJleHBpcmF0aW9uIjoiMjA0MC0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
- OSSAccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
- success_action_status: "200",
- signature: "GPu5wBYVzdhICS/hdJH6rKG0kos=",
- },
- header: {
- "Content-Type": "multipart/form-data",
- 'accept': 'application/json',
- },
- success: function (rs) {
- if (rs.errMsg == 'uploadFile:ok') {
- arr.push('0');
- if (arr.length == trackimgarr.length) {
- that.requestUploadImageApi();
- }
- }
- },
- fail(res) {
- wx.hideLoading()
- }
- })
- }
- },
- requestUploadImageApi() {
- let that = this;
- let imgs = that.data.nowimagearr.map(v => {
- return { serverId: "", img: v, };
- })
- utils.$post({
- url: app.globalData.webUrl + 'api/agentsWork/upload_share_log',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- article_id: that.data.cid,
- file_media_id: imgs,
- remarks: that.data.remark,
- type: "MaterialCase"
- },
- success: function (res) {
- that.setData({
- loading: false
- })
- if (res.data.code == '0') {
- wx.showToast({
- title: '上传成功',
- icon: "success",
- duration: 1500
- })
- that.setData({
- showCutImage: false
- })
- }
- }
- })
- },
- setypetap(e) {
- this.setData({
- type: e.currentTarget.dataset.type
- })
- },
- priceshowtap() {
- this.setData({
- priceflag: true
- })
- },
- closepricetap() {
- this.setData({
- priceflag: false
- })
- },
- showAddressName(e) {
- let type = e.currentTarget.dataset.type;
- if (type == 'hide') {
- this.setData({
- showAddress: false
- })
- } else {
- this.setData({
- showAddress: true
- })
- }
- },
- designertap(){
- if(!!this.data.casemsgobj.designer_id){
- wx.navigateTo({
- url: '/customer/pages/designermsg/designermsg?did='+this.data.casemsgobj.designer_id+"&sid="+this.data.casemsgobj.designer_id+'&type='+(this.data.ltype?1:2)
- })
- }
- },
- prelook(e) {
- let arr = [];
- for (let i in this.data.imgarr) {
- arr.push(app.globalData.imgUrl + this.data.imgarr[i].img);
- }
- wx.previewImage({
- current: e.currentTarget.dataset.img, // 当前显示图片的 http 链接
- urls: arr // 需要预览的图片 http 链接列表
- })
- },
- presharelooktap() {
- if (!app.globalData.personMsg.binded.qrcode) {
- wx.showToast({
- title: "您的微信二维码为空,请上传二维码!",
- icon: 'none',
- duration: 2000
- })
- return false;
- }
- wx.previewImage({
- current: app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode, // 当前显示图片的http链接
- urls: [app.globalData.imgUrl + app.globalData.personMsg.binded.qrcode]// 需要预览的图片http链接列表
- })
- },
- opintap() {
- wx.showToast({
- title: '员工不能预约!',
- icon: 'none',
- duration: 2000
- })
- },
- swiperChange (e) {
- let type = e.detail.currentItemId.split('-')[0];
- this.setData({
- activeType: type
- })
- },
- sharecardtap: function () {
- wx.navigateTo({
- url: '/index/pages/namecard/namecard'
- })
- },
- handleSwitch(e) {
- let type = e.currentTarget.dataset.type;
- let swiperIndex=0;
- if (type == 'vr') {
- swiperIndex = 0;
- } else if (type == 'video') {
- swiperIndex = !!this.data.casemsgobj.vr_case?1:0;
- }
- this.setData({
- swiperIndex: swiperIndex,
- activeType: type,
- })
- },
- casemsgfun: function () {
- var that = this;
- utils.$get({
- url: app.globalData.webUrl + 'api/casedetail',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: this.data.cid,
- uid: app.globalData.personMsg.id,
- },
- success: function (res) {
- let tab=that.data.tab;
- if (res.data.code == '0') {
- wx.setNavigationBarTitle({
- title: res.data.data.title
- })
- if(!!res.data.data.video_case){
- tab[1].count=1;
- that.setData({
- tab: tab,
- activeType:'video'
- })
- }
- if(!!res.data.data.vr_case){
- tab[0].count=1;
- that.setData({
- tab: tab,
- activeType:'vr'
- })
- }
-
- if (!res.data.data.desc) {
- if (!res.data.data.real_case) {
- that.setData({
- type: ''
- })
- } else {
- that.setData({
- type: 2
- })
- }
- } else {
- if (res.data.data.desc != '<p><br></p>') {
- that.setData({
- type: 1
- })
- } else {
- that.setData({
- type: 2
- })
- }
- }
- that.setData({
- casemsgobj: res.data.data,
- caselist: res.data.data.designer_related_cases,
- })
- if (res.data.data.from == 1) {
- that.setData({
- imgarr: JSON.parse(res.data.data.img_content)
- })
- }
- if (that.data.caselist.length > 0) {
- that.imgload();
- }
- }
- wx.hideLoading()
- }
- })
- },
- videotap() {
- videoContext = this.selectComponent('#myVideo');
- videoContext.play();
- wx.showLoading()
- },
- bindprogress() {
- wx.hideLoading();
- this.setData({
- playflag: 1
- })
- },
- openVRLink(e) {
- let type = e.currentTarget.dataset.type;
- if (type == 1) {
- let vrlink = this.data.casemsgobj.vr_case;
- wx.navigateTo({
- url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&aid=' + this.data.casemsgobj.id,
- })
- } else {
- let vrlink = e.currentTarget.dataset.vrlink;
- let aid = e.currentTarget.dataset.id;
- wx.navigateTo({
- url: '/pages/other/other?type=565&vrlink=' + encodeURIComponent(vrlink) + '&cty=materialCase' + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype + '&aid=' + aid,
- })
- }
- },
- imgload: function () {
- var that = this;
- var leftlist = that.data.leftcaselist;
- var rightlist = that.data.rightcaselist;
- var indexlist = that.data.caselist;
- if (indexlist.length == 0) {
- return false;
- }
- if (leftlist.length == 0) {
- leftlist.push(indexlist[0]);
- indexlist.shift();
- that.setData({
- caselist: indexlist,
- leftcaselist: leftlist,
- rightcaselist: rightlist
- })
- } else {
- var leftheight, rightheight;
- const query = wx.createSelectorQuery()
- query.select('.leftcasebox').boundingClientRect();
- query.exec(function (res) {
- leftheight = res[0].height;
- const queryright = wx.createSelectorQuery()
- queryright.select('.rightcasebox').boundingClientRect();
- queryright.exec(function (rs) {
- leftlist = that.data.leftcaselist;
- rightlist = that.data.rightcaselist;
- indexlist = that.data.caselist;
- rightheight = rs[0].height;
- if (leftheight <= rightheight) {
- leftlist.push(indexlist[0]);
- indexlist.shift();
- } else {
- rightlist.push(indexlist[0]);
- indexlist.shift();
- }
- that.setData({
- caselist: indexlist,
- leftcaselist: leftlist,
- rightcaselist: rightlist
- })
- })
- })
- }
- },
- callphonetap: function () {
- wx.makePhoneCall({
- phoneNumber: app.globalData.personMsg.phone //仅为示例,并非真实的电话号码
- })
- },
- sendfriendtap() {
- this.addsharetap();
- },
- addsharetap: function () {
- let that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/share/addlog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- id: that.data.cid,
- type: 'materialCase',
- },
- success: function (r) {}
- })
- },
- setpostertap: function () {
- if (this.data.bType == 'b') {
- wx.navigateTo({
- url: '/index/pages/setposter/setposter?type=materialCase&aid=' + this.data.cid + "&ty=b&listshare=",
- })
- } else {
- wx.navigateTo({
- url: '/index/pages/setposter/setposter?type=materialCase&aid=' + this.data.cid + "&listshare=",
- })
- }
- },
- casemsgtap: function (e) {
- wx.redirectTo({
- url: '/index/pages/casemsg/casemsg?cid=' + e.currentTarget.dataset.cid
- })
- },
- precasetap: function () {
- if (!this.data.casemsgobj.preid) {
- wx.showToast({
- title: '已经第一篇了!',
- icon: 'none',
- duration: 2000
- })
- return false
- }
- wx.redirectTo({
- url: '/index/pages/casemsg/casemsg?cid=' + this.data.casemsgobj.preid
- })
- },
- nextcasetap: function () {
- if (!this.data.casemsgobj.nextid) {
- wx.showToast({
- title: '已经到头了!',
- icon: 'none',
- duration: 2000
- })
- return false
- }
- wx.redirectTo({
- url: '/index/pages/casemsg/casemsg?cid=' + this.data.casemsgobj.nextid
- })
- },
- collectap: function () {
- var that = this;
- var casemsgobj = that.data.casemsgobj;
- utils.$post({
- url: app.globalData.webUrl + 'api/collect',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- user_id: app.globalData.personMsg.id,
- content_type: "materialCase",
- content_id: that.data.cid
- },
- success: function (res) {
- if (res.data.code == '0') {
- wx.showToast({
- title: res.data.msg,
- icon: 'none',
- duration: 2000
- })
- casemsgobj.collected = !casemsgobj.collected;
- that.setData({
- casemsgobj: casemsgobj
- })
- }
- }
- })
- },
- casesharetap: function () {
- this.setData({
- wshareshow: true
- })
- },
- shareurltap: function () {
- wx.showLoading({
- title: '加载中...',
- })
- this.addsharetap();
- if (this.data.bType == 'b') {
- util.schemefun('/share/pages/materialcase/materialcase', 'cid=' + this.data.cid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId, this.data.cid, 'materialCase', '');
- } else {
- util.schemefun('/share/pages/materialcase/materialcase', 'cid=' + this.data.cid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype, this.data.cid, 'materialCase', '');
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- lasttap: function () {
- wx.navigateBack()
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- },
- otherlistfun: function () {
- var that = this;
- var page = that.data.page;
- page = page * 1 + 1;
- utils.$post({
- url: app.globalData.webUrl + 'api/designercases',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- page: page,
- limit: 4,
- designer_id: that.data.casemsgobj.designer_id,
- material_case_id:this.data.cid
- },
- success: function (res) {
- that.setData({
- page: page
- })
- if (res.data.code == '0') {
- // caselist:indexlist,
- // leftcaselist:leftlist,
- // rightcaselist:rightlist
- var caselist = that.data.caselist;
- var arrflag = false;
- if (res.data.data.length == 0) {
- wx.showToast({
- title: '暂无更多数据',
- icon: 'none',
- duration: 2000
- })
- } else {
- if (caselist.length != 0) {
- arrflag = true;
- }
- console.log(caselist)
- caselist = caselist.concat(res.data.data);
- that.setData({
- caselist: caselist
- });
- if (!arrflag) {
- that.imgload();
- }
- }
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- var img = this.data.casemsgobj.cover_share_img?this.data.casemsgobj.cover_share_img:this.data.casemsgobj.cover_img;
- if (this.data.bType == 'b') {
- this.addsharetap();
-
- img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
- return {
- title: this.data.casemsgobj.title,
- imageUrl: img,
- path: '/share/pages/materialcase/materialcase?cid=' + this.data.cid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId
- }
- } else {
- this.addsharetap();
- img = img.replace('http://o.nczyzs.com/', 'https://o.nczyzs.com/');
- return {
- title: this.data.casemsgobj.title,
- imageUrl: img,
- path: '/share/pages/materialcase/materialcase?cid=' + this.data.cid + '&uid=' + app.globalData.personMsg.id + '&ctp=' + app.globalData.clientype
- }
- }
- }
- })
|