作者 朱振飞

121212

... ... @@ -9,10 +9,8 @@
<view wx:if="{{item.price2!=null}}">
<view class='goods_flex'>
<view class='price'>¥{{item.goods_price}}</view>
<view class='price'>¥{{item.price}}</view>
<view class="lineprice">¥{{item.line_price}}</view>
<view class='sell'>已卖出{{item.sales}}件</view>
</view>
... ... @@ -21,7 +19,7 @@
<view class='goods_flex' wx:else>
<!-- <view class='score'>积分</view> -->
<view class='price'>¥{{item.goods_price}}</view>
<view class='price'>¥{{item.price}}</view>
<view class="lineprice">¥{{item.line_price}}</view>
<view class='sell'>已卖出{{item.sales}}件</view>
</view>
... ...
... ... @@ -91,7 +91,7 @@
}
.price {
font-size:30rpx;
font-size:36rpx;
font-family: PingFang SC;
font-weight: bold;
color: rgba(242, 0, 0, 1);
... ...
... ... @@ -5,6 +5,7 @@ Page({
* 页面的初始数据
*/
data: {
selected: 0,
autoplay: true,
interval: 5000,
duration: 500,
... ... @@ -30,41 +31,39 @@ Page({
status1: '',
status2: '',
title2: '',
scrollTop:'',
pid:'',
logok:'',
selected:0,
list:[{
        pagePath: "/packageA/pages/index/index",
        text: "商品",
        iconPath: "/images/tabbar/icon_75.png",
        selectedIconPath: "/images/tabbar/icon_68.png"
      },
      {
        pagePath: "/packageA/pages/message/message",
        text: "消息",
        iconPath: "/images/tabbar/message.png",
        selectedIconPath: "/images/tabbar/messageactive.png"
      },
      {
        pagePath: "/packageA/pages/shop_cart/shop_cart",
        text: "购物车",
        iconPath: "/images/tabbar/icon_70.png",
        selectedIconPath: "/images/tabbar/icon_73.png"
      },
      {
        pagePath"/packageA/pages/my/my",
        text"我的",
        iconPath"/images/tabbar/icon_71.png",
        selectedIconPath"/images/tabbar/icon_72.png"
      }],
category_id1:'',
sort:'',
keyword:'',
shop_arr:[],
pricesheng:false,
xiaoliang:false
scrollTop: '',
pid: '',
logok: '',
typename: 1,
list: [{
pagePath: "/packageA/pages/index/index",
text: "商品",
iconPath: "/images/tabbar/icon_75.png",
selectedIconPath: "/images/tabbar/icon_68.png"
},
{
pagePath: "/packageA/pages/message/message",
text: "消息",
iconPath: "/images/tabbar/message.png",
selectedIconPath: "/images/tabbar/messageactive.png"
},
{
pagePath: "/packageA/pages/shop_cart/shop_cart",
text: "购物车",
iconPath: "/images/tabbar/icon_70.png",
selectedIconPath: "/images/tabbar/icon_73.png"
},
{
pagePath: "/packageA/pages/my/my",
text: "我的",
iconPath: "/images/tabbar/icon_71.png",
selectedIconPath: "/images/tabbar/icon_72.png"
}
]
},
scroll(e) {
// console.log(e.detail.scrollTop)
... ... @@ -83,74 +82,60 @@ Page({
},
onLoad: function(options) {
console.log( app.globalData.index)
if( app.globalData.index==undefined){
onLoad: function (options) {
console.log(app.globalData.index)
if (wx.getStorageSync('entrance_type') == '2') {
wx.setNavigationBarTitle({
title: '工会商城'
})
}else{
wx.setNavigationBarTitle({
title: '劳保商城'
})
}
if (app.globalData.index == undefined) {
let that = this;
let token=wx.getStorageSync('token');
let token = wx.getStorageSync('token');
console.log('woshitoe',token);
if(token!=""){
console.log('woshitoe', token);
if (token != "") {
console.log(9999)
this.getInfoFun()
}
this.get_notice()
this.get_shopnum()
this.getmessagelist();
console.log('998867',this.data.pid)
// if(this.data.pid){
// this.get_info(this.data.pid, 2);
// }else{
// this.get_info(0, 1);
// }
console.log('998867', this.data.pid)
if (this.data.pid) {
this.get_info(this.data.pid, 2);
} else {
this.get_info(0, 1);
}
// 获取活动专区
this.getzhuanqulist();
this.getxianshi();
setTimeout(function() {
setTimeout(function () {
that.setData({
showtime: true
})
}, 990)
}
}
//控制显示隐藏
this.ishow()
// 我写的项目
// 获取一级分类
this.getonkind();
// 获取商品列表
this.getgoodlist()
},
// 获取一级分类
getonkind(){
let that= this;
let url="/sundry/get_category"
app.postk(url, {}).then((r) => {
console.log('商品分类',r)
let obj = {
name: '首页',
id: ''
}
r.data.unshift(obj)
that.setData({
nav_arr: r.data
})
})
},
// 获取个人信息
getInfoFun() {
let that= this;
let that = this;
let u = app.interface.readteacher;
app.post(u, {}).then((r) => {
console.log('3489523498',r)
console.log('3489523498', r)
if (r.code == 200) {
app.globalData.login_new=r.msg.login_new;
app.globalData.login_new = r.msg.login_new;
app.globalData.status = r.msg.status;
console.log(app.globalData.status)
// t.setData({
... ... @@ -170,13 +155,12 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/register/register',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
}else{
let login_new=wx.getStorageSync("login");
if(login_new==0){
} else {
let login_new = wx.getStorageSync("login");
if (login_new == 0) {
// wx.showToast({
// title: '您还不是会员',
// icon:"none"
... ... @@ -196,8 +180,7 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/login/login',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
... ... @@ -206,7 +189,7 @@ this.getgoodlist()
}
wx.navigateTo({
url: '/packageA/pages/xianshi/xianshi?title2='+this.data.title2,
url: '/packageA/pages/xianshi/xianshi?title2=' + this.data.title2,
})
}
... ... @@ -284,7 +267,7 @@ this.getgoodlist()
var that = this;
console.log('999', that.data.endTime)
var time = that.data.endTime;
var interval = setInterval(function() {
var interval = setInterval(function () {
// 秒数
let day = parseInt(time / (60 * 60 * 24));
let hou = parseInt(time % (60 * 60 * 24) / 3600);
... ... @@ -313,15 +296,15 @@ this.getgoodlist()
//获取活动专区列表
getzhuanqulist() {
let that = this
let url = '/activity/get_list';
let url = '/activity/get_all';
let data = {
}
app.postk(url, data, "POST").then((r) => {
app.post(url, data, "POST").then((r) => {
console.log(r)
that.setData({
activity: r.data
activity: r.msg
})
console.log(that.data.activity)
... ... @@ -347,13 +330,12 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/register/register',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
}else{
let login_new=wx.getStorageSync('login');
if(login_new==0){
} else {
let login_new = wx.getStorageSync('login');
if (login_new == 0) {
wx.showModal({
title: '提示',
content: '您还不是会员',
... ... @@ -364,8 +346,7 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/login/login',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
... ... @@ -389,15 +370,14 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/register/register',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
return false
}
let login_new=wx.getStorageSync('login');
if(login_new==0){
let login_new = wx.getStorageSync('login');
if (login_new == 0) {
wx.showModal({
title: '提示',
content: '您还不是会员',
... ... @@ -408,8 +388,7 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/login/login',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
... ... @@ -437,13 +416,12 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/register/register',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
}else{
let login_new=wx.getStorageSync('login');
if(login_new==0){
} else {
let login_new = wx.getStorageSync('login');
if (login_new == 0) {
wx.showModal({
title: '提示',
content: '您还不是会员',
... ... @@ -454,24 +432,18 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/login/login',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
return false
}
let title = this.data.nav_arr[this.data.nav_index].name
let category_id2=e.currentTarget.dataset.id;
let index = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
let pid = this.data.nav_arr[this.data.nav_index].id
wx.navigateTo({
url: '/packageA/pages/search/search_result/search_result?title=' + title + '&category_id2=' + category_id2
url: '/packageA/pages/search/search_result/search_result?title=' + title + "&index=" + index + '&pid=' + pid
})
// let index = e.currentTarget.dataset.index ? e.currentTarget.dataset.index : 0
// let pid = this.data.nav_arr[this.data.nav_index].id
// wx.navigateTo({
// url: '/packageA/pages/search/search_result/search_result?title=' + title + "&index=" + index + '&pid=' + pid
// })
}
},
... ... @@ -495,13 +467,12 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/register/register',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
} else {
let login_new=wx.getStorageSync('login');
if(login_new==0){
let login_new = wx.getStorageSync('login');
if (login_new == 0) {
wx.showModal({
title: '提示',
content: '您还不是会员',
... ... @@ -510,8 +481,7 @@ this.getgoodlist()
wx.navigateTo({
url: '/packageA/pages/login/login',
})
} else if (res.cancel) {
}
} else if (res.cancel) {}
}
})
... ... @@ -522,9 +492,9 @@ this.getgoodlist()
url: '/packageA/pages/outerChain/outerChain?src=' + e.currentTarget.dataset.src
})
} else {
// wx.navigateTo({
// url: '/packageA/pages/shop_detail/shop_detail?id=' + id
// })
wx.navigateTo({
url: '/packageA/pages/shop_detail/shop_detail?id=' + id
})
}
}
... ... @@ -536,129 +506,67 @@ this.getgoodlist()
// 排序
reorder(e) {
let that = this
let index = Number(e.currentTarget.dataset.index)
if (index == 1) {
if (that.data.price == "price") {
that.setData({
page:1,
shop_arr:[]
price: 'price desc'
})
let index = Number(e.currentTarget.dataset.index);
} else {
that.setData({
c_index:index,
sort:index
price: 'price'
})
if(index==1){
this.setData({
pricesheng:!this.data.pricesheng
})
if(this.data.pricesheng==true){
this.setData({
sort:1
}
} else if (index == 2) {
if (that.data.paynum == "paynum") {
that.setData({
paynum: 'paynum desc'
})
}else{
this.setData({
sort:2
} else {
that.setData({
paynum: 'paynum'
})
}
}
if(this.data.index==2){
this.setData({
xiaoliang:!this.data.xiaoliang
})
if(this.data.xiaoliang==true){
this.setData({
sort:3
})
}else{
this.setData({
sort:4
c_index: e.currentTarget.dataset.index,
page: 1,
page_type: false
})
}
}
that.getgoodlist()
// let that = this
// let index = Number(e.currentTarget.dataset.index)
// if (index == 1) {
// if (that.data.price == "price") {
// that.setData({
// price: 'price desc'
// })
// } else {
// that.setData({
// price: 'price'
// })
// }
// } else if (index == 2) {
// if (that.data.paynum == "paynum") {
// that.setData({
// paynum: 'paynum desc'
// })
// } else {
// that.setData({
// paynum: 'paynum'
// })
// }
// }
// this.setData({
// c_index: e.currentTarget.dataset.index,
// page: 1,
// page_type: false
// })
// //调用排序接口
// this.good_list(this.data.pid, e.currentTarget.dataset.index)
//调用排序接口
this.good_list(this.data.pid, e.currentTarget.dataset.index)
},
// 选择一级分类
select_nav(e) {
let index = Number(e.currentTarget.dataset.index)
let id = e.currentTarget.dataset.id;
let newclass_arr=this.data.nav_arr[index].child
this.setData({
category_id1:id,
class_arr:newclass_arr,
nav_index:index
})
},
// 获取商品列表
getgoodlist(){
let that=this;
let url = '/goods/get_goods'
let param={
category_id1:this.data.category_id1,
sort:this.data.sort,
keyword:this.data.keyword,
page:this.data.page,
pageNum:10
}
app.postk(url, param).then((res) => {
if(that.data.page>1){
if(res.data.length==0){
wx.showToast({
title:'没有更多了~',
icon:'none'
pid: id
})
}else{
this.setData({
shop_arr:that.data.shop_arr.concat(res.data)
scrollTop: 0
})
}
}else{
if (index == this.data.nav_index) {
return
} else {
this.setData({
shop_arr:that.data.shop_arr.concat(res.data)
nav_index: index,
page: 1,
page_type: false,
c_index: 0, //筛选分类下标
price: 'price desc', //价格排序方式
paynum: 'paynum desc' //销量排序方式
})
this.get_info(id, 2)
}
console.log(that.data.shop_arr,'轮播图')
})
},
// 轮播图
get_banner() {
let url = '/sundry/get_slide'
app.postk(url, {}).then((res) => {
console.log(res,'轮播图')
let url = app.interface.banner
app.post(url, {}).then((res) => {
this.setData({
imgurl: res.data
imgurl: res.msg
})
})
},
... ... @@ -676,45 +584,45 @@ this.getgoodlist()
})
},
//获取页面信息
// get_info(pid, type) { //type 1为小标题 2为小标题下的小分类
// wx.showLoading({
// title: '加载中'
// })
// let that = this
// let url = app.interface.index
// let params = {
// pid: pid
// }
// app.post(url, params).then((res) => {
// console.log('88776654', res)
// wx.hideLoading()
// if (type == 1) {
get_info(pid, type) { //type 1为小标题 2为小标题下的小分类
wx.showLoading({
title: '加载中'
})
let that = this
let url = app.interface.index
let params = {
pid: pid
}
app.post(url, params).then((res) => {
console.log('88776654', res)
wx.hideLoading()
if (type == 1) {
let obj = {
name: '首页',
id: ''
}
res.msg.unshift(obj)
that.setData({
nav_arr: res.msg
})
that.get_info(res.msg[0].id, 2)
} else if (type == 2) {
console.log('666', res)
// let obj = {
// name: '首页',
// name: '全部',
// id: ''
// }
// res.msg.unshift(obj)
// that.setData({
// nav_arr: res.data
// })
// that.get_info(res.msg[0].id, 2)
// } else if (type == 2) {
// console.log('666', res)
// // let obj = {
// // name: '全部',
// // id: ''
// // }
// // res.msg.unshift(obj)
// that.setData({
// class_arr: res.data,
// cid: ''
// })
// that.good_list(pid, that.data.c_index)
// }
// }).catch((er) => {
// wx.hideLoading()
// })
// },
that.setData({
class_arr: res.msg,
cid: ''
})
that.good_list(pid, that.data.c_index)
}
}).catch((er) => {
wx.hideLoading()
})
},
//获取商品列表
good_list(pid, c_index) {
wx.showLoading({
... ... @@ -768,7 +676,7 @@ this.getgoodlist()
if (res.msg > 0) {
wx.showTabBarRedDot({
index: 2,
success: function(red) {
success: function (red) {
wx.setTabBarBadge({
index: 2,
text: res.msg.toString(),
... ... @@ -798,7 +706,7 @@ this.getgoodlist()
// })
let newlist = [];
r.msg.forEach(function(value, index, array) {
r.msg.forEach(function (value, index, array) {
console.log(newlist)
if (value.status == 1) {
newlist.push(value)
... ... @@ -809,7 +717,7 @@ this.getgoodlist()
if (newlist.length != 0) {
wx.showTabBarRedDot({
index: 1,
success: function(red) {
success: function (red) {
wx.setTabBarBadge({
index: 1,
... ... @@ -827,34 +735,37 @@ this.getgoodlist()
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
onShow: function () {
this.setData({
logok:app.globalData.baseUrlimg+"assets/img/cb2ad36a391388f19f5f912fa021f8f.png"
logok: app.globalData.baseUrlimg + "assets/img/cb2ad36a391388f19f5f912fa021f8f.png"
})
console.log(this.data.logok)
// this.logok=app.globalData.baseUrlimg+"assets/img/cb2ad36a391388f19f5f912fa021f8f.png''
this.get_banner()
console.log(app.globalData.index)
if(app.globalData.index==0){
app.globalData.index=undefined
let token=wx.getStorageSync('token');
console.log('woshitoe',token)
if(token!=""){
if (app.globalData.index == 0) {
app.globalData.index = undefined
let token = wx.getStorageSync('token');
console.log('woshitoe', token)
if (token != "") {
this.getInfoFun()
}
this.get_notice()
this.get_shopnum()
this.getmessagelist();
console.log('998867',this.data.pid)
if(this.data.pid){
// this.get_info(this.data.pid, 2);
}else{
// this.get_info(0, 1);
console.log('998867', this.data.pid)
if (this.data.pid) {
this.get_info(this.data.pid, 2);
} else {
this.get_info(0, 1);
}
//控制显示隐藏
... ... @@ -868,70 +779,63 @@ this.getgoodlist()
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
onPullDownRefresh: function () {
},
loadMore(e){
let newpage=this.data.page;
newpage++;
this.setData({
page:newpage
loadMore(e) {
console.log(e)
let that = this
if (that.data.page_type) {
wx.showToast({
title: '暂无更多数据',
icon: 'none',
duration: 1000
})
this.getgoodlist()
// console.log(e)
// let that = this
// if (that.data.page_type) {
// wx.showToast({
// title: '暂无更多数据',
// icon: 'none',
// duration: 1000
// })
// return
// }
// that.setData({
// page: that.data.page + 1
// })
// that.good_list(that.data.pid, that.data.c_index)
return
}
that.setData({
page: that.data.page + 1
})
that.good_list(that.data.pid, that.data.c_index)
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
// console.log(43898438493)
// let that = this
// if (that.data.page_type) {
// wx.showToast({
// title: '暂无更多数据',
// icon: 'none',
// duration: 1000
// })
// return
// }
// that.setData({
// page: that.data.page + 1
// })
// that.good_list(that.data.pid, that.data.c_index)
onReachBottom: function () {
console.log(43898438493)
let that = this
if (that.data.page_type) {
wx.showToast({
title: '暂无更多数据',
icon: 'none',
duration: 1000
})
return
}
that.setData({
page: that.data.page + 1
})
that.good_list(that.data.pid, that.data.c_index)
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"navigationBarTitleText": "首页",
"navigationBarTitleText": "",
"usingComponents": {
"concat": "/packageA/Components/concat/concat",
"Model_item": "/packageA/Components/Model_item/Model_item",
... ...
... ... @@ -52,10 +52,10 @@ Page({
pageNum: 10,
}
app.post(url, data, "POST").then((r) => {
app.postk(url, data, "POST").then((r) => {
console.log(r)
that.setData({
messagelist: that.data.messagelist.concat(r.msg)
messagelist: that.data.messagelist.concat(r.data)
})
let newlist = [];
... ... @@ -71,7 +71,6 @@ Page({
wx.showTabBarRedDot({
index: 1,
success: function(red) {
wx.setTabBarBadge({
index: 1,
text: newlist.length.toString(),
... ... @@ -99,7 +98,7 @@ Page({
ordertail(e) {
let id = e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/messagedetail/messagedetail?id=' + id,
url: '/packageA/pages/messagedetail/messagedetail?id=' + id,
})
},
... ...
<block wx:if="{{token==''}}">
<navigator class="no_login" catchtap="go_login" url="/pages/register/register" hover-class="none">请先登录</navigator>
<navigator class="no_login" catchtap="go_login" url="/packageA/pages/register/register" hover-class="none">请先登录</navigator>
</block>
<block wx:elif="{{login_new==''}}">
<navigator class="no_login" catchtap="go_login" url="/pages/login/login" hover-class="none">请先绑定会员</navigator>
<navigator class="no_login" catchtap="go_login" url="/packageA/pages/login/login" hover-class="none">请先绑定会员</navigator>
</block>
<block wx:else>
... ...
... ... @@ -9,12 +9,7 @@ Page({
page: 1,
c_index: 0, //筛选分类下标
price: 'price desc', //价格排序方式
paynum: 'paynum desc' ,//销量排序方式
category_id2:'',
shop_arr:[],
keyword:'',
sort:''
paynum: 'paynum desc' //销量排序方式
},
... ... @@ -139,67 +134,30 @@ Page({
wx.setNavigationBarTitle({
title: options.title ? options.title : '搜索'
})
if (options.index){
this.setData({
category_id2:options.category_id2
})
this.getgoodlist()
// if (options.index){
// this.setData({
// nav_index: Number(options.index),
// nav_type: true,
// pid: options.pid
// })
// this.get_info(options.pid)
// } else {
// if (options.name){
// this.setData({
// cid: options.name,
// search_type: true
// })
// this.good_list(options.name, 0)
// } else {
// this.setData({
// cid: options.pid
// })
// this.good_list(options.pid, 0)
// }
// }
},
getgoodlist(){
let that=this;
let url = '/goods/get_goods'
let param={
category_id2:this.data.category_id2,
sort:this.data.sort,
keyword:this.data.keyword,
page:this.data.page,
pageNum:10
}
app.postk(url, param).then((res) => {
if(that.data.page>1){
if(res.data.length==0){
wx.showToast({
title:'没有更多了~',
icon:'none'
nav_index: Number(options.index),
nav_type: true,
pid: options.pid
})
}else{
this.get_info(options.pid)
} else {
if (options.name){
this.setData({
shop_arr:that.data.shop_arr.concat(res.data)
cid: options.name,
search_type: true
})
}
}else{
this.good_list(options.name, 0)
} else {
this.setData({
shop_arr:that.data.shop_arr.concat(res.data)
cid: options.pid
})
this.good_list(options.pid, 0)
}
}
console.log(that.data.shop_arr,'轮播图')
})
},
/**
... ...
... ... @@ -11,6 +11,7 @@ Page({
all_num: 0, //总数量
token:'',
login_new:'',
selected:2,
listarr:[{
        pagePath: "/packageA/pages/index/index",
        text: "商品",
... ... @@ -212,7 +213,7 @@ submit(){
}
}
wx.navigateTo({
url: '/pages/order/order?type=4' + '&info=' + JSON.stringify(info)
url: '/packageA/pages/order/order?type=4' + '&info=' + JSON.stringify(info)
})
},
... ...
<block wx:if="{{no_login}}">
<navigator class="no_login" catchtap="go_login" url="/pages/register/register" hover-class="none">请先登录</navigator>
<navigator class="no_login" catchtap="go_login" url="/packageA/pages/register/register" hover-class="none">请先登录</navigator>
</block>
<block wx:elif="{{login_new==''}}">
<navigator class="no_login" catchtap="go_login" url="/pages/login/login" hover-class="none">请先绑定会员</navigator>
<navigator class="no_login" catchtap="go_login" url="/packageA/pages/login/login" hover-class="none">请先绑定会员</navigator>
</block>
... ...