From 206f7f35167d34b47a35d39d5cf67c7f5e2d53dd Mon Sep 17 00:00:00 2001 From: Ge Hao Date: Fri, 20 Jan 2017 16:24:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E4=BA=8C=E7=BB=B4=E7=A0=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/show_product/show_product.js | 19 ++++++++++++++----- pages/show_product/show_product.wxml | 1 + pages/show_product/show_product.wxss | 11 ++++++++--- utils/product.js | 13 +++++++++++++ 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/pages/show_product/show_product.js b/pages/show_product/show_product.js index be75219..9ef7946 100644 --- a/pages/show_product/show_product.js +++ b/pages/show_product/show_product.js @@ -11,6 +11,7 @@ Page({ pixelRatio: 2, accountType: '', from_share: false, + codeFloatingData: {}, codeFloatingStyle: { width: 100, @@ -20,7 +21,9 @@ Page({ codeFloatingPos: { left: 650, top: 650 - } + }, + codeFloatingUrl: '', + codeFloatingImgStyle: '' }, onShareAppMessage: function () { @@ -77,6 +80,11 @@ Page({ title: product.name }) } + + var reqPath = {path: `pages/show_product/show_product?id=${this.data.product.id}&share=1`} + productUtil.getProductPageQrCode(reqPath, function(resp){ + that.setData({codeFloatingUrl: resp.data.url}) + }) }, onShow() { @@ -176,13 +184,13 @@ Page({ timingFunction: 'ease', }) - var state + var state, width if (this.data.codeFloatingState == "small") { - let width = "750rpx" + width = "750rpx" state = 'big' animation.left(0).top('100rpx').width(width).height(width).step() } else { - let width = "100rpx" + width = "100rpx" let pos = this.data.codeFloatingPos state = 'small' animation.left(`${pos.left}rpx`).top(`${pos.top}rpx`).width(width).height(width).step() @@ -190,7 +198,8 @@ Page({ this.setData({ codeFloatingData: animation.export(), - codeFloatingState: state + codeFloatingState: state, + codeFloatingImgStyle: `width: ${width}; height: ${width};` }) } }) diff --git a/pages/show_product/show_product.wxml b/pages/show_product/show_product.wxml index 47039e8..5de4e5c 100644 --- a/pages/show_product/show_product.wxml +++ b/pages/show_product/show_product.wxml @@ -38,4 +38,5 @@ + \ No newline at end of file diff --git a/pages/show_product/show_product.wxss b/pages/show_product/show_product.wxss index 629e280..024ac3a 100644 --- a/pages/show_product/show_product.wxss +++ b/pages/show_product/show_product.wxss @@ -55,7 +55,12 @@ bottom: 20%; left: 650rpx; top: 650rpx; - background:red; - height:100rpx; - width:100rpx; + background: transparent; + height: 100rpx; + width: 100rpx; +} + +#codeFloating image { + height: 100rpx; + width: 100rpx; } \ No newline at end of file diff --git a/utils/product.js b/utils/product.js index 5093daf..93d5e67 100644 --- a/utils/product.js +++ b/utils/product.js @@ -32,6 +32,15 @@ function getCategories (data, resolve, reject) { }) } +function getProductPageQrCode (data, resolve) { + app.request({ + url: `${app.globalData.API_URL}/product_qr_codes/image`, + data: data, + success: resolve, + fail: function() {} + }) +} + module.exports = { getProducts (resolve) { @@ -48,5 +57,9 @@ module.exports = { getCategories (data, resolve, reject) { return getCategories(data, resolve, reject) + }, + + getProductPageQrCode (data, resolve) { + return getProductPageQrCode(data, resolve) } }