|
| xqd
@@ -1,7 +1,5 @@
|
|
|
import loading from './draw/loading.js'
|
|
|
import { basePage } from './draw/base.js'
|
|
|
-import FLD from './draw/FirstLevelDirectory.js'
|
|
|
-import SLD from './draw/SecondLevelDirectory.js'
|
|
|
import Content from './draw/content.js'
|
|
|
import Details from './draw/details.js'
|
|
|
import setPrice from './draw/price.js'
|
|
| xqd
@@ -16,7 +14,6 @@ import HelpModal from './draw/HelpModal.js';
|
|
|
var url = 'https://t6.9026.com/api/album/cat?parent_id=0&store_id=1'//初始顶级目录url
|
|
|
var SLDsource = []//二级目录对象列表
|
|
|
var GoodsSource = []//商品对象列表
|
|
|
-var AllSource = []//所有商品对象
|
|
|
var GoodsDetail//商品详情
|
|
|
var flag1 = 0//通过flag1来判断现在处于哪一个顶级目录,然后利用flag1传参数获取该顶级目录下的二级目录信息
|
|
|
var flag2 = 0//通过flag1来判断现在处于哪一个二级目录,然后利用flag2传参数获取该顶级目录下的商品列表
|
|
| xqd
@@ -24,19 +21,9 @@ var flag3 = 0//通过flag3来判断选择的是哪一个商品,然后获取它
|
|
|
var flag4 = 0//价格设置参考参数
|
|
|
var flag5 = 0//风格菜单选中状态
|
|
|
|
|
|
-//是否为iPhoneX
|
|
|
-let isiPhoneX
|
|
|
//定义画布
|
|
|
-//let canvas = wx.createCanvas()
|
|
|
let context
|
|
|
|
|
|
-//中间商品列表显示区绘制辅助变量
|
|
|
-let imgx = 0
|
|
|
-let imgy = 0
|
|
|
-let imgX = 0
|
|
|
-let imgY = 0
|
|
|
-let imgyy = 0
|
|
|
-
|
|
|
//定义按钮区域
|
|
|
//一级目录按钮区域
|
|
|
import {
|
|
| xqd
@@ -48,10 +35,13 @@ import {
|
|
|
ContentbtnArea,
|
|
|
SLDArea,
|
|
|
setpriceArea,
|
|
|
+ TopArea,
|
|
|
SearchButtonArea,
|
|
|
SetPriceBtnArea,
|
|
|
page,
|
|
|
modalCloseBtnArea,
|
|
|
+ ProductBuyModalBtnArea,
|
|
|
+ ProductSizeModalBtnArea,
|
|
|
triggerMoveDelta,
|
|
|
homepage_page_size
|
|
|
} from './conf/data.js'
|
|
| xqd
@@ -61,19 +51,9 @@ let current_page = page.homepage
|
|
|
//二级目录按钮区域
|
|
|
let SLDbtnArea = []
|
|
|
|
|
|
-let CA = []
|
|
|
-let DA = []
|
|
|
-let SA = []
|
|
|
-
|
|
|
-
|
|
|
-//搜索按钮
|
|
|
-let pageArea = []
|
|
|
-//尺寸安装图片转换界面
|
|
|
-let attrArea = []
|
|
|
-
|
|
|
-let sp = []
|
|
|
let priceModal
|
|
|
-
|
|
|
+let productBuyModal
|
|
|
+let isTouchMoving = false
|
|
|
|
|
|
GameGlobal.isiPhoneX = false
|
|
|
let res = wx.getSystemInfoSync()
|
|
| xqd
@@ -103,33 +83,10 @@ function init() {
|
|
|
context.fillStyle = '#fff'
|
|
|
context.fillRect(0, 0, screenWidth * drawRatio, screenHeight * drawRatio)
|
|
|
|
|
|
- if (isiPhoneX) {
|
|
|
- imgx = (screenWidth - 240 - 35) / 3
|
|
|
- imgy = (screenHeight - 118) / 3
|
|
|
- } else {
|
|
|
- imgx = (screenWidth - 180) / 3
|
|
|
- imgy = (screenHeight - 118) / 3
|
|
|
- }
|
|
|
-
|
|
|
- imgX = imgx
|
|
|
- imgY = imgy
|
|
|
- imgyy = (screenHeight - 95) / 9
|
|
|
-
|
|
|
- //详情界面按钮区域
|
|
|
- var DA = [{ startX: 0, startY: screenHeight - 50, endX: 50, endY: screenHeight }, { startX: screenWidth / 2 - 200, startY: screenHeight - 35, endX: screenWidth / 2 - 110, endY: screenHeight - 12 }, { startX: screenWidth / 2 - 100, startY: screenHeight - 35, endX: screenWidth / 2 - 10, endY: screenHeight - 12 }, { startX: screenWidth / 2, startY: screenHeight - 35, endX: screenWidth / 2 + 90, endY: screenHeight - 12 }, { startX: screenWidth / 2 + 100, startY: screenHeight - 35, endX: screenWidth / 2 + 190, endY: screenHeight - 12 }, { startX: 10, startY: screenHeight / 2 - 15, endX: 40, endY: screenHeight / 2 + 15 }, { startX: screenWidth - 40, startY: screenHeight / 2 - 15, endX: screenWidth - 10, endY: screenHeight / 2 + 15 }]
|
|
|
- //搜索按钮
|
|
|
- pageArea = [{ startX: screenWidth - 50, startY: screenHeight - 30, endX: screenWidth, endY: screenHeight }, { startX: screenWidth - 50, startY: screenHeight - 65, endX: screenWidth, endY: screenHeight - 35 }]
|
|
|
- //尺寸安装图片转换界面
|
|
|
- attrArea = [{ startX: (screenWidth - (screenHeight - 100) * 1.778) / 2, startY: 30, endX: screenWidth / 2, endY: 60 }, { startX: screenWidth / 2, startY: 30, endX: (screenWidth + (screenHeight - 100) * 1.778) / 2 - 30, endY: 60 }, { startX: (screenWidth + (screenHeight - 100) * 1.778) / 2 - 30, startY: 30, endX: (screenWidth + (screenHeight - 100) * 1.778) / 2, endY: 60 }]
|
|
|
-
|
|
|
- sp = [{ startX: screenWidth / 2 - 150, startY: screenHeight / 2 - 80, endX: screenWidth / 2 + 150, endY: screenHeight / 2 }, { startX: screenWidth / 2 - 40, startY: screenHeight / 2 + 30, endX: screenWidth / 2 + 40, endY: screenHeight / 2 + 70 },]
|
|
|
showLoading()
|
|
|
}
|
|
|
init()
|
|
|
|
|
|
-//定义目录选中状态
|
|
|
-let FLDstatus = false
|
|
|
-let SLDstatus = false
|
|
|
//定义是否在详情界面状态
|
|
|
let Detailstatus = false
|
|
|
//是否隐藏了按钮
|
|
| xqd
@@ -193,7 +150,7 @@ function reStart() {
|
|
|
reset()//清空之前屏幕上的绘制内容,减少缓存占用,及信息重叠
|
|
|
if (current_page === page.homepage || current_page === page.set_price) {
|
|
|
//绘制两个侧边栏
|
|
|
- basePage(context, KeyWord, isAgent, flag1, flag5, setprice).then(({height}) => {
|
|
|
+ return basePage(context, KeyWord, isAgent, flag1, flag5, setprice).then(({height}) => {
|
|
|
if (current_page === page.homepage) {
|
|
|
new Content(GoodsSource, product_page_index, height).draw()
|
|
|
} else {
|
|
| xqd
@@ -208,10 +165,10 @@ function reStart() {
|
|
|
let img = new Image()
|
|
|
img.src = GoodsDetail.detail_pic
|
|
|
if (Buttonstatus == false) {
|
|
|
- dt.showDetails(context, GoodsDetail.detail_pic, GoodsDetail.name, GoodsDetail.price)
|
|
|
+ return dt.showDetails(context, GoodsDetail.detail_pic, GoodsDetail.name, GoodsDetail.price)
|
|
|
}
|
|
|
else {
|
|
|
- drawImage(GoodsDetail.detail_pic, 0, 0, screenWidth, screenHeight)
|
|
|
+ return drawImage(GoodsDetail.detail_pic, 0, 0, screenWidth, screenHeight)
|
|
|
}
|
|
|
|
|
|
} catch (e) {
|
|
| xqd
@@ -238,6 +195,20 @@ wx.onTouchStart(((e) => {
|
|
|
}
|
|
|
|
|
|
}))
|
|
|
+wx.onTouchMove((e) =>{
|
|
|
+ var endX = e.changedTouches[0].clientX * 2 - offsetX
|
|
|
+ var endY = e.changedTouches[0].clientY * 2
|
|
|
+ switch (current_page) {
|
|
|
+
|
|
|
+ case page.product_buy_modal:
|
|
|
+ handleProductBuyModalMoveEvents(startx, starty, endX, endY)
|
|
|
+ startx = endX
|
|
|
+ starty = endY
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+})
|
|
|
+
|
|
|
//滑动响应函数
|
|
|
wx.onTouchEnd(((e) => {
|
|
|
var endX = e.changedTouches[0].clientX * 2 - offsetX
|
|
| xqd
@@ -284,9 +255,11 @@ wx.onTouchEnd(((e) => {
|
|
|
break;
|
|
|
case page.product_buy_modal:
|
|
|
handleModalCloseModal(endX, endY)
|
|
|
+ handleProductBuyModalEvents(endX, endY)
|
|
|
break;
|
|
|
case page.product_size_modal:
|
|
|
handleModalCloseModal(endX, endY)
|
|
|
+ handleProductSizeModalEvents(endX, endY)
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
| xqd
@@ -370,12 +343,13 @@ function handelExitEvents (x, y) {
|
|
|
}
|
|
|
function handleHomepageEvents(x, y) {
|
|
|
//右边一级目录控制
|
|
|
- if (x >= FLDbtnArea[0].startX) {
|
|
|
+ if (x >= FLDbtnArea[0].startX && y > TopArea[0].endY) {
|
|
|
for (let i = 0, len = FLDbtnArea.length; i < len; i++) {
|
|
|
if (x >= FLDbtnArea[i].startX
|
|
|
&& x <= FLDbtnArea[i].endX
|
|
|
&& y >= FLDbtnArea[i].startY
|
|
|
&& y <= FLDbtnArea[i].endY) {
|
|
|
+ KeyWord = ''
|
|
|
for (let i in FLDbtnArea) {//点击该按钮的时候,它变为活跃状态status=true,而其他所有按钮变为非活跃状态status=false
|
|
|
FLDbtnArea[i].status = false
|
|
|
}
|
|
| xqd
@@ -388,16 +362,17 @@ function handleHomepageEvents(x, y) {
|
|
|
flag5 = 0//风格重置为新品
|
|
|
status = 2
|
|
|
//FLDbtnArea[btn].status = true
|
|
|
- current_page = page.homepage
|
|
|
+ // current_page = page.homepage
|
|
|
getFLDsource(callback1, url)//重绘
|
|
|
}
|
|
|
}
|
|
|
- } else if (x <= SLDArea[0].endX) {
|
|
|
+ } else if (x <= SLDArea[0].endX && y > TopArea[0].endY) {
|
|
|
//左边二级目录控制
|
|
|
for (let i = 0; i < SLDArea.length; i++) {
|
|
|
let d = SLDArea[i]
|
|
|
+ KeyWord = ''
|
|
|
if (d && x >= d.startX && x <= d.endX && y >= d.startY && y <= d.endY) {
|
|
|
- current_page = page.homepage
|
|
|
+ // current_page = page.homepage
|
|
|
if (i === 0) { //新品上市
|
|
|
product_page_index = 0
|
|
|
flag2 = 0
|
|
| xqd
@@ -421,6 +396,7 @@ function handleHomepageEvents(x, y) {
|
|
|
setMobile = false
|
|
|
if (setprice == true) { //退出报价
|
|
|
setprice = false
|
|
|
+ current_page = page.homepage
|
|
|
reStart()
|
|
|
} else {
|
|
|
current_page = page.set_price
|
|
| xqd
@@ -440,7 +416,7 @@ function handleHomepageEvents(x, y) {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- } else if (y <= SearchButtonArea[0].startY) {
|
|
|
+ } else if (y <= TopArea[0].endY) {
|
|
|
//搜索
|
|
|
if (x >= SearchButtonArea[0].startX
|
|
|
&& x <= SearchButtonArea[0].endX
|
|
| xqd
@@ -519,7 +495,7 @@ function handleProductHomepageEvents(x, y) {
|
|
|
for (let i = 0; i < DetailbtnArea.length; i++) {
|
|
|
let d = DetailbtnArea[i]
|
|
|
if (x >= d.startX && x <= d.endX && y >= d.startY && y <= d.endY) {
|
|
|
- if (i === 0) {
|
|
|
+ if (i === 0) { //返回
|
|
|
Detailstatus = false
|
|
|
current_page = page.homepage
|
|
|
reStart() //重绘
|
|
| xqd
@@ -532,13 +508,14 @@ function handleProductHomepageEvents(x, y) {
|
|
|
} else if (i === 2) {//联系商家
|
|
|
current_page = page.product_contact_modal
|
|
|
let tel = GoodsDetail.mobile
|
|
|
- new ContactModal(context, GoodsDetail.name, tel, GoodsDetail.addr).draw()
|
|
|
+ new ContactModal(context, FactoryName, tel, GoodsDetail.addr).draw()
|
|
|
} else if (i === 3) {//详情&购买
|
|
|
current_page = page.product_buy_modal
|
|
|
- new ProductModal(context, GoodsDetail).draw()
|
|
|
+ productBuyModal = new ProductModal(context, GoodsDetail)
|
|
|
+ productBuyModal.draw()
|
|
|
} else if (i === 4) {//尺寸&安装
|
|
|
current_page = page.product_size_modal
|
|
|
- new SizeModal(context, GoodsDetail).draw()
|
|
|
+ new SizeModal(context, GoodsDetail, 'size').draw()
|
|
|
} else if (i === 5) {//上一张
|
|
|
Buttonstatus = false
|
|
|
if (flag3 <= 0) {
|
|
| xqd
@@ -638,6 +615,55 @@ function handleSetPriceModalEvents(x, y) {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
+let i = 0
|
|
|
+function handleProductBuyModalMoveEvents(x1, y1, x2, y2) {
|
|
|
+ let p
|
|
|
+ if (!isTouchMoving) {
|
|
|
+ isTouchMoving = true
|
|
|
+ i++
|
|
|
+ console.log("start:" + i)
|
|
|
+ p = productBuyModal.scroll(x1, y1, x2, y2)
|
|
|
+ if (p) {
|
|
|
+ p.then(() => {
|
|
|
+ isTouchMoving = false
|
|
|
+ console.log("end:" + i)
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ isTouchMoving = false
|
|
|
+ console.log("end:" + i)
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+function handleProductBuyModalEvents(x, y) {
|
|
|
+ let d = ProductBuyModalBtnArea[3]
|
|
|
+ if (x >= d.startX && x <= d.endX && y >= d.startY && y <= d.endY) {
|
|
|
+ console.error('没有收藏接口')
|
|
|
+ }
|
|
|
+}
|
|
|
+function handleProductSizeModalEvents(x, y) {
|
|
|
+ let d0 = ProductSizeModalBtnArea[0]
|
|
|
+ let d1 = ProductSizeModalBtnArea[1]
|
|
|
+ let d2 = ProductSizeModalBtnArea[2]
|
|
|
+ if (x >= d0.startX && x <= d0.endX && y >= d0.startY && y <= d0.endY) {
|
|
|
+ reStart().then(() => {
|
|
|
+
|
|
|
+ new SizeModal(context, GoodsDetail, 'size').draw()
|
|
|
+ })
|
|
|
+ } else if (x >= d1.startX && x <= d1.endX && y >= d1.startY && y <= d1.endY) {
|
|
|
+ reStart().then(() => {
|
|
|
+
|
|
|
+ new SizeModal(context, GoodsDetail, 'pic').draw()
|
|
|
+ })
|
|
|
+ } else if (x >= d2.startX && x <= d2.endX && y >= d2.startY && y <= d2.endY) {
|
|
|
+ reStart().then(() => {
|
|
|
+
|
|
|
+ new SizeModal(context, GoodsDetail, 'video').draw()
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//清除之前绘制内容
|
|
|
function reset() {
|
|
|
context.clearRect(0, 0, screenWidth, screenHeight)
|
|
| xqd
@@ -776,12 +802,17 @@ function getGoodsDetail(callback4, GoodsSource) {
|
|
|
Detailstatus = false
|
|
|
// reStart()
|
|
|
}
|
|
|
+ wx.showLoading({
|
|
|
+ title: 'loading',
|
|
|
+ })
|
|
|
+
|
|
|
wx.request({
|
|
|
url: ur,
|
|
|
data: {
|
|
|
},
|
|
|
method: 'GET',
|
|
|
success: function (res) {
|
|
|
+ wx.hideLoading()
|
|
|
try {
|
|
|
GoodsDetail = {}
|
|
|
let test = JSON.stringify(res.data)
|
|
| xqd
@@ -800,14 +831,6 @@ function getGoodsDetail(callback4, GoodsSource) {
|
|
|
})
|
|
|
}
|
|
|
function callback4(res) {
|
|
|
- if (GoodsDetail == null) {
|
|
|
- // wx.hideLoading()
|
|
|
- } else {
|
|
|
- wx.showLoading({
|
|
|
- title: 'loading',
|
|
|
- })
|
|
|
- //console.log(GoodsDetail)
|
|
|
- }
|
|
|
if (Detailstatus == true)//如果没获取到详情,说明所点击区域没有元素,不进行重绘
|
|
|
reStart()
|
|
|
}
|
|
| xqd
@@ -848,7 +871,7 @@ function UserLogin() {
|
|
|
getFLDsource(callback1, url)
|
|
|
}
|
|
|
else {
|
|
|
- isAgent = false
|
|
|
+ isAgent = true
|
|
|
var test = wx.getLaunchOptionsSync()
|
|
|
console.log(test)
|
|
|
agent_id = test.query.agent_id
|