Просмотр исходного кода

open product page from product share
reduce space between header and content

Jeffry Yu 7 лет назад
Родитель
Сommit
2f560c8c70
4 измененных файлов с 25 добавлено и 14 удалено
  1. 2 2
      Album/js/draw/base.js
  2. 1 1
      Album/js/draw/content.js
  3. 1 1
      Album/js/draw/price.js
  4. 21 10
      Album/js/main.js

+ 2 - 2
Album/js/draw/base.js

xqd xqd
@@ -75,7 +75,7 @@ function leftNav(context, active_style, isAgent, set_price) {
   let active_btn
 
   SLDArea.splice(0, SLDArea.length)
-  let next = drawImage(context, 'images/homepage/bg_style@2x.png', 0, header_height + 20, null, screenHeight - header_height - 20).then((dimension) => {
+  let next = drawImage(context, 'images/homepage/bg_style@2x.png', 0, header_height + 10, null, screenHeight - header_height - 10).then((dimension) => {
     bg_width = dimension.width
     bg_height = dimension.height
     return drawImage(context, 'images/homepage/text_eu@2x.png', bg_width / 2, dimension.startY + padding, 'center')
@@ -166,7 +166,7 @@ function rightNav(context, active_category) {
   new_canvas.height = screenHeight
   let new_context = new_canvas.getContext('2d')
 
-  return drawImage(new_context, 'images/homepage/bg_category@2x.png', screenWidth, header_height + 20, null, screenHeight - header_height - 20, 'right').then((dimension) => {
+  return drawImage(new_context, 'images/homepage/bg_category@2x.png', screenWidth, header_height + 10, null, screenHeight - header_height - 10, 'right').then((dimension) => {
     bg_width = dimension.width
     bg_height = dimension.height
     bg_startX = dimension.startX

+ 1 - 1
Album/js/draw/content.js

xqd
@@ -165,7 +165,7 @@ export default class Content {
     for (let i = start; i < end; i++) {
       current_index = i - start
       let x = (current_index % this.line_items) * this.item_width + startX + this.h_gutter * (current_index % this.line_items + 1)
-      let y = Math.floor(current_index / this.line_items) * (item_height + this.v_gutter) + startY + 20
+      let y = Math.floor(current_index / this.line_items) * (item_height + this.v_gutter) + startY + 10
       let d = this.data[i]
       promises[i] = drawImage(context, 'images/homepage/bg_prod@2x.png', x, y, this.item_width, this.item_height).then((dimension, current_index) => {
 

+ 1 - 1
Album/js/draw/price.js

xqd
@@ -67,7 +67,7 @@ export default class Price{
     for (let i = start; i < end; i++) {
       current_index = i - start
       let x = (current_index % this.line_items) * this.item_width + startX + this.h_gutter * (current_index % this.line_items + 1)
-      let y = Math.floor(current_index / this.line_items) * (item_height + this.v_gutter) + startY + 20
+      let y = Math.floor(current_index / this.line_items) * (item_height + this.v_gutter) + startY + 10
       let d = this.data[i]
 
       promises[i] = drawImage(context, d.cover_pic, startX + padding, startY + 20 + current_index * (this.item_height + this.v_gutter), 88.88 * this.item_height / 50, this.item_height).then((dimension) => {

+ 21 - 10
Album/js/main.js

xqd xqd xqd xqd xqd xqd xqd xqd
@@ -201,7 +201,6 @@ function reStart(dontReset) {
         title: '暂无详情',
         icon: 'none'
       })
-      reStart()
     }
   }
 }
@@ -468,13 +467,14 @@ function handleHomepageEvents(x, y) {
         confirmHold: true,
         confirmType: 'done',
         success: function () {
-          wx.onKeyboardConfirm(((res) => {
+          wx.onKeyboardConfirm(function handleKeyboardConfirm(res) {
+            wx.offKeyboardConfirm(handleKeyboardConfirm)
             wx.hideKeyboard({})
             if (res.value && res.value !== KeyWord) {
               KeyWord = res.value
               search(KeyWord)
             }
-          }))
+          })
         }
       })
     }
@@ -497,11 +497,12 @@ function handleHomepageEvents(x, y) {
             confirmHold: true,
             confirmType: 'done',
             success: function () {
-              wx.onKeyboardConfirm(((res) => {
+              wx.onKeyboardConfirm(function handleKeyboardConfirm(res) {
+                wx.offKeyboardConfirm(handleKeyboardConfirm)
                 pricein = res.value
                 priceModal.updatePrice(pricein)
                 wx.hideKeyboard({})
-              }))
+              })
             }
           })
         })
@@ -550,7 +551,7 @@ function handleProductHomepageEvents(x, y) {
          } else if (i === 1) {//分享好友
            wx.shareAppMessage({
              //title: '经销商id:' + agent_id,
-             query: 'agent_id=' + agent_id
+             query: 'agent_id=' + agent_id + '&product_id=' + GoodsDetail.id
            })
 
          } else if (i === 2) {//联系商家
@@ -638,11 +639,12 @@ function handleSetPriceModalEvents(x, y) {
       confirmHold: true,
       confirmType: 'done',
       success: function () {
-        wx.onKeyboardConfirm(((res) => {
+        wx.onKeyboardConfirm(function handleKeyboardConfirm(res) {
+          wx.offKeyboardConfirm(handleKeyboardConfirm)
           pricein = res.value
           priceModal.updatePrice(pricein)
           wx.hideKeyboard({})
-        }))
+        })
       }
     })
   } else if (x >= SetPriceBtnArea[1].startX
@@ -665,6 +667,7 @@ function handleSetPriceModalEvents(x, y) {
       },
       method: 'GET',
       success: function () {
+        wx.hideLoading()
         wx.showToast({
           title: GoodsSource[flag4].name + '价格已更新为' + pricein,
           icon: 'none',
@@ -910,7 +913,15 @@ function callback3(res) {
   console.log(GoodsSource)
 
   isLoading = false
-  reStart()
+
+  reStart().then(() => {
+    let launchOption = wx.getLaunchOptionsSync()
+    if (typeof launchOption.query.product_id !== 'undefined') {
+      console.log("by share", launchOption)
+      current_page = page.product_homepage
+      getGoodsDetail(callback4, launchOption.query.prouct_id)
+    }
+  })
 }
 function getGoodsDetail(callback4, GoodsSource) {
   //如果所点击的区域没有商品展示,那么不进入详情界面
@@ -924,7 +935,7 @@ function getGoodsDetail(callback4, GoodsSource) {
     data: {
       store_id: 1,
       agent_id: agent_id,
-      goods_id: GoodsSource[flag3].id,
+      goods_id: Array.isArray(GoodsSource) ? GoodsSource[flag3].id : GoodsSource,
       user_id: user_id
     },
     method: 'GET',