|
@@ -43,7 +43,8 @@ Page({
|
|
|
const self = this
|
|
|
|
|
|
const tokenData = await commonApi.getToken();
|
|
|
-
|
|
|
+ console.log(tokenData)
|
|
|
+ console.log(requestApi.HEAD.token)
|
|
|
if (tokenData.token && !requestApi.HEAD.token) {
|
|
|
console.log('设置token')
|
|
|
wx.setStorageSync('token', tokenData.token)
|
|
@@ -70,6 +71,12 @@ Page({
|
|
|
wx.setStorageSync('lat', latitude)
|
|
|
const rs = await storeApi.getNearStore(latitude, longitude)
|
|
|
console.log(rs.info);
|
|
|
+ if (!rs.info.distance) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: '该门店打样了哦',
|
|
|
+ })
|
|
|
+ }
|
|
|
self.setData({
|
|
|
locationFlag: true,
|
|
|
storeInfo: rs.info
|
|
@@ -80,7 +87,7 @@ Page({
|
|
|
}
|
|
|
})
|
|
|
} else {
|
|
|
- const rs = await storeApi.getStoreByI(options.storeId)
|
|
|
+ const rs = await storeApi.getStoreById(options.storeId)
|
|
|
self.setData({
|
|
|
storeInfo: rs.info
|
|
|
})
|
|
@@ -89,22 +96,22 @@ Page({
|
|
|
//根据机型设置现有的tab-content盒子高度
|
|
|
let windowHeight = parseInt(wx.getSystemInfoSync().windowHeight) * parseInt(750 / wx.getSystemInfoSync().windowWidth) - 185
|
|
|
|
|
|
- await this.getProductList();
|
|
|
- let tabs = this.data.tabs;
|
|
|
- let activeTab = this.data.activeTab;
|
|
|
- console.log(tabs[activeTab].list.length)
|
|
|
- let productHeight = tabs[activeTab].list.length * 170
|
|
|
- this.setData({
|
|
|
- tabHeight: windowHeight,
|
|
|
- productHeight
|
|
|
+ // await this.getProductList();
|
|
|
+ self.setData({
|
|
|
+ tabHeight: windowHeight
|
|
|
})
|
|
|
|
|
|
+
|
|
|
},
|
|
|
onShow: async function (op) {
|
|
|
console.log(op)
|
|
|
const self = this
|
|
|
+ if (self.data.isShow == 1) {
|
|
|
+ return
|
|
|
+ }
|
|
|
const tokenData = await commonApi.getToken();
|
|
|
if (tokenData.token && !requestApi.HEAD.token) {
|
|
|
+ console.log('onshow设置了token')
|
|
|
wx.setStorageSync('token', tokenData.token)
|
|
|
requestApi.HEAD.token = tokenData.token
|
|
|
}
|
|
@@ -115,11 +122,28 @@ Page({
|
|
|
chooseStoreId: 0
|
|
|
})
|
|
|
}
|
|
|
-
|
|
|
+ await this.productTypeList()
|
|
|
await this.getProductList();
|
|
|
-
|
|
|
+ let tabs = this.data.tabs;
|
|
|
+ let activeTab = this.data.activeTab;
|
|
|
+ let defaultH = '100%'
|
|
|
+ if (tabs[activeTab].list.length) {
|
|
|
+ defaultH = tabs[activeTab].list.length * 170
|
|
|
+ }
|
|
|
+ let productHeight = defaultH
|
|
|
+ self.setData({
|
|
|
+ productHeight,
|
|
|
+ isShow:1
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
+ productTypeList: async function(){
|
|
|
+ const self = this
|
|
|
+ const rs = await productApi.getProductTypeList(1,10)
|
|
|
+ self.setData({
|
|
|
+ tabs: rs.list
|
|
|
+ })
|
|
|
+ },
|
|
|
|
|
|
getProductList: async function (refresh = false) {
|
|
|
const self = this
|
|
@@ -130,7 +154,7 @@ Page({
|
|
|
|
|
|
|
|
|
|
|
|
- let prolist = await productApi.getProductList(activeTab + 1, pageNo[activeTab],10);
|
|
|
+ let prolist = await productApi.getProductList(tabs[activeTab].id, pageNo[activeTab],10);
|
|
|
pageSum[activeTab] = prolist.pageCount;
|
|
|
let list = prolist.list;
|
|
|
|
|
@@ -199,8 +223,20 @@ Page({
|
|
|
},
|
|
|
onTabClick(e) {
|
|
|
const index = e.detail.index
|
|
|
+ let tabs = this.data.tabs
|
|
|
+ let defaultH = 600
|
|
|
+ if (tabs[index].list && tabs[index].list.length) {
|
|
|
+ defaultH = tabs[index].list.length * 170
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ let productHeight = defaultH
|
|
|
+ console.log(productHeight)
|
|
|
+
|
|
|
+ console.log(tabs[index].list)
|
|
|
this.setData({
|
|
|
- activeTab: index
|
|
|
+ activeTab: index,
|
|
|
+ productHeight
|
|
|
})
|
|
|
},
|
|
|
|
|
@@ -324,4 +360,4 @@ Page({
|
|
|
url: '../appointment/appointment?' + 'shopId=' + shopId + '&productId=' + productId + '&address=' + address + "&shopName=" + shopName,
|
|
|
})
|
|
|
}
|
|
|
-})
|
|
|
+})
|