| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249 | import {    ApiModel} from "../../../utils/api";const _Http = new ApiModel();const handleList = require("../../../utils/processingData");let shareTime = null;import queryLogin from '../../../utils/isLogin';Page({    /**     * 页面的初始数据     */    data: {        detalis: {}, //详情数据        shareObj: null,    },    /**     * 生命周期函数--监听页面加载     */    onLoad(options) {        const item = JSON.parse(options.item);        console.log("供需信息", item)        this.setData({            detalis: item        });        /* 获取推荐列表 */        _Http.basic({            "classname": "publicmethod.homepage.homepage",            "method": "query_supplyanddemandList",            "content": {                "getdatafromdbanyway": true,                "pageNumber": 1,                "pageSize": 10,                "siteid": "BWJ",                "where": {                    "ftype": "",                    "fissupply": "0",                    "fstatus": "待对接"                }            }        }).then(res => {            if (res.msg != '成功') return wx.showToast({                title: res.data,                icon: "none"            })            const data = handleList.getYTD(res.data);            this.setData({                productList: data            });        });        let ism = item.tenterprise_userid == wx.getStorageSync('userData').userid        /* 浏览计数 */        if (!ism) _Http.basic({            "accesstoken": wx.getStorageSync('userData').token,            "classname": "customer.supplyanddemand.supplyanddemand",            "method": "query_supplyanddemandMain",            "content": {                "tsupplyanddemandid": item.tsupplyanddemandid            }        }, false).then(res => {            if (res.msg != '成功') _Http.basic({                "classname": "publicmethod.homepage.homepage",                "method": "query_supplyanddemandMain",                "content": {                    "tsupplyanddemandid": item.tsupplyanddemandid,                    "tagentsid": item.tagentsid                }            })        });        this.setData({            ism        })    },    /* 电话联系 */    callUp(e) {        if (!queryLogin()) return;        wx.makePhoneCall({            phoneNumber: e.currentTarget.dataset.phone        })    },    toLinkUp(e) {        if (!queryLogin()) return;        const {            tsupplyanddemandid,            tenterprise_userid        } = this.data.detalis;        if (tenterprise_userid == wx.getStorageSync('userData').userid) return wx.showToast({            title: '无法与自己对话',            icon: "none"        })        _Http.basic({            "accesstoken": wx.getStorageSync('userData').token,            "classname": "customer.supplyanddemand.supplyanddemand",            "method": "OpenImDialog",            "content": {                "tsupplyanddemandid": tsupplyanddemandid            }        }).then(res => {            console.log("创建聊天", res)            if (res.msg != '成功') return wx.showToast({                title: res.data,                icon: "none"            })            wx.navigateTo({                url: '/pages/chatRoom/dialogbox?id=' + res.data[0].timdialogid,            })        })    },    /* 删除供需 */    deleteItem() {        console.log()        wx.showModal({            title: '提示',            content: '是否确认删除该供需',            success: (res) => {                if (res.confirm) _Http.basic({                    "accesstoken": wx.getStorageSync('userData').token,                    "classname": "customer.supplyanddemand.supplyanddemand",                    "method": "deletesupplyanddemand",                    "content": {                        "tsupplyanddemandid": this.data.detalis.tsupplyanddemandid                    }                }).then(res => {                    wx.showToast({                        title: res.data,                        icon: "none"                    })                    if (res.msg == '成功') setTimeout(() => {                        let pages = getCurrentPages(),                            prevPage = pages[pages.length - 2];                        prevPage.backGetList();                        wx.navigateBack({                            delta: 1                        })                    }, 1000)                })            }        })    },    noToLinkUp() {        wx.showToast({            title: '该供需当前不可联系',            icon: "none"        })    },    /**     * 生命周期函数--监听页面初次渲染完成     */    onReady() {    },    /**     * 生命周期函数--监听页面显示     */    onShow() {    },    /**     * 生命周期函数--监听页面隐藏     */    onHide() {    },    /**     * 生命周期函数--监听页面卸载     */    onUnload() {    },    /**     * 页面相关事件处理函数--监听用户下拉动作     */    onPullDownRefresh() {    },    /**     * 页面上拉触底事件的处理函数     */    onReachBottom() {    },    /* 回调 */    shareCallBack({        detail    }) {        this.setData({            shareObj: detail        })    },    /**     * 用户点击右上角分享     */    onShareAppMessage(e) {        const that = this;        if (e.from == 'button') {            const promise = new Promise(resolve => {                shareTime = setInterval(() => {                    if (that.data.shareObj != null) {                        let str = JSON.stringify(that.data.shareObj),                            obj = JSON.parse(str);                        that.setData({                            shareObj: null                        })                        clearInterval(shareTime);                        resolve({                            title: obj.ftitle,                            path: '/pages/tabbar-pages/home/sdDetalis?item=' + str,                            imageUrl: obj.attinfos.length >= 1 ? obj.attinfos[0].fobsurl : '',                            success: function (res) {                                if (res.errMsg == 'shareAppMessage:ok') {                                    wx.showToast({                                        title: '分享成功',                                    })                                }                            },                        })                    }                }, 300)            })            return {                title: '自定义转发标题',                path: '/page/user?id=123',                promise            }            /*  */        } else {            let obj = this.data.detalis,                str = JSON.stringify(obj);            return {                title: obj.ftitle,                path: '/pages/tabbar-pages/home/sdDetalis?item=' + str,                imageUrl: obj.attinfos.length >= 1 ? obj.attinfos[0].fobsurl : '',                success: function (res) {                    if (res.errMsg == 'shareAppMessage:ok') {                        wx.showToast({                            title: '分享成功',                        })                    }                },            }        }    }})
 |