You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
160 lines
4.3 KiB
160 lines
4.3 KiB
// pages/jz/jz.js
|
|
//获取应用实例
|
|
const app = getApp()
|
|
|
|
Page({
|
|
data: {
|
|
imgUrls: [
|
|
'/images/banner1.png'
|
|
],
|
|
indicatorDots: true,
|
|
autoplay: true,
|
|
interval: 5000,
|
|
duration: 1000,
|
|
price: '399',
|
|
img1: '/images/address.png',
|
|
img2: '/images/banner2.png',
|
|
nowDate: new Date().getTime(),
|
|
cityId: 440100000,
|
|
typeFlag: 30,
|
|
addrArray: { id: [440100000, 430426000], name: ['广州', '祁东'] },
|
|
addrIndex: 0,
|
|
items1: [],
|
|
},
|
|
//事件处理函数
|
|
bindViewTap: function () {
|
|
wx.navigateTo({
|
|
url: '../logs/logs'
|
|
})
|
|
},
|
|
getActive: function (e) {
|
|
this.setData({
|
|
typeFlag: e.target.dataset.num
|
|
})
|
|
console.log(e.target.dataset.num);
|
|
},
|
|
bindAddrChange: function (e) {
|
|
this.setData({
|
|
addrIndex: e.detail.value
|
|
})
|
|
let that=this;
|
|
wx.request({
|
|
url: app.gw.hostUrl +'/mall/web/vgoods/list',
|
|
data: { selectedCityId: this.data.addrArray.id[e.detail.value] },
|
|
header: { "Content-Type": "application/json" },
|
|
method: 'GET',
|
|
dataType: 'json',
|
|
responseType: 'text',
|
|
success: function (res) {
|
|
console.log(res.data.response.goodsList.list);
|
|
that.setData({
|
|
items1: res.data.response.goodsList.list
|
|
})
|
|
},
|
|
fail: function (res) {
|
|
wx.showToast({
|
|
title: '网络异常!err:authlogin',
|
|
duration: 2000
|
|
});
|
|
},
|
|
complete: function (res) { },
|
|
})
|
|
},
|
|
loading: function (e) {
|
|
let str = e.currentTarget.dataset.item;
|
|
wx.navigateTo({
|
|
url: '../detail/detail?jsonStr=' + str
|
|
})
|
|
console.log(str);
|
|
},
|
|
loadingClick: function () {
|
|
var price = event.currentTarget.dataset.price;
|
|
console.log(price);
|
|
|
|
var pages = getCurrentPages();
|
|
var currPage = pages[pages.length - 1]; //当前页面
|
|
var prevPage = pages[pages.length]; //下一个页面
|
|
|
|
//直接调用上一个页面的setData()方法,把数据存到下一个页面中去
|
|
prevPage.setData({
|
|
price: price
|
|
});
|
|
},
|
|
onPullDownRefresh() {
|
|
console.log('--------下拉刷新-------')
|
|
wx.showNavigationBarLoading() //在标题栏中显示加载
|
|
wx.request({
|
|
url: app.gw.hostUrl + '/mall/web/vgoods/list',
|
|
data: { selectedCityId: '' },
|
|
header: { "Content-Type": "application/json" },
|
|
method: 'GET',
|
|
dataType: 'json',
|
|
responseType: 'text',
|
|
success: function (res) {
|
|
console.log(res.data.response.goodsList.list);
|
|
that.setData({
|
|
items1: res.data.response.goodsList.list
|
|
})
|
|
},
|
|
fail: function (res) { },
|
|
complete: function (res) {
|
|
// complete
|
|
wx.hideNavigationBarLoading() //完成停止加载
|
|
wx.stopPullDownRefresh() //停止下拉刷新
|
|
},
|
|
})
|
|
},
|
|
onLoad: function () {
|
|
let that = this;
|
|
wx.request({
|
|
url: app.gw.hostUrl + '/mall/web/vgoods/list',
|
|
data: { selectedCityId: '' },
|
|
header: { "Content-Type": "application/json" },
|
|
method: 'GET',
|
|
dataType: 'json',
|
|
responseType: 'text',
|
|
success: function (res) {
|
|
console.log(res.data.response.goodsList.list);
|
|
that.setData({
|
|
items1: res.data.response.goodsList.list
|
|
})
|
|
},
|
|
fail: function (res) { },
|
|
complete: function (res) { },
|
|
})
|
|
if (app.globalData.userInfo) {
|
|
this.setData({
|
|
userInfo: app.globalData.userInfo,
|
|
hasUserInfo: true
|
|
})
|
|
} else if (this.data.canIUse) {
|
|
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
|
|
// 所以此处加入 callback 以防止这种情况
|
|
app.userInfoReadyCallback = res => {
|
|
this.setData({
|
|
userInfo: res.userInfo,
|
|
hasUserInfo: true
|
|
})
|
|
}
|
|
} else {
|
|
// 在没有 open-type=getUserInfo 版本的兼容处理
|
|
// wx.getUserInfo({
|
|
// success: res => {
|
|
// app.globalData.userInfo = res.userInfo
|
|
// this.setData({
|
|
// userInfo: res.userInfo,
|
|
// hasUserInfo: true
|
|
// })
|
|
// }
|
|
// })
|
|
}
|
|
},
|
|
getUserInfo: function (e) {
|
|
console.log(e)
|
|
app.globalData.userInfo = e.detail.userInfo
|
|
this.setData({
|
|
userInfo: e.detail.userInfo,
|
|
hasUserInfo: true
|
|
})
|
|
}
|
|
})
|