Commit 24a7b0191b8600519d7f65cedca4d107ff5f13a3

Authored by vking
1 parent 3937354e

painter

@@ -12,16 +12,15 @@ @@ -12,16 +12,15 @@
12 width: 140rpx; 12 width: 140rpx;
13 height: 140rpx; 13 height: 140rpx;
14 background-size: 100% 100%; 14 background-size: 100% 100%;
15 - background-color: #cccccc;  
16 } 15 }
17 .share-img.wechat{ 16 .share-img.wechat{
18 - background-image: url("http://"); 17 + background-image: url("http://qn.colorcun.com/reserve/share/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201906251004331.png");
19 } 18 }
20 .share-img.quanzi{ 19 .share-img.quanzi{
21 - background-image: url("http://"); 20 + background-image: url("http://qn.colorcun.com/reserve/share/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_20190625100433.png");
22 } 21 }
23 .share-img.qrcode{ 22 .share-img.qrcode{
24 - background-image: url("http://"); 23 + background-image: url("http://qn.colorcun.com/reserve/share/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201906251004332.png");
25 } 24 }
26 .share-name{ 25 .share-name{
27 margin-top: 20rpx; 26 margin-top: 20rpx;
  1 +// component/menu/addDelete.js
  2 +import util from '../../utils/util';
  3 +import App from '../../utils/api';
  4 +
  5 +Component({
  6 + /**
  7 + * 组件的属性列表
  8 + */
  9 + properties: {
  10 +
  11 + },
  12 +
  13 + /**
  14 + * 组件的初始数据
  15 + */
  16 + data: {
  17 +
  18 + },
  19 + attached(){
  20 +
  21 + },
  22 + ready () {
  23 +
  24 + },
  25 + detached(){
  26 +
  27 + },
  28 + /**
  29 + * 组件的方法列表
  30 + */
  31 + methods: {
  32 + saveFile(filePath=''){
  33 + filePath=filePath?filePath:this.data.filePath
  34 + wx.saveImageToPhotosAlbum({
  35 + filePath:filePath,
  36 + fail:()=>{
  37 + wx.showModal({
  38 + title: '授权提示',
  39 + content: '您拒绝了保存文件,请点击确定打开授权',
  40 + confirmColor: '#199095',
  41 + cancelColor: '#999',
  42 + success: function (res) {
  43 + if (res.confirm) {
  44 + util.setting();
  45 + }
  46 + }
  47 + })
  48 + },
  49 + })
  50 + },
  51 + }
  52 +})
  1 +{
  2 + "component": true,
  3 + "usingComponents": {
  4 + "formids": "/components/formids/formids"
  5 + }
  6 +}
  1 +<formids bindclick="saveFile" style="width: 100%;">
  2 + <slot></slot>
  3 +</formids>
  1 +@import "../../app.wxss";
@@ -13,12 +13,16 @@ Page({ @@ -13,12 +13,16 @@ Page({
13 palette:null, 13 palette:null,
14 hasLoadData:false, 14 hasLoadData:false,
15 act:'', 15 act:'',
  16 + hasActName:'',
16 }, 17 },
17 /** 18 /**
18 * 生命周期函数--监听页面加载 19 * 生命周期函数--监听页面加载
19 */ 20 */
20 onLoad: function (options) { 21 onLoad: function (options) {
21 this.options=options; 22 this.options=options;
  23 + this.setData({
  24 + actType:options.act
  25 + })
22 this.GetSellerDetail(); 26 this.GetSellerDetail();
23 }, 27 },
24 28
@@ -142,8 +146,22 @@ Page({ @@ -142,8 +146,22 @@ Page({
142 }, 146 },
143 onImgOK(e){ 147 onImgOK(e){
144 console.log('onImgOK',e.detail.path) 148 console.log('onImgOK',e.detail.path)
145 - this.setData({  
146 - paletteImageSrc:e.detail.path, 149 + wx.getImageInfo({
  150 + src:e.detail.path,
  151 + success:res=>{
  152 + let w=getApp().system.windowWidth
  153 + console.log('getImageInfo',res)
  154 + this.setData({
  155 + paletteImageWidth:w,
  156 + paletteImageHeight:w/res.width*res.height,
  157 + paletteImageSrc:e.detail.path,
  158 + })
  159 + }
147 }) 160 })
148 }, 161 },
  162 + reviewImage(){
  163 + wx.previewImage({
  164 + urls:[this.data.paletteImageSrc],
  165 + })
  166 + }
149 }) 167 })
1 { 1 {
2 "usingComponents": { 2 "usingComponents": {
3 "nav":"/components/nav/nav", 3 "nav":"/components/nav/nav",
4 - "painter":"/components/painter/painter" 4 + "painter":"/components/painter/painter",
  5 + "savefile":"/components/userinfo/savefile"
5 } 6 }
6 } 7 }
1 <!--pages/reserve/share.wxml--> 1 <!--pages/reserve/share.wxml-->
2 -<nav>{{true?'分享图':'二维码下载'}}</nav> 2 +<nav>{{actType=='quanzi'?'分享图':'二维码下载'}}</nav>
3 <loading wx:if="{{!hasLoadData || !paletteImageSrc}}">图片生成中</loading> 3 <loading wx:if="{{!hasLoadData || !paletteImageSrc}}">图片生成中</loading>
4 <view wx:if="{{hasLoadData}}" style="position: fixed;top:-9999rpx;"> 4 <view wx:if="{{hasLoadData}}" style="position: fixed;top:-9999rpx;">
5 <painter palette="{{palette}}" bind:imgOK="onImgOK" bind:imgErr="onImgOK"/> 5 <painter palette="{{palette}}" bind:imgOK="onImgOK" bind:imgErr="onImgOK"/>
6 </view> 6 </view>
7 <view wx:if="{{paletteImageSrc}}" class="pages"> 7 <view wx:if="{{paletteImageSrc}}" class="pages">
8 - <image src="{{paletteImageSrc}}" style="width:100%;height:999px;"></image> 8 + <image src="{{paletteImageSrc}}"
  9 + bindtap="reviewImage"
  10 + style="width:{{paletteImageWidth}}px;height:{{paletteImageHeight}}px;"></image>
  11 + <view class="save">
  12 + <savefile>
  13 + <view class="save-but flex-cc">
  14 + <view class="save-but-icon"></view>
  15 + <view class="save-but-text">保存到相册</view>
  16 + </view>
  17 + </savefile>
  18 + </view>
9 </view> 19 </view>
10 20
1 -/* pages/reserve/share.wxss */  
  1 +/* pages/reserve/share.wxss */
  2 +.save{
  3 + position: fixed;
  4 + bottom: 0;
  5 + width: 100%;
  6 +}
  7 +.save-but{
  8 + width: 90%;
  9 + height: 100rpx;
  10 + margin: 0 auto 30rpx;
  11 + background-color: #C0A369;
  12 + font-size: 32rpx;
  13 + color: #fefefe;
  14 + border-radius: 10rpx;
  15 +}
  16 +.save-but-icon{
  17 + width: 40rpx;
  18 + height: 40rpx;
  19 + background-size: 100% 100%;
  20 + background-image: url("http://qn.colorcun.com/reserve/share/%E5%BE%AE%E4%BF%A1%E5%9B%BE%E7%89%87_201906251004333.png");
  21 +}
  22 +.save-but-text{
  23 + height:40rpx;
  24 + line-height: 40rpx;
  25 + margin-left: 20rpx;
  26 +}