123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- const { getCategoryAPI, getAllGoods} = require('../../API/appraise')
- Page({
-
- data: {
-
- classifyList: [],
-
- scrollTop: 0,
-
- allGoods: [],
- page: 1,
- pageSize: 6,
- flag: true,
- isLoading: false
- },
- userTo() {
- wx.switchTab({
- url: '/pages/user/user',
- })
- },
- classifyTo() {
- wx.switchTab({
- url: '/pages/classify/classify',
- })
- },
- messageTo() {
- wx.switchTab({
- url: '/pages/message/message',
- })
- },
- searchTo() {
- wx.navigateTo({
- url: '/pages/search/search',
- })
- },
-
- detailClassifyTo({ currentTarget }) {
- const id = currentTarget.dataset.num;
- const title = currentTarget.dataset.title;
- wx.navigateTo({
- url: '/pages/classify_detail/classify_detail?classify_id=' + id + '&title=' + title,
- })
- },
- flagChange() {
- this.setData({
- flag: false
- })
- },
-
- onLoad(options) {
- this.getClassifyList();
- this.getGoodsList();
- this.setData({
- avatarUrl:wx.getStorageSync('avatarUrl'),
- nickName: wx.getStorageSync('nickName')
- })
- },
- getClassifyList() {
- getCategoryAPI(this.data)
- .then((res) => {
- const { code, data, mesage } = res.data;
- this.setData({
- classifyList: data
- })
- })
- },
-
- getGoodsList() {
-
- wx.showLoading({
- title: '数据获取中',
- })
- getAllGoods(this.data).then((res) => {
- const { code, data, message } = res.data;
- const d = data.data;
- this.setData({
- allGoods: [...this.data.allGoods, ...d],
- isLoading: true
- })
- })
- this.setData({
- isLoading: false
- })
- },
-
- detailTo(e) {
- console.log(e.currentTarget.dataset);
- const id = e.currentTarget.dataset.id;
- const title = e.currentTarget.dataset.title;
- const price = e.currentTarget.dataset.price;
- const comImg = e.currentTarget.dataset.pic;
- wx.navigateTo({
- url: '/pages/details/details?id=' + id + '&title=' + title + '&price=' + price + '&img=' + comImg,
- })
- },
-
- onReady() {
- },
-
- onShow() {
- },
-
- onHide() {
- },
-
- onUnload() {
- },
-
- onPullDownRefresh() {
- },
-
- onReachBottom() {
- if(this.data.isLoading) {
- this.setData({
- page: this.data.page + 1,
- })
- this.getGoodsList()
- }
- },
-
- onShareAppMessage() {
- },
-
-
-
-
-
-
-
-
-
- })
|