284 lines
8.1 KiB
JavaScript
284 lines
8.1 KiB
JavaScript
|
|
var WxParse = null;
|
|||
|
|
//获取应用实例
|
|||
|
|
var app = getApp()
|
|||
|
|
var sopenFrame=null;
|
|||
|
|
var sopenFrame0=null;
|
|||
|
|
var sopenFrame1=null;
|
|||
|
|
var that=null;
|
|||
|
|
Page({
|
|||
|
|
data: {
|
|||
|
|
indicatorDots: true,
|
|||
|
|
indicatorDots0: true,
|
|||
|
|
vertical: false,
|
|||
|
|
vertical0: false,
|
|||
|
|
autoplay: true,
|
|||
|
|
interval: 6000,
|
|||
|
|
interval0: 8000,
|
|||
|
|
duration: 1000,
|
|||
|
|
loadingHidden: false, // loading
|
|||
|
|
images:[],
|
|||
|
|
images1:[],
|
|||
|
|
Products:[],
|
|||
|
|
Products0:[],
|
|||
|
|
ifxn:0
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//事件处理函数
|
|||
|
|
swiperchange: function(e) {
|
|||
|
|
//console.log(e.detail.current)
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
//事件处理函数
|
|||
|
|
swiperchange0: function(e) {
|
|||
|
|
//console.log(e.detail.current)
|
|||
|
|
},onShow: function () {
|
|||
|
|
if (typeof this.getTabBar === 'function' && this.getTabBar()) {
|
|||
|
|
this.getTabBar().setData({
|
|||
|
|
selected: 2
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
|
|||
|
|
onLoad: function(options) {
|
|||
|
|
|
|||
|
|
that=this;
|
|||
|
|
WxParse = require('../../wxParse/wxParse.js');
|
|||
|
|
/*var shopdata = wx.getStorageSync('shopdata')
|
|||
|
|
if(shopdata){
|
|||
|
|
var resshopdata=JSON.parse(shopdata);
|
|||
|
|
that.setData({
|
|||
|
|
images: resshopdata.pic,
|
|||
|
|
images1: resshopdata.pic1,
|
|||
|
|
Products:resshopdata.products,
|
|||
|
|
Products0:resshopdata.Products0,
|
|||
|
|
loadingHidden:true
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
}*/
|
|||
|
|
|
|||
|
|
that.rdata(0);
|
|||
|
|
|
|||
|
|
|
|||
|
|
sopenFrame=setInterval(function (){
|
|||
|
|
if(app.globalData.IFRefreshshop==1){
|
|||
|
|
app.globalData.IFRefreshshop=0;
|
|||
|
|
that.setData({
|
|||
|
|
Start: 0
|
|||
|
|
});
|
|||
|
|
that.rdata(0);
|
|||
|
|
}
|
|||
|
|
}, 1000);
|
|||
|
|
},onPullDownRefresh: function () {
|
|||
|
|
//在当前页面显示导航条加载动画
|
|||
|
|
wx.showNavigationBarLoading();
|
|||
|
|
//显示 loading 提示框。需主动调用 wx.hideLoading 才能关闭提示框
|
|||
|
|
wx.showLoading({
|
|||
|
|
title: '刷新中...',
|
|||
|
|
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
that.setData({
|
|||
|
|
Start: 0
|
|||
|
|
});
|
|||
|
|
wx.removeStorageSync('selcityid')
|
|||
|
|
wx.removeStorageSync('selcountyid')
|
|||
|
|
wx.removeStorageSync('dlMemberId')
|
|||
|
|
|
|||
|
|
that.rdata(1);
|
|||
|
|
|
|||
|
|
},// 页面上拉触底事件(上拉加载更多)
|
|||
|
|
|
|||
|
|
|
|||
|
|
// 清缓存
|
|||
|
|
clearCache:function(){
|
|||
|
|
that.setData({
|
|||
|
|
loadingHidden:false
|
|||
|
|
});
|
|||
|
|
},rdata:function(t) {
|
|||
|
|
|
|||
|
|
try{
|
|||
|
|
var userId = wx.getStorageSync("userId")
|
|||
|
|
var LoginId = wx.getStorageSync("LoginId")
|
|||
|
|
var selcityid = wx.getStorageSync("selcityid")
|
|||
|
|
var selcountyid = wx.getStorageSync("selcountyid")
|
|||
|
|
var dlMemberId = wx.getStorageSync("dlMemberId")
|
|||
|
|
|
|||
|
|
wx.request({
|
|||
|
|
url: app.globalData.apiurl + "/xapiajax.ashx",
|
|||
|
|
|
|||
|
|
data: {
|
|||
|
|
action:"getshopdata",
|
|||
|
|
userId:(!userId?"":userId),
|
|||
|
|
LoginId:(!LoginId?"":LoginId),
|
|||
|
|
Start:that.data.Start,
|
|||
|
|
cid:that.data.cid,
|
|||
|
|
selcityid:(!selcityid?"":selcityid),
|
|||
|
|
selcountyid:(!selcountyid?"":selcountyid),
|
|||
|
|
dlMemberId:(!dlMemberId?"":dlMemberId),
|
|||
|
|
},
|
|||
|
|
method:"GET",
|
|||
|
|
dataType:"json",
|
|||
|
|
header: {
|
|||
|
|
"content-type": "application/json" // 默认值
|
|||
|
|
},
|
|||
|
|
success (res) {
|
|||
|
|
|
|||
|
|
if(res.data.status==1){
|
|||
|
|
wx.setStorageSync('shopdata', JSON.stringify(res.data))
|
|||
|
|
that.setData({
|
|||
|
|
images: res.data.pic,
|
|||
|
|
images1: res.data.pic1,
|
|||
|
|
Products:res.data.products,
|
|||
|
|
Products0:res.data.products0,
|
|||
|
|
loadingHidden:true
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
if(res.data.userInfo.ifxn==0){
|
|||
|
|
that.setData({
|
|||
|
|
ifxn:1
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if(t==1){
|
|||
|
|
//隐藏loading 提示框
|
|||
|
|
wx.hideLoading();
|
|||
|
|
//隐藏导航条加载动画
|
|||
|
|
wx.hideNavigationBarLoading();
|
|||
|
|
//停止下拉刷新
|
|||
|
|
wx.stopPullDownRefresh();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}else{
|
|||
|
|
if(res.data.msg=="您未登录"||res.data.msg=="参数错误"){
|
|||
|
|
wx.removeStorageSync('userId')
|
|||
|
|
wx.removeStorageSync('LoginId')
|
|||
|
|
that.rdata(0)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}catch(err){
|
|||
|
|
wx.showToast({
|
|||
|
|
title: err,
|
|||
|
|
icon: "none",
|
|||
|
|
duration: 2000
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
},gotodetail:function(e) {
|
|||
|
|
|
|||
|
|
var id = e.currentTarget.dataset.id
|
|||
|
|
wx.navigateTo({
|
|||
|
|
url: "../details/index?id="+id
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
},
|
|||
|
|
onshop: function (e) {
|
|||
|
|
var id = e.currentTarget.dataset.id
|
|||
|
|
|
|||
|
|
wx.navigateTo({
|
|||
|
|
url: "../othershop/index?t=" + id
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
|
|||
|
|
},onnav: function (e) {
|
|||
|
|
var id = e.currentTarget.dataset.id
|
|||
|
|
|
|||
|
|
wx.navigateTo({
|
|||
|
|
url: "../list/index?t=0&id=" + id
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
|
|||
|
|
},getkeyword:function(e) {
|
|||
|
|
that.setData({
|
|||
|
|
keyword:e.detail.value
|
|||
|
|
})
|
|||
|
|
},onsearch:function() {
|
|||
|
|
var keyword=that.data.keyword.replace(/\s+/g, "");
|
|||
|
|
if(keyword!=""){
|
|||
|
|
wx.navigateTo({
|
|||
|
|
url: "../list/index?keyword=" + keyword
|
|||
|
|
})
|
|||
|
|
}else{
|
|||
|
|
wx.showToast({
|
|||
|
|
title: "关键字不能为空",
|
|||
|
|
icon: "none",
|
|||
|
|
duration: 3000
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
},onpd:function(e) {
|
|||
|
|
var ids = e.currentTarget.dataset.id
|
|||
|
|
wx.navigateTo({
|
|||
|
|
url: "../details/index?"+ids
|
|||
|
|
})
|
|||
|
|
},onyjpt:function(e) {
|
|||
|
|
var id = e.currentTarget.dataset.id
|
|||
|
|
var userId = wx.getStorageSync("userId")
|
|||
|
|
var LoginId = wx.getStorageSync("LoginId")
|
|||
|
|
if(userId&&LoginId){
|
|||
|
|
if(that.data.IFAuto==1){
|
|||
|
|
if(that.data.button_title=="一键拼团"){
|
|||
|
|
that.setData({
|
|||
|
|
button_title: "请稍候..."
|
|||
|
|
})
|
|||
|
|
wx.request({
|
|||
|
|
url: app.globalData.apiurl + "/xapiajax.ashx",
|
|||
|
|
data: {
|
|||
|
|
action:"ononekey",
|
|||
|
|
userId:(!userId?"":userId),
|
|||
|
|
LoginId:(!LoginId?"":LoginId),
|
|||
|
|
id:id,
|
|||
|
|
t:1
|
|||
|
|
},
|
|||
|
|
method:"GET",
|
|||
|
|
dataType:"json",
|
|||
|
|
header: {
|
|||
|
|
"content-type": "application/json" // 默认值
|
|||
|
|
},
|
|||
|
|
success (res) {
|
|||
|
|
that.setData({
|
|||
|
|
button_title: "一键拼团"
|
|||
|
|
})
|
|||
|
|
if(res.data.status==1){
|
|||
|
|
wx.showToast({
|
|||
|
|
title: "已下单成功",
|
|||
|
|
icon: "success",
|
|||
|
|
duration: 2000
|
|||
|
|
})
|
|||
|
|
that.setData({
|
|||
|
|
IFAuto:2
|
|||
|
|
})
|
|||
|
|
that.setData({
|
|||
|
|
Start: 0
|
|||
|
|
});
|
|||
|
|
that.getlist(0);
|
|||
|
|
|
|||
|
|
}else{
|
|||
|
|
wx.showToast({
|
|||
|
|
title: res.data.msg,
|
|||
|
|
icon: "none",
|
|||
|
|
duration: 2000
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
if(that.data.IFAuto==0){
|
|||
|
|
wx.navigateTo({
|
|||
|
|
url: "../vip/index"
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}else{
|
|||
|
|
wx.navigateTo({
|
|||
|
|
url: "../login/index"
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
},catchbutton:function(e) {
|
|||
|
|
|
|||
|
|
},onautopt:function(e) {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
})
|