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.
657 lines
18 KiB
657 lines
18 KiB
|
2 years ago
|
// pages/list/store/index.js
|
||
|
|
// import commonApi from "../../../utils/https/common"
|
||
|
|
// import util from "../../../utils/util"
|
||
|
|
import commonApi from "../../utils/https/common"
|
||
|
|
import util from "../../utils/util"
|
||
|
|
let app = getApp()
|
||
|
|
Page({
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面的初始数据
|
||
|
|
*/
|
||
|
|
data: {
|
||
|
|
list:[], //获取的产品列表
|
||
|
|
total:1, //总数
|
||
|
|
keywords:"", //搜索关键字
|
||
|
|
navIndex:0, //一级分类选中下标
|
||
|
|
navList:['列表样式','宫格样式'],
|
||
|
|
flag:true, //切换样式,true按分类,false按店铺展示
|
||
|
|
typeList:[], //左侧的二级分类
|
||
|
|
typeIndex:0, //二级分类选中下标
|
||
|
|
id:'1',
|
||
|
|
cartCount:0,
|
||
|
|
skuFlag:null, //规格弹窗
|
||
|
|
info: null, //规格信息
|
||
|
|
skuIndex: 0, //默认选中第一个规格
|
||
|
|
producNum: 1,
|
||
|
|
showPopup:false, //购物车的弹窗
|
||
|
|
gwcList:[], //gwc里的产品数据
|
||
|
|
allSelectedBtn:false, //全选按钮
|
||
|
|
seachFlag:false, //搜索模式
|
||
|
|
totalPrice:0, //获取购物车总价
|
||
|
|
name:'非遗专卖'
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面加载
|
||
|
|
*/
|
||
|
|
onLoad: function (options) {
|
||
|
|
wx.showShareMenu({
|
||
|
|
withShareTicket: true,
|
||
|
|
menus: ['shareAppMessage', 'shareTimeline']
|
||
|
|
})
|
||
|
|
this.getCount()
|
||
|
|
this.getType()
|
||
|
|
},
|
||
|
|
// 清空
|
||
|
|
delAll() {
|
||
|
|
let ids = []
|
||
|
|
this.data.gwcList.forEach(item => {
|
||
|
|
ids.push(item.sku_id)
|
||
|
|
})
|
||
|
|
commonApi.user_post("cart_within/del_sku", {
|
||
|
|
sku_id: ids+'',
|
||
|
|
type:'2'
|
||
|
|
}).then(res => {
|
||
|
|
if (res.code == 1) {
|
||
|
|
wx.showToast({
|
||
|
|
title: '清空成功',
|
||
|
|
icon: "success"
|
||
|
|
})
|
||
|
|
this.setData({
|
||
|
|
allSelectedBtn:false
|
||
|
|
})
|
||
|
|
this.getCount()
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 减少一个
|
||
|
|
del(e) {
|
||
|
|
let item = e.currentTarget.dataset.item
|
||
|
|
let gwcList = this.data.gwcList
|
||
|
|
commonApi.user_post("cart_within/update_sku", {
|
||
|
|
num:item.num-1,
|
||
|
|
sku_id: item.sku_id,
|
||
|
|
type:'2'
|
||
|
|
}).then(res => {
|
||
|
|
if (res.code == 1) {
|
||
|
|
// this.getCount()
|
||
|
|
commonApi.user_post('cart_within/get_list', {
|
||
|
|
type:'2'
|
||
|
|
}).then(res => {
|
||
|
|
let arr = res.data,totalPrice = 0,cartCount=0
|
||
|
|
if (res.data.length>0) {
|
||
|
|
res.data.forEach(item=> {
|
||
|
|
// totalPrice += item.num*item.sku.price
|
||
|
|
cartCount += item.num
|
||
|
|
gwcList.forEach(el=> {
|
||
|
|
if (el.id == item.id) {
|
||
|
|
item.selected = el.selected
|
||
|
|
}
|
||
|
|
})
|
||
|
|
})
|
||
|
|
res.data.forEach(item=> {
|
||
|
|
if (item.selected ==1) {
|
||
|
|
totalPrice += item.num*item.sku.price
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
let status = res.data.every(el => el.selected === 1)
|
||
|
|
this.setData({
|
||
|
|
cartCount: cartCount, //1
|
||
|
|
gwcList:res.data,
|
||
|
|
allSelectedBtn:status?true:false,
|
||
|
|
totalPrice
|
||
|
|
})
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 添加产品到购物车
|
||
|
|
addCart: function (e) {
|
||
|
|
let item = e.currentTarget.dataset.item
|
||
|
|
app.globalData.postProduct = []
|
||
|
|
app.globalData.list = []
|
||
|
|
commonApi.user_post("/product/checkStock", {
|
||
|
|
sku_id: this.data.showPopup ? item.sku.id : this.data.info.sku[this.data.skuIndex].id,
|
||
|
|
}).then(res => {
|
||
|
|
if (res && res.code != 1) {
|
||
|
|
return;
|
||
|
|
} else {
|
||
|
|
commonApi.user_post("cart_within/add_sku", {
|
||
|
|
sku_id: this.data.showPopup ? item.sku.id :this.data.info.sku[this.data.skuIndex].id,
|
||
|
|
num: this.data.producNum,
|
||
|
|
type:"2"
|
||
|
|
}).then(res => {
|
||
|
|
if (res.code == 1) {
|
||
|
|
commonApi.user_post('cart_within/get_list', {
|
||
|
|
type:'2'
|
||
|
|
}).then(res => {
|
||
|
|
let cartCount = 0,totalPrice = 0,gwcList=this.data.gwcList
|
||
|
|
res.data.forEach(val=> {
|
||
|
|
cartCount+=val.num
|
||
|
|
console.log(this.data.skuFlag);
|
||
|
|
// debugger
|
||
|
|
if (!this.data.skuFlag && !this.data.showPopup) {
|
||
|
|
// debugger
|
||
|
|
if (val.sku.id == this.data.info.sku[this.data.skuIndex].id) {
|
||
|
|
val.selected = 1
|
||
|
|
}
|
||
|
|
}else {
|
||
|
|
// debugger
|
||
|
|
gwcList.forEach(el=> {
|
||
|
|
if (el.id == val.id) {
|
||
|
|
val.selected = el.selected
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
// if (this.data.showPopup) {
|
||
|
|
// totalPrice += Number(val.num*val.sku.price)
|
||
|
|
// gwcList.forEach(el=> {
|
||
|
|
// if (el.id == val.id) {
|
||
|
|
// val.selected = el.selected
|
||
|
|
// }
|
||
|
|
// })
|
||
|
|
// }
|
||
|
|
})
|
||
|
|
res.data.forEach(element=> {
|
||
|
|
if (element.selected == 1) {
|
||
|
|
totalPrice += Number(element.num*element.sku.price)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
let status = res.data.every(el => el.selected === 1)
|
||
|
|
this.setData({
|
||
|
|
cartCount: cartCount,
|
||
|
|
totalPrice,
|
||
|
|
producNum:1,
|
||
|
|
gwcList:res.data,
|
||
|
|
allSelectedBtn:status?true:false,
|
||
|
|
})
|
||
|
|
})
|
||
|
|
// 加动效
|
||
|
|
this.setData({
|
||
|
|
skuFlag: null,
|
||
|
|
aniSkuIndex: this.data.skuIndex,
|
||
|
|
cartImgInfo: null
|
||
|
|
})
|
||
|
|
setTimeout(() => {
|
||
|
|
this.setData({
|
||
|
|
aniSkuIndex: -1
|
||
|
|
})
|
||
|
|
// wx.showModal({
|
||
|
|
// title: "提示",
|
||
|
|
// content: "去购物车结算?",
|
||
|
|
// success: function (res) {
|
||
|
|
// if (res.confirm) {
|
||
|
|
// wx.navigateTo({
|
||
|
|
// url: '/pages/user/cartlist/list',
|
||
|
|
// })
|
||
|
|
// }
|
||
|
|
// }
|
||
|
|
// })
|
||
|
|
}, 650)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
|
||
|
|
},
|
||
|
|
// 去结算
|
||
|
|
order: function () {
|
||
|
|
commonApi.user_post('wx/get_user_keep', {
|
||
|
|
jumpurl: '/pages/user/cartlist/list',
|
||
|
|
title: '购物车',
|
||
|
|
type: 'mini'
|
||
|
|
}).then(res => {
|
||
|
|
if (res.data.subscribe == 0) {
|
||
|
|
this.setData({
|
||
|
|
wxqrcode: res.data.qrcode,
|
||
|
|
showQrCode: true
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
app.globalData.couponInfo = null;
|
||
|
|
util.pagePoint({
|
||
|
|
event: 'cart_order'
|
||
|
|
}, 1)
|
||
|
|
let list = this.data.gwcList,
|
||
|
|
price = 0,
|
||
|
|
product = [],
|
||
|
|
product1 = []
|
||
|
|
list.map(item => {
|
||
|
|
if (item.selected == 1) {
|
||
|
|
// item.product.type="post";
|
||
|
|
if (item.product.type == 'post') {
|
||
|
|
product.push({
|
||
|
|
product: item.product,
|
||
|
|
sku: item.sku,
|
||
|
|
productNum: item.num
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
product1.push(item)
|
||
|
|
app.globalData.list = product1
|
||
|
|
}
|
||
|
|
if (item.product.type.includes('post')) {
|
||
|
|
this.data.productType = 'post'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|
||
|
|
if (product.length == 0 && product1.length == 0) {
|
||
|
|
wx.showToast({
|
||
|
|
title: '请先选择产品',
|
||
|
|
icon: 'none'
|
||
|
|
})
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
if (product.length > 0 && product1.length > 0) {
|
||
|
|
this.setData({
|
||
|
|
flag: 'mix',
|
||
|
|
isCar: 'multiple'
|
||
|
|
})
|
||
|
|
}
|
||
|
|
if (product1.length > 1) {
|
||
|
|
this.setData({
|
||
|
|
isCar: 'multiple'
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
this.setData({
|
||
|
|
isCar: 'single'
|
||
|
|
})
|
||
|
|
}
|
||
|
|
console.log(product1);
|
||
|
|
app.globalData.postProduct = product;
|
||
|
|
if (app.globalData.list) {
|
||
|
|
app.globalData.product = app.globalData.list[app.globalData.index]
|
||
|
|
}
|
||
|
|
wx.navigateTo({
|
||
|
|
url: '/pages/order/postOrder/index?from=cart&flag=' + this.data.flag,
|
||
|
|
})
|
||
|
|
}
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 全选
|
||
|
|
allSelected() {
|
||
|
|
let gwcList = this.data.gwcList
|
||
|
|
let totalPrice = 0
|
||
|
|
if (this.data.allSelectedBtn) {
|
||
|
|
gwcList.forEach(item=> {
|
||
|
|
item.selected =0
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
gwcList.forEach(item=> {
|
||
|
|
item.selected =1
|
||
|
|
})
|
||
|
|
gwcList.forEach(item=> {
|
||
|
|
totalPrice += Number(item.num*item.sku.price)
|
||
|
|
})
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
gwcList,
|
||
|
|
allSelectedBtn:!this.data.allSelectedBtn,
|
||
|
|
totalPrice
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 单选一个
|
||
|
|
selectedIt(e) {
|
||
|
|
let item = e.currentTarget.dataset.item,gwcList= this.data.gwcList,totalPrice=0
|
||
|
|
gwcList.forEach(el=> {
|
||
|
|
if (el.id == item.id) {
|
||
|
|
el.selected == 1 ? el.selected =0 : el.selected = 1
|
||
|
|
}
|
||
|
|
})
|
||
|
|
gwcList.forEach(el=> {
|
||
|
|
if (el.selected == 1) {
|
||
|
|
totalPrice += Number(el.num*el.sku.price)
|
||
|
|
}
|
||
|
|
})
|
||
|
|
let status = gwcList.every(el => el.selected === 1)
|
||
|
|
this.setData({
|
||
|
|
gwcList,
|
||
|
|
allSelectedBtn:status?true:false,
|
||
|
|
totalPrice
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 左侧购物车打开弹窗
|
||
|
|
openPopup() {
|
||
|
|
// this.getCount()
|
||
|
|
let gwcList = this.data.gwcList
|
||
|
|
let status = gwcList.every(el => el.selected === 1)
|
||
|
|
this.setData({
|
||
|
|
showPopup:!this.data.showPopup,
|
||
|
|
allSelectedBtn:status?true:false,
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 获取商户标签列表
|
||
|
|
getSupplierTag() {
|
||
|
|
let list = this.data.list;
|
||
|
|
if(list.length>=this.data.total) return;
|
||
|
|
commonApi.user_post('supplier/get_supplier_by_title_tag_id', {
|
||
|
|
tag_id:5, //标签的ID
|
||
|
|
offset:list.length, //起始查询
|
||
|
|
limit:10, //查询数量
|
||
|
|
title:this.data.keywords //搜索产品名称
|
||
|
|
}).then(res => {
|
||
|
|
res.data.list.map(item=>{
|
||
|
|
item.display_tags = item.display_tags?item.display_tags.split(","):[];
|
||
|
|
item.display_tags = item.display_tags.splice(0,2);
|
||
|
|
})
|
||
|
|
this.setData({
|
||
|
|
list:list.concat(res.data.list),
|
||
|
|
total:res.data.total
|
||
|
|
})
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 获取左侧二级分类
|
||
|
|
getType() {
|
||
|
|
commonApi._post("product/tag_list",{
|
||
|
|
pid:5, //父标签的ID
|
||
|
|
}).then(res=>{
|
||
|
|
this.setData({
|
||
|
|
typeList:res.data
|
||
|
|
})
|
||
|
|
this.getList()
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 获取历史购物车详情
|
||
|
|
getCount() {
|
||
|
|
commonApi.user_post('cart_within/get_list', {
|
||
|
|
type:'2'
|
||
|
|
}).then(res => {
|
||
|
|
let arr = res.data,cartCount=0
|
||
|
|
// let arr = res.data,totalPrice = 0,cartCount=0
|
||
|
|
if (arr.length>0) {
|
||
|
|
arr.forEach(item=> {
|
||
|
|
// totalPrice += item.num*item.sku.price
|
||
|
|
cartCount += item.num
|
||
|
|
})
|
||
|
|
}
|
||
|
|
// console.log(totalPrice);
|
||
|
|
this.setData({
|
||
|
|
cartCount: cartCount, //1
|
||
|
|
gwcList:res.data,
|
||
|
|
// totalPrice,
|
||
|
|
allSelectedBtn:false
|
||
|
|
})
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 重置
|
||
|
|
onReload() {
|
||
|
|
this.setData({
|
||
|
|
list:[],
|
||
|
|
total:1,
|
||
|
|
navIndex:0,
|
||
|
|
typeIndex:0,
|
||
|
|
flag:true,
|
||
|
|
seachFlag:false
|
||
|
|
})
|
||
|
|
this.getList()
|
||
|
|
},
|
||
|
|
// 搜索
|
||
|
|
search:function(e){
|
||
|
|
if (e.detail.keywords == '') {
|
||
|
|
this.setData({
|
||
|
|
seachFlag:false,
|
||
|
|
keywords:'',
|
||
|
|
list:[],
|
||
|
|
total:1
|
||
|
|
})
|
||
|
|
this.onReload()
|
||
|
|
}else {
|
||
|
|
this.setData({
|
||
|
|
seachFlag:true,
|
||
|
|
keywords:e.detail.keywords,
|
||
|
|
list:[],
|
||
|
|
total:1
|
||
|
|
})
|
||
|
|
this.getList();
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 去产品详情页
|
||
|
|
goodsDetail(e){
|
||
|
|
wx.navigateTo({
|
||
|
|
url: '/pages/info/postProductInfo/index?id='+e.currentTarget.dataset.goods.id,
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 去店铺
|
||
|
|
goShop(e){
|
||
|
|
let id = e.currentTarget.dataset.id;
|
||
|
|
util.pagePoint({
|
||
|
|
event: 'legacy_shop',
|
||
|
|
param:{
|
||
|
|
id:id
|
||
|
|
},
|
||
|
|
type:'supplier'
|
||
|
|
},1)
|
||
|
|
wx.navigateTo({
|
||
|
|
url: '/pages/list/store/index?id='+id,
|
||
|
|
})
|
||
|
|
},
|
||
|
|
gotoProduct:function(e){
|
||
|
|
let item = e.currentTarget.dataset.item;
|
||
|
|
util.gotoDetail(item)
|
||
|
|
},
|
||
|
|
// 切换样式
|
||
|
|
changeStyle() {
|
||
|
|
this.setData({
|
||
|
|
navIndex:this.data.navIndex == 0? 1: 0,
|
||
|
|
flag:!this.data.flag,
|
||
|
|
total:1,
|
||
|
|
list:[],
|
||
|
|
typeIndex:0
|
||
|
|
})
|
||
|
|
if (this.data.flag) {
|
||
|
|
this.getType()
|
||
|
|
}else {
|
||
|
|
this.getSupplierTag()
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 切换一级分类
|
||
|
|
changeNav:function(e){
|
||
|
|
let index = e.currentTarget.dataset.index,navList=this.data.navList;
|
||
|
|
this.setData({
|
||
|
|
navIndex:index,
|
||
|
|
list:[],
|
||
|
|
total:1
|
||
|
|
})
|
||
|
|
if (this.data.navIndex == 0) {
|
||
|
|
this.getType()
|
||
|
|
} else {
|
||
|
|
this.getSupplierTag()
|
||
|
|
}
|
||
|
|
},
|
||
|
|
// 切换左侧二级分类
|
||
|
|
changeType(e) {
|
||
|
|
let index = e.currentTarget.dataset.index,typeList=this.data.typeList;
|
||
|
|
this.setData({
|
||
|
|
typeIndex:index,
|
||
|
|
type:typeList[index].id,
|
||
|
|
list:[],
|
||
|
|
total:1
|
||
|
|
})
|
||
|
|
this.getList()
|
||
|
|
},
|
||
|
|
// 获取产品列表
|
||
|
|
getList:function(){
|
||
|
|
let list = this.data.list;
|
||
|
|
if(list.length>=this.data.total) return;
|
||
|
|
commonApi._post("product/get_product_by_tag",{
|
||
|
|
tag_id:this.data.seachFlag? '5':this.data.typeList[this.data.typeIndex].id, //标签的ID
|
||
|
|
offset:list.length, //起始查询
|
||
|
|
limit: 10, //查询数量
|
||
|
|
title:this.data.keywords, //搜索产品名称
|
||
|
|
}).then(res=>{
|
||
|
|
res.data.list.map(item=>{
|
||
|
|
item.display_tags = item.display_tags?item.display_tags.split(","):[];
|
||
|
|
item.display_tags = item.display_tags.splice(0,2);
|
||
|
|
})
|
||
|
|
this.setData({
|
||
|
|
list:list.concat(res.data.list),
|
||
|
|
total:res.data.total
|
||
|
|
})
|
||
|
|
console.log(this.data.list);
|
||
|
|
})
|
||
|
|
// commonApi._post("supplier/get_supplier_by_tag_id",{
|
||
|
|
// tag_id:this.data.flag ? this.data.navList[this.data.navIndex].type :this.data.navList2[this.data.navIndex].type,
|
||
|
|
// limit:10,
|
||
|
|
// offset:list.length,
|
||
|
|
// sort:"weight",
|
||
|
|
// title:this.data.keywords
|
||
|
|
// }).then(res=>{
|
||
|
|
// res.data.list.map(item=>{
|
||
|
|
// item.display_tags = item.display_tags?item.display_tags.split(","):[];
|
||
|
|
// item.display_tags = item.display_tags.splice(0,2);
|
||
|
|
// })
|
||
|
|
// this.setData({
|
||
|
|
// list:list.concat(res.data.list),
|
||
|
|
// total:res.data.total
|
||
|
|
// })
|
||
|
|
// })
|
||
|
|
},
|
||
|
|
// 添加产品弹窗 1.首先获取到该产品下的规格
|
||
|
|
addBuyCart(e) {
|
||
|
|
let item = e.currentTarget.dataset.item
|
||
|
|
console.log(item);
|
||
|
|
commonApi._post("product/get_product_detail", {
|
||
|
|
id: item.id
|
||
|
|
}).then(res => {
|
||
|
|
if (item.skuid) {
|
||
|
|
let sku = res.data.sku.find(skuItem => item.id == skuItem.skuid);
|
||
|
|
res.data.sku = [sku];
|
||
|
|
}
|
||
|
|
res.data.flag = res.data.sku.find(item => item.flag == 'on') ? res.data.flag : 0
|
||
|
|
this.setData({
|
||
|
|
info: res.data,
|
||
|
|
// skuFlag: "cart"
|
||
|
|
})
|
||
|
|
this.showCart()
|
||
|
|
this.BroswerRecord()
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 添加产品弹窗 2.渲染规格,未登录去登录
|
||
|
|
showCart: function () {
|
||
|
|
commonApi.user_post('wx/get_user_keep', {
|
||
|
|
jumpurl: '/pages/info/postProductInfo/index?id=' + this.data.id,
|
||
|
|
title: this.data.info.title,
|
||
|
|
type: 'mini'
|
||
|
|
}).then(res => {
|
||
|
|
if (res.data.subscribe == 0) {
|
||
|
|
this.setData({
|
||
|
|
wxqrcode: res.data.qrcode,
|
||
|
|
showQrCode: true
|
||
|
|
})
|
||
|
|
} else {
|
||
|
|
if (this.data.info.sku.length == 0) {
|
||
|
|
wx.showToast({
|
||
|
|
title: '该产品未设置规格,不能加购',
|
||
|
|
icon: 'none'
|
||
|
|
})
|
||
|
|
return;
|
||
|
|
}
|
||
|
|
this.setData({
|
||
|
|
skuFlag: "cart"
|
||
|
|
})
|
||
|
|
let that = this
|
||
|
|
wx.createSelectorQuery().select('#skuImg').boundingClientRect(function (res) {
|
||
|
|
console.log(res)
|
||
|
|
that.setData({
|
||
|
|
cartImgInfo: 'top:' + res.top + 'px;left:' + res.left + 'px;'
|
||
|
|
})
|
||
|
|
}).exec()
|
||
|
|
}
|
||
|
|
this.getCount()
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 规格弹窗切换其他规格
|
||
|
|
selectSku: function (e) {
|
||
|
|
let index = e.currentTarget.dataset.index;
|
||
|
|
this.setData({
|
||
|
|
skuIndex: index
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 关闭弹窗
|
||
|
|
hideSku: function () {
|
||
|
|
this.setData({
|
||
|
|
skuFlag: null,
|
||
|
|
cartImgInfo: null
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 减少数量
|
||
|
|
minus: function () {
|
||
|
|
if (this.data.producNum == 1) return;
|
||
|
|
this.setData({
|
||
|
|
producNum: this.data.producNum - 1
|
||
|
|
})
|
||
|
|
},
|
||
|
|
// 加数量
|
||
|
|
add: function () {
|
||
|
|
this.setData({
|
||
|
|
producNum: this.data.producNum + 1
|
||
|
|
})
|
||
|
|
},
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面初次渲染完成
|
||
|
|
*/
|
||
|
|
onReady: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面显示
|
||
|
|
*/
|
||
|
|
onShow: function () {
|
||
|
|
this.onReload()
|
||
|
|
// this.setData({
|
||
|
|
// list:[],
|
||
|
|
// total:1,
|
||
|
|
// navIndex:0,
|
||
|
|
// typeIndex:0,
|
||
|
|
// flag:true
|
||
|
|
// })
|
||
|
|
// this.getList()
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面隐藏
|
||
|
|
*/
|
||
|
|
onHide: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 生命周期函数--监听页面卸载
|
||
|
|
*/
|
||
|
|
onUnload: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面相关事件处理函数--监听用户下拉动作
|
||
|
|
*/
|
||
|
|
onPullDownRefresh: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 页面上拉触底事件的处理函数
|
||
|
|
*/
|
||
|
|
onReachBottom: function () {
|
||
|
|
if (this.data.flag) {
|
||
|
|
this.getList()
|
||
|
|
} else {
|
||
|
|
this.getSupplierTag()
|
||
|
|
}
|
||
|
|
},
|
||
|
|
|
||
|
|
/**
|
||
|
|
* 用户点击右上角分享
|
||
|
|
*/
|
||
|
|
onShareAppMessage: function () {
|
||
|
|
|
||
|
|
},
|
||
|
|
onShareTimeline: function() {
|
||
|
|
return {
|
||
|
|
title: '君到苏州-文创特产',
|
||
|
|
query: '',
|
||
|
|
imageUrl: 'https://static.ticket.sz-trip.com/xcxImages/index/icon5New.png'
|
||
|
|
}
|
||
|
|
}
|
||
|
|
})
|