完成二维码显示

code
Ge Hao 8 years ago
parent 56c81fb1d6
commit 206f7f3516
  1. 19
      pages/show_product/show_product.js
  2. 1
      pages/show_product/show_product.wxml
  3. 11
      pages/show_product/show_product.wxss
  4. 13
      utils/product.js

@ -11,6 +11,7 @@ Page({
pixelRatio: 2, pixelRatio: 2,
accountType: '', accountType: '',
from_share: false, from_share: false,
codeFloatingData: {}, codeFloatingData: {},
codeFloatingStyle: { codeFloatingStyle: {
width: 100, width: 100,
@ -20,7 +21,9 @@ Page({
codeFloatingPos: { codeFloatingPos: {
left: 650, left: 650,
top: 650 top: 650
} },
codeFloatingUrl: '',
codeFloatingImgStyle: ''
}, },
onShareAppMessage: function () { onShareAppMessage: function () {
@ -77,6 +80,11 @@ Page({
title: product.name 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() { onShow() {
@ -176,13 +184,13 @@ Page({
timingFunction: 'ease', timingFunction: 'ease',
}) })
var state var state, width
if (this.data.codeFloatingState == "small") { if (this.data.codeFloatingState == "small") {
let width = "750rpx" width = "750rpx"
state = 'big' state = 'big'
animation.left(0).top('100rpx').width(width).height(width).step() animation.left(0).top('100rpx').width(width).height(width).step()
} else { } else {
let width = "100rpx" width = "100rpx"
let pos = this.data.codeFloatingPos let pos = this.data.codeFloatingPos
state = 'small' state = 'small'
animation.left(`${pos.left}rpx`).top(`${pos.top}rpx`).width(width).height(width).step() animation.left(`${pos.left}rpx`).top(`${pos.top}rpx`).width(width).height(width).step()
@ -190,7 +198,8 @@ Page({
this.setData({ this.setData({
codeFloatingData: animation.export(), codeFloatingData: animation.export(),
codeFloatingState: state codeFloatingState: state,
codeFloatingImgStyle: `width: ${width}; height: ${width};`
}) })
} }
}) })

@ -38,4 +38,5 @@
</view> </view>
<view id="codeFloating" catchtouchmove="changeCodeState" catchtap="catchScaleCode" animation="{{codeFloatingData}}"> <view id="codeFloating" catchtouchmove="changeCodeState" catchtap="catchScaleCode" animation="{{codeFloatingData}}">
<image src="{{codeFloatingUrl || '../../images/1.png'}}" style="{{codeFloatingImgStyle}}"></image>
</view> </view>

@ -55,7 +55,12 @@
bottom: 20%; bottom: 20%;
left: 650rpx; left: 650rpx;
top: 650rpx; top: 650rpx;
background:red; background: transparent;
height:100rpx; height: 100rpx;
width:100rpx; width: 100rpx;
}
#codeFloating image {
height: 100rpx;
width: 100rpx;
} }

@ -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 = { module.exports = {
getProducts (resolve) { getProducts (resolve) {
@ -48,5 +57,9 @@ module.exports = {
getCategories (data, resolve, reject) { getCategories (data, resolve, reject) {
return getCategories(data, resolve, reject) return getCategories(data, resolve, reject)
},
getProductPageQrCode (data, resolve) {
return getProductPageQrCode(data, resolve)
} }
} }

Loading…
Cancel
Save