123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153 |
- // nova-tourism/pages/collect/good-list/index.js
- const Parse = getApp().Parse;
- const company = getApp().globalData.company;
- const uid = Parse.User.current()?.id
- const req = require('../../../../utils/request')
- let {
- statusBarHeight,
- screenHeight,
- screenWidth,
- safeArea
- } = wx.getSystemInfoSync()
- let custom = wx.getMenuButtonBoundingClientRect()
- let customHeight = custom.height
- let customWidth = custom.width
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- goodList: [],
- searchTimeOut: null,
- value:'',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- let nav_px = statusBarHeight + customHeight + 10
- let scroll_px = +safeArea.bottom - statusBarHeight - customHeight
- let {store_id}=options
- this.setData({
- nav_px,
- scroll_px,
- cart_buttom: 120,
- statusBarHeight,
- customWidth,
- store_id
- })
- this.getGood()
- },
- /**搜索框输入内容 */
- searchInput() {
- let {
- searchTimeOut
- } = this.data
- if (searchTimeOut) clearTimeout(searchTimeOut)
- let that = this
- let timeOut = setTimeout(() => {
- that.setData({
- goodList: []
- })
- that.getGood()
- }, 500);
- this.setData({
- searchTimeOut: timeOut
- })
- },
- /**获取商品 */
- async getGood() {
- let {
- goodList,
- store_id,
- value
- } = this.data
- if (value && value != '') {}
- let sql = `SELECT good."objectId",good."name",good."price",good."image"
- FROM "ShopGoods" good
- WHERE good."company" = '${company}'
- AND good."isDeleted" IS NOT TRUE
- ${store_id?`AND good."shopStore" = '${store_id}'`:''}
- AND good."status" IS TRUE
- AND good."name" LIKE '%${value}%'
- ORDER BY COALESCE(good."isRecom", FALSE) DESC,
- CASE WHEN good."top"= 0 THEN 1 ELSE 0 END,
- good."top" ASC
- LIMIT 30 OFFSET ${goodList?.length||0}`
- let list = await req.customSQL(sql)||[]
- console.log(list)
- this.setData({
- goodList:[...(goodList||[]),...list]
- })
- },
- /** 跳转*/
- tourl(e) {
- const url = e.currentTarget.dataset.url
- wx.navigateTo({
- url: `${url}` // 目标页面的路径
- });
- },
- goback() {
- wx.navigateBack({
- delta: 1
- });
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- this.getGood()
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|