Browse Source

库存判断 首页广告

master
caichunsheng 4 years ago
parent
commit
e0142ba7c6
  1. 5
      pages/index/index.js
  2. 2
      pages/index/index.wxml
  3. 4
      pages/index/index.wxss
  4. 72
      pages/info/postProductInfo/index.js
  5. 116
      pages/info/sceneProductInfo/index.js

5
pages/index/index.js

@ -46,7 +46,7 @@ Page({
wx.hideTabBar() //这里隐藏了底部导航栏
commonApi._post("adv/getAdv", {
position: 2,
type_id: 5
type_id: 3
}).then(res => {
if (res.data.length > 0) {
this.setData({
@ -191,7 +191,7 @@ Page({
//弹窗广告
commonApi._post("adv/getAdv", {
position: 3,
type_id: 5
type_id: 3
}).then(res => {
if (res.data.length > 0) {
this.setData({
@ -631,7 +631,6 @@ Page({
})
},
bannerJumpNew(item) {
let that = this
item = item.currentTarget.dataset.item
if (item.tdata == '') return

2
pages/index/index.wxml

@ -433,7 +433,7 @@
<swiper class="alertsp" indicator-dots='{{true}}' indicator-color="rgba(255,255,255,0.5)" autoplay="{{true}}" interval="{{3000}}" duration="{{300}}" indicator-active-color="white">
<block wx:for="{{alertSwipeList}}" wx:key="*this">
<swiper-item data-item="{{item}}" bindtap="bannerJumpNew" >
<image src="{{item.head_img}}" style="width: 100%;height: 100%;" mode="widthFix"></image>
<image src="{{item.head_img}}" style="width: 100%; height:100%; border-radius: 10rpx;" mode="aspectFill"></image>
</swiper-item>
</block>
</swiper>

4
pages/index/index.wxss

@ -684,11 +684,11 @@
}
.alertavd{
width: 500rpx;
height: 500rpx;
height: 700rpx;
position: fixed;
top: 50%;
left: 50%;
transform: translate(-250rpx,-150rpx);
transform: translate(-250rpx,-300rpx);
z-index: 999;
}

72
pages/info/postProductInfo/index.js

@ -37,7 +37,8 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let rect = wx.getMenuButtonBoundingClientRect(), that = this;
let rect = wx.getMenuButtonBoundingClientRect(),
that = this;
let height = (rect.top - device.statusBarHeight) * 2 + rect.height + device.statusBarHeight;
this.setData({
top: height,
@ -87,7 +88,7 @@ Page({
}).then(res => {
res.data.list.map(item => {
item.rate = Number(item.rate)
item.create_time = item.create_time.substring(0,10)
item.create_time = item.create_time.substring(0, 10)
})
this.setData({
@ -95,15 +96,15 @@ Page({
commentTotal: res.data.total
})
let arr = this.data.comment
arr.map((item)=>{
arr.map((item) => {
if (item.img_list) {
item.img_list = item.img_list.split(',')
}else{
item.img_list=[]
} else {
item.img_list = []
}
})
this.setData({
comment:arr
comment: arr
})
})
@ -123,16 +124,15 @@ Page({
source_id: this.data.info.id,
url: "/pages/info/postProductInfo/index?id=" + this.data.info.id,
uuid: app.globalData.uuid
}).then(res => {
})
}
else {
}).then(res => {})
} else {
this.BroswerRecord();
}
}, 500)
},
like: function () {
let id = this.data.id, isLike = this.data.isLike;
let id = this.data.id,
isLike = this.data.isLike;
commonApi.user_post("product/" + (isLike == 1 ? "product_cancel_collection" : "product_collection"), {
product_id: id
}).then(res => {
@ -144,7 +144,8 @@ Page({
})
},
changeMenu: function (e) {
let index = e.currentTarget.dataset.index, that = this;
let index = e.currentTarget.dataset.index,
that = this;
const query = wx.createSelectorQuery(); //创建节点查询器
query.select("#box" + index).boundingClientRect() //选择toViewid获取位置信息
query.selectViewport().scrollOffset() //获取页面查询位置的
@ -160,7 +161,8 @@ Page({
})
},
onPageScroll: function (e) {
let that = this, height = this.data.top;
let that = this,
height = this.data.top;
let topHeight = height;
wx.createSelectorQuery().select('#menus').boundingClientRect(function (rect) {
if (rect.top <= topHeight) {
@ -168,8 +170,7 @@ Page({
that.setData({
fixed: true
})
}
else {
} else {
that.setData({
fixed: false
})
@ -185,13 +186,11 @@ Page({
that.setData({
type: 3
})
}
else if (res[1].top < minHeight) {
} else if (res[1].top < minHeight) {
that.setData({
type: 2
})
}
else {
} else {
that.setData({
type: 1
})
@ -258,6 +257,12 @@ Page({
order: function () {
app.globalData.postProduct = null
app.globalData.list = []
// commonApi.user_post("/product/checkStock", {
// sku_id: this.data.info.sku[this.data.skuIndex].id,
// }).then(res => {
// if (res && res.code != 1) {
// return;
// } else {
if (this.data.skuFlag == 'order') {
util.pagePoint({
event: 'product_order',
@ -280,8 +285,7 @@ Page({
wx.navigateTo({
url: '/pages/order/postOrder/index',
})
}
else {
} else {
commonApi.user_post("cart/add_sku", {
sku_id: this.data.info.sku[this.data.skuIndex].id,
num: this.data.producNum
@ -317,6 +321,9 @@ Page({
}
})
}
// }
// })
},
// 分享
share: function () {
@ -344,7 +351,8 @@ Page({
},
// 保存
save() {
let url = this.data.shareImg, that = this;
let url = this.data.shareImg,
that = this;
wx.authorize({
/* 这个就是保存相册的 */
scope: 'scope.writePhotosAlbum',
@ -397,7 +405,8 @@ Page({
},
// 绘制海报
drawImg: function () {
var that = this, userinfo = wx.getStorageSync('jstrip_userInfo');
var that = this,
userinfo = wx.getStorageSync('jstrip_userInfo');
if (!userinfo) {
// 去登录
return false;
@ -436,7 +445,7 @@ Page({
ctx.save();
ctx.beginPath(); //开始绘制
that.handleBorderRect(ctx, 0, 0, 551 * ratio, 407 * ratio, 25 * ratio, '#ccc')
ctx.clip();//画好了圆 剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 这也是我们要save上下文的原因
ctx.clip(); //画好了圆 剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 这也是我们要save上下文的原因
ctx.drawImage(imgs[0].path, 0, 0, 551 * ratio, 407 * ratio);
ctx.restore();
ctx.save();
@ -547,12 +556,13 @@ Page({
},
// 绘制两行文字
drawText: function (ctx, str, x, y, canvasWidth, ratio) {
let row = [], temp = "", chr = str.split("");
let row = [],
temp = "",
chr = str.split("");
for (var a = 0; a < chr.length; a++) {
if (ctx.measureText(temp).width < canvasWidth) {
temp += chr[a];
}
else {
} else {
a--; //这里添加了a-- 是为了防止字符丢失,效果图中有对比
row.push(temp);
temp = "";
@ -569,13 +579,12 @@ Page({
for (var a = 0; a < rowPart.length; a++) {
if (ctx.measureText(test).width < canvasWidth - 30 * ratio) {
test += rowPart[a];
}
else {
} else {
break;
}
}
empty.push(test);
var group = empty[0] + "..."//这里只显示两行,超出的用...表示
var group = empty[0] + "..." //这里只显示两行,超出的用...表示
rowCut.splice(1, 1, group);
row = rowCut;
}
@ -611,8 +620,7 @@ Page({
cartCount: res.data.length
})
})
}
else {
} else {
setTimeout(() => {
this.onShow()
}, 200)

116
pages/info/sceneProductInfo/index.js

@ -6,7 +6,6 @@ import util from "../../../utils/util"
import QRCode from '../../../utils/weapp-qrcode.js'
let app = getApp()
Page({
/**
* 页面的初始数据
*/
@ -23,7 +22,7 @@ Page({
shareImg: null,
showShareFlag: false,
showAllowance: false,
allowance_data:null,
allowance_data: null,
//购物车数量
producNum: 1,
skuIndex: 0,
@ -32,7 +31,7 @@ Page({
cartImgInfo: null,
cartTop: 0,
top: 0,
skuList:[],//立即预定的列表
skuList: [], //立即预定的列表
},
/**
@ -98,16 +97,22 @@ Page({
info: res.data
})
var arr = []
res.data.product.forEach((item,index) => {
item.sku.forEach(itemB=>{
res.data.product.forEach((item, index) => {
item.sku.forEach(itemB => {
itemB.proIndex = index
arr.push(itemB)
})
});
this.setData({
skuList:arr
skuList: arr
})
util.pagePoint({ event: 'scene_view', param: { type: res.data.type, id: res.data.id } }, 1)
util.pagePoint({
event: 'scene_view',
param: {
type: res.data.type,
id: res.data.id
}
}, 1)
this.BroswerRecord()
})
// 获取收藏的状态
@ -141,17 +146,17 @@ Page({
commentTotal: res.data.total
})
let arr = this.data.comment
arr.map((item)=>{
arr.map((item) => {
if (item.img_list) {
let arr = item.img_list.split(',')
item.img_list = arr
}else{
item.img_list=[]
} else {
item.img_list = []
}
})
this.setData({
comment:arr
comment: arr
})
})
},
@ -170,16 +175,15 @@ Page({
source_id: this.data.info.id,
url: "/pages/info/sceneProductInfo/index?id=" + this.data.info.id,
uuid: app.globalData.uuid
}).then(res => {
})
}
else {
}).then(res => {})
} else {
this.BroswerRecord();
}
}, 500)
},
like: function () {
let id = this.data.id, isLike = Number(this.data.isLike);
let id = this.data.id,
isLike = Number(this.data.isLike);
commonApi.user_post(isLike != 1 ? "scene/scene_collection" : "scene/scene_cancel_collection", {
scene_id: id
}).then(res => {
@ -251,17 +255,20 @@ Page({
})
},
order: function (e) {
commonApi.user_post("/product/checkStock",{
sku_id: this.data.skuList[this.data.skuIndex].id,
}).then(res => {
console.log(res)
if(res && res.code != 1){
return;
}else{
// console.log(this.data.info,this.data.skuFlag)
// commonApi.user_post("/product/checkStock", {
// sku_id: this.data.skuList[this.data.skuIndex].id,
// }).then(res => {
// if (res && res.code != 1) {
// wx.showModal({
// title: "温馨提示",
// content: '商品已经被抢光啦~要不要瞧瞧别的~',
// showCancel: false
// })
// return;
// } else {
app.globalData.postProduct = []
app.globalData.list = []
if (this.data.skuFlag == 'order'){
if (this.data.skuFlag == 'order') {
if (e.currentTarget.dataset.disable == 1) return;
util.pagePoint({
event: 'scene_order',
@ -276,12 +283,20 @@ Page({
app.globalData.retailId = this.data.retailId;
// let sku = e.currentTarget.dataset.sku,product = e.currentTarget.dataset.product;
// let sku = {sku:e.currentTarget.dataset.product.sku[this.data.skuIndex]},product = {product: e.currentTarget.dataset.product}
let sku = {sku:this.data.skuList[this.data.skuIndex]},product = {product:this.data.info.product[this.data.skuList[this.data.skuIndex].proIndex]}
app.globalData.product = {...sku,...product}
let sku = {
sku: this.data.skuList[this.data.skuIndex]
},
product = {
product: this.data.info.product[this.data.skuList[this.data.skuIndex].proIndex]
}
app.globalData.product = {
...sku,
...product
}
wx.navigateTo({
url: '/pages/order/scene/index',
})
}else {
} else {
commonApi.user_post("cart/add_sku", {
sku_id: this.data.skuList[this.data.skuIndex].id,
num: this.data.producNum
@ -317,8 +332,8 @@ Page({
}
})
}
}
})
// }
// })
},
pagePoint: function (e) {
util.pagePoint({
@ -333,9 +348,7 @@ Page({
share: function () {
if (!wx.getStorageSync("jstrip_token")) {
wx.setStorageSync('login_from', 'scene_share_login')
commonApi.user_post("user/getMyInfo", {}).then(res => {
}).catch(err => {
})
commonApi.user_post("user/getMyInfo", {}).then(res => {}).catch(err => {})
return;
}
if (!this.data.shareImg) {
@ -351,7 +364,8 @@ Page({
},
// 保存
save() {
let url = this.data.shareImg, that = this;
let url = this.data.shareImg,
that = this;
wx.authorize({
/* 这个就是保存相册的 */
scope: 'scope.writePhotosAlbum',
@ -366,7 +380,13 @@ Page({
that.setData({
showShareFlag: !that.data.showShareFlag
})
util.pagePoint({ event: 'scene_share_save', param: { type: that.data.info.type, id: that.data.info.id } }, 1)
util.pagePoint({
event: 'scene_share_save',
param: {
type: that.data.info.type,
id: that.data.info.id
}
}, 1)
},
fail(res) {
wx.showToast({
@ -396,7 +416,8 @@ Page({
},
// 绘制海报
drawImg: function () {
var that = this, userinfo = wx.getStorageSync('jstrip_userInfo');
var that = this,
userinfo = wx.getStorageSync('jstrip_userInfo');
if (!userinfo) {
// 去登录
return false;
@ -434,7 +455,7 @@ Page({
ctx.save();
ctx.beginPath(); //开始绘制
that.handleBorderRect(ctx, 0, 0, 551 * ratio, 407 * ratio, 25 * ratio, '#ccc')
ctx.clip();//画好了圆 剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 这也是我们要save上下文的原因
ctx.clip(); //画好了圆 剪切 原始画布中剪切任意形状和尺寸。一旦剪切了某个区域,则所有之后的绘图都会被限制在被剪切的区域内 这也是我们要save上下文的原因
ctx.drawImage(imgs[0].path, 0, 0, 551 * ratio, 407 * ratio);
ctx.restore();
ctx.save();
@ -548,12 +569,13 @@ Page({
},
// 绘制两行文字
drawText: function (ctx, str, x, y, canvasWidth, ratio) {
let row = [], temp = "", chr = str.split("");
let row = [],
temp = "",
chr = str.split("");
for (var a = 0; a < chr.length; a++) {
if (ctx.measureText(temp).width < canvasWidth) {
temp += chr[a];
}
else {
} else {
a--; //这里添加了a-- 是为了防止字符丢失,效果图中有对比
row.push(temp);
temp = "";
@ -570,13 +592,12 @@ Page({
for (var a = 0; a < rowPart.length; a++) {
if (ctx.measureText(test).width < canvasWidth - 30 * ratio) {
test += rowPart[a];
}
else {
} else {
break;
}
}
empty.push(test);
var group = empty[0] + "..."//这里只显示两行,超出的用...表示
var group = empty[0] + "..." //这里只显示两行,超出的用...表示
rowCut.splice(1, 1, group);
row = rowCut;
}
@ -644,8 +665,7 @@ Page({
this.setData({
isTest: app.globalData.configJson.isTest
})
}
else {
} else {
setTimeout(() => {
this.onReady()
}, 300)
@ -696,8 +716,7 @@ Page({
}
})
}
}
else {
} else {
setTimeout(() => {
this.onShow()
}, 200)
@ -736,6 +755,5 @@ Page({
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
onShareAppMessage: function () {}
})
Loading…
Cancel
Save