|
@@ -1,9 +1,20 @@
|
|
|
+const pages = require('../../mixin/pages')
|
|
|
+const { getShopDetail } = require('./api/index')
|
|
|
+let leftHeight = 0
|
|
|
+let rightHeight = 0
|
|
|
+let query = null
|
|
|
+
|
|
|
Page({
|
|
|
|
|
|
/**
|
|
|
* 页面的初始数据
|
|
|
*/
|
|
|
data: {
|
|
|
+ ...pages.data(),
|
|
|
+ listUrl: '/api/user/home/shop/product/list',
|
|
|
+ searchForm: {
|
|
|
+ shop_id: ''
|
|
|
+ },
|
|
|
background: ['demo-text-1', 'demo-text-2', 'demo-text-3'],
|
|
|
nav: [
|
|
|
{
|
|
@@ -16,16 +27,21 @@ Page({
|
|
|
}
|
|
|
],
|
|
|
active: '1',
|
|
|
- list: [],
|
|
|
leftList: [],
|
|
|
rightList: []
|
|
|
},
|
|
|
-
|
|
|
+ ...pages.methods,
|
|
|
/**
|
|
|
* 生命周期函数--监听页面加载
|
|
|
*/
|
|
|
onLoad(options) {
|
|
|
-
|
|
|
+ const { businessId } = options
|
|
|
+ this.setData({
|
|
|
+ 'searchForm.shop_id': businessId
|
|
|
+ }, () => {
|
|
|
+ this.fetchShopDetail()
|
|
|
+ this.fetchOrderList()
|
|
|
+ })
|
|
|
},
|
|
|
|
|
|
/**
|
|
@@ -60,21 +76,65 @@ Page({
|
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
|
|
*/
|
|
|
onPullDownRefresh() {
|
|
|
-
|
|
|
+ if (this.data.freshing) {
|
|
|
+ return
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ freshing: true
|
|
|
+ })
|
|
|
+ this.fetchShopDetail()
|
|
|
+ this.bindCallBack()
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 页面上拉触底事件的处理函数
|
|
|
*/
|
|
|
onReachBottom() {
|
|
|
-
|
|
|
+ this.fetchOrderList()
|
|
|
},
|
|
|
-
|
|
|
- /**
|
|
|
- * 用户点击右上角分享
|
|
|
- */
|
|
|
- onShareAppMessage() {
|
|
|
-
|
|
|
+ bindCallBack() {
|
|
|
+ this.fetchShopDetail()
|
|
|
+ this.refreshOrderList()
|
|
|
+ },
|
|
|
+ async fetchShopDetail() {
|
|
|
+ try {
|
|
|
+ const { status, data, msg } = await getShopDetail(this.data.searchForm.shop_id)
|
|
|
+ if (status) {
|
|
|
+
|
|
|
+ } else {
|
|
|
+ wx.showToast({
|
|
|
+ title: msg,
|
|
|
+ icon: 'none'
|
|
|
+ })
|
|
|
+ }
|
|
|
+ } catch (err) {}
|
|
|
+ },
|
|
|
+ async isLeft(list) {
|
|
|
+ const {
|
|
|
+ leftList,
|
|
|
+ rightList
|
|
|
+ } = this.data
|
|
|
+ query = wx.createSelectorQuery()
|
|
|
+ for (const item of list) {
|
|
|
+ leftHeight <= rightHeight ? leftList.push(item) : rightList.push(item)
|
|
|
+ await this.getBoxHeight(leftList, rightList)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getBoxHeight(leftList, rightList) {
|
|
|
+ return new Promise((resolve, reject) => {
|
|
|
+ this.setData({
|
|
|
+ leftList,
|
|
|
+ rightList
|
|
|
+ }, () => {
|
|
|
+ query.select('.waterfall-left').boundingClientRect()
|
|
|
+ query.select('.waterfall-right').boundingClientRect()
|
|
|
+ query.exec((res) => {
|
|
|
+ leftHeight = res[0].height
|
|
|
+ rightHeight = res[1].height
|
|
|
+ resolve()
|
|
|
+ })
|
|
|
+ })
|
|
|
+ })
|
|
|
},
|
|
|
handleNav(e) {
|
|
|
const { value } = e.detail
|