search.js 3.1 KB
require("../../../utils/network.js");

var a = require("../../../utils/util.js");

Page({
    data: {
        keyword: "",
        searchSongList: [],
        isFromSearch: !0,
        searchPageNum: 0,
        callbackcount: "",
        searchLoading: !1,
        searchLoadingComplete: !1
    },
    cancel: function() {
        wx.navigateBack({
            delta: 1
        });
    },
    onLoad: function(a) {},
    onReady: function() {},
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onShareAppMessage: function() {},
    bindKeywordInput: function(a) {
        this.setData({
            keyword: a.detail.value
        });
    },
    fetchSearchList: function() {
        var e = this, t = e.data.keyword, o = e.data.searchPageNum;
        e.data.callbackcount;
        a.getSearchMusic(t, o, function(a) {
            if (a) {
                var t = [];
                0 == (t = e.data.isFromSearch ? a.goods : e.data.searchSongList.concat(a.goods)).length ? wx.showToast({
                    title: "暂无商品",
                    icon: "fail"
                }) : e.setData({
                    searchSongList: t,
                    searchLoading: !0
                });
            } else e.setData({
                searchLoadingComplete: !0,
                searchLoading: !1
            });
        });
    },
    keywordSearch: function(a) {
        "" == this.data.keyword ? wx.showToast({
            title: "请输入查询内容",
            icon: "none"
        }) : (this.setData({
            searchPageNum: 0,
            searchSongList: [],
            isFromSearch: !0,
            searchLoading: !0,
            searchLoadingComplete: !1
        }), this.fetchSearchList());
    },
    searchScrollLower: function() {
        var a = this;
        a.data.searchLoading && !a.data.searchLoadingComplete && (a.setData({
            searchPageNum: a.data.searchPageNum + 1,
            isFromSearch: !1
        }), a.fetchSearchList());
    },
 onShareAppMessage: function (options) {
  let that = this;
  let ouid;
  // 设置菜单中的转发按钮触发转发事件时的转发内容
  var shareObj = {
   title: '嗒咕商场', // 默认是小程序的名称(可以写slogan等)
   path: '/pages/start/start?share_id=' + wx.getStorageSync('ouid'), // 默认是当前页面,必须是以‘/’开头的完整路径
   imgUrl: '',//自定义图片路径,可以是本地文件路径、代码包文件路径或者网络图片路径,支持PNG及JPG,不传入 imageUrl 则使用默认截图。显示图片长宽比是 5:4
   success: function (res) {
    // 转发成功之后的回调
    if (res.errMsg == 'shareAppMessage:ok') { }
   },
   fail: function () {
    // 转发失败之后的回调
    if (res.errMsg == 'shareAppMessage:fail cancel') {
     // 用户取消转发
    } else if (res.errMsg == 'shareAppMessage:fail') {
     // 转发失败,其中 detail message 为详细失败信息
    }
   },
   complete: function () {
    // 转发结束之后的回调(转发成不成功都会执行)
   }
  }
  return shareObj;
 },
});