Authored by htoooth

fix

@@ -4,7 +4,7 @@ @@ -4,7 +4,7 @@
4 "pages/account/chooseArea", 4 "pages/account/chooseArea",
5 "pages/account/bindMobile", 5 "pages/account/bindMobile",
6 "pages/product/detail/detail", 6 "pages/product/detail/detail",
7 - "pages/share/share" 7 + "pages/snapshootShare/snapshootShare"
8 ], 8 ],
9 "window": { 9 "window": {
10 "backgroundTextStyle": "dark", 10 "backgroundTextStyle": "dark",
@@ -22,6 +22,7 @@ Page(Object.assign({ @@ -22,6 +22,7 @@ Page(Object.assign({
22 price: '', 22 price: '',
23 defaultImage: '', 23 defaultImage: '',
24 productDesc: [], 24 productDesc: [],
  25 + snapData: {},
25 26
26 actionSheet: { 27 actionSheet: {
27 componentId: 'shareActionSheet', 28 componentId: 'shareActionSheet',
@@ -97,7 +98,7 @@ Page(Object.assign({ @@ -97,7 +98,7 @@ Page(Object.assign({
97 98
98 if (index === 1) { 99 if (index === 1) {
99 //生成页面给 100 //生成页面给
100 - router.go('snapShare'); 101 + router.go('snapShare', this.snapData);
101 } 102 }
102 }, 103 },
103 productInfo: function() { 104 productInfo: function() {
@@ -122,11 +123,10 @@ Page(Object.assign({ @@ -122,11 +123,10 @@ Page(Object.assign({
122 } 123 }
123 124
124 let default_image = defaultImage; 125 let default_image = defaultImage;
125 - let product_qrCode = config.domains.api + '/wechat/miniapp/img-check.jpg?param=' + res.data.product_skn; // eslint-disable-line 126 + let product_qrCode = config.domains.api + `/wechat/miniapp/img-check.jpg?param=${res.data.product_skn}&uid=${app.getUid()}&limitProductCode=${this.data.limitProductCode}`; // eslint-disable-line
126 127
127 let snapData = { 128 let snapData = {
128 product_name: res.data.product_name, 129 product_name: res.data.product_name,
129 - product_price: '¥' + res.data.price,  
130 default_image, 130 default_image,
131 product_qrCode, 131 product_qrCode,
132 product_skn: this.data.productSkn 132 product_skn: this.data.productSkn
@@ -140,6 +140,7 @@ Page(Object.assign({ @@ -140,6 +140,7 @@ Page(Object.assign({
140 reminderNum: res.data.reminderNum, 140 reminderNum: res.data.reminderNum,
141 defaultImage, 141 defaultImage,
142 productDesc, 142 productDesc,
  143 + snapData
143 }); 144 });
144 } 145 }
145 }); 146 });
@@ -150,7 +150,7 @@ @@ -150,7 +150,7 @@
150 </view> 150 </view>
151 </yoho-alert> --> 151 </yoho-alert> -->
152 152
153 -<yoho-alert> 153 +<!-- <yoho-alert>
154 <view class="modal-content"> 154 <view class="modal-content">
155 <view class="modal-title"> 155 <view class="modal-title">
156 <view class="sub-title">重复助力</view> 156 <view class="sub-title">重复助力</view>
@@ -170,6 +170,6 @@ @@ -170,6 +170,6 @@
170 </view> 170 </view>
171 </view> 171 </view>
172 </view> 172 </view>
173 -</yoho-alert> 173 +</yoho-alert> -->
174 174
175 <template is="zan-actionsheet" data="{{...actionSheet}}" /> 175 <template is="zan-actionsheet" data="{{...actionSheet}}" />
1 -{  
2 - "navigationBarTitleText": "分享到朋友圈",  
3 - "enablePullDownRefresh": false,  
4 - "usingComponents": {  
5 - }  
6 -}  
1 -<view>你的好友邀你为ta助力,购买限定商</view>  
  1 +let app = getApp();
  2 +const windowWidth = app.globalData.systemInfo.windowWidth;
  3 +const windowHeight = app.globalData.systemInfo.windowHeight;
  4 +const screenHeight = app.globalData.systemInfo.screenHeight;
  5 +const scale = windowWidth / 375;
  6 +
  7 +var Point = function(x, y) {
  8 + return {
  9 + x: x,
  10 + y: y
  11 + };
  12 +};
  13 +
  14 +Page({
  15 + /**
  16 + * 组件的初始数据
  17 + */
  18 + data: {
  19 + screenHeight,
  20 + windowWidth,
  21 + windowHeight,
  22 + scale,
  23 + },
  24 +
  25 + onLoad(options) {
  26 +
  27 + },
  28 +
  29 + saveToAlbum() {
  30 + let that = this;
  31 +
  32 + if (wx.getSetting) {
  33 + wx.getSetting({
  34 + success(res) {
  35 + if (!res.authSetting['scope.writePhotosAlbum']) {
  36 + wx.authorize({
  37 + scope: 'scope.writePhotosAlbum',
  38 + success: function() {
  39 + that.saveSnapShoot();
  40 + },
  41 + fail: function(error) {
  42 + if (res.authSetting['scope.writePhotosAlbum'] === false) {
  43 + wx.showModal({
  44 + title: '',
  45 + content: '需要打开小程序的设置,重新授权访问您的系统相册',
  46 + confirmText: '去开启',
  47 + confirmColor: '#000000',
  48 + success: function(r) {
  49 + if (r.confirm) {
  50 + wx.openSetting({
  51 + success: function() {}
  52 + });
  53 + }
  54 + }
  55 + });
  56 + }
  57 + },
  58 + });
  59 + } else {
  60 + that.saveSnapShoot();
  61 + }
  62 + }
  63 + });
  64 + } else {
  65 + wx.showModal({
  66 + title: '提示',
  67 + content: '当前微信版本过低,无法使用该功能,请升级到最新微信版本后重试。'
  68 + });
  69 + }
  70 + },
  71 +
  72 + saveSnapShoot() {
  73 + var that = this;
  74 + var canvasId = 'productDetailCanvas';
  75 +
  76 + wx.canvasToTempFilePath({
  77 + x: 0,
  78 + y: 0,
  79 + width: windowWidth,
  80 + height: screenHeight,
  81 + destWidth: windowWidth * 2,
  82 + destHeight: screenHeight * 2,
  83 + quality: 1.0,
  84 + canvasId: canvasId,
  85 + success: function(result) {
  86 + wx.saveImageToPhotosAlbum({
  87 + filePath: result.tempFilePath,
  88 + success(res) {
  89 + wx.showToast({
  90 + title: '保存成功',
  91 + icon: 'success',
  92 + duration: 2000
  93 + });
  94 + that.hidden();
  95 + },
  96 + fail: function() {
  97 + that.hidden();
  98 + }
  99 + });
  100 + },
  101 + fail: function(error) {
  102 + that.hidden();
  103 + },
  104 + complete: function(res) {
  105 + that.hidden();
  106 + }
  107 + }, this);
  108 + },
  109 +
  110 + creatProductDetailSnapShoot() {
  111 + let that = this;
  112 + let product = that.properties.shareData;
  113 + let pCtx = wx.createCanvasContext('productDetailCanvas', this);
  114 +
  115 + pCtx.setFillStyle('white');
  116 + pCtx.fillRect(0, 0, windowWidth, screenHeight);
  117 + pCtx.drawImage('./images/snapshoot_share_bg@2x.png', 0, 0, windowWidth, 186 * scale);
  118 + pCtx.setFillStyle('white');
  119 + pCtx.setShadow(-5, -2, 40, 'darkgray');
  120 + pCtx.fillRect(27 * scale, 60 * scale, 320 * scale, 430 * scale);
  121 +
  122 + let defaultImage = product.default_image;
  123 +
  124 + if (defaultImage && defaultImage.indexOf('https://') === -1) {
  125 + defaultImage = defaultImage.replace('http://', 'https://');
  126 + }
  127 +
  128 + wx.getImageInfo({
  129 + src: defaultImage,
  130 + success: function(res) {
  131 + pCtx.drawImage(res.path, 27 * scale, 60 * scale, 320 * scale, 430 * scale);
  132 + pCtx.setFillStyle('rgba(0,0,0,0.8)');
  133 + pCtx.fillRect(27 * scale, 370 * scale, 320 * scale, 120 * scale);
  134 + pCtx.setFillStyle('white');
  135 + that.drawLongText(product.product_name, pCtx, 187.5 * scale, 402 * scale, 'white', 14, 20);
  136 + pCtx.setTextAlign('center');
  137 + pCtx.setFontSize(18 * scale);
  138 + pCtx.fillText(product.product_price, 187.5 * scale, 458.5 * scale);
  139 + pCtx.draw(true);
  140 + }
  141 + });
  142 +
  143 + pCtx.setShadow(0, 0, 0, 'white');
  144 + pCtx.drawImage('./images/share-logo@2x.png', 132 * scale, 505 * scale, 111 * scale, 20 * scale);
  145 +
  146 + wx.getImageInfo({
  147 + src: product.product_qrCode,
  148 + success: function(res) {
  149 + pCtx.drawImage(res.path, 148.5 * scale, 539.5 * scale, 78 * scale, 78 * scale);
  150 + pCtx.draw(true);
  151 + }
  152 + });
  153 +
  154 + pCtx.setFillStyle('black');
  155 + pCtx.setTextAlign('center');
  156 + pCtx.setFontSize(11);
  157 + pCtx.fillText('长按扫码查看详情', 187.5 * scale, 632.5 * scale);
  158 + pCtx.drawImage('./images/snapshoot_tip_ic@2x.png', 127 * scale, 645.5 * scale, 9 * scale, 9 * scale);
  159 + pCtx.setFillStyle('#b0b0b0');
  160 + pCtx.setFontSize(9);
  161 + pCtx.fillText('实际价格以页面展示为准', 187.5 * scale, 652.5 * scale);
  162 + pCtx.draw();
  163 + },
  164 +
  165 + drawRoundedRect: function(rect, r, ctx) {
  166 + var ptA = Point(rect.x + r, rect.y);
  167 + var ptB = Point(rect.x + rect.width, rect.y);
  168 + var ptC = Point(rect.x + rect.width, rect.y + rect.height);
  169 + var ptD = Point(rect.x, rect.y + rect.height);
  170 + var ptE = Point(rect.x, rect.y);
  171 +
  172 + ctx.setStrokeStyle('rgba(0,0,0,0)');
  173 +
  174 + ctx.beginPath();
  175 +
  176 + ctx.moveTo(ptA.x, ptA.y);
  177 + ctx.arcTo(ptB.x, ptB.y, ptC.x, ptC.y, r);
  178 + ctx.arcTo(ptC.x, ptC.y, ptD.x, ptD.y, r);
  179 + ctx.arcTo(ptD.x, ptD.y, ptE.x, ptE.y, r);
  180 + ctx.arcTo(ptE.x, ptE.y, ptA.x, ptA.y, r);
  181 +
  182 + ctx.stroke();
  183 + },
  184 +
  185 + Rect: function(x, y, w, h) {
  186 + return {
  187 + x: x,
  188 + y: y,
  189 + width: w,
  190 + height: h
  191 + };
  192 + },
  193 +
  194 + drawLongText(longtext, cxt, begin_width, begin_height, color, fontSize, numsForLine) {
  195 + var linelenght = 20 * scale; //行间距
  196 + var numberOfLine = 2;
  197 + var text = '';
  198 + var count = 0;
  199 + var lineNumber = 1;
  200 + var stringLenght = longtext.length;
  201 + var newtext = longtext.split('');
  202 +
  203 + cxt.setFillStyle(color);
  204 + cxt.setFontSize(fontSize * scale);
  205 + cxt.setTextAlign('center');
  206 +
  207 + for (let i = 0; i <= stringLenght; i++) {
  208 + if (count === numsForLine) {
  209 + if (lineNumber === numberOfLine) {
  210 + let t = text + '...';
  211 +
  212 + cxt.fillText(t, begin_width, begin_height);
  213 + } else {
  214 + cxt.fillText(text, begin_width, begin_height);
  215 + }
  216 + begin_height = begin_height + linelenght;
  217 + text = '';
  218 + count = 0;
  219 + lineNumber++;
  220 + }
  221 +
  222 + if (i === stringLenght) {
  223 + cxt.fillText(text, begin_width, begin_height);
  224 + }
  225 + text = text + newtext[0];
  226 + count++;
  227 + newtext.shift();
  228 + if (lineNumber > numberOfLine) {
  229 + break;
  230 + }
  231 + }
  232 + }
  233 +});
  1 +{
  2 + "navigationBarTitleText": "拼团详情",
  3 + "usingComponents": {}
  4 +}
  1 +<!--pages/snapshootShare/snapshootShare.wxml-->
  2 +<view class="snapshoot-container" >
  3 + <view class="snapshoot-container">
  4 + <view class="snapshoot-content">
  5 + <view class="snapshoot">
  6 + <image class="product-img-bg" src="./images/snapshoot_share_bg@2x.png"></image>
  7 + <view>你的好友邀你为ta助力,购买限定商品</view>
  8 + <view class="snapshoot-productinfo">
  9 + <image class="product-defaultImage" src="{{default_image}}"> </image>
  10 + <view class="product-info-content">
  11 + <text class="product-name">{{product_name}}</text>
  12 + </view>
  13 + </view>
  14 + <view class="product-miniqr">
  15 + <image class="yoho-logo" src="./images/share-logo@2x.png"></image>
  16 + <image class="product-qrcode" src="{{product_qrCode}}"></image>
  17 + <text class="snapshoot-tips">长按扫码查看详情</text>
  18 + <view class='product-tips'>
  19 + <image class="product-tips-img" src="./images/snapshoot_tip_ic@2x.png"></image>
  20 + <text class="product-tips-text">或者在各大应用市场搜索 Yoho!Buy有货 下载App</text>
  21 + </view>
  22 + </view>
  23 + </view>
  24 + </view>
  25 + <!--底部按钮 -->
  26 + <view class="snapshoot-bottom">
  27 + <view class="snapshoot-save" bindtap="saveToAlbum">
  28 + <!-- <image class="img" src="./images/down@2x.png"></image> -->
  29 + <text class="text">保存到相册</text>
  30 + </view>
  31 + <view class="snapshoot-cancel" bindtap="hidden">
  32 + <text class="cancel-text">取消</text>
  33 + </view>
  34 + </view>
  35 + </view>
  36 +
  37 + <view class="snapshoot-canvas" style="width: {{windowWidth}}px;height:{{screenHeight}}px; background-color: white; margin-top: {{screenHeight}}px" >
  38 + <canvas canvas-id="productDetailCanvas" style="width: {{windowWidth}}px;height:{{screenHeight}}px;background-color: white"></canvas>
  39 + </view>
  40 +</view>
  41 +
  42 +
  43 +
  44 +
  1 +/* pages/snapshootShare/snapshootShare.wxss */
  2 +.snapshoot-container {
  3 + position: fixed;
  4 + left: 0rpx;
  5 + top: 0rpx;
  6 + width: 750rpx;
  7 + height: 1206rpx;
  8 + background-color: rgba(0, 0, 0, 0.5);
  9 + flex-direction: column;
  10 + z-index: 9999;
  11 +}
  12 +
  13 +.snapshoot-container .snapshoot-content {
  14 + margin-top: 58rpx;
  15 + margin-left: 105rpx;
  16 + width: 540rpx;
  17 + height: 960rpx;
  18 + background-color: white;
  19 + flex-direction: column;
  20 +}
  21 +
  22 +.snapshoot-container .snapshoot-content .snapshoot {
  23 + width: 100%;
  24 + height: 100%;
  25 + display: flex;
  26 + flex-direction: column;
  27 + align-items: center;
  28 +}
  29 +
  30 +.snapshoot-container .snapshoot-content .snapshoot .img-bg {
  31 + width: 100%;
  32 + height: 168rpx;
  33 +}
  34 +
  35 +.snapshoot-container .snapshoot-content .snapshoot .snapshoot-shopinfo {
  36 + margin-top: -50rpx;
  37 + width: 460rpx;
  38 + height: 460rpx;
  39 + background-color: white;
  40 + box-shadow:5px 5px 3px lightgray;
  41 + border: 0.5rpx solid #e5e5e5;
  42 + display: flex;
  43 + flex-direction: column;
  44 + align-items: center;
  45 +}
  46 +
  47 +.snapshoot-container .snapshoot-content .snapshoot .snapshoot-shopinfo .img-logo {
  48 + margin-top: 30rpx;
  49 + width: 172rpx;
  50 + height: 172rpx;
  51 +}
  52 +
  53 +.snapshoot-container .snapshoot-content .snapshoot .snapshoot-shopinfo .shop-name {
  54 + margin-top: 36rpx;
  55 + font-size: 28rpx;
  56 + font-weight: bold;
  57 + text-align: center;
  58 +}
  59 +
  60 +.snapshoot-container .snapshoot-content .snapshoot .snapshoot-shopinfo .shop-intro {
  61 + margin-top: 61rpx;
  62 + font-size: 20rpx;
  63 + font-weight: bold;
  64 + text-align: left;
  65 + width: 401rpx;
  66 + height: 60rpx;
  67 + line-height:30rpx;
  68 + display: -webkit-box;
  69 + overflow: hidden;
  70 + text-overflow:ellipsis;
  71 + white-space: pre-wrap;
  72 + -webkit-box-orient: vertical;
  73 + -webkit-line-clamp: 2;
  74 +}
  75 +
  76 +.snapshoot .shop-miniqr {
  77 + display: flex;
  78 + flex-direction: column;
  79 + align-items: center;
  80 +}
  81 +
  82 +.yoho-logo {
  83 + width: 160rpx;
  84 + height: 29rpx;
  85 + margin-top: 21rpx;
  86 +}
  87 +
  88 +.snapshoot .shop-miniqr .shop-qrcode {
  89 + width: 130rpx;
  90 + height: 130rpx;
  91 + margin-top: 90rpx;
  92 +}
  93 +
  94 +.product-qrcode {
  95 + width: 130rpx;
  96 + height: 130rpx;
  97 + margin-top: 21rpx;
  98 +}
  99 +
  100 +.snapshoot-container .snapshoot-save {
  101 + width: 260rpx;
  102 + height: 88rpx;
  103 + background-color: red;
  104 + border-radius: 10rpx;
  105 + display: flex;
  106 + flex-direction: row;
  107 + flex-wrap: wrap;
  108 + justify-content: center;
  109 + align-items: center;
  110 +}
  111 +
  112 +.snapshoot-container .snapshoot-cancel {
  113 + margin-left: 20rpx;
  114 + width: 260rpx;
  115 + height: 88rpx;
  116 + background-color: white;
  117 + border-radius: 10rpx;
  118 + display: flex;
  119 + flex-direction: row;
  120 + flex-wrap: wrap;
  121 + justify-content: center;
  122 + align-items: center
  123 + }
  124 +
  125 +.img {
  126 + width: 41rpx;
  127 + height: 38rpx;
  128 +}
  129 +
  130 +.text {
  131 + font: 28rpx;
  132 + color: white;
  133 + text-align: center;
  134 +}
  135 +
  136 +.cancel-text {
  137 + font: 28rpx;
  138 + color: black;
  139 + text-align: center;
  140 +}
  141 +
  142 +.snapshoot-tips {
  143 + margin-top: 16rpx;
  144 + font-size: 16rpx;
  145 + color: #444444;
  146 +}
  147 +
  148 +
  149 +/*商品 */
  150 +.product-img-bg {
  151 + width: 100%;
  152 + height: 268rpx;
  153 +}
  154 +
  155 +.snapshoot-productinfo {
  156 + margin-top: -220rpx;
  157 + width: 460rpx;
  158 + height: 620rpx;
  159 + background-color: white;
  160 + box-shadow:5px 5px 3px rgba(0, 0, 0, 0.05);
  161 + border: 0.5rpx solid #e5e5e5;
  162 + display: flex;
  163 + flex-direction: column;
  164 + align-items: center;
  165 +}
  166 +
  167 +.snapshoot-union {
  168 + margin-top: -220rpx;
  169 + width: 460rpx;
  170 + height: 620rpx;
  171 + background-color: white;
  172 + box-shadow:5px 5px 3px rgba(0, 0, 0, 0.05);
  173 + display: flex;
  174 + flex-direction: column;
  175 + align-items: center;
  176 +}
  177 +
  178 +.product-defaultImage {
  179 + width: 100%;
  180 + height: 100%
  181 +}
  182 +
  183 +.product-info-content {
  184 + width: 100%;
  185 + height: 172rpx;
  186 + margin-top: -172rpx;
  187 + background-color: rgba(0, 0, 0, 0.5);
  188 + display: flex;
  189 + flex-direction: column;
  190 + align-items: center;
  191 +}
  192 +
  193 +.product-name {
  194 + width: 80%;
  195 + margin-top: 30rpx;
  196 + color: white;
  197 + text-align: center;
  198 + font-size: 26rpx;
  199 + margin-bottom: 20rpx;
  200 + line-height: 32rpx;
  201 + display: -webkit-box;
  202 + overflow: hidden;
  203 + text-overflow:ellipsis;
  204 + white-space: pre-wrap;
  205 + -webkit-box-orient: vertical;
  206 + -webkit-line-clamp: 2;
  207 +}
  208 +
  209 +.product-price {
  210 + color: white;
  211 + text-align: center;
  212 + font-size: 34rpx;
  213 +}
  214 +
  215 +.product-tips {
  216 + display: flex;
  217 + flex-direction: row;
  218 + justify-content: center;
  219 + align-items: center;
  220 + margin-top: 10rpx;
  221 +}
  222 +
  223 +.product-tips-img {
  224 + width: 18rpx;
  225 + height: 18rpx;
  226 +}
  227 +
  228 +.product-tips-text {
  229 + font-size: 16rpx;
  230 + color: #b0b0b0;
  231 + margin-left: 10rpx;
  232 +}
  233 +
  234 +
  235 +.product-miniqr {
  236 + /* margin-top: -20; */
  237 + display: flex;
  238 + flex-direction: column;
  239 + align-items: center;
  240 +}
  241 +
  242 +.snapshoot-bottom {
  243 + margin-left: 105rpx;
  244 + margin-top: 50rpx;
  245 + width: 540rpx;
  246 + height: 88rpx;
  247 + display: flex;
  248 + flex-direction: row;
  249 + flex-wrap: wrap;
  250 + justify-content: center;
  251 + align-items: center;
  252 +}
  253 +
  254 +.list-title {
  255 + width: 80%;
  256 + height: 70rpx;
  257 + margin-top: 30rpx;
  258 + color: white;
  259 + text-align: center;
  260 + font-size: 26rpx;
  261 + line-height: 35rpx;
  262 + display: -webkit-box;
  263 + overflow: hidden;
  264 + text-overflow:ellipsis;
  265 + white-space: pre-wrap;
  266 + -webkit-box-orient: vertical;
  267 + -webkit-line-clamp: 2;
  268 +}
  269 +
  270 +.list-content {
  271 + margin-top: 20rpx;
  272 + color: white;
  273 + text-align: center;
  274 + font-size: 14rpx;
  275 +}
  276 + /* .snapshoot-container .snapshoot-content .snapshoot-canvas {
  277 + width: 750rpx;
  278 + height: 1206rpx;
  279 + background-color: white;
  280 +} */
@@ -33,7 +33,7 @@ @@ -33,7 +33,7 @@
33 "list": [] 33 "list": []
34 }, 34 },
35 "miniprogram": { 35 "miniprogram": {
36 - "current": 1, 36 + "current": 2,
37 "list": [ 37 "list": [
38 { 38 {
39 "id": 0, 39 "id": 0,
@@ -48,9 +48,9 @@ @@ -48,9 +48,9 @@
48 "query": "limitProductCode=2018030117484051" 48 "query": "limitProductCode=2018030117484051"
49 }, 49 },
50 { 50 {
51 - "id": -1, 51 + "id": 2,
52 "name": "分享页", 52 "name": "分享页",
53 - "pathName": "pages/share/share", 53 + "pathName": "pages/snapshootShare/snapshootShare",
54 "query": "" 54 "query": ""
55 } 55 }
56 ] 56 ]
@@ -3,5 +3,5 @@ import jump from './jump'; @@ -3,5 +3,5 @@ import jump from './jump';
3 export default { 3 export default {
4 home: {path: '/pages/index/index'}, 4 home: {path: '/pages/index/index'},
5 productDetail: {path: '/pages/product/detail/detail'}, 5 productDetail: {path: '/pages/product/detail/detail'},
6 - snapShare: {path: '/pages/share/share'}, 6 + snapShare: {path: '/pages/snapshootShare/snapshootShare'},
7 }; 7 };