| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887 |
- import Taro, { Component } from '@tarojs/taro'
- import { View, Swiper, SwiperItem, Navigator } from '@tarojs/components'
- import { AtCurtain } from 'taro-ui'
- import { arrToObj } from '@utils'
- import Rooms from './components/dtl/rooms'
- import Around from './components/dtl/around'
- import './dtl.scss'
- class Index extends Component {
- onShareAppMessage() {
- const userInfo = Taro.getStorageSync('APP_userInfo') || {}
- const { curId, curObj } = this.state
- if (userInfo.is_sale == 1) {
- return {
- title: `${userInfo.nickname}给您推荐:${curObj.title}`,
- path: `/pagesRoom/dtl?id=${curId}&referrer=${userInfo.user_id}`,
- }
- } else {
- return {
- title: `${curObj.title}`,
- path: `/pagesRoom/dtl?id=${curId}`,
- }
- }
- }
- onShareTimeline () {
- const userInfo = Taro.getStorageSync('APP_userInfo') || {}
- const { curId, curObj } = this.state
- if (userInfo.is_sale == 1) {
- return {
- title: `${userInfo.nickname}给您推荐:${curObj.title}`,
- path: `/pagesRoom/dtl?id=${curId}&referrer=${userInfo.user_id}`,
- }
- } else {
- return {
- title: `${curObj.title}`,
- path: `/pagesRoom/dtl?id=${curId}`,
- }
- }
- }
- constructor (props) {
- super(props)
- const {id: curId} = this.$router.params
- this.state = {
- referrer: '',
- saleUserObj: {},
- curId,
- curObj: {},
- curImgIndex: 0,
- // curShareCardImg: require('./img/dtl/bg_room_dtl.png')
- curShareCardImg: ''
- }
- }
- config = {
- // navigationBarTitleText: '房源详情',
- navigationStyle: 'custom',
- navigationBarTextStyle: 'white',
- }
- componentWillMount () {
- Taro.$AHU(this)
- this.getDtl()
- Taro.removeStorageSync('APP_MY_REFERRER')
- const {referrer} = this.$router.params
- if (referrer) {
- this.setState({
- referrer
- })
- Taro.removeStorageSync('APP_cur_sale')
- Taro.setStorageSync("APP_MY_REFERRER", referrer)
- }
- }
-
- getDtl = () => {
- const { curId } = this.state
- Taro.api.room.apieshousedetail({id: curId}).then(res => {
- // Taro.setNavigationBarTitle({
- // title: res.title || '房源详情'
- // })
- this.setState({
- curObj: res || {}
- }, () =>{
- if (this.subRooms) this.subRooms.getData(res.es_house_list || [])
- if (this.subAround) this.subAround.getData(res.estate_id)
- const {referrer} = this.$router.params
- if (referrer) {
- Taro.api.room.apisalelist({
- show_status: 1,
- referrer
- }).then(res => {
- const list = res.list || []
- if (list.length > 0) {
- this.setState({
- saleUserObj: list[0]
- })
- } else {
-
- if (res.sale_user.sale_phone === '18907904022') {
- Taro.api.room.apisalelist({
- show_status: 1,
- page_size: 99
- }).then(res => {
- const list = res.list || []
- const arrIndex = Math.floor(Math.random() * list.length)
- this.setState({
- saleUserObj: list[arrIndex],
- })
- Taro.setStorageSync('APP_cur_sale', {curObj: list[arrIndex]})
- })
- } else {
- this.setState({
- saleUserObj: res.sale_user
- })
- }
- }
- })
- } else {
-
- if (res.sale_user.sale_phone === '18907904022') {
- Taro.api.room.apisalelist({
- show_status: 1,
- page_size: 99
- }).then(res => {
- const list = res.list || []
- const arrIndex = Math.floor(Math.random() * list.length)
- this.setState({
- saleUserObj: list[arrIndex],
- })
- Taro.setStorageSync('APP_cur_sale', {curObj: list[arrIndex]})
- })
- } else {
- this.setState({
- saleUserObj: res.sale_user
- })
- }
- }
- })
- })
- }
- componentDidShow () { }
- componentDidHide () { }
- renderHeader () {
- const { curImgIndex, curObj } = this.state
- let moreImg = []
- let images = curObj.images ? curObj.images.split(',') : []
- images.forEach(url => {
- moreImg.push({img_url: `${url}`})
- })
- const imgArr = [{img_url: `${curObj.pri_image}`}, ...moreImg]
- return (
- <View className="dtl-header">
- <Swiper
- circular
- current={curImgIndex}
- onChange={this.headerImgChange.bind(this)}
- className='dh-swiper'>
- {
- curObj.video
- ?
- <SwiperItem>
- <View className='dh-item'>
- <Video
- className="img"
- src={curObj.video}
- controls={true}
- autoplay={false}
- initialTime='0'
- id='video'
- loop={false}
- muted={false}
- />
- </View>
- </SwiperItem>
- : ''
- }
- {
- imgArr.map((item, index) => {
- return (
- <SwiperItem key={index}>
- <View className='dh-item'>
- <Image src={item.img_url ? item.img_url + '_white' : ''} className="img" onClick={this.previewImage2Handle.bind(this, item.img_url, imgArr)} />
- </View>
- </SwiperItem>
- )
- })
- }
- </Swiper>
- <View className="dh-count">
- <View className="bg"></View>
- <View className="num">{curImgIndex + 1}-{imgArr.length + (curObj.video ? 1 : 0)}</View>
- </View>
- </View>
- )
- }
- headerImgChange (e) {
- this.setState({
- curImgIndex: e.detail.current || 0
- })
- }
- previewImage2Handle (cur, arr) {
- const current = `${cur}_plus`
- const urls = arr.map(item => {
- return `${item.img_url}_plus`
- })
- Taro.previewImage({
- current,
- urls
- })
- }
- renderQrcode () {
- const qrcodeImg = 'http://icon.honglounews.com/miniqrcode.jpg'
- return (
- <Image src={qrcodeImg} className="scoped-qrcode" onClick={this.previewQrcodeImageHandle.bind(this, qrcodeImg, [qrcodeImg])} />
- )
- }
- previewQrcodeImageHandle (current, urls) {
- Taro.previewImage({
- current,
- urls
- })
- }
- editHandle () {
- const { curId } = this.state
- const appUserInfo = Taro.getStorageSync('APP_userInfo')
- if (appUserInfo.is_sale == 1) {
- Taro.navigateTo({
- url: `/pagesMore/center/uploadRoom2?id=${curId}`
- })
- }
- }
-
- renderMain () {
- const signRight = require('@img/icon_sign_right.png')
- const dictData = Taro.getStorageSync('dictData')
- const atObj = arrToObj(dictData.area_type)
- const hryObj = arrToObj(dictData.house_room_year)
- const roomDecObj = arrToObj(dictData.room_dec)
- const roomPositionObj = arrToObj(dictData.room_position)
- const { curObj } = this.state
-
- const tagArr = curObj.custom_tag ? curObj.custom_tag.split(',') : []
- const moreImg = require('./img/dtl/bg_estate.png')
- const FH = Number(curObj.floor) || 1
- const H = Number(curObj.storeys) || 1
- let FHstr = '未知'
- if (FH > H * 0.6666) {
- FHstr = '中高层'
- } else if (FH > H * 0.33333) {
- FHstr = '中楼层'
- } else {
- FHstr = '中低层'
- }
- if (FH === 1) FHstr = '一楼'
- if (FH === H) FHstr = '顶楼'
- let houseTypeStr = '未知'
- if (curObj.house_type) {
- let arr = curObj.house_type.split('-')
- houseTypeStr = `${arr[0]}室${arr[1]}厅${arr[2]}卫`
- }
- const stairsRateArr = curObj.stairs_rate ? curObj.stairs_rate.split('-') : []
- const appUserInfo = Taro.getStorageSync('APP_userInfo')
- return (
- <View className="scoped-main">
- {/* {this.renderQrcode()} */}
- <View className="sm-tags">
- {
- appUserInfo.is_sale == 1
- ? <Navigator url={`/pagesRoom/follow/room?id=${curObj.id}`} className="s s2">跟进记录</Navigator>
- : ''
- }
- {
- tagArr.map((tag, tI) => {
- return (
- <View className="s" key={tI}>{tag}</View>
- )
- })
- }
- </View>
- <View className="sm-title" onClick={this.editHandle.bind(this)}>{curObj.title}</View>
- <View className="sm-focus">
- <View className="op">
- <View className="v">{curObj.price}万</View>
- <View className="k">售价</View>
- </View>
- <View className="op" onClick={this.houseImgHandle.bind(this)}>
- <View className="v">{houseTypeStr}</View>
- <View className="k">房型</View>
- </View>
- <View className="op">
- <View className="v">{curObj.area}㎡</View>
- <View className="k">建筑面积</View>
- </View>
- </View>
- <View className="sm-op">
- <View className="op full">
- <View className="k">单价</View>
- <View className="v">{parseInt(curObj.price * 10000 / curObj.area)}元/㎡</View>
- </View>
- <View className="op">
- <View className="k">楼层</View>
- <View className="v">{FHstr}/{curObj.storeys}层</View>
- </View>
- <View className="op" onClick={this.countHandle.bind(this, 'chat')}>
- <View className="m">咨询楼层</View>
- <Image src={signRight} className="r" />
- </View>
- <View className="op">
- <View className="k">满几</View>
- <View className="v">{hryObj[curObj.full_year]}</View>
- </View>
- <View className="op">
- <View className="k">装修</View>
- <View className="v">{roomDecObj[curObj.is_dec]}</View>
- </View>
- <View className="op">
- <View className="k">交房</View>
- <View className="v">{curObj.delivery_at}</View>
- </View>
- <View className="op">
- <View className="k">电梯</View>
- <View className="v">{curObj.is_elevator == 1 ? '有电梯' : '无电梯'}</View>
- </View>
- <View className="op">
- <View className="k">梯户</View>
- <View className="v">{stairsRateArr.length > 0 ? `${stairsRateArr[0]}梯${stairsRateArr[1]}户` : '未知'}</View>
- </View>
- <View className="op">
- <View className="k">方位</View>
- <View className="v">{curObj.position ? roomPositionObj[curObj.position] : '未知'}</View>
- </View>
- {/* <View className="op">
- <View className="k">预约</View>
- <View className="v">房东底价?朝向梯户比?<View onClick={this.countHandle.bind(this, 'chat')} className="s">【免费咨询】</View></View>
- </View> */}
- <View className="op">
- <View className="k">区域</View>
- <View className="v">{atObj[curObj.area_type]}</View>
- </View>
- <Navigator url={`/pagesHouse/indexDtlAround?id=${curObj.estate_id}&name=${curObj.estate_name}`} className="op">
- <View className="m">查看周边配套</View>
- <Image src={signRight} className="r" />
- </Navigator>
- <View className="op">
- <View className="k">其它</View>
- <View className="v">房东底价?套内面积</View>
- </View>
- <View className="op" onClick={this.countHandle.bind(this, 'chat')}>
- <View className="m">免费咨询</View>
- <Image src={signRight} className="r" />
- </View>
- <View className="op full" onClick={this.dtlLink.bind(this)}>
- <View className="k">楼盘</View>
- <View className="v t2">{curObj.estate_name}
- {/* <View onClick={this.dtlLink.bind(this)} className="s">查看该楼盘</View> */}
- </View>
- </View>
- <Navigator url={`/pagesHouse/price?id=${curObj.estate_id}&name=${curObj.estate_name}`} className="op full">
- <View className="k">成交</View>
- <View className="v t2">查看近期成交价</View>
- </Navigator>
- {
- curObj.introduce
- &&
- <View className="op full">
- <View className="k">简介</View>
- <View className="v">{curObj.introduce}</View>
- </View>
- }
- </View>
- <Image className="sm-more" src={moreImg} onClick={this.dtlLink.bind(this)} />
- </View>
- )
- }
- dtlLink () {
- const { curObj } = this.state
- Taro.navigateTo({
- url: `/pagesHouse/indexDtl?id=${curObj.estate_id}`
- })
- }
- renderImg () {
- const { curObj } = this.state
- return (
- <View className="dtl-options">
- <View className="do-title">
- <View className="t">户型图</View>
- </View>
- <View className="do-content" onClick={this.houseImgHandle.bind(this)}>
- <View className="scoped-img">
- <Image src={curObj.house_img} className="img"/>
- <View className="tips">
- <View className="bg"></View>
- <View className="t">查看大图</View>
- </View>
- </View>
- </View>
- </View>
- )
- }
- houseImgHandle () {
- const { curObj } = this.state
- const current = `${curObj.house_img}`
- const urls = [`${curObj.house_img}`]
- Taro.previewImage({
- current,
- urls
- })
- }
- renderAround () {
- const { curObj } = this.state
- return (
- <View className="dtl-options">
- <View className="do-title">
- <View className="t">周边配套</View>
- </View>
- <View className="do-content">
- <Around onRef={this.refAround} />
- </View>
- </View>
- )
- }
- refAround = (ref) => {
- this.subAround = ref
- }
-
- renderOther () {
- const { curObj } = this.state
- return (
- <View className="dtl-options">
- <View className="do-title">
- <View className="t">猜你喜欢</View>
- {/* <Navigator url={'/pagesRoom/list?estate_id=' + curObj.estate_id + '&estate_name=' + curObj.estate_name} className="r">查看更多{' >'}</Navigator> */}
- </View>
- <Rooms onRef={this.refRooms} />
- </View>
- )
- }
- refRooms = (ref) => {
- this.subRooms = ref
- }
- netLink (saleObj) {
- const { curObj } = this.state
- Taro.navigateTo({
- url: `/pagesQa/msg/chat?to_user_id=${saleObj.user_id}&qTitle=${curObj.title}&qId=${curObj.id}`
- })
- }
- callHandle (saleObj) {
- Taro.makePhoneCall({
- phoneNumber: saleObj.sale_phone
- })
- }
- afterCount (type) {
- const { curObj } = this.state
- if (type === 'chat') {
- this.netLink(curObj.sale_user)
- }
- if (type === 'call') {
- this.callHandle(curObj.sale_user)
- }
- }
- countHandle (type) {
- const { curObj } = this.state
- Taro.api.room.apiusercontactclick({
- target_id: curObj.id,
- sale_id: curObj.sale_id,
- click_type: type === 'call' ? '2' : '1' // 1在线聊 2打电话
- }).then(() => {
- this.afterCount(type)
- }).catch(() => {
- this.afterCount(type)
- })
- }
- renderSale () {
- const { curObj, saleUserObj } = this.state
- let saleObj = saleUserObj || {}
- const tagStr = saleObj.custom_tag ? saleObj.custom_tag.substring(0, 8) : ''
- return (
- <View className="scoped-sale">
- <View className="ss-img">
- <Image src={saleObj.sale_avatar} className="img"/>
- </View>
- <View className="ss-info">
- <View className="p1">{saleObj.sale_name}</View>
- <View className="p2">{tagStr}</View>
- </View>
- <View className="ss-r">
- <View className="b" onClick={this.countHandle.bind(this, 'chat')}>在线问</View>
- <View className="b t2" onClick={this.countHandle.bind(this, 'call')}>打电话</View>
- </View>
- </View>
- )
- }
- renderPopup () {
- const { isPopupShow, curShareCardImg } = this.state
- return (
- <AtCurtain
- isOpened={isPopupShow}
- onClose={this.popupClose.bind(this)}
- >
- <View className="scoped-share-card-img">
- <Image
- className="img"
- src={curShareCardImg}
- />
- </View>
- </AtCurtain>
- )
- }
- popupClose () {
- this.setState({
- isPopupShow: false
- })
- }
- popupOpen () {
- this.setState({
- isPopupShow: true
- })
- }
- dealCanvasImg (qrcodeSrc) {
- const { curObj } = this.state
- const that = this
- const imageArr = curObj.images.split(',')
- const processMultipleImages = (url) => {
- return new Promise((resolve, reject) => {
- Taro.getImageInfo({
- src: url,
- success: (res) => {
- resolve(res)
- },
- fail: () => {
- Taro.showToast({
- title: '下载失败!'
- })
- }
- })
- })
- }
- Promise.all(
- imageArr.map(img => processMultipleImages(img+'_adm0'))
- ).then(img => {
- let tempImgArr = img.map(i => i.path)
- that.dealCanvas(tempImgArr)
- })
-
- }
- // drawAndShareImage () {
- // const { curObj } = this.state
- // const imageArr = curObj.images.split(',')
- // if (imageArr.length < 2) {
- // Taro.$msgConfirm('房源图片不足~')
- // return
- // }
- // console.log(curObj)
- // const that = this
- // const cvs = Taro.createOffscreenCanvas({type: '2d', width: 700, height: 990})
- // const ctx = cvs.getContext('2d')
- // ctx.clearRect(0, 0, cvs.width, cvs.height)
- // ctx.rect(0 , 0 , cvs.width , cvs.height)
- // ctx.fillStyle = "#fff"
- // ctx.fill()
-
- // let imgBg = cvs.createImage();
- // imgBg.src = require('./img/dtl/bg_room_dtl.jpg')
- // imgBg.onload = () => {
- // ctx.drawImage(imgBg, 0, 0, 700, 990)
- // }
- // let img1 = cvs.createImage();
- // img1.src = curObj.pri_image + '_adm0'
- // imgBg.onload = () => {
- // ctx.drawImage(img1, 83, 358, 256, 200)
- // }
-
- // let img2 = cvs.createImage();
- // img2.src = curObj.house_img
- // imgBg.onload = () => {
- // ctx.drawImage(img2, 362, 358, 256, 200)
- // }
-
- // let img3 = cvs.createImage();
- // img3.src = imageArr[0] + '_adm0'
- // imgBg.onload = () => {
- // ctx.drawImage(img3, 83, 570, 256, 200)
- // }
-
- // let img4 = cvs.createImage();
- // img4.src = imageArr[1] + '_adm0'
- // imgBg.onload = () => {
- // ctx.drawImage(img4, 362, 570, 256, 200)
- // }
-
-
- // that.drawText(ctx, '#333', curObj.title.length > 25 ? curObj.title.substring(0, 25) + '...' : curObj.title, 98, 846, '18px')
- // if (curObj.estate_name.length > 7) {
- // that.drawText(ctx, '#333', curObj.estate_name, 80, 220, 'normal bold 36px')
- // } else {
- // that.drawText(ctx, '#333', curObj.estate_name, 80, 220, 'normal bold 56px')
- // }
- // that.drawText(ctx, '#333', curObj.area + '㎡', 140, 310, 'normal bold 28px')
- // that.drawText(ctx, '#df6135', curObj.floor_price + '万', 280, 310, 'normal bold 32px')
-
- // // let base64 = ctx.canvas.toDataURL("image/png")
- // // that.setState({
- // // curShareCardImg: base64
- // // })
- // // that.popupOpen()
-
-
- // const imgData = cvs.toDataURL();
- // console.log('imgData')
- // console.log(imgData)
- // const time = new Date().getTime();
- // const fs = wx.getFileSystemManager();
- // const filePath = Taro.env.USER_DATA_PATH + "/poster" + time + "share" + ".png";
- // fs.writeFile({
- // filePath,
- // data: imgData.replace(/^data:image\/\w+;base64,/, ""),
- // encoding: 'base64',
- // success: res => {
- // console.log('成功:'+res)
- // wx.showShareImageMenu({
- // path: filePath,
- // success: res => {
- // console.log(res, 11);
- // }
- // })
- // },
- // fail: err => {
- // // 此处可能存在内存满了的情况
- // // 需要根据具体需求处理
- // console.log(err);
- // }
- // });
- // fs.close()
-
- // }
- async drawAndShareImage () {
- const { curObj, curShareCardImg } = this.state
- if (curShareCardImg) {
- wx.showShareImageMenu({
- path: curShareCardImg,
- success: res => {
- console.log(res, 22);
- }
- })
- return
- }
- const imageArr = curObj.images.split(',')
- if (imageArr.length < 2) {
- Taro.$msgConfirm('房源图片不足~')
- return
- }
- Taro.showLoading({
- mask: true,
- title: '图片智能生成中..'
- })
- const that = this
- const cvs = Taro.createOffscreenCanvas({type: '2d', width: 700, height: 990})
- const ctx = cvs.getContext('2d')
- ctx.clearRect(0, 0, cvs.width, cvs.height)
- ctx.rect(0 , 0 , cvs.width , cvs.height)
- ctx.fillStyle = "#fff"
- ctx.fill()
- let imgBg = cvs.createImage();
- // imgBg.src = require('./img/dtl/bg_room_dtl.jpg')
- imgBg.src = 'https://img.honglounews.com/20240202095009-3067.jpg_adm0?r='+ Math.random()
- await new Promise(resolve => {
- imgBg.onload = resolve;
- })
- ctx.drawImage(imgBg, 0, 0, 700, 990)
- let img1 = cvs.createImage();
- await new Promise(resolve => {
- img1.onload = resolve;
- img1.src = curObj.pri_image + '_adm0'
- })
- ctx.drawImage(img1, 83, 358, 256, 200)
- let img2 = cvs.createImage();
- await new Promise(resolve => {
- img2.onload = resolve;
- img2.src = curObj.house_img
- })
- ctx.drawImage(img2, 362, 358, 256, 200)
- let img3 = cvs.createImage();
- await new Promise(resolve => {
- img3.onload = resolve;
- img3.src = imageArr[0] + '_adm0'
- })
- ctx.drawImage(img3, 83, 570, 256, 200)
- let img4 = cvs.createImage();
- await new Promise(resolve => {
- img4.onload = resolve;
- img4.src = imageArr[1] + '_adm0'
- })
- ctx.drawImage(img4, 362, 570, 256, 200)
-
- that.drawText(ctx, '#333', curObj.title.length > 25 ? curObj.title.substring(0, 25) + '...' : curObj.title, 98, 846, '18px')
- if (curObj.estate_name.length > 7) {
- that.drawText(ctx, '#333', curObj.estate_name, 80, 220, 'normal bold 36px')
- } else {
- that.drawText(ctx, '#333', curObj.estate_name, 80, 220, 'normal bold 56px')
- }
- that.drawText(ctx, '#333', curObj.area + '㎡', 140, 310, 'normal bold 28px')
- that.drawText(ctx, '#df6135', curObj.price + '万', 280, 310, 'normal bold 32px')
-
- // let base64 = ctx.canvas.toDataURL("image/png")
- // that.setState({
- // curShareCardImg: base64
- // })
- // that.popupOpen()
-
- setTimeout(() => {
- imgBg = null
- img1 = null
- img2 = null
- img3 = null
- img4 = null
- Taro.hideLoading()
- }, 6000)
-
- const imgData = cvs.toDataURL();
- const time = new Date().getTime();
- const fs = wx.getFileSystemManager();
- const filePath = Taro.env.USER_DATA_PATH + "/poster" + time + "share" + ".png";
- fs.writeFile({
- filePath,
- data: imgData.replace(/^data:image\/\w+;base64,/, ""),
- encoding: 'base64',
- success: res => {
- that.setState({
- curShareCardImg: filePath
- })
- Taro.hideLoading()
- wx.showShareImageMenu({
- path: filePath,
- success: res => {
- console.log(res, 11);
- }
- })
- },
- fail: err => {
- // 此处可能存在内存满了的情况
- // 需要根据具体需求处理
- console.log(err);
- Taro.hideLoading()
- }
- });
- fs.close()
-
- }
- drawText = (ctx, color, text, x, y, font) => {
- ctx.font=`${font} Microsoft YaHei`;
- ctx.fillStyle = color;
- ctx.textAlign = 'left';
- ctx.fillText(text, x, y);
- ctx.stroke();
- ctx.closePath();
- }
- renderShare () {
- const iconShare = require('@img/images/icon_g_share6s.png')
- return (
- <Button className="g-icon-share btn-to-div" onClick={this.drawAndShareImage.bind(this)}>
- <Image className="img" src={iconShare} />
- </Button>
- )
- }
- renderFixedTopLift () {
- const iconSignLeft = require('@img/icon_sign_left.png')
- return (
- <View className="g-fixed-top-left" onClick={this.goBackPrev.bind(this)}>
- <Image className="img" src={iconSignLeft} />
- </View>
- )
- }
- goBackPrev () {
- // 获取当前页面栈
- const pages = Taro.getCurrentPages()
-
- // 判断是否有上一页
- const hasPreviousPage = pages.length > 1
-
- if (hasPreviousPage) {
- // 如果有上一页,使用 navigateBack 返回至上一页
- Taro.navigateBack({
- delta: 1,
- })
- } else {
- // 若无上一页,可以导航至指定的其它页面或首页
- Taro.navigateTo({
- url: '/pages/index/index',
- })
- }
- }
- render () {
- const { curObj } = this.state
- return (
- <View className="l-box has-footer">
- {this.renderFixedTopLift()}
- {this.renderHeader()}
- {this.renderMain()}
- {this.renderImg()}
- {this.renderAround()}
- {(curObj.es_house_list && curObj.es_house_list.length > 0) && this.renderOther()}
- {this.renderSale()}
- {this.renderPopup()}
- {this.renderShare()}
- </View>
- )
- }
- }
- export default Index
|