123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470 |
- // customer/pages/brokershareinfo/brokershareinfo.js
- var app = getApp();
- var utils = require("../../../utils/http");
- var util = require("../../../utils/util");
- var page = 1;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- cid: "",
- remark: "",
- showdesc: false,
- wshareshow: false,
- loading: false,
- showCutImage: false,
- shareArticleInfo: {},
- trackimgarr: [],
- nowimagearr: [],
- fromType: "",
- platform: "",
- type: "",
- xhwwidth: '',
- bottom: 26,
- isBroker: false
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- if (!!options.from) {
- this.setData({
- fromType: options.from
- })
- }
- if (app.globalData.brokeruserId) {
- this.setData({
- isBroker: true
- })
- } else {
- this.setData({
- isBroker: false
- })
- }
- if (options.id) {
- this.setData({
- cid: options.id
- })
- wx.showLoading({
- title: '加载中...',
- })
- this.getShareArticleInfo();
- }
- },
- 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
- })
- }
- }
- })
- },
- handShowUpload: function() {
- this.setData({
- trackimgarr: [],
- nowimagearr: [],
- remark: "",
- showCutImage: true
- })
- },
- shareArticleBtn() {
- if (this.data.isBroker) {
- this.setData({
- wshareshow: true
- })
- }
- },
- viewdescFunc() {
- console.log(this.data.showdesc);
- this.data.showdesc = !this.data.showdesc;
- this.setData({
- showdesc: this.data.showdesc
- })
- },
- setpostertap: function () {
- wx.navigateTo({
- url: '/index/pages/setposter/setposter?type=shareArticle&aid=' + this.data.cid + '&f=' + this.data.fromType + "&listshare=",
- })
- },
- sendfriendtap() {
- this.addsharetap();
- },
- addsharetap: function () {
- let that = this;
- utils.$post({
- url: app.globalData.webUrl + 'api/agentsWork/agent_sharelog',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- type: "AgentArticle",
- article_id: that.data.cid,
- },
- success: function (r) {}
- })
- },
- shareurltap: function () {
- wx.showLoading({
- title: '加载中...',
- })
- this.addsharetap();
- util.schemefun('/share/pages/brokershareinfo/brokershareinfo', 'cid=' + this.data.cid + '&uid=' + app.globalData.agentEmployeEid + '&ctp=' + app.globalData.clientype + '&agid=' + app.globalData.brokeruserId + '&f=' + this.data.fromType, this.data.cid, 'agentArticle', '','',app.globalData.agentEmployeEid);
- },
- closeDialog: function() {
- this.setData({
- showCutImage: false
- })
- },
- getTextarea(e) {
- this.setData({
- remark: e.detail.value
- })
- },
- submitData() {
- if (!this.data.trackimgarr.length) {
- wx.showToast({
- title: '请上传分享截图!',
- icon: "none",
- duration: 1500,
- })
- return false;
- }
- this.setData({
- loading: true
- })
- this.ossuploadimg();
- },
- requestUploadImageApi() {
- let that = this;
- let imgs = that.data.nowimagearr.filter((item,index,itemArr) => {
- return itemArr.indexOf(item) == index;
- }).map(v => {
- return {serverId: "", img: v,};
- });
- utils.$post({
- url: app.globalData.webUrl + 'api/agentsWork/upload_share_log',
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: {
- type: "AgentArticle",
- article_id: that.data.cid,
- file_media_id: imgs,
- remarks: that.data.remark
- },
- success: function (res) {
- that.setData({
- loading: false
- })
- if (res.data.code == '0') {
- wx.showToast({
- title: '上传成功',
- icon: "success",
- duration: 1500
- })
- that.setData({
- showCutImage: false
- })
- }
- }
- })
- },
- 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++) {
- // 随机生成文件名称
- var fileRandName = Date.now() + "" + parseInt(Math.random() * 10000) + i;
- var imgName = fileRandName + '.' + 'png';
- 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://o.nczyzs.com',
- filePath: trackimgarr[i].tempFilePath,
- name: 'file',
- formData: {
- key: 'broker/' + time + '/' + imgName,
- policy: "eyJleHBpcmF0aW9uIjoiMjAyNS0wMS0wMVQxMjowMDowMC4wMDBaIiwiY29uZGl0aW9ucyI6W1siY29udGVudC1sZW5ndGgtcmFuZ2UiLDAsMTA0ODU3NjAwMF1dfQ==",
- OSSaccessKeyId: "LTAI5tHjWupJSCAycy2yVbQZ",
- success_action_status: "200",
- signature: "bWaeUQYnGAcWynj3FxAfGZLy5n0=",
- },
- 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()
- }
- })
- }
- },
- copyShareText() {
- wx.setClipboardData({
- data: this.data.shareArticleInfo.talkskill,
- success: function (res) {
- console.log(res);
- }
- })
- },
- previewImage(e) {
- let index = e.currentTarget.dataset.index;
- wx.previewImage({
- urls: this.data.shareArticleInfo.file,
- current: this.data.shareArticleInfo.file[index]
- })
- },
- setype(){
- let webUrl = "";
- if (this.data.shareArticleInfo.type == 4) {
- webUrl = this.data.shareArticleInfo.vr_group_url;
- } else {
- webUrl = this.data.shareArticleInfo.files;
- }
- let redurltest='https://hnweizhihui.xiaohongwu.nczyzs.com';//41
- let kjlurltest="https://pano337.p.kujiale.com";
- let jeajurltest="https://vr-17.justeasy.nczyzs.com";
- let jeajurltest1="https://vr.justeasy.nczyzs.com";
- let wlurltest1="https://panorama.m2m88.com";//26
- let wlurltest2="https://panorama.wlwno1.com";//27
- let nowurl="https://wzh.nczyzs.com";//22
- let wl360="https://vr.3d66.nczyzs.com"//26
- if(webUrl.substr(0, 41)==redurltest){
- wx.getSystemInfo({
- success (res) {
- let width=(res.windowWidth-16)*0.48;
- that.setData({
- xhwwidth:width,
- bottom:res.platform=='android'?'26':36
- })
- }
- })
- this.setData({
- type:1,
- platform:app.globalData.platform,
- })
- }else if(webUrl.substr(0, 29)==kjlurltest){
- this.setData({
- type:2,
- platform:app.globalData.platform,
- })
- }else if(webUrl.substr(0, 33)==jeajurltest||webUrl.substr(0, 30)==jeajurltest1){
- this.setData({
- type:3,
- platform:app.globalData.platform,
- })
-
- }else if(webUrl.substr(0, 26)==wlurltest1||webUrl.substr(0, 27)==wlurltest2||webUrl.substr(0, 26)==wl360){
- this.setData({
- type:4,
- platform:app.globalData.platform,
- })
- } else if (webUrl.substr(0, 22)==nowurl){
- this.setData({
- type:5,
- platform:app.globalData.platform,
- })
- }
- },
- getShareArticleInfo() {
- let that = this;
- let params = {
- id: that.data.cid,
- from: that.data.fromType
- };
- let api = app.globalData.brokeruserId ? 'api/agentsWork/share_article_details' : 'api/agents/share_article_details';
- if (!that.data.fromType && !app.globalData.brokeruserId) {
- params.employee_id = app.globalData.brokerEmployeeId;
- }
- utils.$post({
- url: app.globalData.webUrl + api,
- header: {
- 'Authorization': 'bearer ' + app.globalData.token
- },
- data: params,
- success: function (res) {
- wx.hideLoading();
- if (res.data.code == '0') {
- that.setData({
- shareArticleInfo: res.data.data,
- })
- that.setype();
- }
- }
- })
- },
- dothis: function() {},
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- this.addsharetap();
- let imgUrl = '';
- if (this.data.shareArticleInfo.type == 1) {
- imgUrl = `${this.data.shareArticleInfo.file[0]}?x-oss-process=video/snapshot,t_100,f_jpg,w_500,m_fast`;
- } else if (this.data.shareArticleInfo.type == 3||this.data.shareArticleInfo.type == 4) {
- imgUrl = this.data.shareArticleInfo.file_img;
- } else {
- imgUrl = this.data.shareArticleInfo.file[0];
- }
-
- return {
- title: this.data.shareArticleInfo.title,
- img: imgUrl,
- path: "/share/pages/brokershareinfo/brokershareinfo?ctp=" + app.globalData.clientype + '&cid=' + this.data.shareArticleInfo.id + "&uid=" + app.globalData.agentEmployeEid + '&agid=' + app.globalData.brokeruserId + '&f=' + this.data.fromType
- }
- }
- })
|