Showing
7 changed files
with
247 additions
and
67 deletions
| @@ -5,15 +5,7 @@ Component({ | @@ -5,15 +5,7 @@ Component({ | ||
| 5 | * 组件的属性列表 | 5 | * 组件的属性列表 |
| 6 | */ | 6 | */ |
| 7 | properties: { | 7 | properties: { |
| 8 | - seller_id:String, | ||
| 9 | - hasSellerShare:{ | ||
| 10 | - type:Boolean, | ||
| 11 | - value:false, | ||
| 12 | - }, | ||
| 13 | - seller:{ | ||
| 14 | - type:Object, | ||
| 15 | - value:{}, | ||
| 16 | - }, | 8 | + pack:Object, |
| 17 | }, | 9 | }, |
| 18 | 10 | ||
| 19 | /** | 11 | /** |
| @@ -24,7 +16,7 @@ Component({ | @@ -24,7 +16,7 @@ Component({ | ||
| 24 | product:null, | 16 | product:null, |
| 25 | }, | 17 | }, |
| 26 | attached: function () { | 18 | attached: function () { |
| 27 | - this.formatProduct() | 19 | + |
| 28 | }, | 20 | }, |
| 29 | /** | 21 | /** |
| 30 | * 组件的方法列表 | 22 | * 组件的方法列表 |
| @@ -47,30 +39,9 @@ Component({ | @@ -47,30 +39,9 @@ Component({ | ||
| 47 | console.log('shareDo.'+act,e); | 39 | console.log('shareDo.'+act,e); |
| 48 | wx.navigateTo({ | 40 | wx.navigateTo({ |
| 49 | url:util.http_build_query({ | 41 | url:util.http_build_query({ |
| 50 | - id:this.data.seller_id, | ||
| 51 | - act:act, | ||
| 52 | - hasSellerShare:this.data.hasSellerShare | ||
| 53 | - },'/pages/reserve/share') | ||
| 54 | - }) | ||
| 55 | - }, | ||
| 56 | - formatProduct(){ | ||
| 57 | - let seller=this.data.seller | ||
| 58 | - let product= { | ||
| 59 | - item_code:seller.id+"", | ||
| 60 | - title:seller.sellername, | ||
| 61 | - desc:seller.slogan, | ||
| 62 | - category_list:(seller.cate && seller.cate.length>0)?seller.cate:['餐厅','饭店','餐饮','订包间','周到安排'], | ||
| 63 | - image_list:seller.envi_image, | ||
| 64 | - src_mini_program_path:'/pages/reserve/detail?id='+seller.id+'&from=haowu', | ||
| 65 | - brand_info:{ | ||
| 66 | - name:seller.sellername, | ||
| 67 | - logo:seller.seller_image, | ||
| 68 | - phone:seller.seller_tel, | ||
| 69 | - }, | ||
| 70 | - sku_list:[], | ||
| 71 | - } | ||
| 72 | - this.setData({ | ||
| 73 | - product:product, | 42 | + sid:this.data.pack.sid, |
| 43 | + pid:this.data.pack.id, | ||
| 44 | + },'/pages/taocan/share') | ||
| 74 | }) | 45 | }) |
| 75 | }, | 46 | }, |
| 76 | } | 47 | } |
| @@ -19,37 +19,8 @@ Page({ | @@ -19,37 +19,8 @@ Page({ | ||
| 19 | * pid 套餐id | 19 | * pid 套餐id |
| 20 | */ | 20 | */ |
| 21 | onLoad: function (options) { | 21 | onLoad: function (options) { |
| 22 | - this.activityId=options.pid | ||
| 23 | - App.Foodset.GetFoodsetList({sid:options.sid}).then(res=>{ | ||
| 24 | - let packs={} | ||
| 25 | - res.data.some(r=>{ | ||
| 26 | - r.nameSub=r.name.length>6?(r.name.substr(0,6)+'…'):r.name; | ||
| 27 | - r['包间可用']=r.service.indexOf('包间可用')>-1; | ||
| 28 | - r['免预约']=r.service.indexOf('免预约')>-1; | ||
| 29 | - r['随时退']=r.service.indexOf('随时退')>-1; | ||
| 30 | - r.sid=this.data.sid | ||
| 31 | - packs[r.id]=r | ||
| 32 | - }) | ||
| 33 | - while(Object.keys(packs).length<3){ | ||
| 34 | - packs[Math.random()]={} | ||
| 35 | - } | ||
| 36 | - try{ | ||
| 37 | - if(!packs[this.activityId]){ | ||
| 38 | - util.toast('套餐已下架','none') | ||
| 39 | - this.activityId=res.data[0].id | ||
| 40 | - } | ||
| 41 | - this.setData({ | ||
| 42 | - packs:packs, | ||
| 43 | - activityId:this.activityId, | ||
| 44 | - current:this.getCurrent(this.activityId,packs) | ||
| 45 | - }) | ||
| 46 | - this.getActivityDetail() | ||
| 47 | - }catch (e){ | ||
| 48 | - this.setData({ | ||
| 49 | - hasNoSets:true,//没有任何套餐 | ||
| 50 | - }); | ||
| 51 | - } | ||
| 52 | - }) | 22 | + this.options=options |
| 23 | + this.taocanInit() | ||
| 53 | }, | 24 | }, |
| 54 | 25 | ||
| 55 | /** | 26 | /** |
| @@ -118,6 +89,51 @@ Page({ | @@ -118,6 +89,51 @@ Page({ | ||
| 118 | console.log('shareParams==>',shareParams) | 89 | console.log('shareParams==>',shareParams) |
| 119 | return shareParams | 90 | return shareParams |
| 120 | }, | 91 | }, |
| 92 | + | ||
| 93 | + async taocanInitScene(){ | ||
| 94 | + if(this.options.scene){ | ||
| 95 | + //解析scene追加到options | ||
| 96 | + } | ||
| 97 | + //fromid存在则设置推荐关系 | ||
| 98 | + if(this.options.fromid){ | ||
| 99 | + | ||
| 100 | + } | ||
| 101 | + }, | ||
| 102 | + async taocanInit(){ | ||
| 103 | + await this.taocanInitScene(); | ||
| 104 | + let options=this.options | ||
| 105 | + this.activityId=options.pid | ||
| 106 | + App.Foodset.GetFoodsetList({sid:options.sid}).then(res=>{ | ||
| 107 | + let packs={} | ||
| 108 | + res.data.some(r=>{ | ||
| 109 | + r.nameSub=r.name.length>6?(r.name.substr(0,6)+'…'):r.name; | ||
| 110 | + r['包间可用']=r.service.indexOf('包间可用')>-1; | ||
| 111 | + r['免预约']=r.service.indexOf('免预约')>-1; | ||
| 112 | + r['随时退']=r.service.indexOf('随时退')>-1; | ||
| 113 | + r.sid=this.data.sid | ||
| 114 | + packs[r.id]=r | ||
| 115 | + }) | ||
| 116 | + while(Object.keys(packs).length<3){ | ||
| 117 | + packs[Math.random()]={} | ||
| 118 | + } | ||
| 119 | + try{ | ||
| 120 | + if(!packs[this.activityId]){ | ||
| 121 | + util.toast('套餐已下架','none') | ||
| 122 | + this.activityId=res.data[0].id | ||
| 123 | + } | ||
| 124 | + this.setData({ | ||
| 125 | + packs:packs, | ||
| 126 | + activityId:this.activityId, | ||
| 127 | + current:this.getCurrent(this.activityId,packs) | ||
| 128 | + }) | ||
| 129 | + this.getActivityDetail() | ||
| 130 | + }catch (e){ | ||
| 131 | + this.setData({ | ||
| 132 | + hasNoSets:true,//没有任何套餐 | ||
| 133 | + }); | ||
| 134 | + } | ||
| 135 | + }) | ||
| 136 | + }, | ||
| 121 | getCurrent(id,packs){ | 137 | getCurrent(id,packs){ |
| 122 | let ps=Object.keys(packs) | 138 | let ps=Object.keys(packs) |
| 123 | let index=ps.indexOf(id) | 139 | let index=ps.indexOf(id) |
| @@ -29,7 +29,7 @@ | @@ -29,7 +29,7 @@ | ||
| 29 | <block wx:if="{{!hasNoSets}}"> | 29 | <block wx:if="{{!hasNoSets}}"> |
| 30 | <scroll-view class="view margin-left-lg header text-black" | 30 | <scroll-view class="view margin-left-lg header text-black" |
| 31 | scroll-x="true" bindscroll="scroll" scroll-into-view="PID{{activityId}}" | 31 | scroll-x="true" bindscroll="scroll" scroll-into-view="PID{{activityId}}" |
| 32 | - style="width: 100%;white-space: nowrap;height:80rpx;padding-top: 16rpx;"> | 32 | + style="width: 100%;white-space: nowrap;height:80rpx;"> |
| 33 | <block wx:for="{{packs}}" wx:key="*this"> | 33 | <block wx:for="{{packs}}" wx:key="*this"> |
| 34 | <view id="PID{{item.id}}" | 34 | <view id="PID{{item.id}}" |
| 35 | bindtap="touchTab" data-id="{{item.id}}" data-index="{{index}}" | 35 | bindtap="touchTab" data-id="{{item.id}}" data-index="{{index}}" |
| @@ -131,5 +131,5 @@ | @@ -131,5 +131,5 @@ | ||
| 131 | style="width: 520rpx;height: 348rpx;"></image> | 131 | style="width: 520rpx;height: 348rpx;"></image> |
| 132 | <view class="txt-28-h margin-top-lg">该套餐过期啦</view> | 132 | <view class="txt-28-h margin-top-lg">该套餐过期啦</view> |
| 133 | </view> | 133 | </view> |
| 134 | -<share id="share" seller_id="{{seller.id}}" seller="{{seller}}"></share> | 134 | +<share id="share" pack="{{packs[activityId]}}" wx:if="{{packs[activityId].id}}"></share> |
| 135 | 135 |
pages/taocan/share.js
0 → 100644
| 1 | +// pages/reserve/share.js | ||
| 2 | +import util from '../../utils/util'; | ||
| 3 | +import App from '../../utils/api'; | ||
| 4 | +const {regeneratorRuntime} = global | ||
| 5 | +Page({ | ||
| 6 | + | ||
| 7 | + /** | ||
| 8 | + * 页面的初始数据 | ||
| 9 | + */ | ||
| 10 | + data: { | ||
| 11 | + paletteImageSrc:'', | ||
| 12 | + palette:null, | ||
| 13 | + hasLoadData:true, | ||
| 14 | + }, | ||
| 15 | + /** | ||
| 16 | + * 生命周期函数--监听页面加载 | ||
| 17 | + */ | ||
| 18 | + onLoad: function (options) { | ||
| 19 | + this.options=options; | ||
| 20 | + this.setQrcode(); | ||
| 21 | + }, | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 生命周期函数--监听页面初次渲染完成 | ||
| 25 | + */ | ||
| 26 | + onReady: function () { | ||
| 27 | + | ||
| 28 | + }, | ||
| 29 | + | ||
| 30 | + /** | ||
| 31 | + * 生命周期函数--监听页面显示 | ||
| 32 | + */ | ||
| 33 | + onShow: function () { | ||
| 34 | + | ||
| 35 | + }, | ||
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * 生命周期函数--监听页面隐藏 | ||
| 39 | + */ | ||
| 40 | + onHide: function () { | ||
| 41 | + | ||
| 42 | + }, | ||
| 43 | + | ||
| 44 | + /** | ||
| 45 | + * 生命周期函数--监听页面卸载 | ||
| 46 | + */ | ||
| 47 | + onUnload: function () { | ||
| 48 | + | ||
| 49 | + }, | ||
| 50 | + | ||
| 51 | + /** | ||
| 52 | + * 页面相关事件处理函数--监听用户下拉动作 | ||
| 53 | + */ | ||
| 54 | + onPullDownRefresh: function () { | ||
| 55 | + | ||
| 56 | + }, | ||
| 57 | + | ||
| 58 | + /** | ||
| 59 | + * 页面上拉触底事件的处理函数 | ||
| 60 | + */ | ||
| 61 | + onReachBottom: function () { | ||
| 62 | + | ||
| 63 | + }, | ||
| 64 | + async setQrcode(){ | ||
| 65 | + let options=this.options | ||
| 66 | + let openid=await getApp().getOpenid() | ||
| 67 | + this.qrcode=await util.http_build_query({ | ||
| 68 | + page:'pages/taocan/index', | ||
| 69 | + path:'pages/taocan/index', | ||
| 70 | + param:JSON.stringify({ | ||
| 71 | + sid:options.sid, | ||
| 72 | + pid:options.pid, | ||
| 73 | + fromid:openid, | ||
| 74 | + }) | ||
| 75 | + },util.cgi('App.System.GetWxLiteCode')) | ||
| 76 | + this.initImage() | ||
| 77 | + }, | ||
| 78 | + initImage(){ | ||
| 79 | + let palette={ | ||
| 80 | + background: '#fff', | ||
| 81 | + width: '400rpx', | ||
| 82 | + height: '400rpx', | ||
| 83 | + views: [ | ||
| 84 | + { | ||
| 85 | + type: 'image', | ||
| 86 | + url: this.qrcode, | ||
| 87 | + css: { | ||
| 88 | + mode:'scaleToFill', | ||
| 89 | + width: '400rpx', | ||
| 90 | + height: '400rpx', | ||
| 91 | + }, | ||
| 92 | + } | ||
| 93 | + ], | ||
| 94 | + } | ||
| 95 | + this.setData({ | ||
| 96 | + palette:palette | ||
| 97 | + }) | ||
| 98 | + }, | ||
| 99 | + onImgOK(e){ | ||
| 100 | + console.log('onImgOK',e.detail.path) | ||
| 101 | + wx.getImageInfo({ | ||
| 102 | + src:e.detail.path, | ||
| 103 | + success:res=>{ | ||
| 104 | + let w=getApp().system.windowWidth | ||
| 105 | + console.log('getImageInfo',res) | ||
| 106 | + this.setData({ | ||
| 107 | + paletteImageWidth:w, | ||
| 108 | + paletteImageHeight:w/res.width*res.height, | ||
| 109 | + paletteImageSrc:e.detail.path, | ||
| 110 | + }) | ||
| 111 | + } | ||
| 112 | + }) | ||
| 113 | + }, | ||
| 114 | + reviewImage(){ | ||
| 115 | + wx.previewImage({ | ||
| 116 | + urls:[this.data.paletteImageSrc], | ||
| 117 | + }) | ||
| 118 | + }, | ||
| 119 | +}) |
pages/taocan/share.json
0 → 100644
pages/taocan/share.wxml
0 → 100644
| 1 | +<!--pages/reserve/share.wxml--> | ||
| 2 | +<nav>{{actType=='quanzi'?'分享图':'二维码下载'}}</nav> | ||
| 3 | +<loading wx:if="{{!hasLoadData || !paletteImageSrc}}">图片生成中</loading> | ||
| 4 | +<view wx:if="{{hasLoadData}}" style="position: fixed;top:-9999rpx;"> | ||
| 5 | + <painter palette="{{palette}}" bind:imgOK="onImgOK" bind:imgErr="onImgOK"/> | ||
| 6 | +</view> | ||
| 7 | +<view wx:if="{{paletteImageSrc}}" class="pages"> | ||
| 8 | + <view class="pages-view flex-vc" wx:if="{{actType=='quanzi'}}"> | ||
| 9 | + <image src="{{paletteImageSrc}}" | ||
| 10 | + bindtap="reviewImage" | ||
| 11 | + style="width:{{paletteImageWidth}}px;height:{{paletteImageHeight}}px;"></image> | ||
| 12 | + </view> | ||
| 13 | + <view class="pages-view flex-vc" wx:else=""> | ||
| 14 | + <image src="{{paletteImageSrc}}" | ||
| 15 | + bindtap="reviewImage" | ||
| 16 | + style="width:400rpx;height:400rpx; margin-top: 90rpx;"></image> | ||
| 17 | + <view class="qrcode-text">{{seller.sellername}}</view> | ||
| 18 | + </view> | ||
| 19 | + <view class="save flex-vc"> | ||
| 20 | + <savefile filePath="{{paletteImageSrc}}" style="width: 100%"> | ||
| 21 | + <view class="save-but flex-cc"> | ||
| 22 | + 保存到相册 | ||
| 23 | + </view> | ||
| 24 | + </savefile> | ||
| 25 | + </view> | ||
| 26 | +</view> | ||
| 27 | + |
pages/taocan/share.wxss
0 → 100644
| 1 | +/* pages/reserve/share.wxss */ | ||
| 2 | +page{ | ||
| 3 | + background-color: #fefefe; | ||
| 4 | +} | ||
| 5 | +.pages{ | ||
| 6 | + padding-bottom: 100rpx; | ||
| 7 | + width: 100%; | ||
| 8 | + padding-top: 0rpx; | ||
| 9 | + background-size: 100% 100%; | ||
| 10 | +} | ||
| 11 | +.pages-view{ | ||
| 12 | + width: 100%; | ||
| 13 | + margin: 0 auto; | ||
| 14 | +} | ||
| 15 | +.save{ | ||
| 16 | + position: fixed; | ||
| 17 | + bottom: 40rpx; | ||
| 18 | + width: calc(100% - 80rpx); | ||
| 19 | + left:40rpx; | ||
| 20 | +} | ||
| 21 | +.save-but{ | ||
| 22 | + width: 100%; | ||
| 23 | + height: 84rpx; | ||
| 24 | + background: linear-gradient(90deg, #3BBFF5 0%, #57A0FF 100%); | ||
| 25 | + border-radius: 42rpx; | ||
| 26 | + | ||
| 27 | + font-size: 36rpx; | ||
| 28 | + font-family: PingFangSC-Semibold, PingFang SC; | ||
| 29 | + font-weight: 600; | ||
| 30 | + color: #FFFFFF; | ||
| 31 | + line-height: 84rpx; | ||
| 32 | +} | ||
| 33 | +.qrcode-text{ | ||
| 34 | + font-size: 34rpx; | ||
| 35 | + margin-top: 40rpx; | ||
| 36 | + margin-bottom: 90rpx; | ||
| 37 | +} |
-
Please register or login to post a comment